From 3202a115906d5ee0f69446df5e13d45d8dd1c795 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 2 Dec 2025 18:08:29 +0300 Subject: [PATCH 1/5] temporary fix --- res/project_client.lua | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/res/project_client.lua b/res/project_client.lua index 03c43a4bc..0b21a834b 100644 --- a/res/project_client.lua +++ b/res/project_client.lua @@ -1,6 +1,7 @@ local menubg function on_menu_clear() + print("menu clear") if menubg then menubg:destruct() menubg = nil @@ -8,20 +9,24 @@ function on_menu_clear() end function on_menu_setup() - local controller = {} - function controller.resize_menu_bg() - local w, h = unpack(gui.get_viewport()) - if menubg then - menubg.region = {0, math.floor(h / 48), math.floor(w / 48), 0} - menubg.pos = {0, 0} + -- //TODO: + time.post_runnable(function() + local controller = {} + function controller.resize_menu_bg() + local w, h = unpack(gui.get_viewport()) + if menubg then + menubg.region = {0, math.floor(h / 48), math.floor(w / 48), 0} + menubg.pos = {0, 0} + end + return w, h end - return w, h - end - gui.root.root:add( + gui.root.root:add( "", controller) - menubg = gui.root.menubg - controller.resize_menu_bg() + menubg = gui.root.menubg + controller.resize_menu_bg() + end) + menu.page = "main" menu.visible = true end From 4df4209bc59944e97102be7a618292378dc301a4 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 2 Dec 2025 18:21:52 +0300 Subject: [PATCH 2/5] fix generated item's script --- src/content/ContentLoader.cpp | 3 +++ src/items/ItemDef.cpp | 7 ++++--- src/items/ItemDef.hpp | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/content/ContentLoader.cpp b/src/content/ContentLoader.cpp index c9b982810..c98d51686 100644 --- a/src/content/ContentLoader.cpp +++ b/src/content/ContentLoader.cpp @@ -289,6 +289,9 @@ 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"; + + logger.info() << "scriptFile: " << item.scriptFile; for (uint j = 0; j < 4; j++) { item.emission[j] = def.emission[j]; 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"; From afb7049248b20a4fa55aa27bfefc43947114fbea Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 2 Dec 2025 18:27:09 +0300 Subject: [PATCH 3/5] cleanup --- src/content/ContentLoader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/content/ContentLoader.cpp b/src/content/ContentLoader.cpp index c98d51686..ed4ab34d8 100644 --- a/src/content/ContentLoader.cpp +++ b/src/content/ContentLoader.cpp @@ -290,8 +290,6 @@ void ContentLoader::loadContent(const dv::value& root) { item.placingBlock = def.name; item.tags = def.tags; item.scriptFile = def.name + BLOCK_ITEM_SUFFIX + ".lua"; - - logger.info() << "scriptFile: " << item.scriptFile; for (uint j = 0; j < 4; j++) { item.emission[j] = def.emission[j]; From e678195a2ae3cfd1ddc39435dd103292806dd4bc Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 2 Dec 2025 21:32:31 +0300 Subject: [PATCH 4/5] fix canvas:set_data with table argument --- res/scripts/stdmin.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From f2ee9950c9c2a3fe6a47f671edb8df47e14635a0 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 2 Dec 2025 22:59:56 +0300 Subject: [PATCH 5/5] temporary fix improvement --- res/project_client.lua | 36 ++++++++++++++--------------- src/graphics/ui/elements/UINode.cpp | 9 ++++++-- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/res/project_client.lua b/res/project_client.lua index 0b21a834b..16f607663 100644 --- a/res/project_client.lua +++ b/res/project_client.lua @@ -1,32 +1,32 @@ local menubg function on_menu_clear() - print("menu clear") if menubg then menubg:destruct() menubg = nil end end -function on_menu_setup() - -- //TODO: - time.post_runnable(function() - local controller = {} - function controller.resize_menu_bg() - local w, h = unpack(gui.get_viewport()) - if menubg then - menubg.region = {0, math.floor(h / 48), math.floor(w / 48), 0} - menubg.pos = {0, 0} - end - return w, h +local function setup_backround() + local controller = {} + function controller.resize_menu_bg() + local w, h = unpack(gui.get_viewport()) + if menubg then + menubg.region = {0, math.floor(h / 48), math.floor(w / 48), 0} + menubg.pos = {0, 0} end - gui.root.root:add( - "", controller) - menubg = gui.root.menubg - controller.resize_menu_bg() - end) + return w, h + end + 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/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) {