generated ui nodes indexing
This commit is contained in:
@@ -13,17 +13,21 @@ UiDocument::UiDocument(
|
||||
std::shared_ptr<gui::UINode> root,
|
||||
std::unique_ptr<scripting::Environment> env
|
||||
) : id(id), script(script), root(root), env(std::move(env)) {
|
||||
buildIndices(map, root);
|
||||
gui::UINode::getIndices(root, map);
|
||||
}
|
||||
|
||||
void UiDocument::rebuildIndices() {
|
||||
buildIndices(map, root);
|
||||
gui::UINode::getIndices(root, map);
|
||||
}
|
||||
|
||||
const uinodes_map& UiDocument::getMap() const {
|
||||
return map;
|
||||
}
|
||||
|
||||
uinodes_map& UiDocument::getMapWriteable() {
|
||||
return map;
|
||||
}
|
||||
|
||||
const std::string& UiDocument::getId() const {
|
||||
return id;
|
||||
}
|
||||
@@ -48,19 +52,6 @@ int UiDocument::getEnvironment() const {
|
||||
return env->getId();
|
||||
}
|
||||
|
||||
void UiDocument::buildIndices(uinodes_map& map, std::shared_ptr<gui::UINode> node) {
|
||||
const std::string& id = node->getId();
|
||||
if (!id.empty()) {
|
||||
map[id] = node;
|
||||
}
|
||||
auto container = std::dynamic_pointer_cast<gui::Container>(node);
|
||||
if (container) {
|
||||
for (auto subnode : container->getNodes()) {
|
||||
buildIndices(map, subnode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<UiDocument> UiDocument::read(int penv, std::string name, fs::path file) {
|
||||
const std::string text = files::read_string(file);
|
||||
auto xmldoc = xml::parse(file.u8string(), text);
|
||||
|
||||
Reference in New Issue
Block a user