Fix selecting next game

This commit is contained in:
DevilXD committed 2022-01-11 11:58:52 +01:00
1 parent 826b6647d0
commit fb10d2ae78
2 files changed
+11 -9

No files matched your search

+10 -8
View File
@@ -294,16 +294,18 @@ class GameSelector:
return first_game
return self._games[self._selection]
def get_next_selection(self) -> Optional[Game]:
def select_next(self) -> Optional[Game]:
current = self._list.curselection()
if not current:
return self.get_selection()
game_name = self._list.get(current[0]+1)
if game_name:
return self._games[game_name]
else:
next_idx = current[0]+1
game_name = self._list.get(next_idx)
if not game_name:
# this was the last game on the list
return None
self._list.selection_set(next_idx)
self._selection = game_name
return self._games[game_name]
class _BaseVars(TypedDict):
@@ -856,9 +858,9 @@ if __name__ == "__main__":
create_game(491115, "Paladins"),
# create_game(460630, "Tom Clancy's Rainbow Six Siege"),
])
gui.games.get_next_selection()
gui.games.get_next_selection()
gui.games.get_next_selection()
gui.games.select_next()
gui.games.select_next()
gui.games.select_next()
# Channel list
gui.channels.display(create_channel("PaladinsGame", 0, None, 0, 0))
channel = create_channel("Traitus", 1, None, 0, 0)
+1 -1
View File
@@ -262,7 +262,7 @@ class Twitch:
break
else:
self.stop_watching()
selected_game = self.gui.games.get_next_selection()
selected_game = self.gui.games.select_next()
if selected_game is None:
self.gui.print("No suitable channel to watch.")
# TODO: Figure out what to do here.