about to add SDL and probably break everything

This commit is contained in:
2023-01-16 10:01:06 -08:00
parent 18d3b074f9
commit 7585891276
53 changed files with 891 additions and 132 deletions

View File

@ -6,5 +6,6 @@
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
PixelVNScene.cpp
PokerVNScene.cpp
)

View 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>();
}

View 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;
};
}

View File

@ -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>();

View File

@ -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;

View 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;
}
};
}

View 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;
}
};
}

View 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;
}
};
}

View 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;
}
};
}

View File

@ -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) {}
};
}

View 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;
}
};
}

View 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;
}
};
}

View 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;
}
};
}

View 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;
}
};
}

View 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;
}
};
}

View 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;
}
};
}

View 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;
}
};
}

View 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;
}
};
}

View File

@ -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>();