Fix: Lang check failed due to popup

This commit is contained in:
LmeSzinc 2023-12-08 22:00:11 +08:00
parent fcb81bde46
commit 6acd64a1f4
2 changed files with 13 additions and 1 deletions

View File

@ -64,6 +64,7 @@ class MainPage(PopupHandler):
plane: MapPlane = KEYWORDS_MAP_PLANE.Herta_ParlorCar
_lang_checked = False
_lang_check_success = True
def update_plane(self, lang=None) -> MapPlane | None:
"""
@ -108,6 +109,8 @@ class MainPage(PopupHandler):
if lang_unknown or lang != server.lang:
self.config.Emulator_GameLanguage = lang
server.set_lang(lang)
MainPage._lang_checked = True
MainPage._lang_check_success = True
return lang
if lang_unknown:
@ -115,6 +118,8 @@ class MainPage(PopupHandler):
raise RequestHumanTakeover
else:
logger.warning(f'Cannot detect in-game text language, assume current lang={server.lang} is correct')
MainPage._lang_checked = True
MainPage._lang_check_success = False
return server.lang
def handle_lang_check(self, page: Page):
@ -131,7 +136,6 @@ class MainPage(PopupHandler):
return False
self.check_lang_from_map_plane()
MainPage._lang_checked = True
return True
def acquire_lang_checked(self):

View File

@ -72,8 +72,16 @@ class PopupHandler(ModuleBase):
If handled.
"""
if self.appear_then_click(MONTHLY_CARD_REWARD, interval=interval):
# Language check at the first login of the day may fail due to popups
# Retry later
from tasks.base.main_page import MainPage
if not MainPage._lang_check_success:
MainPage._lang_checked = False
return True
if self.appear_then_click(MONTHLY_CARD_GET_ITEM, interval=interval):
from tasks.base.main_page import MainPage
if not MainPage._lang_check_success:
MainPage._lang_checked = False
return True
return False