diff --git a/blcrack/cracker/cracker.cpp b/blcrack/cracker/cracker.cpp index ff51fcc1e..84630fe20 100644 --- a/blcrack/cracker/cracker.cpp +++ b/blcrack/cracker/cracker.cpp @@ -347,6 +347,10 @@ void Cracker::disable_skip_story() { DISABLE(SKIP_STORY); } +void Cracker::set_chapter_auto_clear_step_interval(double interval) { + m_mover.interval.store(interval); +} + void Cracker::enable_chapter_auto_clear() { ENABLE(CHAPTER_AUTO_CLEAR); } @@ -1567,6 +1571,7 @@ Cracker::Config Cracker::get_config() { .gg_factor = m_gg_factor, .exercise_more_power_rate = static_cast(m_exercise_more_power_rate.load() * 100), .better_global_speedup_rate = static_cast(m_better_global_speedup_rate.load()), + .chapter_auto_clear_step_interval = m_mover.interval.load(), }; return config; } @@ -1593,6 +1598,7 @@ void Cracker::apply_config(Config& config) { } if(IS_CONFIG_ENABLED(CHAPTER_AUTO_CLEAR)) { + set_chapter_auto_clear_step_interval(config.chapter_auto_clear_step_interval); enable_chapter_auto_clear(); } else { disable_chapter_auto_clear(); @@ -1895,7 +1901,7 @@ void Cracker::mover_step(sol::this_state& L) { if (m_mover.idx <= m_mover.path.value().size()) { Lua::Object tr = m_lua_res.Timer_New(L, [this](sol::this_state l, Lua::VariadicArgs args) { mover_step(l); - }, m_mover.interval, 1); + }, m_mover.interval.load(), 1); m_lua_res.Timer_Start(L, tr); } else { mover_stop(L); diff --git a/blcrack/cracker/cracker.hpp b/blcrack/cracker/cracker.hpp index a85771a61..070eede3d 100644 --- a/blcrack/cracker/cracker.hpp +++ b/blcrack/cracker/cracker.hpp @@ -123,6 +123,7 @@ public: int gg_factor = 1; int exercise_more_power_rate = 1; int better_global_speedup_rate = 1; + double chapter_auto_clear_step_interval = 0.5; }; public: @@ -161,6 +162,7 @@ public: void enable_skip_story(); void disable_skip_story(); + void set_chapter_auto_clear_step_interval(double interval); void enable_chapter_auto_clear(); void disable_chapter_auto_clear(); @@ -433,7 +435,7 @@ private: int currentStepSize = 3; int lastTargetIdx = 0; std::optional lastMoveStartP; - double interval = 0.5; + std::atomic interval = 0.5; std::optional view; } m_mover; diff --git a/blcrack/cracker/server.cpp b/blcrack/cracker/server.cpp index c96e7778a..44169bf27 100644 --- a/blcrack/cracker/server.cpp +++ b/blcrack/cracker/server.cpp @@ -1131,6 +1131,21 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/set_chapter_auto_clear_step_interval", [](const httplib::Request& req, httplib::Response& res) { + try { + Json::Reader reader; + Json::Value j; + reader.parse(req.body, j); + auto interval = j["interval"].asDouble(); + Cracker::Instance().set_chapter_auto_clear_step_interval(interval); + } catch (std::exception& e) { + SPDLOG_ERROR("Set chapter auto clear step interval failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/enable_chapter_auto_clear", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_chapter_auto_clear(); diff --git a/blcrack/cracker/ui/ui.cpp b/blcrack/cracker/ui/ui.cpp index 6b70f9739..4c71a022a 100644 --- a/blcrack/cracker/ui/ui.cpp +++ b/blcrack/cracker/ui/ui.cpp @@ -158,6 +158,9 @@ void CrackerUI::draw_menu() { ImGui::Checkbox("演习我方伤害增加 X %", &CONFIG_FLAG(EXERCISE_MORE_POWER)); ImGui::DragInt("(%)##Exercise Power Rate", &m_cracker_config.exercise_more_power_rate); + ImGui::Text("章节图自动开荒移动间隔(s)"); + ImGui::InputDouble("##StepInterval", &m_cracker_config.chapter_auto_clear_step_interval, 0.1f, 0, "%.1f"); + ImGui::EndTabItem(); } if(ImGui::BeginTabItem("倍率")) { diff --git a/config/template.json b/config/template.json index 23ea86d4f..3950b1d2f 100644 --- a/config/template.json +++ b/config/template.json @@ -229,6 +229,7 @@ "ChapterAutoNextBattle": false, "ChapterAutoAmbush": false, "ChapterAutoClear": false, + "ChapterAutoClearStepInterval": 0.5, "SkipStory": false, "InfiniteBattle": false }, diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 44cb0a6f5..edd0d0feb 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -910,6 +910,10 @@ "type": "checkbox", "value": false }, + "ChapterAutoClearStepInterval": { + "type": "input", + "value": 0.5 + }, "SkipStory": { "type": "checkbox", "value": false diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index f3b09112a..bb9223c9b 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -894,6 +894,7 @@ Misc: ChapterAutoNextBattle: false ChapterAutoAmbush: false ChapterAutoClear: false + ChapterAutoClearStepInterval: 0.5 SkipStory: false InfiniteBattle: false diff --git a/module/config/config_generated.py b/module/config/config_generated.py index ec45389b0..fef41dd31 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -549,6 +549,7 @@ class GeneratedConfig: Misc_ChapterAutoNextBattle = False Misc_ChapterAutoAmbush = False Misc_ChapterAutoClear = False + Misc_ChapterAutoClearStepInterval = 0.5 Misc_SkipStory = False Misc_InfiniteBattle = False diff --git a/module/config/full_config_generated.py b/module/config/full_config_generated.py index bff6228c6..fa47a3c98 100644 --- a/module/config/full_config_generated.py +++ b/module/config/full_config_generated.py @@ -162,6 +162,7 @@ class FullGeneratedConfig: Hook_Misc_ChapterAutoNextBattle = None Hook_Misc_ChapterAutoAmbush = None Hook_Misc_ChapterAutoClear = None + Hook_Misc_ChapterAutoClearStepInterval = None Hook_Misc_SkipStory = None Hook_Misc_InfiniteBattle = None Hook_ShipProperty_Method = None diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index faf717b1a..88bc33f10 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -3165,6 +3165,10 @@ "name": "Misc.ChapterAutoClear.name", "help": "Misc.ChapterAutoClear.help" }, + "ChapterAutoClearStepInterval": { + "name": "Misc.ChapterAutoClearStepInterval.name", + "help": "Misc.ChapterAutoClearStepInterval.help" + }, "SkipStory": { "name": "Misc.SkipStory.name", "help": "Misc.SkipStory.help" diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 84bfd1ebb..61f1253ee 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -3165,6 +3165,10 @@ "name": "Misc.ChapterAutoClear.name", "help": "Misc.ChapterAutoClear.help" }, + "ChapterAutoClearStepInterval": { + "name": "Misc.ChapterAutoClearStepInterval.name", + "help": "Misc.ChapterAutoClearStepInterval.help" + }, "SkipStory": { "name": "Misc.SkipStory.name", "help": "Misc.SkipStory.help" diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 79a2250bc..82da60f30 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -3165,6 +3165,10 @@ "name": "章节图自动开荒", "help": "" }, + "ChapterAutoClearStepInterval": { + "name": "章节图自动开荒移动间隔", + "help": "" + }, "SkipStory": { "name": "跳过剧情", "help": "" diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 1123a66aa..0d71f715a 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -3165,6 +3165,10 @@ "name": "Misc.ChapterAutoClear.name", "help": "Misc.ChapterAutoClear.help" }, + "ChapterAutoClearStepInterval": { + "name": "Misc.ChapterAutoClearStepInterval.name", + "help": "Misc.ChapterAutoClearStepInterval.help" + }, "SkipStory": { "name": "Misc.SkipStory.name", "help": "Misc.SkipStory.help" diff --git a/module/luahook/api.py b/module/luahook/api.py index e129d1853..eeef3e1f3 100644 --- a/module/luahook/api.py +++ b/module/luahook/api.py @@ -54,6 +54,9 @@ class CrackApi: class ExerciseMorePowerRate(BaseModel): rate: float + class ChapterAutoClearStepInterval(BaseModel): + interval: float + def __init__(self, base_url, timeout=10): self.api_url = base_url self.timeout = timeout @@ -380,6 +383,9 @@ class CrackApi: def disable_chapter_auto_ambush(self): self.post("disable_chapter_auto_ambush") + def set_chapter_auto_clear_step_interval(self, param: ChapterAutoClearStepInterval): + self.post("set_chapter_auto_clear_step_interval", data=param.json()) + def enable_chapter_auto_clear(self): self.post("enable_chapter_auto_clear") diff --git a/module/luahook/crack.py b/module/luahook/crack.py index 7b1a6d836..0514c0f30 100644 --- a/module/luahook/crack.py +++ b/module/luahook/crack.py @@ -323,6 +323,7 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. api.disable_chapter_auto_ambush() elif op == CrackOp.EnableChapterAutoClear: if full_config.Hook_Misc_ChapterAutoClear: + api.set_chapter_auto_clear_step_interval(CrackApi.ChapterAutoClearStepInterval(interval=float(full_config.Hook_Misc_ChapterAutoClearStepInterval))) api.enable_chapter_auto_clear() elif op == CrackOp.DisableChapterAutoClear: api.disable_chapter_auto_clear()