mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-06-07 21:04:35 +00:00
Utilize inventory changed events to manage the overview tab;
instead of the progress notification system
This commit is contained in:
2
gui.py
2
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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user