Просмотр исходного кода

fix(Restart): Reuse global UI assets for login and mail dialogs
- replace login cancel and mail confirmation assets with shared global UI assets
- remove obsolete Restart image rules, metadata entries, and PNG files
- update the main page hook to use the shared cancel asset

neptine 1 месяц назад
Родитель
Сommit
5b556e92cf

+ 4 - 0
tasks/ActivityShikigami/script_task.py

@@ -265,6 +265,10 @@ class ScriptTask(StateMachine, GameUi, Battle, BaseActivity, SwitchSoul, Activit
                 break
             if self.appear(self.I_CHECK_BATTLE_MAIN) and self.appear_then_click(self.I_UI_BACK_YELLOW, interval=2.5):
                 continue
+            if self.appear_then_click(self.I_UI_BACK_CIRCLE, interval=2.5):
+                continue
+            if self.appear_then_click(self.I_UI_BACK_RED, interval=1.5):
+                continue
 
     def _run_ap(self):
         """

+ 1 - 1
tasks/GameUi/default_pages.py

@@ -61,7 +61,7 @@ page_login.add_enter_success_hooks(handle_login_page)
 # 庭院主页(此处通过提高阈值来处理部分探索章节会识别成原始庭院的问题, 后续有其他更好方法需改善)
 page_main = Page(GameUiAssets.I_CHECK_MAIN, category="global")
 page_main.add_enter_success_hooks(
-    GameUiAssets.I_AD_CLOSE_RED, GlobalGameAssets.I_UI_BACK_RED, RestartAssets.I_CANCEL_BATTLE,
+    GameUiAssets.I_AD_CLOSE_RED, GlobalGameAssets.I_UI_BACK_RED, GlobalGameAssets.I_UI_CANCEL_SAMLL,
     conditional_action(RestartAssets.I_LOGIN_COURTYARD, RestartAssets.C_LOGIN_SCROLL_CLOSE_AREA),
 )
 

+ 4 - 4
tasks/GlobalGame/assets.py

@@ -42,11 +42,11 @@ class GlobalGameAssets:
 	# 长一点的确认(旧) 
 	I_UI_CONFIRM_OLD = RuleImage(roi_front=(685,376,179,66), roi_back=(663,334,232,193), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_confirm_old.png")
 	# 长一点的确认 
-	I_UI_CONFIRM = RuleImage(roi_front=(664,407,179,66), roi_back=(643,389,214,95), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_confirm.png")
+	I_UI_CONFIRM = RuleImage(roi_front=(664,407,179,66), roi_back=(643,345,231,320), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_confirm.png")
 	# 长一点的取消(旧) 
 	I_UI_CANCEL_OLD = RuleImage(roi_front=(417,368,177,62), roi_back=(366,349,261,173), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_cancel_old.png")
 	# 长一点的取消 
-	I_UI_CANCEL = RuleImage(roi_front=(438,407,177,62), roi_back=(356,384,276,125), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_cancel.png")
+	I_UI_CANCEL = RuleImage(roi_front=(438,407,177,62), roi_back=(356,384,275,256), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_cancel.png")
 	# '获得奖励' 四个大字 
 	I_UI_REWARD = RuleImage(roi_front=(530,126,211,66), roi_back=(464,69,352,303), threshold=0.73, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_reward.png")
 	# description 
@@ -64,12 +64,12 @@ class GlobalGameAssets:
 	# 短一点的取消 
 	I_UI_CANCEL_SAMLL = RuleImage(roi_front=(472,389,128,62), roi_back=(360,377,272,185), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_cancel_samll.png")
 	# description 
-	I_UI_UNCHECK = RuleImage(roi_front=(567,343,33,36), roi_back=(497,303,216,100), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_uncheck.png")
+	I_UI_UNCHECK = RuleImage(roi_front=(545,343,33,36), roi_back=(497,303,216,100), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_uncheck.png")
 	# 勾选 
 	I_UI_CHECK = RuleImage(roi_front=(564,341,40,38), roi_back=(512,329,164,78), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_check.png")
 	# 知道了 
 	I_UI_GOTIT_SMALL = RuleImage(roi_front=(678,396,127,60), roi_back=(622,371,242,100), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_gotit_small.png")
 	# 圆形返回按钮(移植自mine) 
-	# I_UI_BACK_CIRCLE = RuleImage(roi_front=(24,21,36,39), roi_back=(0,0,95,101), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_back_circle.png")
+	I_UI_BACK_CIRCLE = RuleImage(roi_front=(24,21,36,39), roi_back=(0,0,95,101), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_back_circle.png")
 
 

+ 3 - 3
tasks/GlobalGame/ui/image.json

@@ -12,7 +12,7 @@
     "itemName": "ui_confirm",
     "imageName": "ui_ui_confirm.png",
     "roiFront": "664,407,179,66",
-    "roiBack": "643,389,214,95",
+    "roiBack": "643,345,231,320",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "长一点的确认"
@@ -30,7 +30,7 @@
     "itemName": "ui_cancel",
     "imageName": "ui_ui_cancel.png",
     "roiFront": "438,407,177,62",
-    "roiBack": "356,384,276,125",
+    "roiBack": "356,384,275,256",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "长一点的取消"
@@ -110,7 +110,7 @@
   {
     "itemName": "ui_uncheck",
     "imageName": "ui_ui_uncheck.png",
-    "roiFront": "567,343,33,36",
+    "roiFront": "545,343,33,36",
     "roiBack": "497,303,216,100",
     "method": "Template matching",
     "threshold": 0.8,

+ 0 - 8
tasks/Restart/assets.py

@@ -44,8 +44,6 @@ class RestartAssets:
 	I_HARVEST_MAIL_ALL = RuleImage(roi_front=(69,579,80,67), roi_back=(28,551,142,144), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_mail_all.png")
 	# 有些邮件需要点击一次 
 	I_HARVEST_MAIL_OPEN = RuleImage(roi_front=(163,367,45,48), roi_back=(139,86,100,487), threshold=0.9, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_mail_open.png")
-	# 确认收取邮件 
-	I_HARVEST_MAIL_CONFIRM = RuleImage(roi_front=(687,543,168,64), roi_back=(687,543,168,64), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_mail_confirm.png")
 	# description 
 	I_HARVEST_SOUL = RuleImage(roi_front=(241,497,38,36), roi_back=(68,480,930,72), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_soul.png")
 	# description 
@@ -108,8 +106,6 @@ class RestartAssets:
 	I_LOGIN_YELLOW_CLOSE = RuleImage(roi_front=(29,17,46,44), roi_back=(0,0,94,86), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_yellow_close.png")
 	# 用于判断是否出现登录选区的 
 	I_LOGIN_8 = RuleImage(roi_front=(178,572,53,60), roi_back=(1,547,241,105), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_8.png")
-	# 登录时候不观看CG视频 
-	I_WATCH_VIDEO_CANCEL = RuleImage(roi_front=(466,396,130,61), roi_back=(466,396,130,61), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_watch_video_cancel.png")
 	# 指定角色进入游戏,默认第一个 
 	I_LOGIN_SPECIFIC_SERVE = RuleImage(roi_front=(0,0,120,120), roi_back=(0,0,120,120), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_specific_serve.png")
 	# 下载插画 
@@ -118,8 +114,6 @@ class RestartAssets:
 	I_LOGIN_LOGIN_GOTO_BIND_PHONE = RuleImage(roi_front=(940,430,170,150), roi_back=(940,430,170,150), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_goto_bind_phone.png")
 	# 登录界面 弹出框 确定绑定手机 
 	I_LOGIN_LOGIN_ENSURE_BIND_PHONE = RuleImage(roi_front=(670,460,160,100), roi_back=(670,460,160,100), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_ensure_bind_phone.png")
-	# 登录界面 弹出框 取消绑定手机 
-	I_LOGIN_LOGIN_CANCEL_BIND_PHONE = RuleImage(roi_front=(450,460,160,100), roi_back=(450,460,160,100), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_cancel_bind_phone.png")
 	# 登录界面 弹出框 阴阳师精灵 
 	I_LOGIN_LOGIN_ONMYOJI_GENIE = RuleImage(roi_front=(80,110,280,120), roi_back=(80,110,280,120), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_login_onmyoji_genie.png")
 	# 已有角色 
@@ -130,8 +124,6 @@ class RestartAssets:
 	I_EARLY_SERVER = RuleImage(roi_front=(596,269,115,33), roi_back=(596,269,115,33), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_early_server.png")
 	# 取消体验服切换弹窗 
 	I_EARLY_SERVER_CANCEL = RuleImage(roi_front=(435,404,172,56), roi_back=(435,404,172,56), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_early_server_cancel.png")
-	# 取消继续战斗 
-	I_CANCEL_BATTLE = RuleImage(roi_front=(471,395,129,55), roi_back=(367,227,545,296), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_cancel_battle.png")
 	# 庭院卷轴收起状态标志(移植自mine) 
 	I_LOGIN_COURTYARD = RuleImage(roi_front=(40,640,100,50), roi_back=(40,640,100,50), threshold=0.8, method="Template matching", file="./tasks/Restart/login/login_courtyard.png")
 

BIN
tasks/Restart/harvest/harvest_harvest_mail_confirm.png


+ 1 - 10
tasks/Restart/harvest/image.json

@@ -62,15 +62,6 @@
     "threshold": 0.9,
     "description": "有些邮件需要点击一次"
   },
-  {
-    "itemName": "harvest_mail_confirm",
-    "imageName": "harvest_harvest_mail_confirm.png",
-    "roiFront": "687,543,168,64",
-    "roiBack": "687,543,168,64",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "确认收取邮件"
-  },
   {
     "itemName": "harvest_soul",
     "imageName": "harvest_harvest_soul.png",
@@ -251,4 +242,4 @@
     "threshold": 0.8,
     "description": "邮件红点"
   }
-]
+]

+ 4 - 4
tasks/Restart/login.py

@@ -46,7 +46,7 @@ class LoginHandler(BaseTask, RestartAssets, GameUiAssets, GeneralBuffAssets):
             self._burst()
 
             # 取消继续战斗
-            if self.appear_then_click(self.I_CANCEL_BATTLE, interval=0.8):
+            if self.appear_then_click(self.I_UI_CANCEL_SAMLL, interval=0.8):
                 logger.info('Cancel continue battle')
                 continue
             # 确认进入庭院(优化:先检测加成图标确认在庭院页面,再检测式神录图标)
@@ -79,7 +79,7 @@ class LoginHandler(BaseTask, RestartAssets, GameUiAssets, GeneralBuffAssets):
                 logger.info('Download inbetweening')
                 continue
             # 不观看视频
-            if self.appear_then_click(self.I_WATCH_VIDEO_CANCEL, interval=0.6):
+            if self.appear_then_click(self.I_UI_CANCEL_SAMLL, interval=0.6):
                 logger.info('Close video')
                 continue
             # 右上角的红色的关闭
@@ -94,7 +94,7 @@ class LoginHandler(BaseTask, RestartAssets, GameUiAssets, GeneralBuffAssets):
             if self.appear_then_click(self.I_LOGIN_LOGIN_GOTO_BIND_PHONE):
                 while 1:
                     self.screenshot()
-                    if self.appear_then_click(self.I_LOGIN_LOGIN_CANCEL_BIND_PHONE):
+                    if self.appear_then_click(self.I_UI_CANCEL_SAMLL):
                         logger.info("Close bind phone")
                         break
                 continue
@@ -310,7 +310,7 @@ class LoginHandler(BaseTask, RestartAssets, GameUiAssets, GeneralBuffAssets):
             self.screenshot()
             if timeout_timer.reached():
                 break
-            if self.appear_then_click(self.I_HARVEST_MAIL_CONFIRM, interval=0.8):
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=0.8):
                 break
 
             if self.appear_then_click(self.I_READ_ALL_MAIL, interval=1.5):

+ 0 - 27
tasks/Restart/login/image.json

@@ -53,15 +53,6 @@
     "threshold": 0.8,
     "description": "用于判断是否出现登录选区的"
   },
-  {
-    "itemName": "watch_video_cancel",
-    "imageName": "login_watch_video_cancel.png",
-    "roiFront": "466,396,130,61",
-    "roiBack": "466,396,130,61",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "登录时候不观看CG视频"
-  },
   {
     "itemName": "login_specific_serve",
     "imageName": "login_login_specific_serve.png",
@@ -98,15 +89,6 @@
     "threshold": 0.8,
     "description": "登录界面 弹出框 确定绑定手机"
   },
-  {
-    "itemName": "login_login_cancel_bind_phone",
-    "imageName": "login_login_cancel_bind_phone.png",
-    "roiFront": "450,460,160,100",
-    "roiBack": "450,460,160,100",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "登录界面 弹出框 取消绑定手机"
-  },
   {
     "itemName": "login_login_onmyoji_genie",
     "imageName": "login_login_onmyoji_genie.png",
@@ -152,15 +134,6 @@
     "threshold": 0.8,
     "description": "取消体验服切换弹窗"
   },
-  {
-    "itemName": "cancel_battle",
-    "imageName": "login_cancel_battle.png",
-    "roiFront": "471,395,129,55",
-    "roiBack": "367,227,545,296",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "取消继续战斗"
-  },
   {
     "itemName": "login_courtyard",
     "imageName": "login_courtyard.png",

BIN
tasks/Restart/login/login_cancel_battle.png


BIN
tasks/Restart/login/login_login_cancel_bind_phone.png


BIN
tasks/Restart/login/login_watch_video_cancel.png