about to add SDL and probably break everything
This commit is contained in:
2
lib/glfw
2
lib/glfw
Submodule lib/glfw updated: dd8a678a66...57cbded076
2
lib/glm
2
lib/glm
Submodule lib/glm updated: 0a6d3334ea...efec5db081
@ -46,7 +46,7 @@ void AssetManager::queueSwap(
|
||||
auto itUnload = oldAssets.begin();
|
||||
while(itUnload != oldAssets.end()) {
|
||||
auto inNewAssets = std::find(newAssets.begin(), newAssets.end(), *itUnload);
|
||||
if(inNewAssets == oldAssets.end()) unload.push_back(*itUnload);
|
||||
if(inNewAssets == newAssets.end()) unload.push_back(*itUnload);
|
||||
++itUnload;
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,15 @@ namespace Dawn {
|
||||
*/
|
||||
virtual int32_t update(float_t delta) = 0;
|
||||
|
||||
/**
|
||||
* Changes to a new scene, will dispose the currently active scene as part
|
||||
* of that process. This assumes the other scene has already been loaded
|
||||
* and staged.
|
||||
*
|
||||
* @param scene Scene to cut over to.
|
||||
*/
|
||||
virtual void sceneCutover(Scene *scene) = 0;
|
||||
|
||||
/**
|
||||
* Cleanup the memory of the DawnGame instance.
|
||||
*/
|
||||
|
@ -37,7 +37,15 @@ SceneItem * Scene::createSceneItem() {
|
||||
}
|
||||
|
||||
Scene::~Scene() {
|
||||
// Early cleanup without disposing.
|
||||
auto it = this->items.begin();
|
||||
while(it != this->items.end()) {
|
||||
it->second->destroy();
|
||||
++it;
|
||||
}
|
||||
|
||||
// Now dispose everything.
|
||||
it = this->items.begin();
|
||||
while(it != this->items.end()) {
|
||||
delete it->second;
|
||||
++it;
|
||||
|
@ -59,8 +59,17 @@ void SceneItem::init() {
|
||||
} while(waitingOn != 0);
|
||||
}
|
||||
|
||||
void SceneItem::destroy() {
|
||||
auto it = this->components.begin();
|
||||
while(it != this->components.end()) {
|
||||
(*it)->onDispose();
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
SceneItem::~SceneItem() {
|
||||
auto it = this->components.begin();
|
||||
it = this->components.begin();
|
||||
while(it != this->components.end()) {
|
||||
delete *it;
|
||||
++it;
|
||||
|
@ -37,6 +37,12 @@ namespace Dawn {
|
||||
*/
|
||||
void init();
|
||||
|
||||
/**
|
||||
* Called by the Scene when cleanup needs to occur but before anything in
|
||||
* the scene has been disposed.
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* Adds a component to this scene item. Components will only have their
|
||||
* init methods invoked on the first frame we enter the scene. If you add
|
||||
|
@ -37,6 +37,10 @@ void SceneItemComponent::onStart() {
|
||||
|
||||
}
|
||||
|
||||
void SceneItemComponent::onDispose() {
|
||||
|
||||
}
|
||||
|
||||
SceneItemComponent::~SceneItemComponent() {
|
||||
|
||||
}
|
@ -58,9 +58,15 @@ namespace Dawn {
|
||||
*/
|
||||
virtual void onStart();
|
||||
|
||||
/**
|
||||
* Intended for subclasses to detect when they need to clean themselves up
|
||||
* but before anything has been completely free'd from memory.
|
||||
*/
|
||||
virtual void onDispose();
|
||||
|
||||
/**
|
||||
* Cleanup the SceneItemComponent.
|
||||
*/
|
||||
virtual ~SceneItemComponent();
|
||||
~SceneItemComponent();
|
||||
};
|
||||
}
|
@ -25,6 +25,6 @@ void AnimationController::onStart() {
|
||||
getScene()->eventSceneUnpausedUpdate.addListener(this, &AnimationController::onSceneUpdate);
|
||||
}
|
||||
|
||||
AnimationController::~AnimationController() {
|
||||
void AnimationController::onDispose() {
|
||||
getScene()->eventSceneUnpausedUpdate.removeListener(this, &AnimationController::onSceneUpdate);
|
||||
}
|
@ -18,7 +18,6 @@ namespace Dawn {
|
||||
AnimationController(SceneItem *item);
|
||||
|
||||
void onStart() override;
|
||||
|
||||
~AnimationController();
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
@ -58,10 +58,13 @@ void Camera::setRenderTarget(RenderTarget *renderTarget) {
|
||||
this, &Camera::onRenderTargetResize
|
||||
);
|
||||
this->updateProjection();
|
||||
this->eventRenderTargetResized.invoke(
|
||||
renderTarget->getWidth(), renderTarget->getHeight()
|
||||
);
|
||||
}
|
||||
|
||||
float_t Camera::getAspect() {
|
||||
RenderTarget *target = this->getRenderTarget();
|
||||
auto target = this->getRenderTarget();
|
||||
return target->getWidth() / target->getHeight();
|
||||
}
|
||||
|
||||
@ -71,9 +74,10 @@ void Camera::onStart() {
|
||||
|
||||
void Camera::onRenderTargetResize(RenderTarget *target, float_t w, float_t h) {
|
||||
this->updateProjection();
|
||||
this->eventRenderTargetResized.invoke(w, h);
|
||||
}
|
||||
|
||||
Camera::~Camera() {
|
||||
void Camera::onDispose() {
|
||||
this->getRenderTarget()->eventRenderTargetResized.removeListener(
|
||||
this, &Camera::onRenderTargetResize
|
||||
);
|
||||
|
@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
#include "scene/SceneItemComponent.hpp"
|
||||
#include "display/RenderTarget.hpp"
|
||||
#include "scene/Scene.hpp"
|
||||
#include "scene/Scene.hpp "
|
||||
|
||||
namespace Dawn {
|
||||
enum CameraType {
|
||||
@ -21,6 +21,8 @@ namespace Dawn {
|
||||
void onRenderTargetResize(RenderTarget *target, float_t w, float_t h);
|
||||
|
||||
public:
|
||||
Event<float_t, float_t> eventRenderTargetResized;
|
||||
|
||||
static Camera * create(Scene *scene) {
|
||||
auto item = scene->createSceneItem();
|
||||
auto cam = item->addComponent<Camera>();
|
||||
@ -81,10 +83,6 @@ namespace Dawn {
|
||||
* Event triggered by the scene item when the item is added to the scene.
|
||||
*/
|
||||
void onStart() override;
|
||||
|
||||
/**
|
||||
* Disposes a previously initialized camera.
|
||||
*/
|
||||
~Camera();
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
@ -18,9 +18,7 @@ std::vector<SceneItemComponent*> PixelPerfectCamera::getDependencies() {
|
||||
};
|
||||
}
|
||||
|
||||
void PixelPerfectCamera::onRenderTargetResized(
|
||||
RenderTarget *t, float_t w, float_t h
|
||||
) {
|
||||
void PixelPerfectCamera::onRenderTargetResized(float_t w, float_t h) {
|
||||
this->updateDimensions();
|
||||
}
|
||||
|
||||
@ -58,13 +56,13 @@ void PixelPerfectCamera::updateDimensions() {
|
||||
void PixelPerfectCamera::onStart() {
|
||||
assertNotNull(this->camera);
|
||||
this->updateDimensions();
|
||||
camera->getRenderTarget()->eventRenderTargetResized
|
||||
.addListener(this, &PixelPerfectCamera::onRenderTargetResized)
|
||||
;
|
||||
camera->eventRenderTargetResized.addListener(
|
||||
this, &PixelPerfectCamera::onRenderTargetResized
|
||||
);
|
||||
}
|
||||
|
||||
PixelPerfectCamera::~PixelPerfectCamera() {
|
||||
camera->getRenderTarget()->eventRenderTargetResized
|
||||
.removeListener(this, &PixelPerfectCamera::onRenderTargetResized)
|
||||
;
|
||||
void PixelPerfectCamera::onDispose() {
|
||||
camera->eventRenderTargetResized.removeListener(
|
||||
this, &PixelPerfectCamera::onRenderTargetResized
|
||||
);
|
||||
}
|
@ -11,7 +11,7 @@ namespace Dawn {
|
||||
protected:
|
||||
Camera *camera = nullptr;
|
||||
/** Event for when the render target is resized. */
|
||||
void onRenderTargetResized(RenderTarget *target, float_t w, float_t h);
|
||||
void onRenderTargetResized(float_t w, float_t h);
|
||||
|
||||
/**
|
||||
* Updates the underlying camera's projection information.
|
||||
@ -30,7 +30,6 @@ namespace Dawn {
|
||||
|
||||
std::vector<SceneItemComponent*> getDependencies() override;
|
||||
void onStart() override;
|
||||
|
||||
~PixelPerfectCamera();
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
@ -72,7 +72,7 @@ void SimpleRenderTargetQuad::onStart() {
|
||||
}
|
||||
}
|
||||
|
||||
SimpleRenderTargetQuad::~SimpleRenderTargetQuad() {
|
||||
void SimpleRenderTargetQuad::onDispose() {
|
||||
if(this->renderTarget != nullptr) {
|
||||
this->renderTarget->eventRenderTargetResized.removeListener(
|
||||
this, &SimpleRenderTargetQuad::onRenderTargetResized
|
||||
|
@ -36,7 +36,6 @@ namespace Dawn {
|
||||
|
||||
std::vector<SceneItemComponent*> getDependencies() override;
|
||||
void onStart() override;
|
||||
|
||||
~SimpleRenderTargetQuad();
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
@ -39,6 +39,6 @@ void ExampleSpin::onUnpausedUpdate() {
|
||||
this->transform->setLocalRotation(quat);
|
||||
}
|
||||
|
||||
ExampleSpin::~ExampleSpin() {
|
||||
void ExampleSpin::onDispose() {
|
||||
getScene()->eventSceneUnpausedUpdate.removeListener(this, &ExampleSpin::onUnpausedUpdate);
|
||||
}
|
@ -14,6 +14,6 @@ namespace Dawn {
|
||||
|
||||
ExampleSpin(SceneItem *item);
|
||||
void onUnpausedUpdate();
|
||||
~ExampleSpin();
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
@ -17,6 +17,10 @@ void SubSceneCameraAlign::onRenderTargetResize(
|
||||
this->realign();
|
||||
}
|
||||
|
||||
void SubSceneCameraAlign::onCameraResize(float_t w, float_t h) {
|
||||
this->realign();
|
||||
}
|
||||
|
||||
void SubSceneCameraAlign::realign() {
|
||||
float_t diff;
|
||||
if(this->camera == nullptr) return;
|
||||
@ -68,8 +72,8 @@ void SubSceneCameraAlign::setCamera(Camera *camera) {
|
||||
assertTrue(this->camera != camera);
|
||||
|
||||
if(this->camera != nullptr) {
|
||||
this->camera->getRenderTarget()->eventRenderTargetResized.removeListener(
|
||||
this, &SubSceneCameraAlign::onRenderTargetResize
|
||||
this->camera->eventRenderTargetResized.removeListener(
|
||||
this, &SubSceneCameraAlign::onCameraResize
|
||||
);
|
||||
}
|
||||
|
||||
@ -77,8 +81,8 @@ void SubSceneCameraAlign::setCamera(Camera *camera) {
|
||||
this->realign();
|
||||
|
||||
if(this->camera != nullptr) {
|
||||
this->camera->getRenderTarget()->eventRenderTargetResized.addListener(
|
||||
this, &SubSceneCameraAlign::onRenderTargetResize
|
||||
this->camera->eventRenderTargetResized.addListener(
|
||||
this, &SubSceneCameraAlign::onCameraResize
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -87,15 +91,15 @@ void SubSceneCameraAlign::onStart() {
|
||||
this->realign();
|
||||
}
|
||||
|
||||
SubSceneCameraAlign::~SubSceneCameraAlign() {
|
||||
void SubSceneCameraAlign::onDispose() {
|
||||
if(this->renderTarget != nullptr) {
|
||||
this->renderTarget->eventRenderTargetResized.removeListener(
|
||||
this, &SubSceneCameraAlign::onRenderTargetResize
|
||||
);
|
||||
}
|
||||
if(this->camera != nullptr) {
|
||||
this->camera->getRenderTarget()->eventRenderTargetResized.removeListener(
|
||||
this, &SubSceneCameraAlign::onRenderTargetResize
|
||||
this->camera->eventRenderTargetResized.removeListener(
|
||||
this, &SubSceneCameraAlign::onCameraResize
|
||||
);
|
||||
}
|
||||
}
|
@ -15,18 +15,37 @@ namespace Dawn {
|
||||
Camera *camera = nullptr;
|
||||
|
||||
void onRenderTargetResize(RenderTarget *target, float_t w, float_t h);
|
||||
void onCameraResize(float_t w, float_t h);
|
||||
|
||||
/**
|
||||
* Realigns the camera to match the render target quad.
|
||||
*/
|
||||
void realign();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Create the sub scene camera align component. This will align a camera
|
||||
* to match a render target quad (Refer SimpleRenderTargetQuad)
|
||||
*
|
||||
* @param item Scene Item that this component belongs to.
|
||||
*/
|
||||
SubSceneCameraAlign(SceneItem *item);
|
||||
|
||||
/**
|
||||
* Set the render target for this alignment to use.
|
||||
*
|
||||
* @param renderTarget Render target to align to.
|
||||
*/
|
||||
void setRenderTarget(TextureRenderTarget *renderTarget);
|
||||
|
||||
/**
|
||||
* Sets the camera that will be aligned.
|
||||
*
|
||||
* @param camera Camera to align.
|
||||
*/
|
||||
void setCamera(Camera *camera);
|
||||
|
||||
void onStart() override;
|
||||
|
||||
~SubSceneCameraAlign();
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
@ -38,7 +38,7 @@ void SubSceneController::onStart() {
|
||||
myScene->eventSceneUpdate.addListener(this, &SubSceneController::onSceneUpdate);
|
||||
}
|
||||
|
||||
SubSceneController::~SubSceneController() {
|
||||
void SubSceneController::onDispose() {
|
||||
auto myScene = this->getScene();
|
||||
myScene->eventSceneUnpausedUpdate.removeListener(this, &SubSceneController::onSceneUnpausedUpdate);
|
||||
myScene->eventSceneUpdate.removeListener(this, &SubSceneController::onSceneUpdate);
|
||||
|
@ -23,7 +23,6 @@ namespace Dawn {
|
||||
void setSubScene(Scene *scene);
|
||||
|
||||
void onStart() override;
|
||||
|
||||
~SubSceneController();
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
@ -18,7 +18,7 @@ UICanvas * UICanvas::create(Scene *scene) {
|
||||
UICanvas::UICanvas(SceneItem *item) : SceneItemComponent(item) {
|
||||
}
|
||||
|
||||
void UICanvas::onRenderTargetResize(RenderTarget *target, float_t w, float_t h){
|
||||
void UICanvas::onRenderTargetResize(float_t w, float_t h){
|
||||
auto it = this->children.begin();
|
||||
while(it != this->children.end()) {
|
||||
(*it)->updatePositions();
|
||||
@ -30,7 +30,7 @@ void UICanvas::setCamera(Camera *camera) {
|
||||
assertTrue(camera != this->camera);
|
||||
|
||||
if(this->camera != nullptr) {
|
||||
this->camera->getRenderTarget()->eventRenderTargetResized.removeListener(
|
||||
this->camera->eventRenderTargetResized.removeListener(
|
||||
this, &UICanvas::onRenderTargetResize
|
||||
);
|
||||
}
|
||||
@ -38,7 +38,7 @@ void UICanvas::setCamera(Camera *camera) {
|
||||
this->camera = camera;
|
||||
|
||||
if(this->camera != nullptr) {
|
||||
this->camera->getRenderTarget()->eventRenderTargetResized.addListener(
|
||||
this->camera->eventRenderTargetResized.addListener(
|
||||
this, &UICanvas::onRenderTargetResize
|
||||
);
|
||||
}
|
||||
@ -65,16 +65,16 @@ void UICanvas::onStart() {
|
||||
}
|
||||
}
|
||||
|
||||
UICanvas::~UICanvas() {
|
||||
void UICanvas::onDispose() {
|
||||
if(this->camera != nullptr) {
|
||||
this->camera->eventRenderTargetResized.removeListener(
|
||||
this, &UICanvas::onRenderTargetResize
|
||||
);
|
||||
}
|
||||
|
||||
auto it = this->children.begin();
|
||||
while(it != this->children.end()) {
|
||||
delete *it;
|
||||
++it;
|
||||
}
|
||||
|
||||
if(this->camera != nullptr) {
|
||||
this->camera->getRenderTarget()->eventRenderTargetResized.removeListener(
|
||||
this, &UICanvas::onRenderTargetResize
|
||||
);
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ namespace Dawn {
|
||||
protected:
|
||||
Camera *camera = nullptr;
|
||||
|
||||
void onRenderTargetResize(RenderTarget *target, float_t w, float_t h);
|
||||
void onRenderTargetResize(float_t w, float_t h);
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -91,7 +91,6 @@ namespace Dawn {
|
||||
float_t getHeight();
|
||||
|
||||
void onStart() override;
|
||||
|
||||
~UICanvas();
|
||||
void onDispose() override;
|
||||
};
|
||||
}
|
@ -64,15 +64,11 @@ bool_t IVisualNovelEvent::update() {
|
||||
IVisualNovelEvent * IVisualNovelEvent::end() {
|
||||
this->onEnd();
|
||||
|
||||
std::cout << "End";
|
||||
|
||||
if(this->doNext != nullptr) {
|
||||
std::cout << " Nexter" << std::endl;
|
||||
auto next = this->doNext;
|
||||
this->doNext = nullptr;
|
||||
return next;
|
||||
}
|
||||
std::cout << " No nxt" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
38
src/dawn/visualnovel/events/VisualNovelCallbackEvent.hpp
Normal file
38
src/dawn/visualnovel/events/VisualNovelCallbackEvent.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "visualnovel/VisualNovelManager.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
template<class T>
|
||||
class VisualNovelCallbackEvent : public IVisualNovelEvent {
|
||||
protected:
|
||||
T *instance;
|
||||
void (T::*callback)();
|
||||
|
||||
void onStart(IVisualNovelEvent *previous) {
|
||||
|
||||
}
|
||||
|
||||
bool_t onUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void onEnd() {
|
||||
((*this->instance).*(this->callback))();
|
||||
}
|
||||
|
||||
public:
|
||||
VisualNovelCallbackEvent(
|
||||
VisualNovelManager *manager,
|
||||
T *instance,
|
||||
void (T::*callback)()
|
||||
) : IVisualNovelEvent(manager) {
|
||||
this->instance = instance;
|
||||
this->callback = callback;
|
||||
}
|
||||
};
|
||||
}
|
@ -17,7 +17,7 @@ std::vector<Asset*> SimpleVNScene::getRequiredAssets() {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets;
|
||||
vectorAppend(&assets, VisualNovelTextboxPrefab::getRequiredAssets(assMan));
|
||||
return std::vector<Asset*>();
|
||||
return assets;
|
||||
}
|
||||
|
||||
void SimpleVNScene::stage() {
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "visualnovel/events/VisualNovelTextboxEvent.hpp"
|
||||
#include "visualnovel/events/VisualNovelPauseEvent.hpp"
|
||||
#include "visualnovel/events/VisualNovelFadeEvent.hpp"
|
||||
#include "visualnovel/events/VisualNovelCAllbackEvent.hpp"
|
||||
#include "visualnovel/events/VisualNovelChangeSimpleBackgroundEvent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
|
@ -78,7 +78,7 @@ int32_t DawnHost::init(DawnGame *game) {
|
||||
}
|
||||
|
||||
// Set up event listeners
|
||||
glfwSetWindowSizeCallback(this->data->window, &glfwOnResize);
|
||||
glfwSetFramebufferSizeCallback(this->data->window, &glfwOnResize);
|
||||
glfwSetKeyCallback(this->data->window, &glfwOnKey);
|
||||
|
||||
return DAWN_HOST_INIT_RESULT_SUCCESS;
|
||||
@ -118,6 +118,7 @@ int32_t DawnHost::start(DawnGame *game) {
|
||||
}
|
||||
|
||||
int32_t DawnHost::update(DawnGame *game, float_t delta) {
|
||||
// Tick game.
|
||||
auto ret = game->update(delta);
|
||||
switch(ret) {
|
||||
case DAWN_GAME_UPDATE_RESULT_SUCCESS:
|
||||
@ -148,17 +149,11 @@ void glfwOnError(int error, const char* description) {
|
||||
fputs(description, stderr);
|
||||
}
|
||||
|
||||
void glfwOnResize(
|
||||
GLFWwindow *window,
|
||||
int32_t width,
|
||||
int32_t height
|
||||
) {
|
||||
void glfwOnResize(GLFWwindow *window, int32_t w, int32_t h) {
|
||||
if(DAWN_HOST == nullptr) return;
|
||||
|
||||
// TODO: I may throttle this, it calls for every frame the window's resized.
|
||||
DAWN_HOST->game->renderManager.backBuffer.setSize(
|
||||
(float_t)width,
|
||||
(float_t)height
|
||||
);
|
||||
DAWN_HOST->game->renderManager.backBuffer.setSize((float_t)w, (float_t)h);
|
||||
}
|
||||
|
||||
void glfwOnKey(
|
||||
|
@ -4,7 +4,11 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "DawnGame.hpp"
|
||||
#include "scenes/SubsceneTest.hpp"
|
||||
#include "scenes/SubSceneRendererScene.hpp"
|
||||
#include "scenes/Scene_1.hpp"
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
@ -22,12 +26,23 @@ int32_t DawnGame::init() {
|
||||
this->localeManager.init();
|
||||
this->renderManager.init();
|
||||
|
||||
this->scene = new SubsceneTest(this);
|
||||
this->scene = new SubSceneRendererScene<Scene_4>(this);
|
||||
|
||||
return DAWN_GAME_INIT_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DawnGame::update(float_t delta) {
|
||||
if(this->sceneToCutTo != nullptr) {
|
||||
if(this->sceneToCutTo == this->scene) {
|
||||
delete this->scene;
|
||||
this->scene = nullptr;
|
||||
} else {
|
||||
delete this->scene;
|
||||
this->scene = this->sceneToCutTo;
|
||||
}
|
||||
this->sceneToCutTo = nullptr;
|
||||
}
|
||||
|
||||
this->assetManager.update();
|
||||
this->inputManager.update();
|
||||
this->timeManager.update(delta);
|
||||
@ -37,4 +52,10 @@ int32_t DawnGame::update(float_t delta) {
|
||||
this->renderManager.update();
|
||||
|
||||
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void DawnGame::sceneCutover(Scene *scene) {
|
||||
if(scene == nullptr) scene = this->scene;
|
||||
this->sceneToCutTo = scene;
|
||||
}
|
@ -10,6 +10,9 @@
|
||||
|
||||
namespace Dawn {
|
||||
class DawnGame : public IDawnGame {
|
||||
private:
|
||||
Scene *sceneToCutTo = nullptr;
|
||||
|
||||
public:
|
||||
DawnHost *host;
|
||||
RenderManager renderManager;
|
||||
@ -22,5 +25,6 @@ namespace Dawn {
|
||||
DawnGame(DawnHost *host);
|
||||
int32_t init() override;
|
||||
int32_t update(float_t delta) override;
|
||||
void sceneCutover(Scene *scene) override;
|
||||
};
|
||||
}
|
@ -14,6 +14,8 @@
|
||||
namespace Dawn {
|
||||
class PennyPrefab : public SceneItemPrefab<PennyPrefab> {
|
||||
public:
|
||||
VisualNovelCharacter *vnCharacter;
|
||||
|
||||
static std::vector<Asset*> prefabAssets(AssetManager *assMan) {
|
||||
return std::vector<Asset*>{
|
||||
assMan->get<TextureAsset>("texture_penny"),
|
||||
@ -33,7 +35,7 @@ namespace Dawn {
|
||||
auto tiledSprite = this->addComponent<TiledSprite>();
|
||||
auto animation = this->addComponent<AnimationController>();
|
||||
auto pokerPlayer = this->addComponent<PokerPlayer>();
|
||||
auto vnCharacter = this->addComponent<VisualNovelCharacter>();
|
||||
vnCharacter = this->addComponent<VisualNovelCharacter>();
|
||||
|
||||
vnCharacter->nameKey = "character.penny.name";
|
||||
|
||||
@ -44,10 +46,10 @@ namespace Dawn {
|
||||
tiledSprite->setTile(0);
|
||||
this->transform.setLocalPosition(glm::vec3(0, 0, 0));
|
||||
|
||||
// auto anim = new TiledSpriteAnimation(tiledSprite);
|
||||
// anim->addSequentialKeyframes(0.1f, 0, 22);
|
||||
// anim->loop = true;
|
||||
// animation->animation = anim;
|
||||
auto anim = new TiledSpriteAnimation(tiledSprite);
|
||||
anim->addSequentialKeyframes(0.1f, 0, 22);
|
||||
anim->loop = true;
|
||||
animation->animation = anim;
|
||||
}
|
||||
};
|
||||
}
|
@ -15,6 +15,7 @@ namespace Dawn {
|
||||
static std::vector<Asset*> prefabAssets(AssetManager *man) {
|
||||
std::vector<Asset*> assets;
|
||||
assets.push_back(man->get<TrueTypeAsset>("truetype_ark"));
|
||||
vectorAppend(&assets, UIBorderPrefab::getRequiredAssets(man));
|
||||
return assets;
|
||||
}
|
||||
|
||||
|
@ -6,5 +6,6 @@
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
PixelVNScene.cpp
|
||||
PokerVNScene.cpp
|
||||
)
|
28
src/dawnpokergame/scenes/PixelVNScene.cpp
Normal file
28
src/dawnpokergame/scenes/PixelVNScene.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "PixelVNScene.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
PixelVNScene::PixelVNScene(DawnGame *game) :
|
||||
SimpleVNScene(game),
|
||||
renderTarget(320, 180)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> PixelVNScene::getRequiredAssets() {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets;
|
||||
vectorAppend(&assets, SimpleVNScene::getRequiredAssets());
|
||||
return assets;
|
||||
}
|
||||
|
||||
void PixelVNScene::vnStage() {
|
||||
this->renderTarget.setClearColor(COLOR_RED);
|
||||
this->camera->setRenderTarget(&this->renderTarget);
|
||||
auto pixelPerfectCamera = this->camera->item->addComponent<PixelPerfectCamera>();
|
||||
}
|
29
src/dawnpokergame/scenes/PixelVNScene.hpp
Normal file
29
src/dawnpokergame/scenes/PixelVNScene.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "visualnovel/scene/SimpleVNScene.hpp"
|
||||
#include "display/TextureRenderTarget.hpp"
|
||||
#include "game/DawnGame.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class PixelVNScene : public SimpleVNScene {
|
||||
protected:
|
||||
void vnStage() override;
|
||||
|
||||
public:
|
||||
TextureRenderTarget renderTarget;
|
||||
|
||||
/**
|
||||
* Create a simple Poker Visual Novel Scene. Simplifies some of the less
|
||||
* interesting parts of a poker VN game.
|
||||
*
|
||||
* @param game Game that this poker scene belongs to.
|
||||
*/
|
||||
PixelVNScene(DawnGame *game);
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override;
|
||||
};
|
||||
}
|
@ -7,27 +7,20 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
PokerVNScene::PokerVNScene(DawnGame *game) :
|
||||
SimpleVNScene(game),
|
||||
renderTarget(320, 180)
|
||||
{
|
||||
PokerVNScene::PokerVNScene(DawnGame *game) : PixelVNScene(game) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> PokerVNScene::getRequiredAssets() {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets;
|
||||
vectorAppend(&assets, SimpleVNScene::getRequiredAssets());
|
||||
vectorAppend(&assets, PixelVNScene::getRequiredAssets());
|
||||
vectorAppend(&assets, PokerPlayerDisplay::getAssets(assMan));
|
||||
return assets;
|
||||
}
|
||||
|
||||
void PokerVNScene::vnStage() {
|
||||
this->renderTarget.setClearColor(COLOR_BLACK);
|
||||
this->camera->setRenderTarget(&this->renderTarget);
|
||||
|
||||
auto pixelPerfectCamera = this->camera->item->addComponent<PixelPerfectCamera>();
|
||||
|
||||
PixelVNScene::vnStage();
|
||||
auto pokerGameItem = this->createSceneItem();
|
||||
this->pokerGame = pokerGameItem->addComponent<PokerGame>();
|
||||
|
||||
|
@ -4,15 +4,14 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "visualnovel/scene/SimpleVNScene.hpp"
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "poker/PokerGame.hpp"
|
||||
#include "visualnovel/events/PokerBetLoopEvent.hpp"
|
||||
#include "visualnovel/events/PokerInitialEvent.hpp"
|
||||
#include "ui/PokerPlayerDisplay.hpp"
|
||||
#include "display/TextureRenderTarget.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class PokerVNScene : public SimpleVNScene {
|
||||
class PokerVNScene : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override;
|
||||
std::vector<Asset*> getRequiredAssets() override;
|
||||
@ -24,10 +23,7 @@ namespace Dawn {
|
||||
*/
|
||||
virtual std::vector<PokerPlayer*> getPokerPlayers() = 0;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
TextureRenderTarget renderTarget;
|
||||
PokerGame *pokerGame;
|
||||
std::vector<PokerPlayer*> pokerPlayers;
|
||||
std::map<PokerPlayer*, PokerPlayerDisplay*> pokerPlayerDisplays;
|
||||
|
47
src/dawnpokergame/scenes/Scene_1.hpp
Normal file
47
src/dawnpokergame/scenes/Scene_1.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "scenes/Scene_2.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_1 : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
PixelVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_2>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
|
||||
|
||||
start
|
||||
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.1.1"))
|
||||
->then(new VisualNovelCallbackEvent<Scene_1>(vnManager, this, &Scene_1::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_1(DawnGame *game) : PixelVNScene(game) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
46
src/dawnpokergame/scenes/Scene_10.hpp
Normal file
46
src/dawnpokergame/scenes/Scene_10.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "scenes/Scene_11.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_10 : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
PixelVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_11>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
|
||||
|
||||
start
|
||||
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.10.1"))
|
||||
->then(new VisualNovelCallbackEvent<Scene_10>(vnManager, this, &Scene_10::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_10(DawnGame *game) : PixelVNScene(game) {
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
46
src/dawnpokergame/scenes/Scene_11.hpp
Normal file
46
src/dawnpokergame/scenes/Scene_11.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "scenes/Scene_12.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_11 : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
PixelVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_12>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
|
||||
|
||||
start
|
||||
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.11.1"))
|
||||
->then(new VisualNovelCallbackEvent<Scene_11>(vnManager, this, &Scene_11::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_11(DawnGame *game) : PixelVNScene(game) {
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
66
src/dawnpokergame/scenes/Scene_12.hpp
Normal file
66
src/dawnpokergame/scenes/Scene_12.hpp
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "PokerVNScene.hpp"
|
||||
#include "prefabs/characters/PennyPrefab.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_12 : public PokerVNScene {
|
||||
protected:
|
||||
PennyPrefab *penny;
|
||||
PennyPrefab *julie;
|
||||
PennyPrefab *sammy;
|
||||
PennyPrefab *lucy;
|
||||
|
||||
void vnStage() override {
|
||||
penny = PennyPrefab::create(this);
|
||||
julie = PennyPrefab::create(this);
|
||||
sammy = PennyPrefab::create(this);
|
||||
lucy = PennyPrefab::create(this);
|
||||
|
||||
PokerVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
// auto scene = new SubSceneRendererScene<Scene_13>(this->game);
|
||||
// auto assets = game->scene->getRequiredAssets();
|
||||
// game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
// game->assetManager.syncLoad();
|
||||
// scene->stage();
|
||||
// this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
std::vector<PokerPlayer *> getPokerPlayers() override {
|
||||
return std::vector<PokerPlayer*>{
|
||||
this->penny->getComponent<PokerPlayer>(),
|
||||
this->julie->getComponent<PokerPlayer>(),
|
||||
this->sammy->getComponent<PokerPlayer>(),
|
||||
this->lucy->getComponent<PokerPlayer>()
|
||||
};
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.12.1");
|
||||
|
||||
start
|
||||
->then(new VisualNovelCallbackEvent<Scene_12>(vnManager, this, &Scene_12::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_12(DawnGame *game) : PokerVNScene(game) {}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets;
|
||||
vectorAppend(&assets, PokerVNScene::getRequiredAssets());
|
||||
vectorAppend(&assets, PennyPrefab::getRequiredAssets(assMan));
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "visualnovel/scene/SimpleVNScene.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_1_1 : public SimpleVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelTextboxEvent(vnManager,nullptr,"scene.1.1");
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_1_1(DawnGame *game) : SimpleVNScene(game) {}
|
||||
};
|
||||
}
|
47
src/dawnpokergame/scenes/Scene_2.hpp
Normal file
47
src/dawnpokergame/scenes/Scene_2.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "scenes/Scene_3.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_2 : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
PixelVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_3>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
|
||||
|
||||
start
|
||||
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.2.1"))
|
||||
->then(new VisualNovelCallbackEvent<Scene_2>(vnManager, this, &Scene_2::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_2(DawnGame *game) : PixelVNScene(game) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
47
src/dawnpokergame/scenes/Scene_3.hpp
Normal file
47
src/dawnpokergame/scenes/Scene_3.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "scenes/Scene_4.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_3 : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
PixelVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_4>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
|
||||
|
||||
start
|
||||
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.3.1"))
|
||||
->then(new VisualNovelCallbackEvent<Scene_3>(vnManager, this, &Scene_3::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_3(DawnGame *game) : PixelVNScene(game) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
67
src/dawnpokergame/scenes/Scene_4.hpp
Normal file
67
src/dawnpokergame/scenes/Scene_4.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "PokerVNScene.hpp"
|
||||
#include "prefabs/characters/PennyPrefab.hpp"
|
||||
#include "scenes/Scene_5.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_4 : public PokerVNScene {
|
||||
protected:
|
||||
PennyPrefab *penny;
|
||||
PennyPrefab *julie;
|
||||
PennyPrefab *sammy;
|
||||
PennyPrefab *lucy;
|
||||
|
||||
void vnStage() override {
|
||||
penny = PennyPrefab::create(this);
|
||||
julie = PennyPrefab::create(this);
|
||||
sammy = PennyPrefab::create(this);
|
||||
lucy = PennyPrefab::create(this);
|
||||
|
||||
PokerVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_5>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
std::vector<PokerPlayer *> getPokerPlayers() override {
|
||||
return std::vector<PokerPlayer*>{
|
||||
this->penny->getComponent<PokerPlayer>(),
|
||||
this->julie->getComponent<PokerPlayer>(),
|
||||
this->sammy->getComponent<PokerPlayer>(),
|
||||
this->lucy->getComponent<PokerPlayer>()
|
||||
};
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.4.1");
|
||||
|
||||
start
|
||||
->then(new VisualNovelCallbackEvent<Scene_4>(vnManager, this, &Scene_4::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_4(DawnGame *game) : PokerVNScene(game) {}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets;
|
||||
vectorAppend(&assets, PokerVNScene::getRequiredAssets());
|
||||
vectorAppend(&assets, PennyPrefab::getRequiredAssets(assMan));
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
47
src/dawnpokergame/scenes/Scene_5.hpp
Normal file
47
src/dawnpokergame/scenes/Scene_5.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "scenes/Scene_6.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_5 : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
PixelVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_6>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
|
||||
|
||||
start
|
||||
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.5.1"))
|
||||
->then(new VisualNovelCallbackEvent<Scene_5>(vnManager, this, &Scene_5::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_5(DawnGame *game) : PixelVNScene(game) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
47
src/dawnpokergame/scenes/Scene_6.hpp
Normal file
47
src/dawnpokergame/scenes/Scene_6.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "scenes/Scene_7.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_6 : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
PixelVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_7>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
|
||||
|
||||
start
|
||||
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.6.1"))
|
||||
->then(new VisualNovelCallbackEvent<Scene_6>(vnManager, this, &Scene_6::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_6(DawnGame *game) : PixelVNScene(game) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
46
src/dawnpokergame/scenes/Scene_7.hpp
Normal file
46
src/dawnpokergame/scenes/Scene_7.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "scenes/Scene_8.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_7 : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
PixelVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_8>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
|
||||
|
||||
start
|
||||
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.7.1"))
|
||||
->then(new VisualNovelCallbackEvent<Scene_7>(vnManager, this, &Scene_7::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_7(DawnGame *game) : PixelVNScene(game) {
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
67
src/dawnpokergame/scenes/Scene_8.hpp
Normal file
67
src/dawnpokergame/scenes/Scene_8.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "PokerVNScene.hpp"
|
||||
#include "prefabs/characters/PennyPrefab.hpp"
|
||||
#include "scenes/Scene_9.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_8 : public PokerVNScene {
|
||||
protected:
|
||||
PennyPrefab *penny;
|
||||
PennyPrefab *julie;
|
||||
PennyPrefab *sammy;
|
||||
PennyPrefab *lucy;
|
||||
|
||||
void vnStage() override {
|
||||
penny = PennyPrefab::create(this);
|
||||
julie = PennyPrefab::create(this);
|
||||
sammy = PennyPrefab::create(this);
|
||||
lucy = PennyPrefab::create(this);
|
||||
|
||||
PokerVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_9>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
std::vector<PokerPlayer *> getPokerPlayers() override {
|
||||
return std::vector<PokerPlayer*>{
|
||||
this->penny->getComponent<PokerPlayer>(),
|
||||
this->julie->getComponent<PokerPlayer>(),
|
||||
this->sammy->getComponent<PokerPlayer>(),
|
||||
this->lucy->getComponent<PokerPlayer>()
|
||||
};
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelTextboxEvent(vnManager, penny->vnCharacter, "scene.8.1");
|
||||
|
||||
start
|
||||
->then(new VisualNovelCallbackEvent<Scene_8>(vnManager, this, &Scene_8::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_8(DawnGame *game) : PokerVNScene(game) {}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
auto assMan = &this->game->assetManager;
|
||||
std::vector<Asset*> assets;
|
||||
vectorAppend(&assets, PokerVNScene::getRequiredAssets());
|
||||
vectorAppend(&assets, PennyPrefab::getRequiredAssets(assMan));
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
46
src/dawnpokergame/scenes/Scene_9.hpp
Normal file
46
src/dawnpokergame/scenes/Scene_9.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scenes/PixelVNScene.hpp"
|
||||
#include "scenes/Scene_10.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class Scene_9 : public PixelVNScene {
|
||||
protected:
|
||||
void vnStage() override {
|
||||
PixelVNScene::vnStage();
|
||||
}
|
||||
|
||||
void onSceneEnded() {
|
||||
auto scene = new SubSceneRendererScene<Scene_10>(this->game);
|
||||
auto assets = game->scene->getRequiredAssets();
|
||||
game->assetManager.queueSwap(assets, this->getRequiredAssets());
|
||||
game->assetManager.syncLoad();
|
||||
scene->stage();
|
||||
this->game->sceneCutover(scene);
|
||||
}
|
||||
|
||||
IVisualNovelEvent * getVNEvent() override {
|
||||
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
|
||||
|
||||
start
|
||||
->then(new VisualNovelTextboxEvent(vnManager, nullptr, "scene.9.1"))
|
||||
->then(new VisualNovelCallbackEvent<Scene_9>(vnManager, this, &Scene_9::onSceneEnded))
|
||||
;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
public:
|
||||
Scene_9(DawnGame *game) : PixelVNScene(game) {
|
||||
}
|
||||
|
||||
std::vector<Asset*> getRequiredAssets() override {
|
||||
std::vector<Asset*> assets = PixelVNScene::getRequiredAssets();
|
||||
return assets;
|
||||
}
|
||||
};
|
||||
}
|
@ -6,16 +6,16 @@
|
||||
#pragma once
|
||||
#include "scene/Scene.hpp"
|
||||
#include "game/DawnGame.hpp"
|
||||
#include "scenes/TestScene.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class SubsceneTest : public Scene {
|
||||
template<class T>
|
||||
class SubSceneRendererScene : public Scene {
|
||||
public:
|
||||
Camera *camera;
|
||||
SceneItem *sceneItem;
|
||||
TestScene subScene;
|
||||
T subScene;
|
||||
|
||||
SubsceneTest(DawnGame *game) : Scene(game), subScene(game) {
|
||||
SubSceneRendererScene(DawnGame *game) : Scene(game), subScene(game) {
|
||||
|
||||
}
|
||||
|
||||
@ -24,10 +24,14 @@ namespace Dawn {
|
||||
}
|
||||
|
||||
void stage() override {
|
||||
this->camera = Camera::create(this);
|
||||
|
||||
// Stage subscene
|
||||
this->subScene.stage();
|
||||
|
||||
// Create camera to render.
|
||||
this->camera = Camera::create(this);
|
||||
this->camera->getRenderTarget()->setClearColor(COLOR_BLACK);
|
||||
|
||||
// Add render quad.
|
||||
this->sceneItem = this->createSceneItem();
|
||||
auto host = this->sceneItem->addComponent<MeshHost>();
|
||||
auto renderer = this->sceneItem->addComponent<MeshRenderer>();
|
Reference in New Issue
Block a user