Scene change support
This commit is contained in:
@ -14,7 +14,7 @@ namespace Dawn {
|
||||
AssetManager *assetManager;
|
||||
std::string name;
|
||||
uint8_t state = 0x00;
|
||||
bool loaded = false;
|
||||
bool_t loaded = false;
|
||||
Event<> eventLoaded;
|
||||
StateEvent<> event2Loaded;
|
||||
|
||||
|
@ -95,11 +95,11 @@ namespace Dawn {
|
||||
* @return The count of bytes read.
|
||||
*/
|
||||
template<class T>
|
||||
size_t loadBufferedCallback(T *instance, bool (T::*callback)(uint8_t n)) {
|
||||
size_t loadBufferedCallback(T *instance, bool_t (T::*callback)(uint8_t n)) {
|
||||
uint8_t buffer[1024];
|
||||
size_t read, length;
|
||||
int32_t i;
|
||||
bool result;
|
||||
bool_t result;
|
||||
|
||||
assertNotNull(instance);
|
||||
assertNotNull(callback);
|
||||
|
@ -147,7 +147,7 @@ void Transform::setWorldTransform(glm::mat4 transform) {
|
||||
|
||||
|
||||
void Transform::setParent(Transform *parent) {
|
||||
assertTrue(parent != this);
|
||||
assertTrue(parent == nullptr || parent != this);
|
||||
|
||||
auto currentParent = this->getParent();
|
||||
if(currentParent == parent) return;
|
||||
@ -190,6 +190,6 @@ Transform::~Transform() {
|
||||
auto it = this->children.begin();
|
||||
while(it != this->children.end()) {
|
||||
(*it)->setParent(nullptr);
|
||||
++it;
|
||||
it = this->children.begin();
|
||||
}
|
||||
}
|
@ -32,6 +32,8 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
|
||||
assertUnreachable();
|
||||
}
|
||||
|
||||
if(face->glyph->bitmap.width == 0 || face->glyph->bitmap.rows == 0) continue;
|
||||
|
||||
// Update the width and height
|
||||
w = mathMax<size_t>(w, face->glyph->bitmap.width);
|
||||
h += face->glyph->bitmap.rows;
|
||||
|
@ -33,6 +33,13 @@ int32_t DawnGame::update(float_t delta) {
|
||||
|
||||
this->renderManager.update();
|
||||
|
||||
if(this->sceneToCutTo != nullptr) {
|
||||
delete this->scene;
|
||||
this->scene = nullptr;
|
||||
this->scene = this->sceneToCutTo;
|
||||
this->sceneToCutTo = nullptr;
|
||||
}
|
||||
|
||||
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
25
src/dawn/games/vn/events/VNSceneChangeEvent.hpp
Normal file
25
src/dawn/games/vn/events/VNSceneChangeEvent.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "VNEvent.hpp"
|
||||
#include "scene/Scene.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
template<class T>
|
||||
class VNSceneChangeEvent : public VNEvent {
|
||||
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();
|
||||
nextScene->stage();
|
||||
game->sceneCutover(nextScene);
|
||||
}
|
||||
};
|
||||
}
|
@ -10,6 +10,7 @@ target_sources(${DAWN_TARGET_NAME}
|
||||
UIComponent.cpp
|
||||
UIComponentRenderable.cpp
|
||||
UIImage.cpp
|
||||
UIEmpty.cpp
|
||||
UIBorder.cpp
|
||||
)
|
||||
|
||||
|
15
src/dawn/scene/components/ui/UIEmpty.cpp
Normal file
15
src/dawn/scene/components/ui/UIEmpty.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "UIEmpty.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
UIEmpty::UIEmpty(SceneItem *item) : UIComponent(item) { }
|
||||
|
||||
float_t UIEmpty::getContentWidth() { return 0.0f; }
|
||||
float_t UIEmpty::getContentHeight() { return 0.0f; }
|
||||
float_t UIEmpty::getChildOffsetX() { return 0.0f; }
|
||||
float_t UIEmpty::getChildOffsetY() { return 0.0f; }
|
18
src/dawn/scene/components/ui/UIEmpty.hpp
Normal file
18
src/dawn/scene/components/ui/UIEmpty.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "UIComponent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class UIEmpty : public UIComponent {
|
||||
public:
|
||||
UIEmpty(SceneItem *item);
|
||||
float_t getContentWidth() override;
|
||||
float_t getContentHeight() override;
|
||||
float_t getChildOffsetX() override;
|
||||
float_t getChildOffsetY() override;
|
||||
};
|
||||
}
|
@ -211,7 +211,9 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
|
||||
// Now, iterate each character
|
||||
for(int32_t i = 0; i < len; i++) {
|
||||
char ch = text.text[i];
|
||||
std::u32string::value_type ch = text.text[i];
|
||||
// FT_ULong ch = text.text[i];
|
||||
char c = text.text[i];
|
||||
|
||||
// Handle special characters
|
||||
if(ch == '\n') {
|
||||
@ -228,8 +230,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
assertTrue(ch != '\n');
|
||||
|
||||
// Get font data.
|
||||
FT_ULong c = ch;
|
||||
auto charInfo = realText.texture->getCharacterData(c);
|
||||
auto charInfo = realText.texture->getCharacterData(ch);
|
||||
|
||||
// Word wrapping
|
||||
if(
|
||||
|
Reference in New Issue
Block a user