fix(task): 再次修复无法处理未读交流跳过确认对话框
将处理未读交流的循环展开,合并到其他调用方的循环内。
This commit is contained in:
parent
6ea16b50ae
commit
82064f7127
|
@ -1 +1 @@
|
|||
{"definitions":{"f1f21925-3e22-4dd1-b53b-bb52bcf26c2b":{"name":"Common.ButtonCommuSkip","displayName":"跳过交流按钮","type":"template","annotationId":"f1f21925-3e22-4dd1-b53b-bb52bcf26c2b","useHintRect":false}},"annotations":[{"id":"f1f21925-3e22-4dd1-b53b-bb52bcf26c2b","type":"rect","data":{"x1":180,"y1":1187,"x2":204,"y2":1215}}]}
|
||||
{"definitions":{"f1f21925-3e22-4dd1-b53b-bb52bcf26c2b":{"name":"Common.ButtonCommuSkip","displayName":"跳过交流按钮","type":"template","annotationId":"f1f21925-3e22-4dd1-b53b-bb52bcf26c2b","useHintRect":false},"f6ca6bd3-543f-4779-8367-c5c883f04b95":{"name":"Common.ButtonCommuFastforward","displayName":"快进交流按钮","type":"template","annotationId":"f6ca6bd3-543f-4779-8367-c5c883f04b95","useHintRect":false}},"annotations":[{"id":"f1f21925-3e22-4dd1-b53b-bb52bcf26c2b","type":"rect","data":{"x1":180,"y1":1187,"x2":204,"y2":1215}},{"id":"f6ca6bd3-543f-4779-8367-c5c883f04b95","type":"rect","data":{"x1":583,"y1":1187,"x2":618,"y2":1213}}]}
|
Binary file not shown.
After Width: | Height: | Size: 437 KiB |
|
@ -0,0 +1 @@
|
|||
{"definitions":{"4d78add6-1027-4939-bb51-f99fca7db2ce":{"name":"Common.TextSkipCommuComfirmation","displayName":"跳过未读交流确认对话框标题","type":"template","annotationId":"4d78add6-1027-4939-bb51-f99fca7db2ce","useHintRect":false}},"annotations":[{"id":"4d78add6-1027-4939-bb51-f99fca7db2ce","type":"rect","data":{"x1":53,"y1":920,"x2":260,"y2":958}}]}
|
|
@ -23,14 +23,22 @@ def skip_button():
|
|||
preprocessors=[WhiteFilter()]
|
||||
)
|
||||
|
||||
@action('获取 FASTFORWARD 按钮', screenshot_mode='manual-inherit')
|
||||
def fastforward_button():
|
||||
device.screenshot()
|
||||
return image.find(
|
||||
R.Common.ButtonCommuFastforward,
|
||||
threshold=0.6,
|
||||
) or image.find(
|
||||
R.Common.ButtonCommuFastforward,
|
||||
threshold=0.6,
|
||||
preprocessors=[WhiteFilter()]
|
||||
)
|
||||
|
||||
@action('检查是否处于交流')
|
||||
def is_at_commu():
|
||||
return skip_button() is not None
|
||||
|
||||
@action('跳过交流')
|
||||
def skip_commu():
|
||||
device.click(image.expect_wait(R.Common.ButtonCommuSkip))
|
||||
|
||||
@action('检查未读交流', screenshot_mode='manual')
|
||||
def handle_unread_commu(img: MatLike | None = None) -> bool:
|
||||
"""
|
||||
|
@ -39,37 +47,27 @@ def handle_unread_commu(img: MatLike | None = None) -> bool:
|
|||
:param img: 截图。
|
||||
:return: 是否跳过了交流。
|
||||
"""
|
||||
ret = False
|
||||
logger.debug('Check and skip commu')
|
||||
img = use_screenshot(img)
|
||||
skip_btn = image.find(R.Common.ButtonCommuSkip, preprocessors=[WhiteFilter()])
|
||||
if skip_btn is None:
|
||||
logger.info('No skip button found. Not at a commu.')
|
||||
return ret
|
||||
|
||||
ret = True
|
||||
logger.debug('Skip button found. Check commu')
|
||||
|
||||
it = Interval()
|
||||
cd = Countdown(3)
|
||||
while True:
|
||||
device.screenshot()
|
||||
if skip := skip_button():
|
||||
device.click(skip)
|
||||
logger.debug('Clicked skip button.')
|
||||
if image.find(R.Common.ButtonConfirm):
|
||||
logger.info('Unread commu found.')
|
||||
device.click()
|
||||
logger.debug('Clicked confirm button.')
|
||||
logger.debug('Pushing notification...')
|
||||
user.info('发现未读交流', images=[img])
|
||||
if not is_at_commu():
|
||||
break
|
||||
logger.debug('Skipping commu...')
|
||||
it.wait()
|
||||
|
||||
logger.info('Commu skip done.')
|
||||
return ret
|
||||
if skip := skip_button():
|
||||
device.click(skip)
|
||||
logger.debug('Clicked skip button.')
|
||||
return True
|
||||
# 有时会碰见只有快进按钮的交流
|
||||
# [screenshots/produce/in_produce/pre_final_exam_commu.png]
|
||||
if fastforward := fastforward_button():
|
||||
device.click(fastforward)
|
||||
logger.debug('Clicked fastforward button.')
|
||||
return True
|
||||
if image.find(R.Common.TextSkipCommuComfirmation):
|
||||
logger.info('Unread commu found.')
|
||||
device.click(image.expect(R.Common.ButtonConfirm))
|
||||
logger.debug('Clicked confirm button.')
|
||||
logger.debug('Pushing notification...')
|
||||
user.info('发现未读交流', images=[img])
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -140,6 +140,12 @@ def fast_acquisitions() -> AcquisitionType | None:
|
|||
"""处理行动开始前和结束后可能需要处理的事件"""
|
||||
img = device.screenshot()
|
||||
logger.info("Acquisition stuffs...")
|
||||
|
||||
# 加载画面
|
||||
if loading():
|
||||
logger.info("Loading...")
|
||||
return "Loading"
|
||||
device.click(0, 0)
|
||||
|
||||
# 跳过未读交流
|
||||
logger.debug("Check skip commu...")
|
||||
|
@ -147,12 +153,6 @@ def fast_acquisitions() -> AcquisitionType | None:
|
|||
return "SkipCommu"
|
||||
device.click(0, 0)
|
||||
|
||||
# 加载画面
|
||||
if loading():
|
||||
logger.info("Loading...")
|
||||
return "Loading"
|
||||
device.click(0, 0)
|
||||
|
||||
# P饮料到达上限
|
||||
logger.debug("Check PDrink max...")
|
||||
# TODO: 需要封装一个更好的实现方式。比如 wait_stable?
|
||||
|
@ -205,8 +205,6 @@ def fast_acquisitions() -> AcquisitionType | None:
|
|||
return "NetworkError"
|
||||
device.click(0, 0)
|
||||
|
||||
# === 需要 OCR 的放在最后执行 ===
|
||||
|
||||
# 物品选择对话框
|
||||
logger.debug("Check award select dialog...")
|
||||
if image.find(R.InPurodyuusu.TextClaim):
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 581 KiB |
Loading…
Reference in New Issue