Some fixes

This commit is contained in:
Federico Cecchetto 2021-09-17 00:12:10 +02:00
parent 34db360fa1
commit b4c1ecef2b
3 changed files with 19 additions and 6 deletions

View File

@ -322,7 +322,7 @@ namespace ui_scripting::lua::engine
{ {
check_resize(); check_resize();
for (const auto& menu : menus) for (auto& menu : menus)
{ {
if (is_menu_visible(menu.second)) if (is_menu_visible(menu.second))
{ {

View File

@ -16,6 +16,12 @@ namespace ui_scripting
void menu::open() void menu::open()
{ {
if (this->visible)
{
return;
}
this->cursor_was_enabled = *game::keyCatchers & 0x40;
if (this->cursor) if (this->cursor)
{ {
*game::keyCatchers |= 0x40; *game::keyCatchers |= 0x40;
@ -26,7 +32,12 @@ namespace ui_scripting
void menu::close() void menu::close()
{ {
if (this->cursor) if (!this->visible)
{
return;
}
if (this->cursor && !this->cursor_was_enabled)
{ {
*game::keyCatchers &= ~0x40; *game::keyCatchers &= ~0x40;
} }
@ -34,11 +45,12 @@ namespace ui_scripting
this->visible = false; 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) for (auto& element : this->children)

View File

@ -17,12 +17,13 @@ namespace ui_scripting
bool visible = false; bool visible = false;
bool cursor = false; bool cursor = false;
bool cursor_was_enabled = false;
void open(); void open();
void close(); void close();
void add_child(element* el); void add_child(element* el);
void render() const; void render();
menu_type type = normal; menu_type type = normal;