mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Add: take picture method (#1)
* Add: take picture method * Upd: CAMERA_CHECK & TAKE_PICTURE template * Upt: use OCR to detect whether picture was taken * Upd: move camera to daily; use match template instead of OCR * Upd: break process into two loops;
This commit is contained in:
parent
02b9c96e7b
commit
27c08df0ca
BIN
assets/cn/daily/PICTURE_TAKEN.png
Normal file
BIN
assets/cn/daily/PICTURE_TAKEN.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
BIN
assets/share/base/page/CAMERA_CHECK.png
Normal file
BIN
assets/share/base/page/CAMERA_CHECK.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/share/base/page/MENU_GOTO_CAMERA.png
Normal file
BIN
assets/share/base/page/MENU_GOTO_CAMERA.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/share/daily/TAKE_PICTURE.png
Normal file
BIN
assets/share/daily/TAKE_PICTURE.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
@ -13,6 +13,16 @@ BATTLE_PASS_CHECK = ButtonWrapper(
|
||||
button=(42, 22, 72, 55),
|
||||
),
|
||||
)
|
||||
CAMERA_CHECK = ButtonWrapper(
|
||||
name='CAMERA_CHECK',
|
||||
share=Button(
|
||||
file='./assets/share/base/page/CAMERA_CHECK.png',
|
||||
area=(1120, 346, 1160, 375),
|
||||
search=(1100, 326, 1180, 395),
|
||||
color=(215, 215, 215),
|
||||
button=(1120, 346, 1160, 375),
|
||||
),
|
||||
)
|
||||
CHARACTER_CHECK = ButtonWrapper(
|
||||
name='CHARACTER_CHECK',
|
||||
share=Button(
|
||||
@ -203,6 +213,16 @@ MENU_CHECK = ButtonWrapper(
|
||||
button=(1222, 638, 1252, 669),
|
||||
),
|
||||
)
|
||||
MENU_GOTO_CAMERA = ButtonWrapper(
|
||||
name='MENU_GOTO_CAMERA',
|
||||
share=Button(
|
||||
file='./assets/share/base/page/MENU_GOTO_CAMERA.png',
|
||||
area=(1219, 465, 1255, 495),
|
||||
search=(1199, 445, 1275, 515),
|
||||
color=(51, 52, 53),
|
||||
button=(1219, 465, 1255, 495),
|
||||
),
|
||||
)
|
||||
MESSAGE_CLOSE = ButtonWrapper(
|
||||
name='MESSAGE_CLOSE',
|
||||
share=Button(
|
||||
|
@ -125,3 +125,8 @@ page_main.link(MAIN_GOTO_MISSION, destination=page_mission)
|
||||
page_message = Page(MESSAGE_CLOSE)
|
||||
page_message.link(MESSAGE_CLOSE, destination=page_main)
|
||||
page_main.link(MAIN_GOTO_MESSAGE, destination=page_message)
|
||||
|
||||
# Camera
|
||||
page_camera = Page(CAMERA_CHECK)
|
||||
page_camera.link(CLOSE, destination=page_menu)
|
||||
page_menu.link(MENU_GOTO_CAMERA, destination=page_camera)
|
||||
|
25
tasks/daily/assets/assets_daily.py
Normal file
25
tasks/daily/assets/assets_daily.py
Normal file
@ -0,0 +1,25 @@
|
||||
from module.base.button import Button, ButtonWrapper
|
||||
|
||||
# This file was auto-generated, do not modify it manually. To generate:
|
||||
# ``` python -m dev_tools.button_extract ```
|
||||
|
||||
PICTURE_TAKEN = ButtonWrapper(
|
||||
name='PICTURE_TAKEN',
|
||||
cn=Button(
|
||||
file='./assets/cn/daily/PICTURE_TAKEN.png',
|
||||
area=(1030, 620, 1069, 639),
|
||||
search=(1010, 600, 1089, 659),
|
||||
color=(153, 153, 155),
|
||||
button=(1030, 620, 1069, 639),
|
||||
),
|
||||
)
|
||||
TAKE_PICTURE = ButtonWrapper(
|
||||
name='TAKE_PICTURE',
|
||||
share=Button(
|
||||
file='./assets/share/daily/TAKE_PICTURE.png',
|
||||
area=(1120, 346, 1160, 375),
|
||||
search=(1100, 326, 1180, 395),
|
||||
color=(215, 215, 215),
|
||||
button=(1120, 346, 1160, 375),
|
||||
),
|
||||
)
|
43
tasks/daily/camera.py
Normal file
43
tasks/daily/camera.py
Normal file
@ -0,0 +1,43 @@
|
||||
from module.logger import logger
|
||||
from module.ocr.ocr import *
|
||||
from tasks.base.page import page_camera
|
||||
from tasks.base.ui import UI
|
||||
from tasks.base.assets.assets_base_page import CLOSE
|
||||
from tasks.daily.assets.assets_daily import *
|
||||
|
||||
class CameraUI(UI):
|
||||
def take_picture(self, skip_first_screenshot=True):
|
||||
"""
|
||||
Examples:
|
||||
self = CameraUI('alas')
|
||||
self.device.screenshot()
|
||||
self.take_picture()
|
||||
"""
|
||||
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()
|
||||
if self.appear_then_click(TAKE_PICTURE):
|
||||
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()
|
||||
if self.appear(TAKE_PICTURE):
|
||||
logger.info('Back to camera main page')
|
||||
break
|
||||
if self.appear_then_click(CLOSE):
|
||||
logger.info('Photo page was exited')
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user