Fix: Slowly appeared WITHDRAW button (#4044)

This commit is contained in:
LmeSzinc 2024-08-02 01:00:05 +08:00
parent d79859e6ed
commit 8dd6ec7811
5 changed files with 31 additions and 10 deletions

View File

@ -1,9 +1,9 @@
from module.campaign.assets import SWITCH_20240725_COMBAT, SWITCH_20240725_STORY from module.campaign.assets import SWITCH_20240725_COMBAT, SWITCH_20240725_STORY
from module.campaign.campaign_base import CampaignBase as CampaignBase_ from module.campaign.campaign_base import CampaignBase as CampaignBase_
from module.campaign.campaign_ui import ModeSwitch
from module.logger import logger from module.logger import logger
from module.ui.switch import Switch
MODE_SWITCH_20240725 = Switch('Mode_switch_20240725', offset=(30, 30)) MODE_SWITCH_20240725 = ModeSwitch('Mode_switch_20240725', offset=(30, 30))
MODE_SWITCH_20240725.add_status('combat', SWITCH_20240725_COMBAT) MODE_SWITCH_20240725.add_status('combat', SWITCH_20240725_COMBAT)
MODE_SWITCH_20240725.add_status('story', SWITCH_20240725_STORY) MODE_SWITCH_20240725.add_status('story', SWITCH_20240725_STORY)

View File

@ -6,6 +6,7 @@ from module.base.timer import Timer
from module.base.utils import * from module.base.utils import *
from module.exception import CampaignNameError from module.exception import CampaignNameError
from module.logger import logger from module.logger import logger
from module.map.assets import WITHDRAW
from module.ocr.ocr import Ocr from module.ocr.ocr import Ocr
from module.template.assets import * from module.template.assets import *
@ -335,7 +336,9 @@ class CampaignOcr(ModuleBase):
while 1: while 1:
if timeout.reached(): if timeout.reached():
raise CampaignNameError raise CampaignNameError
if self.appear(WITHDRAW, offset=(30, 30)):
logger.warning(f'get_chapter_index: WITHDRAW appears')
raise CampaignNameError
try: try:
self._get_stage_name(image) self._get_stage_name(image)
break break

View File

@ -2,20 +2,30 @@ from module.base.timer import Timer
from module.campaign.assets import * from module.campaign.assets import *
from module.campaign.campaign_event import CampaignEvent from module.campaign.campaign_event import CampaignEvent
from module.campaign.campaign_ocr import CampaignOcr from module.campaign.campaign_ocr import CampaignOcr
from module.exception import CampaignNameError, ScriptEnd from module.exception import CampaignEnd, CampaignNameError, ScriptEnd
from module.logger import logger from module.logger import logger
from module.map.assets import WITHDRAW
from module.map.map_operation import MapOperation
from module.ui.assets import CAMPAIGN_CHECK from module.ui.assets import CAMPAIGN_CHECK
from module.ui.switch import Switch from module.ui.switch import Switch
MODE_SWITCH_1 = Switch('Mode_switch_1', offset=(30, 10))
class ModeSwitch(Switch):
def handle_additional(self, main):
if main.appear(WITHDRAW, offset=(30, 30)):
logger.warning(f'ModeSwitch: WITHDRAW appears')
raise CampaignNameError
MODE_SWITCH_1 = ModeSwitch('Mode_switch_1', offset=(30, 10))
MODE_SWITCH_1.add_status('normal', SWITCH_1_NORMAL) MODE_SWITCH_1.add_status('normal', SWITCH_1_NORMAL)
MODE_SWITCH_1.add_status('hard', SWITCH_1_HARD) MODE_SWITCH_1.add_status('hard', SWITCH_1_HARD)
MODE_SWITCH_2 = Switch('Mode_switch_2', offset=(30, 10)) MODE_SWITCH_2 = ModeSwitch('Mode_switch_2', offset=(30, 10))
MODE_SWITCH_2.add_status('hard', SWITCH_2_HARD) MODE_SWITCH_2.add_status('hard', SWITCH_2_HARD)
MODE_SWITCH_2.add_status('ex', SWITCH_2_EX) MODE_SWITCH_2.add_status('ex', SWITCH_2_EX)
class CampaignUI(CampaignEvent, CampaignOcr): class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
ENTRANCE = Button(area=(), color=(), button=(), name='default_button') ENTRANCE = Button(area=(), color=(), button=(), name='default_button')
def campaign_ensure_chapter(self, index, skip_first_screenshot=True): def campaign_ensure_chapter(self, index, skip_first_screenshot=True):
@ -210,6 +220,14 @@ class CampaignUI(CampaignEvent, CampaignOcr):
return True return True
except CampaignNameError: except CampaignNameError:
pass pass
if self.appear(WITHDRAW, offset=(30, 30)):
# logger.info("WITHDRAW button found, wait until map loaded to prevent bugs in game client")
self.ensure_no_info_bar(timeout=2)
try:
self.withdraw()
except CampaignEnd:
pass
continue
self.device.screenshot() self.device.screenshot()

View File

@ -207,8 +207,7 @@ class Benchmark(DaemonBase, CampaignUI):
def run(self): def run(self):
self.config.override(Emulator_ScreenshotMethod='ADB') self.config.override(Emulator_ScreenshotMethod='ADB')
self.device.uninstall_minicap() self.device.uninstall_minicap()
self.ui_goto_campaign() self.ensure_campaign_ui('7-2', mode='normal')
self.campaign_set_chapter('7-2')
logger.attr('DeviceType', self.config.Benchmark_DeviceType) logger.attr('DeviceType', self.config.Benchmark_DeviceType)
logger.attr('TestScene', self.config.Benchmark_TestScene) logger.attr('TestScene', self.config.Benchmark_TestScene)

View File

@ -514,7 +514,8 @@ class UI(InfoHandler):
# - Game client freezes at page_campaign W12, clicking anywhere on the screen doesn't get responses # - Game client freezes at page_campaign W12, clicking anywhere on the screen doesn't get responses
# - Restart game client again fix the issue # - Restart game client again fix the issue
logger.info("WITHDRAW button found, wait until map loaded to prevent bugs in game client") logger.info("WITHDRAW button found, wait until map loaded to prevent bugs in game client")
self.device.sleep(3) self.device.sleep(2)
self.device.screenshot()
if self.appear_then_click(WITHDRAW, offset=(30, 30)): if self.appear_then_click(WITHDRAW, offset=(30, 30)):
self.interval_reset(WITHDRAW) self.interval_reset(WITHDRAW)
return True return True