Remove idle arg, make it default
This commit is contained in:
1 parent
423e51bc27
commit
f6453dafaf
4 files changed
+24
-15
No files matched your search
Vendored
+3
-3
@@ -16,7 +16,7 @@
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "main.py",
|
||||
"args": ["--no-run-check", "--idle", "-vv"],
|
||||
"args": ["--no-run-check", "-vv"],
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false
|
||||
},
|
||||
@@ -25,7 +25,7 @@
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "main.py",
|
||||
"args": ["--no-run-check", "--idle", "-vvv"],
|
||||
"args": ["--no-run-check", "-vvv"],
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false
|
||||
},
|
||||
@@ -34,7 +34,7 @@
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "main.py",
|
||||
"args": ["--no-run-check", "--idle", "-vvv", "--debug-ws"],
|
||||
"args": ["--no-run-check", "-vvv", "--debug-ws"],
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false
|
||||
},
|
||||
|
||||
@@ -289,6 +289,7 @@ class GameSelector:
|
||||
|
||||
def _on_select(self, event):
|
||||
current = self._list.curselection()
|
||||
print(current)
|
||||
if not current:
|
||||
# can happen when the user clicks on an empty list
|
||||
new_selection = None
|
||||
@@ -298,17 +299,20 @@ class GameSelector:
|
||||
self._selection = new_selection
|
||||
self._manager._twitch.change_state(State.GAME_SELECT)
|
||||
|
||||
def get_selection(self) -> Game:
|
||||
def get_selection(self) -> Optional[Game]:
|
||||
if self._selection is None:
|
||||
if not self._games:
|
||||
raise RuntimeError("No games to select from")
|
||||
return None
|
||||
return self._games[self._selection]
|
||||
|
||||
def set_first(self) -> Game:
|
||||
# select and return the first game from the list
|
||||
self._list.selection_clear(0, "end")
|
||||
self._list.selection_set(0)
|
||||
first_game = next(iter(self._games.values()))
|
||||
self._selection = str(first_game)
|
||||
for game_name, first_game in self._games.items():
|
||||
# just one iteration to get, set and return the first game
|
||||
self._selection = game_name
|
||||
return first_game
|
||||
return self._games[self._selection]
|
||||
raise RuntimeError("No games to select from")
|
||||
|
||||
|
||||
class _BaseVars(TypedDict):
|
||||
|
||||
@@ -20,7 +20,6 @@ class ParsedArgs(argparse.Namespace):
|
||||
_debug_ws: bool
|
||||
_debug_gql: bool
|
||||
log: bool
|
||||
idle: bool
|
||||
tray: bool
|
||||
no_run_check: bool
|
||||
game: Optional[str]
|
||||
@@ -69,7 +68,6 @@ parser.add_argument("--no-run-check", dest="no_run_check", action="store_true")
|
||||
parser.add_argument("--debug-ws", dest="_debug_ws", action="store_true")
|
||||
parser.add_argument("--debug-gql", dest="_debug_gql", action="store_true")
|
||||
parser.add_argument("-g", "--game", default=None)
|
||||
parser.add_argument("--idle", action="store_true")
|
||||
parser.add_argument("--tray", action="store_true")
|
||||
parser.add_argument("--log", action="store_true")
|
||||
options: ParsedArgs = parser.parse_args(namespace=ParsedArgs())
|
||||
|
||||
@@ -179,6 +179,7 @@ class Twitch:
|
||||
WebsocketTopic("User", "Drops", self._user_id, self.process_drops),
|
||||
WebsocketTopic("User", "CommunityPoints", self._user_id, self.process_points),
|
||||
])
|
||||
first_select: bool = True
|
||||
games: List[Game] = []
|
||||
full_cleanup: bool = False
|
||||
channels: Final[OrderedDict[int, Channel]] = self.channels
|
||||
@@ -215,18 +216,24 @@ class Twitch:
|
||||
# only start the websocket after we confirm there are drops to mine
|
||||
await self.websocket.start()
|
||||
self.gui.games.set_games(games)
|
||||
if self.options.idle:
|
||||
self.options.idle = False
|
||||
self.change_state(State.IDLE)
|
||||
else:
|
||||
self.change_state(State.GAME_SELECT)
|
||||
elif self._state is State.GAME_SELECT:
|
||||
self.game = self.gui.games.get_selection()
|
||||
if self.game is None:
|
||||
if first_select:
|
||||
# on first select, let the user make the choice
|
||||
first_select = False
|
||||
else:
|
||||
self.game = self.gui.games.set_first()
|
||||
if self.game is not None:
|
||||
# restart the watch loop if needed
|
||||
self.restart_watching()
|
||||
# signal channel cleanup that we're removing everything
|
||||
full_cleanup = True
|
||||
self.change_state(State.CHANNELS_CLEANUP)
|
||||
else:
|
||||
# with no game selected, we switch to IDLE
|
||||
self.change_state(State.IDLE)
|
||||
elif self._state is State.CHANNELS_CLEANUP:
|
||||
if self.game is None or full_cleanup:
|
||||
# no game selected or we're doing full cleanup: remove everything
|
||||
|
||||
Reference in new issue
Block a user