diff --git a/res/project_client.lua b/res/project_client.lua index 03c43a4bc..16f607663 100644 --- a/res/project_client.lua +++ b/res/project_client.lua @@ -7,7 +7,7 @@ function on_menu_clear() end end -function on_menu_setup() +local function setup_backround() local controller = {} function controller.resize_menu_bg() local w, h = unpack(gui.get_viewport()) @@ -17,11 +17,16 @@ function on_menu_setup() end return w, h end - gui.root.root:add( - "", controller) - menubg = gui.root.menubg + local bgid = random.uuid() + gui.root.root:add(string.format( + "", bgid), controller) + menubg = gui.root[bgid] controller.resize_menu_bg() +end + +function on_menu_setup() + setup_backround() menu.page = "main" menu.visible = true end diff --git a/res/scripts/stdmin.lua b/res/scripts/stdmin.lua index f2201d949..4ae34b2fd 100644 --- a/res/scripts/stdmin.lua +++ b/res/scripts/stdmin.lua @@ -46,6 +46,7 @@ local _ffi = ffi function __vc_Canvas_set_data(self, data) if type(data) == "cdata" then self:_set_data(tostring(_ffi.cast("uintptr_t", data.bytes)), data.size) + return end local width = self.width local height = self.height @@ -60,7 +61,7 @@ function __vc_Canvas_set_data(self, data) for i=0, size - 1 do canvas_ffi_buffer[i] = data[i + 1] end - self:_set_data(tostring(_ffi.cast("uintptr_t", canvas_ffi_buffer)), data.size) + self:_set_data(tostring(_ffi.cast("uintptr_t", canvas_ffi_buffer)), size) end local ipairs_mt_supported = false diff --git a/src/content/ContentLoader.cpp b/src/content/ContentLoader.cpp index c9b982810..ed4ab34d8 100644 --- a/src/content/ContentLoader.cpp +++ b/src/content/ContentLoader.cpp @@ -289,6 +289,7 @@ void ContentLoader::loadContent(const dv::value& root) { item.icon = def.name; item.placingBlock = def.name; item.tags = def.tags; + item.scriptFile = def.name + BLOCK_ITEM_SUFFIX + ".lua"; for (uint j = 0; j < 4; j++) { item.emission[j] = def.emission[j]; diff --git a/src/graphics/ui/elements/UINode.cpp b/src/graphics/ui/elements/UINode.cpp index e62ff1df2..cbcb1c909 100644 --- a/src/graphics/ui/elements/UINode.cpp +++ b/src/graphics/ui/elements/UINode.cpp @@ -390,9 +390,14 @@ void UINode::getIndices( const std::string& id = node->getId(); if (!id.empty()) { const auto& found = map.find(id); - if (found == map.end() || found->second.expired()) { - map[id] = node; + + if (found != map.end()) { + auto prev = found->second.lock(); + if (prev && prev->getParent()) { + return; + } } + map[id] = node; } auto container = std::dynamic_pointer_cast(node); if (container) { diff --git a/src/items/ItemDef.cpp b/src/items/ItemDef.cpp index 236efc6b2..bff25e7af 100644 --- a/src/items/ItemDef.cpp +++ b/src/items/ItemDef.cpp @@ -2,9 +2,10 @@ #include "util/stringutil.hpp" -ItemDef::ItemDef(const std::string& name) : name(name) { - caption = util::id_to_caption(name); - description = ""; +ItemDef::ItemDef(const std::string& name) + : name(name), + caption(util::id_to_caption(name)), + scriptName(name.substr(name.find(':') + 1)) { } void ItemDef::cloneTo(ItemDef& dst) { dst.caption = caption; diff --git a/src/items/ItemDef.hpp b/src/items/ItemDef.hpp index 40e052b9c..ee37215a6 100644 --- a/src/items/ItemDef.hpp +++ b/src/items/ItemDef.hpp @@ -37,7 +37,7 @@ struct ItemDef { std::string caption; /// @brief Item description will shown in inventory - std::string description; + std::string description = ""; dv::value properties = nullptr; @@ -60,7 +60,7 @@ struct ItemDef { std::string icon = "blocks:notfound"; std::string placingBlock = "core:air"; - std::string scriptName = name.substr(name.find(':') + 1); + std::string scriptName; std::string modelName = name + ".model";