add project start application script
This commit is contained in:
parent
05de043154
commit
87ff77a73f
@ -4,6 +4,7 @@
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "interfaces/Process.hpp"
|
||||
#include "interfaces/Serializable.hpp"
|
||||
|
||||
namespace scripting {
|
||||
@ -15,6 +16,7 @@ struct Project : Serializable {
|
||||
std::string title;
|
||||
std::vector<std::string> basePacks;
|
||||
std::unique_ptr<scripting::IClientProjectScript> clientScript;
|
||||
std::unique_ptr<Process> setupCoroutine;
|
||||
|
||||
~Project();
|
||||
|
||||
|
||||
@ -62,13 +62,24 @@ static std::unique_ptr<ImageData> load_icon() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static std::unique_ptr<scripting::IClientProjectScript> load_client_project_script() {
|
||||
static std::unique_ptr<scripting::IClientProjectScript> load_project_client_script() {
|
||||
io::path scriptFile = "project:project_client.lua";
|
||||
if (io::exists(scriptFile)) {
|
||||
logger.info() << "starting project script";
|
||||
logger.info() << "starting project client script";
|
||||
return scripting::load_client_project_script(scriptFile);
|
||||
} else {
|
||||
logger.warning() << "project script does not exists";
|
||||
logger.warning() << "project client script does not exists";
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static std::unique_ptr<Process> load_project_start_script() {
|
||||
io::path scriptFile = "project:start.lua";
|
||||
if (io::exists(scriptFile)) {
|
||||
logger.info() << "starting project start script";
|
||||
return scripting::start_app_script(scriptFile);
|
||||
} else {
|
||||
logger.warning() << "project start script does not exists";
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -226,7 +237,10 @@ void Engine::initialize(CoreParameters coreParameters) {
|
||||
langs::setup(lang, paths.resPaths.collectRoots());
|
||||
}, true));
|
||||
|
||||
project->clientScript = load_client_project_script();
|
||||
project->setupCoroutine = load_project_start_script();
|
||||
if (!params.headless) {
|
||||
project->clientScript = load_project_client_script();
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::loadSettings() {
|
||||
@ -301,6 +315,12 @@ void Engine::detachDebugger() {
|
||||
debuggingServer.reset();
|
||||
}
|
||||
|
||||
void Engine::applicationTick() {
|
||||
if (project->setupCoroutine && project->setupCoroutine->isActive()) {
|
||||
project->setupCoroutine->update();
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::updateFrontend() {
|
||||
double delta = time.getDelta();
|
||||
updateHotkeys();
|
||||
|
||||
@ -105,6 +105,7 @@ public:
|
||||
|
||||
void postUpdate();
|
||||
|
||||
void applicationTick();
|
||||
void updateFrontend();
|
||||
void renderFrame();
|
||||
void nextFrame();
|
||||
|
||||
@ -38,6 +38,7 @@ void Mainloop::run() {
|
||||
logger.info() << "main loop started";
|
||||
while (!window.isShouldClose()){
|
||||
time.update(window.time());
|
||||
engine.applicationTick();
|
||||
engine.updateFrontend();
|
||||
|
||||
if (!window.isIconified()) {
|
||||
|
||||
@ -60,6 +60,7 @@ void ServerMainloop::run() {
|
||||
controller->getLevel()->getWorld()->updateTimers(delta);
|
||||
controller->update(glm::min(delta, 0.2), false);
|
||||
}
|
||||
engine.applicationTick();
|
||||
engine.postUpdate();
|
||||
|
||||
if (!coreParams.testMode) {
|
||||
|
||||
@ -12,9 +12,11 @@
|
||||
#include "window/Camera.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
|
||||
MenuScreen::MenuScreen(Engine& engine) : Screen(engine) {
|
||||
uicamera =
|
||||
std::make_unique<Camera>(glm::vec3(), engine.getWindow().getSize().y);
|
||||
MenuScreen::MenuScreen(Engine& engine)
|
||||
: Screen(engine),
|
||||
uicamera(
|
||||
std::make_unique<Camera>(glm::vec3(), engine.getWindow().getSize().y)
|
||||
) {
|
||||
uicamera->perspective = false;
|
||||
uicamera->near = -1.0f;
|
||||
uicamera->far = 1.0f;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user