diff --git a/src/graphics/ui/elements/Panel.cpp b/src/graphics/ui/elements/Panel.cpp index ed9af66c5..885ae3d61 100644 --- a/src/graphics/ui/elements/Panel.cpp +++ b/src/graphics/ui/elements/Panel.cpp @@ -67,7 +67,7 @@ void Panel::remove(UINode* node) { } void Panel::refresh() { - UINode::refresh(); + Container::refresh(); float x = padding.x; float y = padding.y; diff --git a/src/logic/scripting/lua/libs/libgui.cpp b/src/logic/scripting/lua/libs/libgui.cpp index e8cc70186..4d1506e23 100644 --- a/src/logic/scripting/lua/libs/libgui.cpp +++ b/src/logic/scripting/lua/libs/libgui.cpp @@ -577,6 +577,13 @@ static int p_get_options(UINode* node, lua::State* L) { return 0; } +static int p_get_zindex(UINode* node, lua::State* L) { + if (node == nullptr) { + return 0; + } + return lua::pushinteger(L, node->getZIndex()); +} + static int p_is_exists(UINode* node, lua::State* L) { return lua::pushboolean(L, node != nullptr); } @@ -677,6 +684,7 @@ static int l_gui_getattr(lua::State* L) { {"parent", p_get_parent}, {"region", p_get_region}, {"options", p_get_options}, + {"zIndex", p_get_zindex}, }; auto func = getters.find(attr); if (func != getters.end()) { @@ -813,6 +821,15 @@ static void p_set_options(UINode* node, lua::State* L, int idx) { selectbox->setOptions(std::move(options)); } } +static void p_set_zindex(UINode* node, lua::State* L, int idx) { + if (node == nullptr) { + return; + } + node->setZIndex(lua::tointeger(L, idx)); + if (auto parent = node->getParent()) { + parent->setMustRefresh(); + } +} static void p_set_value(UINode* node, lua::State* L, int idx) { if (auto bar = dynamic_cast(node)) { bar->setValue(lua::tonumber(L, idx)); @@ -961,6 +978,7 @@ static int l_gui_setattr(lua::State* L) { {"focused", p_set_focused}, {"region", p_set_region}, {"options", p_set_options}, + {"zIndex", p_set_zindex}, }; auto func = setters.find(attr); if (func != setters.end()) {