Merge pull request #80 from LmeSzinc/dev

Bug fix
This commit is contained in:
LmeSzinc 2023-09-03 00:29:57 +08:00 committed by GitHub
commit 0e1b6578eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -47,10 +47,10 @@ OCR_ASSIGNMENT_LIMIT = ButtonWrapper(
name='OCR_ASSIGNMENT_LIMIT',
share=Button(
file='./assets/share/assignment/ui/OCR_ASSIGNMENT_LIMIT.png',
area=(1095, 82, 1180, 125),
search=(1075, 62, 1200, 145),
color=(41, 44, 50),
button=(1095, 82, 1180, 125),
area=(1095, 95, 1180, 119),
search=(1075, 75, 1200, 139),
color=(51, 54, 60),
button=(1095, 95, 1180, 119),
),
)
OCR_ASSIGNMENT_LIST = ButtonWrapper(

View File

@ -13,6 +13,7 @@ from tasks.combat.assets.assets_combat_prepare import COMBAT_PREPARE
class UI(PopupHandler):
ui_current: Page
ui_main_confirm_timer = Timer(0.2, count=0)
def ui_page_appear(self, page):
"""
@ -112,6 +113,8 @@ class UI(PopupHandler):
# Destination page
if self.ui_page_appear(destination):
logger.info(f'Page arrive: {destination}')
if self.ui_page_confirm(destination):
logger.info(f'Page arrive confirm {destination}')
break
# Other pages
@ -121,6 +124,8 @@ class UI(PopupHandler):
continue
if self.appear(page.check_button, interval=5):
logger.info(f'Page switch: {page} -> {page.parent}')
if self.ui_page_confirm(page):
logger.info(f'Page arrive confirm {page}')
button = page.links[page.parent]
self.device.click(button)
self.ui_button_interval_reset(button)
@ -287,6 +292,45 @@ class UI(PopupHandler):
return False
def _ui_button_confirm(
self,
button,
confirm=Timer(0.1, count=0),
timeout=Timer(2, count=6),
skip_first_screenshot=True
):
confirm.reset()
timeout.reset()
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
if timeout.reached():
logger.warning(f'_ui_button_confirm({button}) timeout')
break
if self.appear(button):
if confirm.reached():
break
else:
confirm.reset()
def ui_page_confirm(self, page):
"""
Args:
page (Page):
Returns:
bool: If handled
"""
if page == page_main:
self._ui_button_confirm(page.check_button)
return True
return False
def ui_button_interval_reset(self, button):
"""
Reset interval of some button to avoid mistaken clicks

View File

@ -31,6 +31,7 @@ class DailyQuestOcr(Ocr):
if self.lang == 'ch':
result = result.replace("J", "")
result = result.replace(";", "")
result = result.replace("", "")
result = result.replace("宇审", "宇宙")
# 进行中」hbadarin
if "进行中" in result: