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