mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 14:01:49 +00:00
fix uinode.parent property
This commit is contained in:
parent
b1311fd03c
commit
902c885fe0
1 changed files with 13 additions and 10 deletions
|
|
@ -420,15 +420,19 @@ static int p_get_data(UINode* node, lua::State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::string& request_node_id(const DocumentNode& docnode) {
|
static const std::string& request_node_id(UiDocument& document, UINode& node) {
|
||||||
std::string id = docnode.node->getId();
|
const std::string& id = node.getId();
|
||||||
if (id.empty()) {
|
if (id.empty()) {
|
||||||
id = "#" + std::to_string(
|
node.setId( "#" + std::to_string(
|
||||||
reinterpret_cast<std::ptrdiff_t>(docnode.node.get()));
|
reinterpret_cast<std::ptrdiff_t>(&node)));
|
||||||
|
document.pushIndices(node.shared_from_this());
|
||||||
|
return node.getId();
|
||||||
}
|
}
|
||||||
docnode.node->setId(std::move(id));
|
return id;
|
||||||
docnode.document->pushIndices(docnode.node);
|
}
|
||||||
return docnode.node->getId();
|
|
||||||
|
static const std::string& request_node_id(const DocumentNode& docnode) {
|
||||||
|
return request_node_id(*docnode.document, *docnode.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Push UI-document node object to stack
|
/// @brief Push UI-document node object to stack
|
||||||
|
|
@ -443,15 +447,14 @@ static int push_document_node(lua::State* L, const std::string& id) {
|
||||||
|
|
||||||
static int p_get_parent(UINode* node, lua::State* L) {
|
static int p_get_parent(UINode* node, lua::State* L) {
|
||||||
auto parent = node->getParent();
|
auto parent = node->getParent();
|
||||||
if (!parent) {
|
if (parent == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto docname = lua::require_string(L, 1);
|
auto docname = lua::require_string(L, 1);
|
||||||
auto element = lua::require_string(L, 2);
|
auto element = lua::require_string(L, 2);
|
||||||
auto docnode = get_document_node_impl(L, docname, element);
|
auto docnode = get_document_node_impl(L, docname, element);
|
||||||
|
|
||||||
const auto& id = request_node_id(docnode);
|
const auto& id = request_node_id(*docnode.document, *parent);
|
||||||
|
|
||||||
return push_document_node(L, id);
|
return push_document_node(L, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue