mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
71 lines
1.8 KiB
Python
71 lines
1.8 KiB
Python
from module.base.timer import Timer
|
|
from module.logger import logger
|
|
from tasks.base.page import page_main
|
|
from tasks.base.ui import UI
|
|
from tasks.login.assets.assets_login import LOGIN_CONFIRM, USER_AGREEMENT_ACCEPT
|
|
|
|
|
|
class Login(UI):
|
|
def _handle_app_login(self):
|
|
"""
|
|
Pages:
|
|
in: Any page
|
|
out: page_main
|
|
|
|
Raises:
|
|
GameStuckError:
|
|
GameTooManyClickError:
|
|
"""
|
|
logger.hr('App login')
|
|
|
|
orientation_timer = Timer(5)
|
|
login_success = False
|
|
|
|
while 1:
|
|
# Watch device rotation
|
|
if not login_success and orientation_timer.reached():
|
|
# Screen may rotate after starting an app
|
|
self.device.get_orientation()
|
|
orientation_timer.reset()
|
|
|
|
self.device.screenshot()
|
|
|
|
# End
|
|
if self.ui_page_appear(page_main):
|
|
logger.info('Login to main confirm')
|
|
break
|
|
|
|
# Login
|
|
if self.appear_then_click(LOGIN_CONFIRM):
|
|
continue
|
|
if self.appear_then_click(USER_AGREEMENT_ACCEPT):
|
|
continue
|
|
# Additional
|
|
if self.ui_additional():
|
|
continue
|
|
|
|
return True
|
|
|
|
def handle_app_login(self):
|
|
self.device.screenshot_interval_set(1.0)
|
|
try:
|
|
self._handle_app_login()
|
|
finally:
|
|
self.device.screenshot_interval_set()
|
|
|
|
def app_stop(self):
|
|
logger.hr('App stop')
|
|
self.device.app_stop()
|
|
|
|
def app_start(self):
|
|
logger.hr('App start')
|
|
self.device.app_start()
|
|
self.handle_app_login()
|
|
|
|
def app_restart(self):
|
|
logger.hr('App restart')
|
|
self.device.app_stop()
|
|
self.device.app_start()
|
|
self.handle_app_login()
|
|
self.config.task_delay(server_update=True)
|