StarRailCopilot/tasks/daily/camera.py

54 lines
1.8 KiB
Python
Raw Normal View History

from module.logger import logger
2023-06-12 02:40:46 +00:00
from tasks.base.assets.assets_base_page import CLOSE
2023-06-14 17:25:47 +00:00
from tasks.base.page import page_camera, page_main
from tasks.base.ui import UI
2023-06-14 17:25:47 +00:00
from tasks.daily.assets.assets_daily_camera import PICTURE_TAKEN, TAKE_PICTURE
2023-06-12 02:40:46 +00:00
class CameraUI(UI):
def take_picture(self, skip_first_screenshot=True):
"""
Examples:
self = CameraUI('alas')
self.device.screenshot()
self.take_picture()
2023-06-12 02:40:46 +00:00
Pages:
in: Any
out: page_camera, TAKE_PICTURE
"""
2023-06-18 10:41:58 +00:00
logger.hr('Take picture', level=2)
self.ui_ensure(page_camera, skip_first_screenshot)
# Take picture
skip_first_screenshot = True
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
2023-06-14 17:25:47 +00:00
if self.appear_then_click(TAKE_PICTURE, interval=1):
logger.info('Taking picture')
continue
if self.appear(PICTURE_TAKEN):
logger.info('Picture was taken')
break
# Quit from the picture ui
skip_first_screenshot = True
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
2023-06-14 17:25:47 +00:00
if self.appear(page_main.check_button):
logger.info('Back to camera main page')
break
2023-06-14 17:25:47 +00:00
if self.appear(PICTURE_TAKEN, interval=1):
self.device.click(CLOSE)
logger.info(f'{PICTURE_TAKEN} -> {CLOSE}')
self.interval_reset(TAKE_PICTURE)
continue
if self.appear(TAKE_PICTURE, interval=1):
self.device.click(CLOSE)
logger.info(f'{TAKE_PICTURE} -> {CLOSE}')
continue