Utilize inventory changed events to manage the overview tab;

instead of the progress notification system
This commit is contained in:
DevilXD committed 2022-04-27 19:17:43 +02:00
1 parent a92f6be1a8
commit 0b32d09285
2 files changed
+9 -2

No files matched your search

+1 -1
View File
@@ -1460,7 +1460,7 @@ class GUIManager:
self, drop: TimedDrop, *, countdown: bool = True, subone: bool = False self, drop: TimedDrop, *, countdown: bool = True, subone: bool = False
) -> None: ) -> None:
self.progress.display(drop, countdown=countdown, subone=subone) # main tab 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 self.tray.update_title(drop) # tray
def print(self, *args, **kwargs): def print(self, *args, **kwargs):
+8 -1
View File
@@ -13,8 +13,8 @@ if TYPE_CHECKING:
from collections import abc from collections import abc
from twitch import Twitch from twitch import Twitch
from gui import GUIManager
from constants import JsonType from constants import JsonType
from gui import GUIManager, InventoryOverview
DIMS_PATTERN = re.compile(r'-\d+x\d+(?=\.(?:jpg|png|gif)$)', re.I) 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) super().__init__(campaign, data, claimed_benefits)
self._manager: GUIManager = self._twitch.gui self._manager: GUIManager = self._twitch.gui
self._gui_inv: InventoryOverview = self._manager.inv
self.current_minutes: int = 0 self.current_minutes: int = 0
if "self" in data: if "self" in data:
self.current_minutes = data["self"]["currentMinutesWatched"] self.current_minutes = data["self"]["currentMinutesWatched"]
@@ -170,9 +171,15 @@ class TimedDrop(BaseDrop):
def progress(self) -> float: def progress(self) -> float:
return self.current_minutes / self.required_minutes 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: def _on_minutes_changed(self) -> None:
invalidate_cache(self, "progress", "remaining_minutes") invalidate_cache(self, "progress", "remaining_minutes")
self.campaign._on_minutes_changed() self.campaign._on_minutes_changed()
self._gui_inv.update_drop(self)
async def claim(self) -> bool: async def claim(self) -> bool:
result = await super().claim() result = await super().claim()