diff --git a/res/layouts/404.xml b/res/layouts/404.xml
new file mode 100644
index 00000000..375d4fde
--- /dev/null
+++ b/res/layouts/404.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/src/frontend/UiDocument.cpp b/src/frontend/UiDocument.cpp
index b8ee13b3..00511d66 100644
--- a/src/frontend/UiDocument.cpp
+++ b/src/frontend/UiDocument.cpp
@@ -62,8 +62,9 @@ std::unique_ptr UiDocument::read(int penv, std::string namesp, fs::p
const std::string text = files::read_string(file);
auto xmldoc = xml::parse(file.u8string(), text);
- auto env = scripting::create_doc_environment(penv, namesp);
- gui::UiXmlReader reader(*env);
+ auto env = penv == -1 ? nullptr : scripting::create_doc_environment(penv, namesp);
+ scripting::Environment envview {penv == -1 ? 0 : env->getId()};
+ gui::UiXmlReader reader(envview);
InventoryView::createReaders(reader);
auto view = reader.readXML(
file.u8string(), xmldoc->getRoot()
@@ -72,7 +73,12 @@ std::unique_ptr UiDocument::read(int penv, std::string namesp, fs::p
uidocscript script {};
auto scriptFile = fs::path(file.u8string()+".lua");
if (fs::is_regular_file(scriptFile)) {
- scripting::load_layout_script(env->getId(), namesp, scriptFile, script);
+ scripting::load_layout_script(envview.getId(), namesp, scriptFile, script);
}
- return std::make_unique(namesp, script, view, std::move(env));
+ return std::make_unique(namesp, script, view, penv == -1 ? nullptr : std::move(env));
}
+
+std::shared_ptr UiDocument::readElement(fs::path file) {
+ auto document = read(-1, file.filename().u8string(), file);
+ return document->getRoot();
+}
\ No newline at end of file
diff --git a/src/frontend/UiDocument.h b/src/frontend/UiDocument.h
index 05185879..943008cf 100644
--- a/src/frontend/UiDocument.h
+++ b/src/frontend/UiDocument.h
@@ -48,6 +48,7 @@ public:
static void collect(uinodes_map& map, std::shared_ptr node);
static std::unique_ptr read(int env, std::string namesp, fs::path file);
+ static std::shared_ptr readElement(fs::path file);
};
#endif // FRONTEND_UI_DOCUMENT_H_
diff --git a/src/frontend/menu/menu.cpp b/src/frontend/menu/menu.cpp
index ed85ca7d..2fa1d147 100644
--- a/src/frontend/menu/menu.cpp
+++ b/src/frontend/menu/menu.cpp
@@ -13,6 +13,7 @@
#include "../../graphics/ui/elements/containers.h"
#include "../../graphics/ui/elements/controls.h"
#include "../screens.h"
+#include "../UiDocument.h"
#include "../../coders/png.h"
#include "../../util/stringutil.h"
@@ -281,12 +282,7 @@ void create_main_menu_panel(Engine* engine) {
void create_404_page(Engine* engine) {
auto menu = engine->getGUI()->getMenu();
- menu->addPage("404", guiutil::create(
- ""
- ""
- ""
- ""
- ));
+ menu->addPage("404", UiDocument::readElement(engine->getResPaths()->find("layouts/404.xml")));
}
void menus::create_menus(Engine* engine) {