diff --git a/src/client/game/ui_scripting/lua/engine.cpp b/src/client/game/ui_scripting/lua/engine.cpp index 563b43ef..65353238 100644 --- a/src/client/game/ui_scripting/lua/engine.cpp +++ b/src/client/game/ui_scripting/lua/engine.cpp @@ -322,7 +322,7 @@ namespace ui_scripting::lua::engine { check_resize(); - for (const auto& menu : menus) + for (auto& menu : menus) { if (is_menu_visible(menu.second)) { diff --git a/src/client/game/ui_scripting/menu.cpp b/src/client/game/ui_scripting/menu.cpp index 8a7f019e..4b8a05f3 100644 --- a/src/client/game/ui_scripting/menu.cpp +++ b/src/client/game/ui_scripting/menu.cpp @@ -16,6 +16,12 @@ namespace ui_scripting void menu::open() { + if (this->visible) + { + return; + } + + this->cursor_was_enabled = *game::keyCatchers & 0x40; if (this->cursor) { *game::keyCatchers |= 0x40; @@ -26,7 +32,12 @@ namespace ui_scripting void menu::close() { - if (this->cursor) + if (!this->visible) + { + return; + } + + if (this->cursor && !this->cursor_was_enabled) { *game::keyCatchers &= ~0x40; } @@ -34,11 +45,12 @@ namespace ui_scripting this->visible = false; } - void menu::render() const + void menu::render() { - if (this->cursor) + if (this->cursor && !(*game::keyCatchers & 0x40)) { - *game::keyCatchers |= 0x40; + this->visible = false; + return; } for (auto& element : this->children) diff --git a/src/client/game/ui_scripting/menu.hpp b/src/client/game/ui_scripting/menu.hpp index a726fdaa..9b295b02 100644 --- a/src/client/game/ui_scripting/menu.hpp +++ b/src/client/game/ui_scripting/menu.hpp @@ -17,12 +17,13 @@ namespace ui_scripting bool visible = false; bool cursor = false; + bool cursor_was_enabled = false; void open(); void close(); void add_child(element* el); - void render() const; + void render(); menu_type type = normal;