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