From 0b32d0928524f744edbd897b404452280f6b141a Mon Sep 17 00:00:00 2001 From: DevilXD Date: Wed, 27 Apr 2022 19:17:43 +0200 Subject: [PATCH] Utilize inventory changed events to manage the overview tab; instead of the progress notification system --- gui.py | 2 +- inventory.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gui.py b/gui.py index ec4b4b9..b7878aa 100644 --- a/gui.py +++ b/gui.py @@ -1460,7 +1460,7 @@ class GUIManager: self, drop: TimedDrop, *, countdown: bool = True, subone: bool = False ) -> None: self.progress.display(drop, countdown=countdown, subone=subone) # main tab - self.inv.update_drop(drop) # inventory + # inventory overview is updated from within drops themselves via change events self.tray.update_title(drop) # tray def print(self, *args, **kwargs): diff --git a/inventory.py b/inventory.py index c641edd..02ce775 100644 --- a/inventory.py +++ b/inventory.py @@ -13,8 +13,8 @@ if TYPE_CHECKING: from collections import abc from twitch import Twitch - from gui import GUIManager from constants import JsonType + from gui import GUIManager, InventoryOverview DIMS_PATTERN = re.compile(r'-\d+x\d+(?=\.(?:jpg|png|gif)$)', re.I) @@ -141,6 +141,7 @@ class TimedDrop(BaseDrop): ): super().__init__(campaign, data, claimed_benefits) self._manager: GUIManager = self._twitch.gui + self._gui_inv: InventoryOverview = self._manager.inv self.current_minutes: int = 0 if "self" in data: self.current_minutes = data["self"]["currentMinutesWatched"] @@ -170,9 +171,15 @@ class TimedDrop(BaseDrop): def progress(self) -> float: return self.current_minutes / self.required_minutes + def _on_claim(self) -> None: + result = super()._on_claim() + self._gui_inv.update_drop(self) + return result + def _on_minutes_changed(self) -> None: invalidate_cache(self, "progress", "remaining_minutes") self.campaign._on_minutes_changed() + self._gui_inv.update_drop(self) async def claim(self) -> bool: result = await super().claim()