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();
for (const auto& menu : menus)
for (auto& menu : menus)
{
if (is_menu_visible(menu.second))
{

View File

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

View File

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