lua environmnents-related update
This commit is contained in:
@@ -10,8 +10,9 @@
|
||||
UiDocument::UiDocument(
|
||||
std::string namesp,
|
||||
uidocscript script,
|
||||
std::shared_ptr<gui::UINode> root
|
||||
) : namesp(namesp), script(script), root(root) {
|
||||
std::shared_ptr<gui::UINode> root,
|
||||
int env
|
||||
) : namesp(namesp), script(script), root(root), env(env) {
|
||||
collect(map, root);
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ std::unique_ptr<UiDocument> UiDocument::read(std::string namesp, fs::path file)
|
||||
uidocscript script {};
|
||||
auto scriptFile = fs::path(file.u8string()+".lua");
|
||||
if (fs::is_regular_file(scriptFile)) {
|
||||
scripting::load_layout_script(scriptFile, script);
|
||||
scripting::load_layout_script(env->getId(), scriptFile, script);
|
||||
}
|
||||
return std::make_unique<UiDocument>(namesp, script, view);
|
||||
return std::make_unique<UiDocument>(namesp, script, view, env.release()->getId());
|
||||
}
|
||||
|
||||
@@ -25,8 +25,13 @@ class UiDocument {
|
||||
uidocscript script;
|
||||
uinodes_map map;
|
||||
std::shared_ptr<gui::UINode> root;
|
||||
int env;
|
||||
public:
|
||||
UiDocument(std::string namesp, uidocscript script, std::shared_ptr<gui::UINode> root);
|
||||
UiDocument(
|
||||
std::string namesp,
|
||||
uidocscript script,
|
||||
std::shared_ptr<gui::UINode> root,
|
||||
int env);
|
||||
|
||||
const uinodes_map& getMap() const;
|
||||
const std::string& getNamespace() const;
|
||||
|
||||
@@ -117,7 +117,11 @@ static std::shared_ptr<UINode> readButton(UiXmlReader& reader, xml::xmlelement e
|
||||
_readPanel(reader, element, *button);
|
||||
|
||||
if (element->has("onclick")) {
|
||||
auto callback = scripting::create_runnable("<onclick>", element->attr("onclick").getText(), reader.getEnvironment());
|
||||
auto callback = scripting::create_runnable(
|
||||
reader.getEnvironment().getId(),
|
||||
"<onclick>",
|
||||
element->attr("onclick").getText()
|
||||
);
|
||||
button->listenAction([callback](GUI*) {
|
||||
callback();
|
||||
});
|
||||
@@ -137,6 +141,7 @@ static std::shared_ptr<UINode> readTextBox(UiXmlReader& reader, xml::xmlelement
|
||||
|
||||
if (element->has("consumer")) {
|
||||
auto consumer = scripting::create_wstring_consumer(
|
||||
reader.getEnvironment().getId(),
|
||||
element->attr("consumer").getText(),
|
||||
reader.getFilename()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user