minor refactor
This commit is contained in:
parent
252e9f0d19
commit
c8ca56fb8e
@ -14,6 +14,7 @@
|
||||
#include "../content/Content.h"
|
||||
#include "../content/ContentPack.h"
|
||||
#include "../logic/scripting/scripting.h"
|
||||
#include "../logic/scripting/Environment.h"
|
||||
|
||||
static debug::Logger logger("assets-loader");
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#include "../graphics/core/Font.h"
|
||||
#include "../graphics/core/TextureAnimation.h"
|
||||
#include "../frontend/UiDocument.h"
|
||||
#include "../logic/scripting/scripting.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
#include "ContentPack.h"
|
||||
#include "../logic/scripting/scripting.h"
|
||||
#include "../logic/scripting/Environment.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include "../files/files.h"
|
||||
#include "../files/engine_paths.h"
|
||||
#include "../data/dynamic.h"
|
||||
#include "../logic/scripting/scripting.h"
|
||||
#include "../logic/scripting/Environment.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@ -145,3 +145,6 @@ ContentPackRuntime::ContentPackRuntime(
|
||||
) : info(info), env(std::move(env))
|
||||
{
|
||||
}
|
||||
|
||||
ContentPackRuntime::~ContentPackRuntime() {
|
||||
}
|
||||
|
||||
@ -91,6 +91,7 @@ public:
|
||||
ContentPack info,
|
||||
std::unique_ptr<scripting::Environment> env
|
||||
);
|
||||
~ContentPackRuntime();
|
||||
|
||||
inline const ContentPackStats& getStats() const {
|
||||
return stats;
|
||||
|
||||
@ -13,17 +13,14 @@
|
||||
#include "frontend/locale/langs.h"
|
||||
#include "frontend/menu/menu.h"
|
||||
#include "frontend/screens.h"
|
||||
#include "frontend/UiDocument.h"
|
||||
#include "graphics/core/Batch2D.h"
|
||||
#include "graphics/core/GfxContext.h"
|
||||
#include "graphics/core/ImageData.h"
|
||||
#include "graphics/core/Shader.h"
|
||||
#include "graphics/ui/GUI.h"
|
||||
#include "graphics/ui/elements/UINode.h"
|
||||
#include "graphics/ui/elements/containers.h"
|
||||
#include "logic/scripting/scripting.h"
|
||||
#include "util/platform.h"
|
||||
#include "util/listutil.h"
|
||||
#include "util/platform.h"
|
||||
#include "voxels/DefaultWorldGenerator.h"
|
||||
#include "voxels/FlatWorldGenerator.h"
|
||||
#include "window/Camera.h"
|
||||
@ -32,12 +29,9 @@
|
||||
#include "window/Window.h"
|
||||
#include "world/WorldGenerators.h"
|
||||
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
#include <filesystem>
|
||||
#include <unordered_set>
|
||||
#include <functional>
|
||||
|
||||
@ -116,12 +110,7 @@ Engine::Engine(EngineSettings& settings, EnginePaths* paths)
|
||||
}
|
||||
|
||||
void Engine::onAssetsLoaded() {
|
||||
assets->store(new UiDocument(
|
||||
"core:root",
|
||||
uidocscript {},
|
||||
std::dynamic_pointer_cast<gui::UINode>(gui->getContainer()),
|
||||
nullptr
|
||||
), "core:root");
|
||||
gui->onAssetsLoad(assets.get());
|
||||
}
|
||||
|
||||
void Engine::updateTimers() {
|
||||
@ -145,12 +134,13 @@ void Engine::updateHotkeys() {
|
||||
}
|
||||
|
||||
void Engine::mainloop() {
|
||||
logger.info() << "starting menu screen";
|
||||
setScreen(std::make_shared<MenuScreen>(this));
|
||||
|
||||
Batch2D batch(1024);
|
||||
lastTime = Window::time();
|
||||
|
||||
logger.info() << "initialized";
|
||||
|
||||
logger.info() << "engine started";
|
||||
while (!Window::isShouldClose()){
|
||||
assert(screen != nullptr);
|
||||
updateTimers();
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include "../items/Inventory.h"
|
||||
#include "../items/ItemDef.h"
|
||||
#include "../logic/scripting/scripting.h"
|
||||
#include "../logic/scripting/Environment.h"
|
||||
#include "../maths/voxmaths.h"
|
||||
#include "../objects/Player.h"
|
||||
#include "../util/stringutil.h"
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#ifndef FRONTEND_UI_DOCUMENT_H_
|
||||
#define FRONTEND_UI_DOCUMENT_H_
|
||||
|
||||
#include "../logic/scripting/Environment.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <filesystem>
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include "../logic/LevelController.h"
|
||||
#include "../logic/scripting/scripting_hud.h"
|
||||
#include "../logic/scripting/scripting.h"
|
||||
#include "../logic/scripting/Environment.h"
|
||||
#include "../objects/Player.h"
|
||||
#include "../physics/Hitbox.h"
|
||||
#include "../util/stringutil.h"
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "../../assets/Assets.h"
|
||||
#include "../../frontend/UiDocument.h"
|
||||
#include "../../graphics/core/Batch2D.h"
|
||||
#include "../../graphics/core/Shader.h"
|
||||
#include "../../graphics/core/GfxContext.h"
|
||||
@ -34,6 +35,15 @@ std::shared_ptr<Menu> GUI::getMenu() {
|
||||
return menu;
|
||||
}
|
||||
|
||||
void GUI::onAssetsLoad(Assets* assets) {
|
||||
assets->store(new UiDocument(
|
||||
"core:root",
|
||||
uidocscript {},
|
||||
std::dynamic_pointer_cast<gui::UINode>(container),
|
||||
nullptr
|
||||
), "core:root");
|
||||
}
|
||||
|
||||
/** Mouse related input and logic handling
|
||||
* @param delta delta time
|
||||
*/
|
||||
|
||||
@ -122,6 +122,8 @@ namespace gui {
|
||||
/// @deprecated
|
||||
std::shared_ptr<Container> getContainer() const;
|
||||
|
||||
void onAssetsLoad(Assets* assets);
|
||||
|
||||
void postRunnable(runnable callback);
|
||||
};
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "../../logic/scripting/scripting.h"
|
||||
#include "../../logic/scripting/Environment.h"
|
||||
#include "../../frontend/locale/langs.h"
|
||||
#include "../../util/stringutil.h"
|
||||
#include "../../delegates.h"
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
#include "../../frontend/locale/langs.h"
|
||||
#include "../../logic/scripting/scripting.h"
|
||||
#include "../../logic/scripting/Environment.h"
|
||||
#include "../../util/stringutil.h"
|
||||
|
||||
using namespace gui;
|
||||
|
||||
19
src/logic/scripting/Environment.h
Normal file
19
src/logic/scripting/Environment.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef LOGIC_SCRIPTING_ENVIRONMENT_H_
|
||||
#define LOGIC_SCRIPTING_ENVIRONMENT_H_
|
||||
|
||||
namespace scripting {
|
||||
/// @brief Lua environment wrapper for automatic deletion
|
||||
class Environment {
|
||||
int env;
|
||||
public:
|
||||
Environment(int env);
|
||||
~Environment();
|
||||
|
||||
int getId() const;
|
||||
|
||||
// @brief Release namespace control
|
||||
void release();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // LOGIC_SCRIPTING_ENVIRONMENT_H_
|
||||
@ -17,6 +17,7 @@
|
||||
#include "../../logic/LevelController.h"
|
||||
#include "../../frontend/UiDocument.h"
|
||||
#include "../../engine.h"
|
||||
#include "Environment.h"
|
||||
#include "lua/LuaState.h"
|
||||
#include "../../util/stringutil.h"
|
||||
#include "../../util/timeutil.h"
|
||||
|
||||
@ -33,18 +33,7 @@ namespace scripting {
|
||||
extern BlocksController* blocks;
|
||||
extern LevelController* controller;
|
||||
|
||||
/// @brief Lua environment wrapper for automatic deletion
|
||||
class Environment {
|
||||
int env;
|
||||
public:
|
||||
Environment(int env);
|
||||
~Environment();
|
||||
|
||||
int getId() const;
|
||||
|
||||
// @brief Release namespace control
|
||||
void release();
|
||||
};
|
||||
class Environment;
|
||||
|
||||
void initialize(Engine* engine);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user