Skip to content

Commit

Permalink
Fix: campaign_ensure_chapter incorrect due to slow animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Air111 committed Apr 24, 2024
1 parent 0264e3f commit 5baad52
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions module/campaign/campaign_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def campaign_ensure_chapter(self, index, skip_first_screenshot=True):
# A copy of use ui_ensure_index.
logger.hr("UI ensure index")
retry = Timer(1, count=2)
error_confirm = Timer(0.2, count=0)
error_confirm_1 = Timer(0.2, count=0)
error_confirm_2 = Timer(0.2, count=0)
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
Expand All @@ -44,15 +45,23 @@ def campaign_ensure_chapter(self, index, skip_first_screenshot=True):
logger.attr("Index", current)
diff = index - current
if diff == 0:
break
# index=4, current=4, actual=14
error_confirm_2.start()
if not error_confirm_2.reached():
continue
else:
break
else:
error_confirm_2.clear()

# 14-4 may be OCR as 4-1 due to slow animation, confirm if it is 4-1
# index=14, current=4, actual=14
if index >= 11 and index % 10 == current:
error_confirm.start()
if not error_confirm.reached():
error_confirm_1.start()
if not error_confirm_1.reached():
continue
else:
error_confirm.reset()
error_confirm_1.reset()

# Switch
if retry.reached():
Expand Down

0 comments on commit 5baad52

Please sign in to comment.