diff --git a/assets/gui/css/alas.css b/assets/gui/css/alas.css index a0b482c68..91c5649fa 100644 --- a/assets/gui/css/alas.css +++ b/assets/gui/css/alas.css @@ -376,6 +376,7 @@ pre.rich-traceback-code { #pywebio-scope-scheduler-bar, #pywebio-scope-log-bar, #pywebio-scope-log, +#pywebio-scope-daemon-log-bar, #pywebio-scope-daemon-overview #pywebio-scope-groups { font-weight: 500; margin: 0.3125rem; diff --git a/assets/gui/css/dark-alas.css b/assets/gui/css/dark-alas.css index ba011c61e..7cdc1e819 100644 --- a/assets/gui/css/dark-alas.css +++ b/assets/gui/css/dark-alas.css @@ -133,12 +133,13 @@ pre.rich-traceback-code { color: #c9d1d9; } -#pywebio-scope-scheduler-bar, -#pywebio-scope-log-bar, -#pywebio-scope-log, #pywebio-scope-running, #pywebio-scope-pending, #pywebio-scope-waiting, +#pywebio-scope-scheduler-bar, +#pywebio-scope-log-bar, +#pywebio-scope-log, +#pywebio-scope-daemon-log-bar, #pywebio-scope-daemon-overview #pywebio-scope-groups { background-color: #2f3136; border: 1px solid #21262d; diff --git a/assets/gui/css/light-alas.css b/assets/gui/css/light-alas.css index 12651e918..ed295b88b 100644 --- a/assets/gui/css/light-alas.css +++ b/assets/gui/css/light-alas.css @@ -133,12 +133,13 @@ pre.rich-traceback-code { border: 1px solid lightgrey; } -#pywebio-scope-scheduler-bar, -#pywebio-scope-log-bar, -#pywebio-scope-log, #pywebio-scope-running, #pywebio-scope-pending, #pywebio-scope-waiting, +#pywebio-scope-scheduler-bar, +#pywebio-scope-log-bar, +#pywebio-scope-log, +#pywebio-scope-daemon-log-bar, #pywebio-scope-daemon-overview #pywebio-scope-groups { background-color: white; border: 1px solid lightgrey; diff --git a/assets/share/base/daemon/CHAT_CLOSE.png b/assets/share/base/daemon/CHAT_CLOSE.png new file mode 100644 index 000000000..6d177e680 Binary files /dev/null and b/assets/share/base/daemon/CHAT_CLOSE.png differ diff --git a/assets/share/base/daemon/CHAT_OPTION.BUTTON.png b/assets/share/base/daemon/CHAT_OPTION.BUTTON.png new file mode 100644 index 000000000..4a0f42558 Binary files /dev/null and b/assets/share/base/daemon/CHAT_OPTION.BUTTON.png differ diff --git a/assets/share/base/daemon/CHAT_OPTION.png b/assets/share/base/daemon/CHAT_OPTION.png new file mode 100644 index 000000000..2b2fe3e94 Binary files /dev/null and b/assets/share/base/daemon/CHAT_OPTION.png differ diff --git a/assets/share/base/daemon/STORY_NEXT.BUTTON.png b/assets/share/base/daemon/STORY_NEXT.BUTTON.png new file mode 100644 index 000000000..4b4a8e0d6 Binary files /dev/null and b/assets/share/base/daemon/STORY_NEXT.BUTTON.png differ diff --git a/assets/share/base/daemon/STORY_NEXT.png b/assets/share/base/daemon/STORY_NEXT.png new file mode 100644 index 000000000..d5c2d5b24 Binary files /dev/null and b/assets/share/base/daemon/STORY_NEXT.png differ diff --git a/assets/share/base/daemon/STORY_OPTION.BUTTON.png b/assets/share/base/daemon/STORY_OPTION.BUTTON.png new file mode 100644 index 000000000..045bfc589 Binary files /dev/null and b/assets/share/base/daemon/STORY_OPTION.BUTTON.png differ diff --git a/assets/share/base/daemon/STORY_OPTION.png b/assets/share/base/daemon/STORY_OPTION.png new file mode 100644 index 000000000..2a2c50ccd Binary files /dev/null and b/assets/share/base/daemon/STORY_OPTION.png differ diff --git a/config/template.json b/config/template.json index 953863a6d..88a76434d 100644 --- a/config/template.json +++ b/config/template.json @@ -194,5 +194,10 @@ "RogueDebug": { "DebugMode": false } + }, + "Daemon": { + "Daemon": { + "Enable": true + } } } \ No newline at end of file diff --git a/module/base/base.py b/module/base/base.py index 36587b662..7ecfff3c0 100644 --- a/module/base/base.py +++ b/module/base/base.py @@ -298,6 +298,9 @@ class ModuleBase: """ Add a tracking image, image will be saved """ + if not self.config.Error_SaveError: + return + logger.info('screenshot_tracking_add') data = self.device.screenshot_deque[-1] image = data['image'] diff --git a/module/config/argument/args.json b/module/config/argument/args.json index bde713911..d382f09f1 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -1291,5 +1291,19 @@ "value": false } } + }, + "Daemon": { + "Daemon": { + "Enable": { + "type": "state", + "value": true, + "option": [ + true + ], + "option_bold": [ + true + ] + } + } } } \ No newline at end of file diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 2d2e0c2e0..7b029707a 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -252,3 +252,13 @@ RogueBlessing: RogueDebug: DebugMode: false + +# ==================== Tool ==================== + +Daemon: + Enable: + type: state + value: true + option: [ true ] + option_bold: [ true, ] + diff --git a/module/config/argument/menu.json b/module/config/argument/menu.json index 1d51b5eec..1d71e0235 100644 --- a/module/config/argument/menu.json +++ b/module/config/argument/menu.json @@ -26,5 +26,12 @@ "Weekly", "Rogue" ] + }, + "Tool": { + "menu": "list", + "page": "tool", + "tasks": [ + "Daemon" + ] } } \ No newline at end of file diff --git a/module/config/argument/task.yaml b/module/config/argument/task.yaml index a235be9a7..2067b574a 100644 --- a/module/config/argument/task.yaml +++ b/module/config/argument/task.yaml @@ -44,6 +44,7 @@ Daily: Freebies: - Scheduler - SupportReward + # ==================== Weekly ==================== Weekly: @@ -60,3 +61,12 @@ Weekly: - RogueCurio - RoguePath - RogueDebug + +# ==================== Tool ==================== + +Tool: + menu: 'list' + page: 'tool' + tasks: + Daemon: + - Daemon diff --git a/module/config/config.py b/module/config/config.py index 465306142..028a2c541 100644 --- a/module/config/config.py +++ b/module/config/config.py @@ -129,13 +129,17 @@ class AzurLaneConfig(ConfigUpdater, ManualConfig, GeneratedConfig, ConfigWatcher """ Args: func (str, Function): Function to run - func_list (set): Set of tasks to be bound + func_list (list[str]): List of tasks to be bound """ - if func_list is None: - func_list = ["Alas"] if isinstance(func, Function): func = func.command - func_list.append(func) + # func_list: ["Alas", , *func_list] + if func_list is None: + func_list = [] + if func not in func_list: + func_list.insert(0, func) + if "Alas" not in func_list: + func_list.insert(0, "Alas") logger.info(f"Bind task {func_list}") # Bind arguments diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 990e0d471..480990676 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -136,3 +136,6 @@ class GeneratedConfig: # Group `RogueDebug` RogueDebug_DebugMode = False + + # Group `Daemon` + Daemon_Enable = True # True diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index abfd647db..bb91a64dd 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -11,6 +11,10 @@ "Weekly": { "name": "Weekly", "help": "" + }, + "Tool": { + "name": "Tools", + "help": "" } }, "Task": { @@ -53,6 +57,10 @@ "Rogue": { "name": "Simulated Universe", "help": "" + }, + "Daemon": { + "name": "Dialogue Clicker", + "help": "" } }, "Scheduler": { @@ -884,6 +892,17 @@ "help": "No stop conditions, no error handling, stop when encountering an error. Please report errors according to the doc: https://github.com/LmeSzinc/StarRailCopilot/wiki/RogueMap_cn" } }, + "Daemon": { + "_info": { + "name": "Dialogue Clicker", + "help": "Tools need to stop the scheduler and then run independently" + }, + "Enable": { + "name": "Dialogue Clicker", + "help": "Monitor game, automatically click dialogue, phone chatting, and blessing in simulated universe (follow the simulated universe task settings)", + "True": "Enabled" + } + }, "Gui": { "Aside": { "Install": "Install", diff --git a/module/config/i18n/es-ES.json b/module/config/i18n/es-ES.json index 27e73a77b..8c8574ecc 100644 --- a/module/config/i18n/es-ES.json +++ b/module/config/i18n/es-ES.json @@ -11,6 +11,10 @@ "Weekly": { "name": "Semanario", "help": "" + }, + "Tool": { + "name": "útiles", + "help": "" } }, "Task": { @@ -53,6 +57,10 @@ "Rogue": { "name": "Universo Simulado", "help": "" + }, + "Daemon": { + "name": "Clic de diálogo", + "help": "" } }, "Scheduler": { @@ -63,7 +71,7 @@ "Enable": { "name": "Activar tarea", "help": "Añadir tarea al Planificador.", - "True": "Verdadero", + "True": "Activado", "False": "Falso" }, "NextRun": { @@ -884,6 +892,17 @@ "help": "Sin condiciones de parada, sin manejo de errores, deténgase cuando encuentre un error. Informe el error de acuerdo con el documento: https://github.com/LmeSzinc/StarRailCopilot/wiki/RogueMap_cn" } }, + "Daemon": { + "_info": { + "name": "Clic de diálogo", + "help": "Las herramientas necesitan detener el programador y luego ejecutarlo de forma independiente" + }, + "Enable": { + "name": "Clic de diálogo", + "help": "Monitorear el juego, hacer clic automáticamente en el diálogo, chatear por teléfono y bendecir en el universo simulado (sigue la configuración de tareas del universo simulado)", + "True": "Activado" + } + }, "Gui": { "Aside": { "Install": "Instalar", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 572f9ae5f..fd1d223f9 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -11,6 +11,10 @@ "Weekly": { "name": "Menu.Weekly.name", "help": "Menu.Weekly.help" + }, + "Tool": { + "name": "Menu.Tool.name", + "help": "Menu.Tool.help" } }, "Task": { @@ -53,6 +57,10 @@ "Rogue": { "name": "Task.Rogue.name", "help": "Task.Rogue.help" + }, + "Daemon": { + "name": "Task.Daemon.name", + "help": "Task.Daemon.help" } }, "Scheduler": { @@ -884,6 +892,17 @@ "help": "RogueDebug.DebugMode.help" } }, + "Daemon": { + "_info": { + "name": "Daemon._info.name", + "help": "Daemon._info.help" + }, + "Enable": { + "name": "Daemon.Enable.name", + "help": "Daemon.Enable.help", + "True": "True" + } + }, "Gui": { "Aside": { "Install": "インストール", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 779e35086..7664e11c0 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -11,6 +11,10 @@ "Weekly": { "name": "每周", "help": "" + }, + "Tool": { + "name": "工具", + "help": "" } }, "Task": { @@ -53,6 +57,10 @@ "Rogue": { "name": "模拟宇宙", "help": "" + }, + "Daemon": { + "name": "剧情连点器", + "help": "" } }, "Scheduler": { @@ -884,6 +892,17 @@ "help": "无停止条件,无异常处理,遇错误即停止,请按文档上报异常:https://github.com/LmeSzinc/StarRailCopilot/wiki/RogueMap_cn" } }, + "Daemon": { + "_info": { + "name": "剧情连点器", + "help": "工具需要停止调度器再单独运行" + }, + "Enable": { + "name": "剧情连点器", + "help": "监听画面自动点击剧情、手机聊天、模拟宇宙祝福(遵循模拟宇宙任务设置)", + "True": "已启用" + } + }, "Gui": { "Aside": { "Install": "安装", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 94471e287..de1d41ff5 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -11,6 +11,10 @@ "Weekly": { "name": "每週", "help": "" + }, + "Tool": { + "name": "工具", + "help": "" } }, "Task": { @@ -53,6 +57,10 @@ "Rogue": { "name": "模擬宇宙", "help": "" + }, + "Daemon": { + "name": "劇情連點器", + "help": "" } }, "Scheduler": { @@ -881,7 +889,18 @@ }, "DebugMode": { "name": "開發模式", - "help": "無停止條件,無異常處理,遇錯誤即停止,請依文件回報異常:https://github.com/LmeSzinc/StarRailCopilot/wiki/RogueMap_cn" + "help": "無停止條件,無異常處理,遇錯誤即停止,請依檔案回報異常:https://github.com/LmeSzinc/StarRailCopilot/wiki/RogueMap_cn" + } + }, + "Daemon": { + "_info": { + "name": "劇情連點器", + "help": "工具需要停止調度器再單獨運作" + }, + "Enable": { + "name": "劇情連點器", + "help": "監聽畫面自動點擊劇情、手機聊天、模擬宇宙祝福(遵循模擬宇宙任務設定)", + "True": "已啟用" } }, "Gui": { diff --git a/module/webui/app.py b/module/webui/app.py index 01d44a555..1aebe46e7 100644 --- a/module/webui/app.py +++ b/module/webui/app.py @@ -617,7 +617,7 @@ class AlasGUI(Frame): [ put_scope("scheduler-bar"), put_scope("groups"), - put_scope("log-bar"), + put_scope("daemon-log-bar"), put_scope("log", [put_html("")]), ], ) @@ -631,7 +631,7 @@ class AlasGUI(Frame): [ put_scope( "_daemon_upper", - [put_scope("scheduler-bar"), put_scope("log-bar")], + [put_scope("scheduler-bar"), put_scope("daemon-log-bar")], ), put_scope("groups"), put_scope("log", [put_html("")]), @@ -660,16 +660,17 @@ class AlasGUI(Frame): scope="scheduler_btn", ) - with use_scope("log-bar"): - put_text(t("Gui.Overview.Log")).style( - "font-size: 1.25rem; margin: auto .5rem auto;" - ) - put_scope( - "log-bar-btns", - [ - put_scope("log_scroll_btn"), - ], - ) + with use_scope("daemon-log-bar"): + with use_scope("log-title"): + put_text(t("Gui.Overview.Log")).style( + "font-size: 1.25rem; margin: auto .5rem auto;" + ) + put_scope( + "log-bar-btns", + [ + put_scope("log_scroll_btn"), + ], + ) switch_log_scroll = BinarySwitchButton( label_on=t("Gui.Button.ScrollON"), diff --git a/module/webui/process_manager.py b/module/webui/process_manager.py index bad0db104..f414654f8 100644 --- a/module/webui/process_manager.py +++ b/module/webui/process_manager.py @@ -147,6 +147,10 @@ class ProcessManager: if e is not None: AzurLaneAutoScript.stop_event = e StarRailCopilot(config_name=config_name).loop() + elif func == "Daemon": + from tasks.base.daemon import Daemon + + Daemon(config=config_name, task="Daemon").run() else: logger.critical(f"No function matched: {func}") logger.info(f"[{config_name}] exited. Reason: Finish\n") diff --git a/tasks/base/assets/assets_base_daemon.py b/tasks/base/assets/assets_base_daemon.py new file mode 100644 index 000000000..390624613 --- /dev/null +++ b/tasks/base/assets/assets_base_daemon.py @@ -0,0 +1,45 @@ +from module.base.button import Button, ButtonWrapper + +# This file was auto-generated, do not modify it manually. To generate: +# ``` python -m dev_tools.button_extract ``` + +CHAT_CLOSE = ButtonWrapper( + name='CHAT_CLOSE', + share=Button( + file='./assets/share/base/daemon/CHAT_CLOSE.png', + area=(1115, 96, 1145, 126), + search=(1095, 76, 1165, 146), + color=(180, 180, 180), + button=(1115, 96, 1145, 126), + ), +) +CHAT_OPTION = ButtonWrapper( + name='CHAT_OPTION', + share=Button( + file='./assets/share/base/daemon/CHAT_OPTION.png', + area=(628, 483, 648, 537), + search=(608, 463, 668, 557), + color=(217, 215, 214), + button=(649, 496, 1129, 525), + ), +) +STORY_NEXT = ButtonWrapper( + name='STORY_NEXT', + share=Button( + file='./assets/share/base/daemon/STORY_NEXT.png', + area=(631, 673, 649, 682), + search=(611, 653, 669, 702), + color=(124, 108, 83), + button=(927, 606, 1219, 693), + ), +) +STORY_OPTION = ButtonWrapper( + name='STORY_OPTION', + share=Button( + file='./assets/share/base/daemon/STORY_OPTION.png', + area=(783, 456, 795, 485), + search=(763, 436, 815, 505), + color=(158, 167, 171), + button=(813, 453, 1069, 488), + ), +) diff --git a/tasks/base/daemon.py b/tasks/base/daemon.py new file mode 100644 index 000000000..6379692c7 --- /dev/null +++ b/tasks/base/daemon.py @@ -0,0 +1,58 @@ +from module.base.timer import Timer +from module.logger import logger +from tasks.base.assets.assets_base_daemon import * +from tasks.base.main_page import MainPage +from tasks.base.page import page_main, page_rogue +from tasks.daily.assets.assets_daily_camera import PICTURE_TAKEN +from tasks.map.assets.assets_map_bigmap import TELEPORT_RIGHT +from tasks.rogue.route.base import RouteBase + + +class Daemon(RouteBase): + def run(self): + # Rebind daemon settings along with rogue settings + self.config.bind('Daemon', func_list=['Rogue']) + self.device.disable_stuck_detection() + + teleport_confirm = Timer(1, count=5) + while 1: + self.device.screenshot() + + # Check lang + if not MainPage._lang_checked and self.ui_page_appear(page_main, interval=5): + self.handle_lang_check(page=page_main) + # Check again + if not MainPage._lang_check_success: + MainPage._lang_checked = False + # Story + if self.appear_then_click(STORY_NEXT, interval=0.7): + self.interval_reset(STORY_OPTION) + continue + if self.appear_then_click(STORY_OPTION, interval=1): + continue + # Story teleport + if self.appear_then_click(TELEPORT_RIGHT, interval=3): + teleport_confirm.reset() + continue + if teleport_confirm.started() and not teleport_confirm.reached(): + if self.handle_popup_confirm(): + logger.info(f'{TELEPORT_RIGHT} -> popup') + continue + # Chat + if self.appear_then_click(CHAT_OPTION, interval=3): + continue + if self.appear_then_click(CHAT_CLOSE, interval=3): + continue + # Popup + if self.handle_reward(interval=1.5): + continue + if self.handle_ui_close(PICTURE_TAKEN, interval=1): + continue + # Rogue + if self.handle_blessing(): + continue + if self.ui_page_appear(page_rogue): + if self.handle_event_continue(): + continue + if self.handle_event_option(): + continue diff --git a/tasks/base/ui.py b/tasks/base/ui.py index 2bf5ed385..09d18db42 100644 --- a/tasks/base/ui.py +++ b/tasks/base/ui.py @@ -18,12 +18,13 @@ class UI(MainPage): ui_current: Page ui_main_confirm_timer = Timer(0.2, count=0) - def ui_page_appear(self, page): + def ui_page_appear(self, page, interval=0): """ Args: page (Page): + interval: """ - return self.appear(page.check_button) + return self.appear(page.check_button, interval=interval) def ui_get_current_page(self, skip_first_screenshot=True): """