Close menus

This commit is contained in:
Federico Cecchetto 2021-09-14 02:59:36 +02:00
parent ccaefd866c
commit d901845e03

View File

@ -331,9 +331,28 @@ namespace ui_scripting::lua::engine
} }
} }
void close_all_menus()
{
for (auto& menu : menus)
{
if (!is_menu_visible(menu.second))
{
continue;
}
event event;
event.element = &menu.second;
event.name = "close";
notify(event);
menu.second.close();
}
}
void clear_menus() void clear_menus()
{ {
menus.clear(); menus.clear();
for (const auto element : elements) for (const auto element : elements)
{ {
delete element; delete element;
@ -379,6 +398,7 @@ namespace ui_scripting::lua::engine
void start() void start()
{ {
close_all_menus();
get_scripts().clear(); get_scripts().clear();
clear_menus(); clear_menus();
load_scripts(); load_scripts();
@ -386,6 +406,7 @@ namespace ui_scripting::lua::engine
void stop() void stop()
{ {
close_all_menus();
get_scripts().clear(); get_scripts().clear();
clear_menus(); clear_menus();
} }