Пример #1
0
class CategoryTracker(Tracker[CategoryTrackerConfig, WindowData]):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.proc = None
        self.time_total = None
        self.run_state = None

    def initialize(self):
        self.time_total = 0
        self.run_state = RunState()

    def poll(self, proc: Spel2Process, config: CategoryTrackerConfig) -> WindowData:
        game_state = proc.get_state()
        if game_state is None:
            return None

        # Check if we've reset, if so, reinitialize
        new_time_total = game_state.time_total
        if new_time_total < self.time_total:
            self.initialize()
        self.time_total = new_time_total

        self.run_state.update(game_state)
        label = self.run_state.get_display(game_state.screen, config)
        return WindowData(label)
Пример #2
0
class CategoryWatcherThread(WatcherThread):
    def __init__(self, *args, always_show_modifiers=False, **kwargs):
        super().__init__(*args, **kwargs)
        self.time_total = None
        self.run_state = None
        self.always_show_modifiers = always_show_modifiers

    def initialize(self):
        self.time_total = 0
        self.run_state = RunState(
            always_show_modifiers=self.always_show_modifiers,
        )

    def poll(self):
        game_state = self.proc.get_state()
        if game_state is None:
            self.shutdown()
            return
        # Check if we've reset, if so, reinitialize
        new_time_total = game_state.time_total
        if new_time_total < self.time_total:
            self.initialize()
        self.time_total = new_time_total

        self.run_state.update(game_state)
        label = self.run_state.get_display(game_state.screen)
        self.send(Command.LABEL, label)