Merge pull request #630 from LmeSzinc/dev

Bug fix
This commit is contained in:
LmeSzinc 2024-09-15 02:55:40 +08:00 committed by GitHub
commit 4d41d35282
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 79 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -469,6 +469,9 @@ class NemuIpc(Platform):
""" """
# Try existing settings first # Try existing settings first
if self.config.EmulatorInfo_path: if self.config.EmulatorInfo_path:
if 'MuMuPlayerGlobal' in self.config.EmulatorInfo_path:
logger.info(f'nemu_ipc is not available on MuMuPlayerGlobal, {self.config.EmulatorInfo_path}')
raise RequestHumanTakeover
folder = os.path.abspath(os.path.join(self.config.EmulatorInfo_path, '../../')) folder = os.path.abspath(os.path.join(self.config.EmulatorInfo_path, '../../'))
index = NemuIpcImpl.serial_to_id(self.serial) index = NemuIpcImpl.serial_to_id(self.serial)
if index is not None: if index is not None:
@ -488,6 +491,9 @@ class NemuIpc(Platform):
if self.emulator_instance is None: if self.emulator_instance is None:
logger.error('Unable to use NemuIpc because emulator instance not found') logger.error('Unable to use NemuIpc because emulator instance not found')
raise RequestHumanTakeover raise RequestHumanTakeover
if 'MuMuPlayerGlobal' in self.emulator_instance.path:
logger.info(f'nemu_ipc is not available on MuMuPlayerGlobal, {self.emulator_instance.path}')
raise RequestHumanTakeover
try: try:
return NemuIpcImpl( return NemuIpcImpl(
nemu_folder=self.emulator_instance.emulator.abspath('../'), nemu_folder=self.emulator_instance.emulator.abspath('../'),

View File

@ -51,6 +51,47 @@ def _merge_boxed_result(left: BoxedResult, right: BoxedResult) -> BoxedResult:
return left return left
def merge_result_button(
results: list[BoxedResult],
left_func: callable,
right_func: callable,
text_func: callable
) -> list[BoxedResult]:
"""
Args:
results:
left_func: Function that inputs ocr_text (str) and outputs bool
True means mark as left text
right_func:
text_func: Function that inputs left_text (str) right_text (str) and outputs text (str)
"""
left = None
right = None
for result in results:
if left_func(result.ocr_text):
left = result
elif right_func(result.ocr_text):
right = result
text = text_func(
left.ocr_text if left is not None else '',
right.ocr_text if right is not None else ''
)
if left is not None:
if right is not None:
results.remove(right)
left.box = _merge_area(left.box, right.box)
left.ocr_text = text
else:
left.ocr_text = text
else:
if right is not None:
right.ocr_text = text
else:
pass
return results
def merge_buttons(buttons: list[BoxedResult], thres_x=20, thres_y=20) -> list[BoxedResult]: def merge_buttons(buttons: list[BoxedResult], thres_x=20, thres_y=20) -> list[BoxedResult]:
""" """
Args: Args:

View File

@ -23,6 +23,10 @@ class OcrPlaneName(OcrWhiteLetterOnComplexBackground):
result = result.replace('avatia', 'avalia') result = result.replace('avatia', 'avalia')
# 苏乐达™热砂海选会场 # 苏乐达™热砂海选会场
result = re.sub(r'(苏乐达|蘇樂達|SoulGlad|スラーダ|FelizAlma)[rtT]*M*', r'\1', result) result = re.sub(r'(苏乐达|蘇樂達|SoulGlad|スラーダ|FelizAlma)[rtT]*M*', r'\1', result)
# SoulGladtM Scorchsand Audition Ven
if 'Audition' in result:
right = result.find('Audition') + len('Audition')
result = result[:right] + ' Venue'
# 幽囚狱 # 幽囚狱
result = result.replace('幽因狱', '幽囚狱') result = result.replace('幽因狱', '幽囚狱')
result = result.replace('幽因獄', '幽囚獄') result = result.replace('幽因獄', '幽囚獄')

View File

@ -1,4 +1,5 @@
import re import re
from copy import copy
import cv2 import cv2
from pponnxcr.predict_system import BoxedResult from pponnxcr.predict_system import BoxedResult
@ -10,7 +11,7 @@ from module.base.timer import Timer
from module.base.utils import area_center, area_limit, area_offset, crop, image_size from module.base.utils import area_center, area_limit, area_offset, crop, image_size
from module.logger import logger from module.logger import logger
from module.ocr.ocr import Ocr, OcrResultButton from module.ocr.ocr import Ocr, OcrResultButton
from module.ocr.utils import split_and_pair_button_attr, split_and_pair_buttons from module.ocr.utils import merge_result_button, split_and_pair_button_attr, split_and_pair_buttons
from module.ui.draggable_list import DraggableList from module.ui.draggable_list import DraggableList
from module.ui.switch import Switch from module.ui.switch import Switch
from tasks.base.page import page_guide from tasks.base.page import page_guide
@ -40,6 +41,7 @@ class OcrDungeonName(Ocr):
# 苏乐达™热砂海选会场 # 苏乐达™热砂海选会场
result = re.sub(r'(苏乐达|蘇樂達|SoulGlad|スラーダ|FelizAlma)[rtT]*M*', r'\1', result) result = re.sub(r'(苏乐达|蘇樂達|SoulGlad|スラーダ|FelizAlma)[rtT]*M*', r'\1', result)
result = re.sub(r'["\']', '', result) result = re.sub(r'["\']', '', result)
result = re.sub('Aud[it]+on', 'Audition', result)
result = super().after_process(result) result = super().after_process(result)
@ -106,6 +108,17 @@ class OcrDungeonList(OcrDungeonName):
else: else:
result.box = area_offset(result.box, offset=OCR_DUNGEON_NAME.area[:2]) result.box = area_offset(result.box, offset=OCR_DUNGEON_NAME.area[:2])
before = copy(results)
# Calyx_Crimson_The_Hunt_Penacony_SoulGladScorchsandAuditionVenue
merge_result_button(
results,
left_func=lambda x: 'Audition' in x,
right_func=lambda x: 'Venue' in x,
text_func=lambda l, r: f'SoulGladScorchsandAuditionVenue'
)
if results != before:
logger.attr(name=self.name,
text=str([result.ocr_text for result in results]))
return results return results
def _match_result(self, *args, **kwargs): def _match_result(self, *args, **kwargs):

View File

@ -3,6 +3,17 @@ from module.base.button import Button, ButtonWrapper
# This file was auto-generated, do not modify it manually. To generate: # This file was auto-generated, do not modify it manually. To generate:
# ``` python -m dev_tools.button_extract ``` # ``` python -m dev_tools.button_extract ```
ACCOUNT_CONFIRM = ButtonWrapper(
name='ACCOUNT_CONFIRM',
cn=Button(
file='./assets/cn/login/ACCOUNT_CONFIRM.png',
area=(583, 424, 696, 450),
search=(563, 404, 716, 470),
color=(172, 145, 92),
button=(583, 424, 696, 450),
),
en=None,
)
LOGIN_CONFIRM = ButtonWrapper( LOGIN_CONFIRM = ButtonWrapper(
name='LOGIN_CONFIRM', name='LOGIN_CONFIRM',
share=[ share=[

View File

@ -3,7 +3,7 @@ from module.exception import GameNotRunningError
from module.logger import logger from module.logger import logger
from tasks.base.page import page_main from tasks.base.page import page_main
from tasks.base.ui import UI from tasks.base.ui import UI
from tasks.login.assets.assets_login import LOGIN_CONFIRM, LOGIN_LOADING, USER_AGREEMENT_ACCEPT from tasks.login.assets.assets_login import *
from tasks.login.cloud import LoginAndroidCloud from tasks.login.cloud import LoginAndroidCloud
@ -62,6 +62,8 @@ class Login(UI, LoginAndroidCloud):
continue continue
if self.appear_then_click(USER_AGREEMENT_ACCEPT): if self.appear_then_click(USER_AGREEMENT_ACCEPT):
continue continue
if self.appear_then_click(ACCOUNT_CONFIRM):
continue
# Additional # Additional
if self.handle_popup_single(): if self.handle_popup_single():
continue continue