diff --git a/blcrack/cracker/cracker.cpp b/blcrack/cracker/cracker.cpp index d0d7a4794..4e64868ff 100644 --- a/blcrack/cracker/cracker.cpp +++ b/blcrack/cracker/cracker.cpp @@ -608,16 +608,18 @@ void Cracker::disable_remove_hard_mode_ship_properties_limit() { DISABLE(REMOVE_HARD_MODE_SHIP_PROPERTIES_LIMIT); } +void Cracker::fast_stage_move_pause(bool need_pause) { + m_fast_stage_move_need_pause.store(need_pause); +} + void Cracker::enable_fast_stage_move() { - m_state["ChapterConst"]["ShipStepDuration"] = 0.0; - m_state["ChapterConst"]["ShipStepQuickPlayScale"] = 0.0; ENABLE(FAST_STAGE_MOVE_CRACK); + fast_stage_move_set_duration(0.0); } void Cracker::disable_fast_stage_move() { - m_state["ChapterConst"]["ShipStepDuration"] = 0.5; - m_state["ChapterConst"]["ShipStepQuickPlayScale"] = 0.5; DISABLE(FAST_STAGE_MOVE_CRACK); + fast_stage_move_set_duration(0.5); } void Cracker::update_global_ship_properties(const ShipProperties& properties) { @@ -632,6 +634,25 @@ void Cracker::disable_global_ship_properties_crack() { DISABLE(GLOBAL_SHIP_PROPERTIES_CRACK); } +void Cracker::fast_stage_move_set_duration(double duration) { + if (m_fast_stage_move_need_pause.load()) { + fast_stage_move_set_duration_with_pause(duration); + } else { + fast_stage_move_set_duration_without_pause(duration); + } +} + +void Cracker::fast_stage_move_set_duration_with_pause(double duration) { + LUA_STATUS_PAUSER_GUARD(); + m_state["ChapterConst"]["ShipStepDuration"] = duration; + m_state["ChapterConst"]["ShipStepQuickPlayScale"] = duration; +} + +void Cracker::fast_stage_move_set_duration_without_pause(double duration) { + m_state["ChapterConst"]["ShipStepDuration"] = duration; + m_state["ChapterConst"]["ShipStepQuickPlayScale"] = duration; +} + void Cracker::skip_battle_celebrate_set_duration(double duration) { if (m_skip_battle_celebrate_need_pause.load()) { skip_battle_celebrate_set_duration_with_pause(duration); diff --git a/blcrack/cracker/cracker.hpp b/blcrack/cracker/cracker.hpp index 2facd8668..c2909e439 100644 --- a/blcrack/cracker/cracker.hpp +++ b/blcrack/cracker/cracker.hpp @@ -249,6 +249,7 @@ public: void enable_remove_hard_mode_ship_properties_limit(); void disable_remove_hard_mode_ship_properties_limit(); + void fast_stage_move_pause(bool need_pause); void enable_fast_stage_move(); void disable_fast_stage_move(); @@ -266,6 +267,10 @@ public: void apply_config(Config& config); private: + void fast_stage_move_set_duration(double duration); + void fast_stage_move_set_duration_with_pause(double duration); + void fast_stage_move_set_duration_without_pause(double duration); + void skip_battle_celebrate_set_duration(double duration); void skip_battle_celebrate_set_duration_with_pause(double duration); void skip_battle_celebrate_set_duration_without_pause(double duration); @@ -451,6 +456,7 @@ private: std::mutex m_pauser_lock; std::atomic m_better_global_speedup_need_pause = false; std::atomic m_skip_battle_celebrate_need_pause = false; + std::atomic m_fast_stage_move_need_pause = false; }; #endif //CRACKER_HPP diff --git a/blcrack/cracker/server.cpp b/blcrack/cracker/server.cpp index d3cf64c78..5e48ac9e5 100644 --- a/blcrack/cracker/server.cpp +++ b/blcrack/cracker/server.cpp @@ -106,7 +106,9 @@ CrackerServer::CrackerServer() { Post("/enable_fast_stage_move", [](const httplib::Request& req, httplib::Response& res) { try { - Cracker::Instance().enable_fast_stage_move(); + auto& ins = Cracker::Instance(); + ins.fast_stage_move_pause(true); + ins.enable_fast_stage_move(); } catch (std::exception& e) { SPDLOG_ERROR("Enable fast stage move failed: {}", e.what()); res.status = 500; @@ -117,7 +119,9 @@ CrackerServer::CrackerServer() { Post("/disable_fast_stage_move", [](const httplib::Request& req, httplib::Response& res) { try { - Cracker::Instance().disable_fast_stage_move(); + auto& ins = Cracker::Instance(); + ins.fast_stage_move_pause(true); + ins.disable_fast_stage_move(); } catch (std::exception& e) { SPDLOG_ERROR("Disable fast stage move failed: {}", e.what()); res.status = 500; diff --git a/blcrack/cracker/ui/ui.cpp b/blcrack/cracker/ui/ui.cpp index 2ce54b993..7c2632017 100644 --- a/blcrack/cracker/ui/ui.cpp +++ b/blcrack/cracker/ui/ui.cpp @@ -88,6 +88,7 @@ void CrackerUI::draw_menu() { auto& ins = Cracker::Instance(false); ins.better_global_speedup_pause(false); ins.skip_battle_celebrate_pause(false); + ins.fast_stage_move_pause(false); ins.apply_config(m_cracker_config); } ImGui::SameLine();