1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-22 06:59:28 +08:00

add: pause lua state when setting fast stage move duration

This commit is contained in:
0O0o0oOoO00
2025-11-21 22:24:42 +08:00
parent 550f852dac
commit bd6aeb6fef
4 changed files with 38 additions and 6 deletions

View File

@@ -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);

View File

@@ -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<bool> m_better_global_speedup_need_pause = false;
std::atomic<bool> m_skip_battle_celebrate_need_pause = false;
std::atomic<bool> m_fast_stage_move_need_pause = false;
};
#endif //CRACKER_HPP

View File

@@ -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;

View File

@@ -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();