mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 12:19:24 +08:00
add: pause lua state when setting skip battle celebrate duration
This commit is contained in:
@@ -458,14 +458,18 @@ void Cracker::disable_better_global_speedup() {
|
||||
better_global_speedup_set_rate(1.0);
|
||||
}
|
||||
|
||||
void Cracker::skip_battle_celebrate_pause(bool need_pause) {
|
||||
m_skip_battle_celebrate_need_pause.store(need_pause);
|
||||
}
|
||||
|
||||
void Cracker::enable_skip_battle_celebrate() {
|
||||
ENABLE(SKIP_BATTLE_CELEBRATE);
|
||||
m_state["ys"]["Battle"]["BattleConfig"]["CelebrateDuration"] = 0.01;
|
||||
skip_battle_celebrate_set_duration(0.01);
|
||||
}
|
||||
|
||||
void Cracker::disable_skip_battle_celebrate() {
|
||||
DISABLE(SKIP_BATTLE_CELEBRATE);
|
||||
m_state["ys"]["Battle"]["BattleConfig"]["CelebrateDuration"] = 3;
|
||||
skip_battle_celebrate_set_duration(3);
|
||||
}
|
||||
|
||||
void Cracker::enable_monster_kill_self() {
|
||||
@@ -611,6 +615,23 @@ void Cracker::disable_global_ship_properties_crack() {
|
||||
DISABLE(GLOBAL_SHIP_PROPERTIES_CRACK);
|
||||
}
|
||||
|
||||
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);
|
||||
} else {
|
||||
skip_battle_celebrate_set_duration_without_pause(duration);
|
||||
}
|
||||
}
|
||||
|
||||
void Cracker::skip_battle_celebrate_set_duration_with_pause(double duration) {
|
||||
LUA_STATUS_PAUSER_GUARD();
|
||||
m_state["ys"]["Battle"]["BattleConfig"]["CelebrateDuration"] = duration;
|
||||
}
|
||||
|
||||
void Cracker::skip_battle_celebrate_set_duration_without_pause(double duration) {
|
||||
m_state["ys"]["Battle"]["BattleConfig"]["CelebrateDuration"] = duration;
|
||||
}
|
||||
|
||||
void Cracker::print_table_field(std::vector<std::string>& path) {
|
||||
Lua::Table t = m_state.globals();
|
||||
for (const auto& p : path) {
|
||||
|
||||
@@ -204,6 +204,7 @@ public:
|
||||
void update_better_global_speedup_rate(double rate);
|
||||
void disable_better_global_speedup();
|
||||
|
||||
void skip_battle_celebrate_pause(bool need_pause);
|
||||
void enable_skip_battle_celebrate();
|
||||
void disable_skip_battle_celebrate();
|
||||
|
||||
@@ -263,6 +264,10 @@ public:
|
||||
void apply_config(Config& config);
|
||||
|
||||
private:
|
||||
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);
|
||||
|
||||
void better_global_speedup_set_rate_with_pause(double rate);
|
||||
void better_global_speedup_set_rate_without_pause(double rate);
|
||||
|
||||
@@ -442,6 +447,7 @@ private:
|
||||
std::atomic<double> m_better_global_speedup_rate = 1.0;
|
||||
LuaStatePauser m_lua_state_pauser;
|
||||
std::atomic<bool> m_better_global_speedup_need_pause = false;
|
||||
std::atomic<bool> m_skip_battle_celebrate_need_pause = false;
|
||||
};
|
||||
|
||||
#endif //CRACKER_HPP
|
||||
|
||||
@@ -772,7 +772,9 @@ CrackerServer::CrackerServer() {
|
||||
|
||||
Post("/enable_skip_battle_celebrate", [](const httplib::Request& req, httplib::Response& res) {
|
||||
try {
|
||||
Cracker::Instance().enable_skip_battle_celebrate();
|
||||
auto& ins = Cracker::Instance();
|
||||
ins.skip_battle_celebrate_pause(true);
|
||||
ins.enable_skip_battle_celebrate();
|
||||
} catch (std::exception& e) {
|
||||
SPDLOG_ERROR("Enable skip battle celebrate failed: {}", e.what());
|
||||
res.status = 500;
|
||||
@@ -783,7 +785,9 @@ CrackerServer::CrackerServer() {
|
||||
|
||||
Post("/disable_skip_battle_celebrate", [](const httplib::Request& req, httplib::Response& res) {
|
||||
try {
|
||||
Cracker::Instance().disable_skip_battle_celebrate();
|
||||
auto& ins = Cracker::Instance();
|
||||
ins.skip_battle_celebrate_pause(true);
|
||||
ins.disable_skip_battle_celebrate();
|
||||
} catch (std::exception& e) {
|
||||
SPDLOG_ERROR("Disable skip battle celebrate failed: {}", e.what());
|
||||
res.status = 500;
|
||||
|
||||
@@ -87,6 +87,7 @@ void CrackerUI::draw_menu() {
|
||||
if(ImGui::Button("应用")) {
|
||||
auto& ins = Cracker::Instance(false);
|
||||
ins.better_global_speedup_pause(false);
|
||||
ins.skip_battle_celebrate_pause(false);
|
||||
ins.apply_config(m_cracker_config);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
Reference in New Issue
Block a user