Opt: Skip first load_rows() if tab switched

This commit is contained in:
LmeSzinc 2024-05-21 02:31:27 +08:00
parent 83333a8a63
commit 28af865d75

View File

@ -151,19 +151,23 @@ class AssignmentUI(UI):
Args: Args:
group (AssignmentGroup): group (AssignmentGroup):
Returns:
bool: If group switched
Examples: Examples:
self = AssignmentUI('src') self = AssignmentUI('src')
self.device.screenshot() self.device.screenshot()
self.goto_group(KEYWORDS_ASSIGNMENT_GROUP.Character_Materials) self.goto_group(KEYWORDS_ASSIGNMENT_GROUP.Character_Materials)
""" """
if ASSIGNMENT_GROUP_SWITCH.get(self) == group:
if not ASSIGNMENT_ENTRY_LIST.cur_buttons:
ASSIGNMENT_ENTRY_LIST.load_rows(self)
return
logger.hr('Assignment group goto', level=3) logger.hr('Assignment group goto', level=3)
if ASSIGNMENT_GROUP_SWITCH.set(group, self): if ASSIGNMENT_GROUP_SWITCH.set(group, self):
self._wait_until_entry_loaded() self._wait_until_entry_loaded()
self._wait_until_correct_entry_loaded(group) self._wait_until_correct_entry_loaded(group)
return True
else:
if not ASSIGNMENT_ENTRY_LIST.cur_buttons:
ASSIGNMENT_ENTRY_LIST.load_rows(self)
return False
def goto_entry(self, entry: AssignmentEntry, insight: bool = True): def goto_entry(self, entry: AssignmentEntry, insight: bool = True):
""" """
@ -185,8 +189,11 @@ class AssignmentUI(UI):
return return
raise ScriptError(err_msg) raise ScriptError(err_msg)
else: else:
self.goto_group(entry.group) if self.goto_group(entry.group):
ASSIGNMENT_ENTRY_LIST.select_row(entry, self, insight=insight) # Already insight in goto_group() - _wait_until_correct_entry_loaded()
ASSIGNMENT_ENTRY_LIST.select_row(entry, self, insight=False)
else:
ASSIGNMENT_ENTRY_LIST.select_row(entry, self, insight=insight)
def _wait_until_group_loaded(self): def _wait_until_group_loaded(self):
skip_first_screenshot = True skip_first_screenshot = True