mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 00:35:34 +00:00
Fix: Ensure assignment entry loaded
This commit is contained in:
parent
43fddd445c
commit
a1a77f921e
@ -35,7 +35,6 @@ class Assignment(AssignmentClaim, SynthesizeUI):
|
||||
self.has_new_dispatch = False
|
||||
self.ensure_scroll_top(page_menu)
|
||||
self.ui_ensure(page_assignment)
|
||||
self._wait_until_group_loaded()
|
||||
event_ongoing = next((
|
||||
g for g in self._iter_groups()
|
||||
if isinstance(g, AssignmentEventGroup)
|
||||
@ -91,12 +90,14 @@ class Assignment(AssignmentClaim, SynthesizeUI):
|
||||
logger.info(
|
||||
f'User specified assignments: {", ".join([x.name for x in assignments])}')
|
||||
remain = None
|
||||
insight = False
|
||||
for assignment in assignments:
|
||||
if assignment in self.dispatched:
|
||||
continue
|
||||
logger.hr('Assignment inlist', level=2)
|
||||
logger.info(f'Check assignment inlist: {assignment}')
|
||||
self.goto_entry(assignment)
|
||||
self.goto_entry(assignment, insight=insight)
|
||||
insight = True
|
||||
if remain is None:
|
||||
_, remain, _ = self._limit_status
|
||||
status = self._check_assignment_status()
|
||||
@ -106,6 +107,7 @@ class Assignment(AssignmentClaim, SynthesizeUI):
|
||||
if status == AssignmentStatus.DISPATCHED:
|
||||
self.dispatched[assignment] = datetime.now() + \
|
||||
self._get_assignment_time()
|
||||
insight = False
|
||||
continue
|
||||
# General assignments must be dispatchable here
|
||||
if remain <= 0:
|
||||
|
@ -40,7 +40,8 @@ class AssignmentOcr(Ocr):
|
||||
(KEYWORDS_ASSIGNMENT_ENTRY.Legend_of_the_Puppet_Master, '^师传说'),
|
||||
(KEYWORDS_ASSIGNMENT_ENTRY.The_Wages_of_Humanity, '[赠]养人类'),
|
||||
(KEYWORDS_ASSIGNMENT_EVENT_ENTRY.Car_Thief, '.*的偷车贼.*'),
|
||||
(KEYWORDS_ASSIGNMENT_EVENT_ENTRY.Synesthesia_Beacon_Function_Iteration, '联觉信标功能[送]代'),
|
||||
(KEYWORDS_ASSIGNMENT_EVENT_ENTRY.Synesthesia_Beacon_Function_Iteration,
|
||||
'联觉信标功能[送]代'),
|
||||
],
|
||||
'en': [
|
||||
# (KEYWORDS_ASSIGNMENT_EVENT_ENTRY.Food_Improvement_Plan.name,
|
||||
@ -160,6 +161,7 @@ class AssignmentUI(UI):
|
||||
logger.hr('Assignment group goto', level=3)
|
||||
if ASSIGNMENT_GROUP_SWITCH.set(group, self):
|
||||
self._wait_until_entry_loaded()
|
||||
self._wait_until_correct_entry_loaded(group)
|
||||
|
||||
def goto_entry(self, entry: AssignmentEntry, insight: bool = True):
|
||||
"""
|
||||
@ -218,6 +220,27 @@ class AssignmentUI(UI):
|
||||
logger.info('Entry loaded')
|
||||
break
|
||||
|
||||
def _wait_until_correct_entry_loaded(self, group: AssignmentGroup):
|
||||
skip_first_screenshot = True
|
||||
timeout = Timer(3, count=3).start()
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if timeout.reached():
|
||||
logger.warning('Wait correct entry loaded timeout')
|
||||
break
|
||||
|
||||
ASSIGNMENT_ENTRY_LIST.load_rows(self)
|
||||
if all(
|
||||
x.matched_keyword.group == group
|
||||
for x in ASSIGNMENT_ENTRY_LIST.cur_buttons
|
||||
):
|
||||
logger.info('Correct entry loaded')
|
||||
break
|
||||
|
||||
@property
|
||||
def _limit_status(self) -> tuple[int, int, int]:
|
||||
self.device.screenshot()
|
||||
@ -279,7 +302,7 @@ class AssignmentUI(UI):
|
||||
"""
|
||||
Iterate entries from top to bottom
|
||||
"""
|
||||
ASSIGNMENT_ENTRY_LIST.load_rows(main=self)
|
||||
# load_rows is done in _wait_until_correct_entry_loaded already
|
||||
# Freeze ocr results here
|
||||
yield from [
|
||||
button.matched_keyword
|
||||
|
Loading…
Reference in New Issue
Block a user