diff --git a/src/delegates.h b/src/delegates.h index f179251d..61360464 100644 --- a/src/delegates.h +++ b/src/delegates.h @@ -6,6 +6,7 @@ using runnable = std::function; using stringconsumer = std::function; +using wstringsupplier = std::function; using wstringconsumer = std::function; #endif // DELEGATES_H_ diff --git a/src/frontend/UiDocument.cpp b/src/frontend/UiDocument.cpp index b47d8363..9df8f123 100644 --- a/src/frontend/UiDocument.cpp +++ b/src/frontend/UiDocument.cpp @@ -55,7 +55,7 @@ std::unique_ptr UiDocument::read(AssetsLoader& loader, int penv, std const std::string text = files::read_string(file); auto xmldoc = xml::parse(file.u8string(), text); - auto env = scripting::create_environment(penv); + auto env = scripting::create_doc_environment(penv, namesp); gui::UiXmlReader reader(*env, loader); InventoryView::createReaders(reader); auto view = reader.readXML( diff --git a/src/frontend/gui/controls.h b/src/frontend/gui/controls.h index df6208fc..ae07b4d7 100644 --- a/src/frontend/gui/controls.h +++ b/src/frontend/gui/controls.h @@ -17,9 +17,6 @@ class Batch2D; class Assets; namespace gui { - using wstringsupplier = std::function; - using wstringconsumer = std::function; - using doublesupplier = std::function; using doubleconsumer = std::function; diff --git a/src/frontend/gui/gui_xml.cpp b/src/frontend/gui/gui_xml.cpp index f2d7a7e1..2721b5c1 100644 --- a/src/frontend/gui/gui_xml.cpp +++ b/src/frontend/gui/gui_xml.cpp @@ -133,7 +133,7 @@ static std::shared_ptr readButton(UiXmlReader& reader, xml::xmlelement e auto callback = scripting::create_runnable( reader.getEnvironment().getId(), element->attr("onclick").getText(), - "" + reader.getFilename()+".lua" ); button->listenAction([callback](GUI*) { callback(); @@ -156,7 +156,7 @@ static std::shared_ptr readTextBox(UiXmlReader& reader, xml::xmlelement auto consumer = scripting::create_wstring_consumer( reader.getEnvironment().getId(), element->attr("consumer").getText(), - reader.getFilename() + reader.getFilename()+"lua" ); textbox->textConsumer(consumer); } diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index b951ad2d..6c663285 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -43,6 +43,7 @@ #include "LevelFrontend.h" #include "UiDocument.h" #include "../engine.h" +#include "../delegates.h" #include "../core_defs.h" #include "../items/ItemDef.h" #include "../items/Inventory.h" @@ -53,7 +54,7 @@ using glm::vec3; using glm::vec4; using namespace gui; -static std::shared_ptr