Scene cutover and LoadingScene sample.

This commit is contained in:
2023-10-09 22:26:10 -05:00
parent 8df7cd23ea
commit 2423fd9f70
13 changed files with 81 additions and 10 deletions

View File

@ -40,10 +40,18 @@ int32_t DawnGame::update(float_t delta) {
this->sceneToCutTo = nullptr;
}
if(this->closeRequested) {
return DAWN_GAME_UPDATE_RESULT_EXIT;
}
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
}
void DawnGame::sceneCutover(Scene *scene) {
if(scene == nullptr) scene = this->scene;
this->sceneToCutTo = scene;
}
void DawnGame::close() {
this->closeRequested = true;
}

View File

@ -25,6 +25,7 @@ namespace Dawn {
class DawnGame {
private:
Scene *sceneToCutTo = nullptr;
bool_t closeRequested = false;
public:
DawnHost *host;
@ -75,6 +76,11 @@ namespace Dawn {
* @param scene Scene to cut over to.
*/
void sceneCutover(Scene *scene);
/**
* Gracefully requests that the game should be closed as soon as possible.
*/
void close();
};
/**

View File

@ -5,7 +5,7 @@
#pragma once
#include "VNEvent.hpp"
#include "scene/Scene.hpp"
#include "scenes/LoadingScene.hpp"
namespace Dawn {
template<class T>
@ -13,11 +13,7 @@ namespace Dawn {
protected:
void onStart() override {
auto game = this->manager->getGame();
T *nextScene = new T(this->manager->getGame());
auto assets = nextScene->getRequiredAssets();
game->assetManager.queueLoad(assets);
game->assetManager.syncLoad();
LoadingScene<T> *nextScene = new LoadingScene<T>(this->manager->getGame());
nextScene->stage();
game->sceneCutover(nextScene);
}

View File

@ -47,7 +47,6 @@ namespace Dawn {
UI_LABEL_TEXT_ALIGN_LEFT,
UI_LABEL_TEXT_ALIGN_CENTER,
UI_LABEL_TEXT_ALIGN_RIGHT
// TODO: Add justify
};
class UILabel : public UIComponentRenderable {