ui scripting related fixes
This commit is contained in:
@@ -55,7 +55,7 @@ std::unique_ptr<UiDocument> 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(
|
||||
|
||||
@@ -17,9 +17,6 @@ class Batch2D;
|
||||
class Assets;
|
||||
|
||||
namespace gui {
|
||||
using wstringsupplier = std::function<std::wstring()>;
|
||||
using wstringconsumer = std::function<void(std::wstring)>;
|
||||
|
||||
using doublesupplier = std::function<double()>;
|
||||
using doubleconsumer = std::function<void(double)>;
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ static std::shared_ptr<UINode> readButton(UiXmlReader& reader, xml::xmlelement e
|
||||
auto callback = scripting::create_runnable(
|
||||
reader.getEnvironment().getId(),
|
||||
element->attr("onclick").getText(),
|
||||
"<onclick>"
|
||||
reader.getFilename()+".lua"
|
||||
);
|
||||
button->listenAction([callback](GUI*) {
|
||||
callback();
|
||||
@@ -156,7 +156,7 @@ static std::shared_ptr<UINode> 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);
|
||||
}
|
||||
|
||||
@@ -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<Label> create_label(gui::wstringsupplier supplier) {
|
||||
static std::shared_ptr<Label> create_label(wstringsupplier supplier) {
|
||||
auto label = std::make_shared<Label>(L"-");
|
||||
label->textSupplier(supplier);
|
||||
return label;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "../window/Window.h"
|
||||
#include "../engine.h"
|
||||
#include "../settings.h"
|
||||
#include "../delegates.h"
|
||||
#include "../content/Content.h"
|
||||
#include "../content/ContentLUT.h"
|
||||
#include "../content/ContentPack.h"
|
||||
@@ -46,7 +47,7 @@ inline uint64_t randU64() {
|
||||
((uint64_t)rand() << 56);
|
||||
}
|
||||
|
||||
static std::shared_ptr<Label> create_label(gui::wstringsupplier supplier) {
|
||||
static std::shared_ptr<Label> create_label(wstringsupplier supplier) {
|
||||
auto label = std::make_shared<Label>(L"-");
|
||||
label->textSupplier(supplier);
|
||||
return label;
|
||||
|
||||
Reference in New Issue
Block a user