mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
commit
57d62980a9
6 changed files with 26 additions and 13 deletions
|
|
@ -7,7 +7,7 @@ function on_menu_clear()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_menu_setup()
|
local function setup_backround()
|
||||||
local controller = {}
|
local controller = {}
|
||||||
function controller.resize_menu_bg()
|
function controller.resize_menu_bg()
|
||||||
local w, h = unpack(gui.get_viewport())
|
local w, h = unpack(gui.get_viewport())
|
||||||
|
|
@ -17,11 +17,16 @@ function on_menu_setup()
|
||||||
end
|
end
|
||||||
return w, h
|
return w, h
|
||||||
end
|
end
|
||||||
gui.root.root:add(
|
local bgid = random.uuid()
|
||||||
"<image id='menubg' src='gui/menubg' size-func='DATA.resize_menu_bg' "..
|
gui.root.root:add(string.format(
|
||||||
"z-index='-1' interactive='true'/>", controller)
|
"<image id='%s' src='gui/menubg' size-func='DATA.resize_menu_bg' "..
|
||||||
menubg = gui.root.menubg
|
"z-index='-1' interactive='true'/>", bgid), controller)
|
||||||
|
menubg = gui.root[bgid]
|
||||||
controller.resize_menu_bg()
|
controller.resize_menu_bg()
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_menu_setup()
|
||||||
|
setup_backround()
|
||||||
menu.page = "main"
|
menu.page = "main"
|
||||||
menu.visible = true
|
menu.visible = true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ local _ffi = ffi
|
||||||
function __vc_Canvas_set_data(self, data)
|
function __vc_Canvas_set_data(self, data)
|
||||||
if type(data) == "cdata" then
|
if type(data) == "cdata" then
|
||||||
self:_set_data(tostring(_ffi.cast("uintptr_t", data.bytes)), data.size)
|
self:_set_data(tostring(_ffi.cast("uintptr_t", data.bytes)), data.size)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
local width = self.width
|
local width = self.width
|
||||||
local height = self.height
|
local height = self.height
|
||||||
|
|
@ -60,7 +61,7 @@ function __vc_Canvas_set_data(self, data)
|
||||||
for i=0, size - 1 do
|
for i=0, size - 1 do
|
||||||
canvas_ffi_buffer[i] = data[i + 1]
|
canvas_ffi_buffer[i] = data[i + 1]
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
local ipairs_mt_supported = false
|
local ipairs_mt_supported = false
|
||||||
|
|
|
||||||
|
|
@ -289,6 +289,7 @@ void ContentLoader::loadContent(const dv::value& root) {
|
||||||
item.icon = def.name;
|
item.icon = def.name;
|
||||||
item.placingBlock = def.name;
|
item.placingBlock = def.name;
|
||||||
item.tags = def.tags;
|
item.tags = def.tags;
|
||||||
|
item.scriptFile = def.name + BLOCK_ITEM_SUFFIX + ".lua";
|
||||||
|
|
||||||
for (uint j = 0; j < 4; j++) {
|
for (uint j = 0; j < 4; j++) {
|
||||||
item.emission[j] = def.emission[j];
|
item.emission[j] = def.emission[j];
|
||||||
|
|
|
||||||
|
|
@ -390,9 +390,14 @@ void UINode::getIndices(
|
||||||
const std::string& id = node->getId();
|
const std::string& id = node->getId();
|
||||||
if (!id.empty()) {
|
if (!id.empty()) {
|
||||||
const auto& found = map.find(id);
|
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<gui::Container>(node);
|
auto container = std::dynamic_pointer_cast<gui::Container>(node);
|
||||||
if (container) {
|
if (container) {
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
#include "util/stringutil.hpp"
|
#include "util/stringutil.hpp"
|
||||||
|
|
||||||
ItemDef::ItemDef(const std::string& name) : name(name) {
|
ItemDef::ItemDef(const std::string& name)
|
||||||
caption = util::id_to_caption(name);
|
: name(name),
|
||||||
description = "";
|
caption(util::id_to_caption(name)),
|
||||||
|
scriptName(name.substr(name.find(':') + 1)) {
|
||||||
}
|
}
|
||||||
void ItemDef::cloneTo(ItemDef& dst) {
|
void ItemDef::cloneTo(ItemDef& dst) {
|
||||||
dst.caption = caption;
|
dst.caption = caption;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ struct ItemDef {
|
||||||
std::string caption;
|
std::string caption;
|
||||||
|
|
||||||
/// @brief Item description will shown in inventory
|
/// @brief Item description will shown in inventory
|
||||||
std::string description;
|
std::string description = "";
|
||||||
|
|
||||||
dv::value properties = nullptr;
|
dv::value properties = nullptr;
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ struct ItemDef {
|
||||||
std::string icon = "blocks:notfound";
|
std::string icon = "blocks:notfound";
|
||||||
|
|
||||||
std::string placingBlock = "core:air";
|
std::string placingBlock = "core:air";
|
||||||
std::string scriptName = name.substr(name.find(':') + 1);
|
std::string scriptName;
|
||||||
|
|
||||||
std::string modelName = name + ".model";
|
std::string modelName = name + ".model";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue