mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 20:41:49 +00:00
fix gui.load_document environment extension
This commit is contained in:
parent
cfacc3dd48
commit
b1974405c6
7 changed files with 44 additions and 40 deletions
|
|
@ -61,16 +61,19 @@ std::unique_ptr<UiDocument> UiDocument::read(
|
|||
const scriptenv& penv,
|
||||
const std::string& name,
|
||||
const io::path& file,
|
||||
const std::string& fileName
|
||||
const std::string& fileName,
|
||||
scriptenv&& env
|
||||
) {
|
||||
const std::string text = io::read_string(file);
|
||||
auto xmldoc = xml::parse(file.string(), text);
|
||||
|
||||
auto env = penv == nullptr
|
||||
? scripting::create_doc_environment(scripting::get_root_environment(), name)
|
||||
: scripting::create_doc_environment(penv, name);
|
||||
if (env == nullptr) {
|
||||
env = penv == nullptr
|
||||
? scripting::create_doc_environment(scripting::get_root_environment(), name)
|
||||
: scripting::create_doc_environment(penv, name);
|
||||
}
|
||||
|
||||
gui::UiXmlReader reader(gui, scriptenv(env));
|
||||
gui::UiXmlReader reader(gui, env);
|
||||
auto view = reader.readXML(file.string(), *xmldoc->getRoot());
|
||||
view->setId("root");
|
||||
UiDocScript script {};
|
||||
|
|
@ -82,9 +85,3 @@ std::unique_ptr<UiDocument> UiDocument::read(
|
|||
}
|
||||
return std::make_unique<UiDocument>(name, script, view, env);
|
||||
}
|
||||
|
||||
std::shared_ptr<gui::UINode> UiDocument::readElement(
|
||||
gui::GUI& gui, const io::path& file, const std::string& fileName
|
||||
) {
|
||||
return read(gui, nullptr, file.name(), file, fileName)->getRoot();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,9 +50,7 @@ public:
|
|||
const scriptenv& parent_env,
|
||||
const std::string& name,
|
||||
const io::path& file,
|
||||
const std::string& fileName
|
||||
);
|
||||
static std::shared_ptr<gui::UINode> readElement(
|
||||
gui::GUI&, const io::path& file, const std::string& fileName
|
||||
const std::string& fileName,
|
||||
scriptenv&& env = nullptr
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue