mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
Merge branch 'main' into world-regions-works
This commit is contained in:
commit
cfd97ed4e6
15 changed files with 164 additions and 61 deletions
|
|
@ -209,6 +209,15 @@ static int p_get_inventory(UINode* node, lua::State* L) {
|
|||
if (auto inventory = dynamic_cast<InventoryView*>(node)) {
|
||||
auto inv = inventory->getInventory();
|
||||
return lua::pushinteger(L, inv ? inv->getId() : 0);
|
||||
} else if (auto slot = dynamic_cast<SlotView*>(node)) {
|
||||
return lua::pushinteger(L, slot->getInventoryId());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_slot_index(UINode* node, lua::State* L) {
|
||||
if (auto slot = dynamic_cast<SlotView*>(node)) {
|
||||
return lua::pushinteger(L, slot->getIndex());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -568,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);
|
||||
}
|
||||
|
|
@ -661,12 +677,14 @@ static int l_gui_getattr(lua::State* L) {
|
|||
{"reset", p_get_reset},
|
||||
{"paste", p_get_paste},
|
||||
{"inventory", p_get_inventory},
|
||||
{"slotIndex", p_get_slot_index},
|
||||
{"focused", p_get_focused},
|
||||
{"cursor", p_get_cursor},
|
||||
{"data", p_get_data},
|
||||
{"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()) {
|
||||
|
|
@ -803,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<TrackBar*>(node)) {
|
||||
bar->setValue(lua::tonumber(L, idx));
|
||||
|
|
@ -951,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()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue