From d71b9179ce95fe136e62d88a57214a2a0b126143 Mon Sep 17 00:00:00 2001 From: 0O0o0oOoO00 <11174151+0O0o0oOoO00@users.noreply.github.com> Date: Mon, 27 Oct 2025 17:20:55 +0800 Subject: [PATCH] add: add hook operation tool --- alas.py | 9 +++++++++ config/template.json | 8 ++++++++ module/config/argument/args.json | 20 ++++++++++++++++++++ module/config/argument/argument.yaml | 7 +++++++ module/config/argument/menu.json | 3 ++- module/config/argument/task.yaml | 2 ++ module/config/config_generated.py | 3 +++ module/config/full_config_generated.py | 4 ++++ module/config/i18n/en-US.json | 16 ++++++++++++++++ module/config/i18n/ja-JP.json | 16 ++++++++++++++++ module/config/i18n/zh-CN.json | 16 ++++++++++++++++ module/config/i18n/zh-TW.json | 16 ++++++++++++++++ module/submodule/utils.py | 9 ++++++++- 13 files changed, 127 insertions(+), 2 deletions(-) diff --git a/alas.py b/alas.py index 38f144349..f268fdda1 100644 --- a/alas.py +++ b/alas.py @@ -903,6 +903,15 @@ class AzurLaneAutoScript(AzurLaneAutoScript): def coalition_sp(self): super().coalition_sp() + def hook_op(self): + op = self.config.full_config.HookOp_HookOp_Operation + if op == "inject": + CrackResource(self.config, self.device).ensure() + elif op == "apply": + do_crack_op(self.config, self.device, CrackOp.EnableAll) + else: + logger.error(f"Unknown Hook Operation: {op}") + def get_next_task(self): while 1: task = self.config.get_next() diff --git a/config/template.json b/config/template.json index f77d1c0ee..b2a10f0f8 100644 --- a/config/template.json +++ b/config/template.json @@ -2677,5 +2677,13 @@ "Storage": { "Storage": {} } + }, + "HookOp": { + "HookOp": { + "Operation": "apply" + }, + "Storage": { + "Storage": {} + } } } \ No newline at end of file diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 7da390d6b..b7fdfd76d 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -16919,5 +16919,25 @@ "display": "disabled" } } + }, + "HookOp": { + "HookOp": { + "Operation": { + "type": "select", + "value": "apply", + "option": [ + "inject", + "apply" + ] + } + }, + "Storage": { + "Storage": { + "type": "storage", + "value": {}, + "valuetype": "ignore", + "display": "disabled" + } + } } } \ No newline at end of file diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 1e45b0562..52d255842 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -1004,3 +1004,10 @@ Comment: Content: type: textarea value: '' + +# ==================== Remark ====================== + +HookOp: + Operation: + value: apply + option: [ inject, apply ] \ No newline at end of file diff --git a/module/config/argument/menu.json b/module/config/argument/menu.json index 929d2cedb..8d0ea7e96 100644 --- a/module/config/argument/menu.json +++ b/module/config/argument/menu.json @@ -121,7 +121,8 @@ "EventStory", "Benchmark", "AzurLaneUncensored", - "GameManager" + "GameManager", + "HookOp" ] } } \ No newline at end of file diff --git a/module/config/argument/task.yaml b/module/config/argument/task.yaml index 17e0d5f84..283e373e1 100644 --- a/module/config/argument/task.yaml +++ b/module/config/argument/task.yaml @@ -431,3 +431,5 @@ Tool: - AzurLaneUncensored GameManager: - GameManager + HookOp: + - HookOp \ No newline at end of file diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 3f6a2b0ea..72e5ec9cf 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -639,5 +639,8 @@ class GeneratedConfig: # Group `Comment` Comment_Content = None + # Group `HookOp` + HookOp_Operation = 'apply' # inject, apply + # Group `Storage` Storage_Storage = {} diff --git a/module/config/full_config_generated.py b/module/config/full_config_generated.py index b39b41f00..59c06a133 100644 --- a/module/config/full_config_generated.py +++ b/module/config/full_config_generated.py @@ -1929,3 +1929,7 @@ class FullGeneratedConfig: # Task `GameManager` GameManager_GameManager_AutoRestart = None GameManager_Storage_Storage = None + + # Task `HookOp` + HookOp_HookOp_Operation = None + HookOp_Storage_Storage = None diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index e8a06c599..994751558 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -321,6 +321,10 @@ "GameManager": { "name": "Game Manager(WIP)", "help": "" + }, + "HookOp": { + "name": "Task.HookOp.name", + "help": "Task.HookOp.help" } }, "Scheduler": { @@ -3464,6 +3468,18 @@ "help": "Comment.Content.help" } }, + "HookOp": { + "_info": { + "name": "HookOp._info.name", + "help": "HookOp._info.help" + }, + "Operation": { + "name": "HookOp.Operation.name", + "help": "HookOp.Operation.help", + "inject": "inject", + "apply": "apply" + } + }, "Storage": { "_info": { "name": "Task status", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 69505aecd..cd84b0dbd 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -321,6 +321,10 @@ "GameManager": { "name": "Game Manager(WIP)", "help": "" + }, + "HookOp": { + "name": "Task.HookOp.name", + "help": "Task.HookOp.help" } }, "Scheduler": { @@ -3464,6 +3468,18 @@ "help": "Comment.Content.help" } }, + "HookOp": { + "_info": { + "name": "HookOp._info.name", + "help": "HookOp._info.help" + }, + "Operation": { + "name": "HookOp.Operation.name", + "help": "HookOp.Operation.help", + "inject": "inject", + "apply": "apply" + } + }, "Storage": { "_info": { "name": "Storage._info.name", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 0d2cad6a1..fbe6c7bda 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -321,6 +321,10 @@ "GameManager": { "name": "游戏管理器(未完成)", "help": "" + }, + "HookOp": { + "name": "Hook操作", + "help": "" } }, "Scheduler": { @@ -3464,6 +3468,18 @@ "help": "" } }, + "HookOp": { + "_info": { + "name": "Hook操作", + "help": "" + }, + "Operation": { + "name": "操作", + "help": "", + "inject": "注入", + "apply": "设置Hook" + } + }, "Storage": { "_info": { "name": "任务状态", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index ecc426ea4..1bfb6ee04 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -321,6 +321,10 @@ "GameManager": { "name": "遊戲管理器(未完成)", "help": "" + }, + "HookOp": { + "name": "Task.HookOp.name", + "help": "Task.HookOp.help" } }, "Scheduler": { @@ -3464,6 +3468,18 @@ "help": "Comment.Content.help" } }, + "HookOp": { + "_info": { + "name": "HookOp._info.name", + "help": "HookOp._info.help" + }, + "Operation": { + "name": "HookOp.Operation.name", + "help": "HookOp.Operation.help", + "inject": "inject", + "apply": "apply" + } + }, "Storage": { "_info": { "name": "任務狀態", diff --git a/module/submodule/utils.py b/module/submodule/utils.py index fec05125a..ae7f991ba 100644 --- a/module/submodule/utils.py +++ b/module/submodule/utils.py @@ -88,4 +88,11 @@ def get_config_mod(config_name): return 'alas' def has_config_mod(config_name): - return os.path.exists(f"./config/{config_name}.json") \ No newline at end of file + return os.path.exists(f"./config/{config_name}.json") + + +old_get_available_func = get_available_func + + +def get_available_func(): + return [*old_get_available_func(), "HookOp"]