mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-25 18:05:26 +00:00
Add: [ALAS] Switch.wait()
This commit is contained in:
parent
f4afb86d0e
commit
af80aa3d4c
@ -137,14 +137,14 @@ class Switch:
|
|||||||
current = self.get(main=main)
|
current = self.get(main=main)
|
||||||
logger.attr(self.name, current)
|
logger.attr(self.name, current)
|
||||||
|
|
||||||
# Handle additional popups
|
|
||||||
if self.handle_additional(main=main):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# End
|
# End
|
||||||
if current == state:
|
if current == state:
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
# Handle additional popups
|
||||||
|
if self.handle_additional(main=main):
|
||||||
|
continue
|
||||||
|
|
||||||
# Warning
|
# Warning
|
||||||
if current == 'unknown':
|
if current == 'unknown':
|
||||||
if warning_show_timer.reached():
|
if warning_show_timer.reached():
|
||||||
@ -165,3 +165,36 @@ class Switch:
|
|||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
def wait(self, main, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Wait until any state activated
|
||||||
|
|
||||||
|
Args:
|
||||||
|
main (ModuleBase):
|
||||||
|
skip_first_screenshot:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: If success
|
||||||
|
"""
|
||||||
|
timeout = Timer(2, count=6).start()
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
main.device.screenshot()
|
||||||
|
|
||||||
|
# Detect
|
||||||
|
current = self.get(main=main)
|
||||||
|
logger.attr(self.name, current)
|
||||||
|
|
||||||
|
# End
|
||||||
|
if current != 'unknown':
|
||||||
|
return True
|
||||||
|
if timeout.reached():
|
||||||
|
logger.warning(f'{self.name} wait activated timeout')
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Handle additional popups
|
||||||
|
if self.handle_additional(main=main):
|
||||||
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user