This commit is contained in:
MihailRis 2026-02-03 14:00:58 +03:00
parent 895a496f6e
commit 2475a7e8f5
20 changed files with 88 additions and 79 deletions

View file

@ -10,7 +10,7 @@
UiDocument::UiDocument(
std::string id,
uidocscript script,
UiDocScript script,
const std::shared_ptr<gui::UINode>& root,
scriptenv env
) : id(std::move(id)), script(script), root(root), env(std::move(env)) {
@ -48,7 +48,7 @@ std::shared_ptr<gui::UINode> UiDocument::get(const std::string& id) const {
return found->second.lock();
}
const uidocscript& UiDocument::getScript() const {
const UiDocScript& UiDocument::getScript() const {
return script;
}
@ -73,7 +73,7 @@ std::unique_ptr<UiDocument> UiDocument::read(
gui::UiXmlReader reader(gui, scriptenv(env));
auto view = reader.readXML(file.string(), *xmldoc->getRoot());
view->setId("root");
uidocscript script {};
UiDocScript script {};
auto scriptFile = io::path(file.string()+".lua");
if (io::is_regular_file(scriptFile)) {
scripting::load_layout_script(

View file

@ -13,7 +13,7 @@ namespace gui {
class UINode;
}
struct uidocscript {
struct UiDocScript {
bool onopen : 1;
bool onprogress : 1;
bool onclose : 1;
@ -23,14 +23,14 @@ using UINodesMap = std::unordered_map<std::string, std::weak_ptr<gui::UINode>>;
class UiDocument {
std::string id;
uidocscript script;
UiDocScript script;
UINodesMap map;
std::shared_ptr<gui::UINode> root;
scriptenv env;
public:
UiDocument(
std::string id,
uidocscript script,
UiDocScript script,
const std::shared_ptr<gui::UINode> &root,
scriptenv env
);
@ -42,7 +42,7 @@ public:
const UINodesMap& getMap() const;
std::shared_ptr<gui::UINode> getRoot() const;
std::shared_ptr<gui::UINode> get(const std::string& id) const;
const uidocscript& getScript() const;
const UiDocScript& getScript() const;
scriptenv getEnvironment() const;
static std::unique_ptr<UiDocument> read(

View file

@ -1,9 +1,3 @@
#include <bitset>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include "audio/audio.hpp"
#include "constants.hpp"
#include "content/Content.hpp"
@ -37,6 +31,12 @@
#include "world/Level.hpp"
#include "world/World.hpp"
#include <bitset>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
using namespace gui;
static std::shared_ptr<Label> create_label(GUI& gui, wstringsupplier supplier) {

View file

@ -10,7 +10,6 @@
#include <glm/glm.hpp>
class Camera;
class Block;
class Assets;
class Player;
class Engine;
@ -25,7 +24,6 @@ namespace gui {
class GUI;
class Menu;
class UINode;
class Panel;
class Container;
class InventoryView;
class SlotView;

View file

@ -61,7 +61,7 @@ LevelScreen::LevelScreen(
assert(player != nullptr);
controller =
std::make_unique<LevelController>(&engine, std::move(levelPtr), player);
std::make_unique<LevelController>(engine, std::move(levelPtr), player);
playerController = std::make_unique<PlayerController>(
settings, *level, *player, *controller->getBlocksController()
);
@ -112,11 +112,10 @@ LevelScreen::~LevelScreen() {
saveDecorations();
}
scripting::on_frontend_close();
// unblock all bindings
input.getBindings().enableAll();
playerController->getPlayer()->chunks->saveAndClear();
controller->onWorldQuit();
engine.getPaths().setCurrentWorldFolder("");
}
void LevelScreen::onOpen() {