diff --git a/src/frontend/UiDocument.cpp b/src/frontend/UiDocument.cpp index 3e9a3a27..da4fec51 100644 --- a/src/frontend/UiDocument.cpp +++ b/src/frontend/UiDocument.cpp @@ -23,11 +23,12 @@ void UiDocument::rebuildIndices() { map["root"] = root; } -const UINodesMap& UiDocument::getMap() const { - return map; +void UiDocument::pushIndices(const std::shared_ptr& node) { + gui::UINode::getIndices(node, map); + map["root"] = root; } -UINodesMap& UiDocument::getMapWriteable() { +const UINodesMap& UiDocument::getMap() const { return map; } diff --git a/src/frontend/UiDocument.hpp b/src/frontend/UiDocument.hpp index 9d6e6eca..2ad00da8 100644 --- a/src/frontend/UiDocument.hpp +++ b/src/frontend/UiDocument.hpp @@ -36,10 +36,10 @@ public: ); void rebuildIndices(); + void pushIndices(const std::shared_ptr& node); const std::string& getId() const; const UINodesMap& getMap() const; - UINodesMap& getMapWriteable(); std::shared_ptr getRoot() const; std::shared_ptr get(const std::string& id) const; const uidocscript& getScript() const; diff --git a/src/graphics/ui/GUI.cpp b/src/graphics/ui/GUI.cpp index 99eb3375..22ae5b90 100644 --- a/src/graphics/ui/GUI.cpp +++ b/src/graphics/ui/GUI.cpp @@ -310,7 +310,7 @@ bool GUI::isFocusCaught() const { } void GUI::add(std::shared_ptr node) { - UINode::getIndices(node, rootDocument->getMapWriteable()); + rootDocument->pushIndices(node); container->add(std::move(node)); } diff --git a/src/logic/scripting/lua/libs/libgui.cpp b/src/logic/scripting/lua/libs/libgui.cpp index de34b9bd..b08d5445 100644 --- a/src/logic/scripting/lua/libs/libgui.cpp +++ b/src/logic/scripting/lua/libs/libgui.cpp @@ -105,7 +105,7 @@ static int l_container_add(lua::State* L) { auto subnode = guiutil::create( engine->getGUI(), xmlsrc, std::move(env) ); - UINode::getIndices(subnode, docnode.document->getMapWriteable()); + docnode.document->pushIndices(subnode); node->add(std::move(subnode)); } catch (const std::exception& err) { throw std::runtime_error("container:add(...): " + std::string(err.what())); @@ -410,9 +410,7 @@ static const std::string& request_node_id(const DocumentNode& docnode) { reinterpret_cast(docnode.node.get())); } docnode.node->setId(std::move(id)); - UINode::getIndices( - docnode.node, docnode.document->getMapWriteable() - ); + docnode.document->pushIndices(docnode.node); return docnode.node->getId(); }