cleanup
This commit is contained in:
parent
0a02d3fbec
commit
9fcff65cca
@ -1,13 +1,13 @@
|
||||
local menubg
|
||||
|
||||
function on_screen_changed(screen)
|
||||
if screen ~= "menu" then
|
||||
if menubg then
|
||||
menubg:destruct()
|
||||
menubg = nil
|
||||
end
|
||||
return
|
||||
local function clear_menu()
|
||||
if menubg then
|
||||
menubg:destruct()
|
||||
menubg = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function configure_menu()
|
||||
local controller = {}
|
||||
function controller.resize_menu_bg()
|
||||
local w, h = unpack(gui.get_viewport())
|
||||
@ -19,8 +19,16 @@ function on_screen_changed(screen)
|
||||
end
|
||||
_GUI_ROOT.root:add(
|
||||
"<image id='menubg' src='gui/menubg' size-func='DATA.resize_menu_bg' "..
|
||||
"z-index='-1000' interactive='true'/>", controller)
|
||||
"z-index='-1' interactive='true'/>", controller)
|
||||
menubg = _GUI_ROOT.menubg
|
||||
controller.resize_menu_bg()
|
||||
menu.page = "main"
|
||||
end
|
||||
|
||||
function on_screen_changed(screen)
|
||||
if screen ~= "menu" then
|
||||
clear_menu()
|
||||
else
|
||||
configure_menu()
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
#include "Project.hpp"
|
||||
|
||||
#include "data/dv_util.hpp"
|
||||
#include "logic/scripting/scripting.hpp"
|
||||
|
||||
Project::~Project() = default;
|
||||
|
||||
dv::value Project::serialize() const {
|
||||
return dv::object({
|
||||
|
||||
@ -2,13 +2,21 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "interfaces/Serializable.hpp"
|
||||
|
||||
namespace scripting {
|
||||
class IProjectScript;
|
||||
}
|
||||
|
||||
struct Project : Serializable {
|
||||
std::string name;
|
||||
std::string title;
|
||||
std::vector<std::string> basePacks;
|
||||
std::unique_ptr<scripting::IProjectScript> script;
|
||||
|
||||
~Project();
|
||||
|
||||
dv::value serialize() const override;
|
||||
void deserialize(const dv::value& src) override;
|
||||
|
||||
@ -185,7 +185,7 @@ void Engine::initialize(CoreParameters coreParameters) {
|
||||
langs::setup(lang, paths.resPaths.collectRoots());
|
||||
}, true));
|
||||
|
||||
projectScript = load_project_script();
|
||||
project->script = load_project_script();
|
||||
}
|
||||
|
||||
void Engine::loadSettings() {
|
||||
@ -242,7 +242,6 @@ void Engine::run() {
|
||||
}
|
||||
}
|
||||
|
||||
#include "graphics/ui/elements/Container.hpp"
|
||||
void Engine::postUpdate() {
|
||||
network->update();
|
||||
postRunnables.run();
|
||||
@ -285,7 +284,6 @@ void Engine::saveSettings() {
|
||||
}
|
||||
|
||||
void Engine::close() {
|
||||
projectScript.reset();
|
||||
saveSettings();
|
||||
logger.info() << "shutting down";
|
||||
if (screen) {
|
||||
@ -302,6 +300,7 @@ void Engine::close() {
|
||||
audio::close();
|
||||
network.reset();
|
||||
clearKeepedObjects();
|
||||
project.reset();
|
||||
scripting::close();
|
||||
logger.info() << "scripting finished";
|
||||
if (!params.headless) {
|
||||
@ -368,8 +367,8 @@ void Engine::setScreen(std::shared_ptr<Screen> screen) {
|
||||
if (this->screen) {
|
||||
this->screen->onOpen();
|
||||
}
|
||||
if (projectScript && this->screen) {
|
||||
projectScript->onScreenChange(this->screen->getName());
|
||||
if (project->script && this->screen) {
|
||||
project->script->onScreenChange(this->screen->getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -75,7 +75,6 @@ class Engine : public util::ObjectsKeeper {
|
||||
std::unique_ptr<Input> input;
|
||||
std::unique_ptr<gui::GUI> gui;
|
||||
std::unique_ptr<devtools::Editor> editor;
|
||||
std::unique_ptr<scripting::IProjectScript> projectScript;
|
||||
PostRunnables postRunnables;
|
||||
Time time;
|
||||
OnWorldOpen levelConsumer;
|
||||
@ -183,8 +182,4 @@ public:
|
||||
const Project& getProject() {
|
||||
return *project;
|
||||
}
|
||||
|
||||
scripting::IProjectScript* getProjectScript() {
|
||||
return projectScript.get();
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user