From 3a05e5e104d0657e0c858c4cad535841fdf42ab2 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Sun, 16 Jan 2022 23:10:52 +0100 Subject: [PATCH] More accurate active drop pre-display --- gui.py | 9 ++++++--- inventory.py | 4 ++-- twitch.py | 6 ++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gui.py b/gui.py index 5ab83ee..cf4374c 100644 --- a/gui.py +++ b/gui.py @@ -437,7 +437,7 @@ class CampaignProgress: self._timer_task.cancel() self._timer_task = None - def display(self, drop: TimedDrop, *, countdown: bool = True): + def display(self, drop: TimedDrop, *, countdown: bool = True, subone: bool = False): self._drop = drop # drop update vars_drop = self._vars["drop"] @@ -459,11 +459,14 @@ class CampaignProgress: # reschedule our seconds update timer self.stop_timer() self.start_timer() - else: + elif subone: # display the current remaining time at 0 seconds (after substracting the minute) # this is because the watch loop will substract this minute - # right after the first watch payload is sent + # right after the first watch payload returns with a time update self._update_time(0) + else: + # display full time with no substracting + self._update_time(60) class ConsoleOutput: diff --git a/inventory.py b/inventory.py index 1418333..dbff0b0 100644 --- a/inventory.py +++ b/inventory.py @@ -174,8 +174,8 @@ class TimedDrop(BaseDrop): self.current_minutes = minutes self._on_minutes_changed() - def display(self, *, countdown: bool = True): - self.campaign._twitch.gui.progress.display(self, countdown=countdown) + def display(self, *, countdown: bool = True, subone: bool = False): + self.campaign._twitch.gui.progress.display(self, countdown=countdown, subone=subone) def bump_minutes(self): if self.current_minutes < self.required_minutes: diff --git a/twitch.py b/twitch.py index 4efc933..9da6319 100644 --- a/twitch.py +++ b/twitch.py @@ -266,6 +266,12 @@ class Twitch: live_streams: List[Channel] = await self.get_live_streams( selected_game, [DROPS_ENABLED_TAG] ) + if live_streams: + # there are online streams, so let's pre-display the active drop again, + # but this time with a substracted minute + active_drop = self.get_active_drop(selected_game) + if active_drop is not None: + active_drop.display(countdown=False, subone=True) # add them, filtering out ones we already have for channel in live_streams: if channel.id not in self.channels: