From 7763157cdc31dfc7299904a6ec0520f4d7a49c2c Mon Sep 17 00:00:00 2001 From: ChancellorIkseew Date: Sat, 2 Nov 2024 05:09:55 +1000 Subject: [PATCH] bindings bug fix If binding was blocked in one world, it stayed being blocked in other. --- src/logic/scripting/lua/libs/libcore.cpp | 2 ++ src/window/Events.cpp | 7 +++++++ src/window/Events.hpp | 1 + 3 files changed, 10 insertions(+) diff --git a/src/logic/scripting/lua/libs/libcore.cpp b/src/logic/scripting/lua/libs/libcore.cpp index ee611b63..891cd791 100644 --- a/src/logic/scripting/lua/libs/libcore.cpp +++ b/src/logic/scripting/lua/libs/libcore.cpp @@ -60,6 +60,8 @@ static int l_close_world(lua::State* L) { if (save_world) { controller->saveWorld(); } + // unblock all bindings + Events::enableBindings(); // destroy LevelScreen and run quit callbacks engine->setScreen(nullptr); // create and go to menu screen diff --git a/src/window/Events.cpp b/src/window/Events.cpp index 625b0a53..4db271be 100644 --- a/src/window/Events.cpp +++ b/src/window/Events.cpp @@ -231,3 +231,10 @@ void Events::loadBindings( } } } + +void Events::enableBindings() { + for (auto& entry : bindings) { + auto& binding = entry.second; + binding.enable = true; + } +} diff --git a/src/window/Events.hpp b/src/window/Events.hpp index f5ed5720..8155bb2b 100644 --- a/src/window/Events.hpp +++ b/src/window/Events.hpp @@ -60,4 +60,5 @@ public: const std::string& filename, const std::string& source, BindType bindType ); + static void enableBindings(); };