diff --git a/src/dawn/display/CMakeLists.txt b/src/dawn/display/CMakeLists.txt index a113819a..aac2a745 100644 --- a/src/dawn/display/CMakeLists.txt +++ b/src/dawn/display/CMakeLists.txt @@ -8,6 +8,7 @@ target_sources(${DAWN_TARGET_NAME} PRIVATE RenderPipeline.cpp Transform.cpp + Tileset.cpp ) # Subdirs diff --git a/src/dawn/display/Tileset.cpp b/src/dawn/display/Tileset.cpp new file mode 100644 index 00000000..87f7390d --- /dev/null +++ b/src/dawn/display/Tileset.cpp @@ -0,0 +1,78 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "Tileset.hpp" + +using namespace Dawn; + +struct Tile Tileset::getTile(int32_t tile) { + assertTrue(tile >= 0); + assertTrue(tile < this->tiles.size()); + return this->tiles[tile]; +} + +TilesetGrid::TilesetGrid() { + +} + + +TilesetGrid::TilesetGrid( + int32_t columns, + int32_t rows, + int32_t w, + int32_t h, + int32_t gapX, + int32_t gapY, + int32_t borderX, + int32_t borderY +) { + assertTrue(columns >= 1); + assertTrue(rows >= 1); + assertTrue(w >= 1); + assertTrue(h >= 1); + assertTrue(gapX >= 0); + assertTrue(gapY >= 0); + assertTrue(borderX >= 0); + assertTrue(borderY >= 0); + assertTrue(w >= (columns + (gapX * columns) + borderX + borderX)); + assertTrue(h >= (rows + (gapY * rows) + borderY + borderY)); + + this->rows = rows; + this->columns = columns; + + // Calculate division sizes (pixels) + this->divX = (w - (borderX * 2) - (gapX * (columns - 1))) / columns; + this->divY = (h - (borderY * 2) - (gapY * (rows - 1))) / rows; + + // Calculate the division sizes (units) + float_t tdivX = (float_t)this->divX / (float_t)w; + float_t tdivY = (float_t)this->divY / (float_t)h; + + for(int32_t y = 0; y < rows; y++) { + for(int32_t x = 0; x < columns; x++) { + struct Tile tile; + tile.uv0.x = (borderX + ((float_t)this->divX * x) + (gapX * x)) / w; + tile.uv1.x = tile.uv0.x + tdivX; + + tile.uv0.y = (borderY + ((float_t)this->divY * y) + (gapY * y)) / h; + tile.uv1.y = tile.uv0.y + tdivY; + this->tiles.push_back(tile); + } + } +} + +float_t TilesetGrid::getTileWidth() { + return this->divX; +} + +float_t TilesetGrid::getTileHeight() { + return this->divY; +} + +struct Tile TilesetGrid::getTileFromGrid(int32_t column, int32_t row) { + assertTrue(row > 0 && row < this->rows); + assertTrue(column > 0 && column < this->columns); + return this->getTile(row + (column * this->rows)); +} \ No newline at end of file diff --git a/src/dawn/display/Tileset.hpp b/src/dawn/display/Tileset.hpp index 3a3ab0fb..84509b1d 100644 --- a/src/dawn/display/Tileset.hpp +++ b/src/dawn/display/Tileset.hpp @@ -5,23 +5,25 @@ #pragma once #include "dawnlibs.hpp" +#include "assert/assert.hpp" namespace Dawn { struct Tile { - public: - glm::vec2 uv0; - glm::vec2 uv1; + glm::vec2 uv0; + glm::vec2 uv1; }; struct Tileset { public: std::vector tiles; - struct Tile getTile(int32_t tile) { - assertTrue(tile >= 0); - assertTrue(tile < this->tiles.size()); - return this->tiles[tile]; - } + /** + * Returns the tile at the given tile index. + * + * @param tile Tile index to get. + * @return Tile at that index. + */ + struct Tile getTile(int32_t tile); }; struct TilesetGrid : public Tileset{ @@ -31,10 +33,23 @@ namespace Dawn { int32_t divX; int32_t divY; - TilesetGrid() { - - } - + /** + * Constructs a new Tileset Grid. + */ + TilesetGrid(); + + /** + * Constructs a new Tileset Grid. + * + * @param columns How many columns in the grid of tiles. + * @param rows How many rows in the grid of tiles. + * @param w Width of the grid. + * @param h Height of te grid. + * @param gapX Gap / Gutter between tiles. + * @param gapY Gap / Gutter between tiles. + * @param borderX Border at the edge of the grid before the first tiles. + * @param borderY Border at the edge of the grid before the first tiles. + */ TilesetGrid( int32_t columns, int32_t rows, @@ -44,46 +59,29 @@ namespace Dawn { int32_t gapY, int32_t borderX, int32_t borderY - ) { - assertTrue(columns >= 1); - assertTrue(rows >= 1); - assertTrue(w >= 1); - assertTrue(h >= 1); - assertTrue(gapX >= 0); - assertTrue(gapY >= 0); - assertTrue(borderX >= 0); - assertTrue(borderY >= 0); - assertTrue(w >= (columns + (gapX * columns) + borderX + borderX)); - assertTrue(h >= (rows + (gapY * rows) + borderY + borderY)); + ); - this->rows = rows; - this->columns = columns; + /** + * Returns the width of an individual tile. + * + * @return The tile width. + */ + float_t getTileWidth(); - // Calculate division sizes (pixels) - this->divX = (w - (borderX * 2) - (gapX * (columns - 1))) / columns; - this->divY = (h - (borderY * 2) - (gapY * (rows - 1))) / rows; + /** + * Returns the height of an individual tile. + * + * @return The tile height. + */ + float_t getTileHeight(); - // Calculate the division sizes (units) - float_t tdivX = (float_t)this->divX / (float_t)w; - float_t tdivY = (float_t)this->divY / (float_t)h; - - for(int32_t y = 0; y < rows; y++) { - for(int32_t x = 0; x < columns; x++) { - struct Tile tile; - tile.uv0.x = (borderX + ((float_t)this->divX * x) + (gapX * x)) / w; - tile.uv1.x = tile.uv0.x + tdivX; - - tile.uv0.y = (borderY + ((float_t)this->divY * y) + (gapY * y)) / h; - tile.uv1.y = tile.uv0.y + tdivY; - this->tiles.push_back(tile); - } - } - } - - struct Tile getTileFromGrid(int32_t row, int32_t column) { - assertTrue(row > 0 && row < this->rows); - assertTrue(column > 0 && column < this->columns); - return this->getTile(row + (column * this->rows)); - } + /** + * Returns the tile at a given grid position. + * + * @param column Column (0 indexed) to get the tile of. + * @param row Row (0 indexed) to get the tile of. + * @return Tile at this grid position. + */ + struct Tile getTileFromGrid(int32_t column, int32_t row); }; } \ No newline at end of file diff --git a/src/dawn/util/array.hpp b/src/dawn/util/array.hpp index 036cc133..d5c15715 100644 --- a/src/dawn/util/array.hpp +++ b/src/dawn/util/array.hpp @@ -8,6 +8,12 @@ #include "assert/assert.hpp" namespace Dawn { + /** + * Append a list on to another list. + * + * @param list Pointer to list that is being appended to. + * @param append Pointer to list that will be appended. + */ template void vectorAppend(std::vector *list, std::vector *append) { assertNotNull(list); @@ -20,6 +26,12 @@ namespace Dawn { } } + /** + * Append a list on to another list. + * + * @param list Pointer to list that is being appended to. + * @param append List that will be appended. + */ template void vectorAppend(std::vector *list, std::vector append) { assertNotNull(list); diff --git a/src/dawn/visualnovel/scene/SimpleVNScene.cpp b/src/dawn/visualnovel/scene/SimpleVNScene.cpp index 8389a34d..f651a2c5 100644 --- a/src/dawn/visualnovel/scene/SimpleVNScene.cpp +++ b/src/dawn/visualnovel/scene/SimpleVNScene.cpp @@ -25,11 +25,9 @@ void SimpleVNScene::stage() { // Camera this->camera = Camera::create(this); - this->camera->transform->lookAtPixelPerfect( - glm::vec3(0, 0, 0), - glm::vec3(0, 0, 0), - this->camera->getRenderTarget()->getHeight(), - camera->fov + this->camera->transform->lookAt( + glm::vec3(0, 0, 3), + glm::vec3(0, 0, 0) ); this->background = SimpleVisualNovelBackground::create(this); diff --git a/src/dawnpokergame/CMakeLists.txt b/src/dawnpokergame/CMakeLists.txt index 0cf3b496..d09a4a87 100644 --- a/src/dawnpokergame/CMakeLists.txt +++ b/src/dawnpokergame/CMakeLists.txt @@ -22,6 +22,7 @@ target_include_directories(${DAWN_TARGET_NAME} add_subdirectory(game) add_subdirectory(ui) add_subdirectory(visualnovel) +add_subdirectory(prefabs) add_subdirectory(save) add_subdirectory(scenes) @@ -32,6 +33,7 @@ tool_texture(texture_test texture_test.png) tool_language(language_en ${DIR_GAME_ASSETS}/locale/en.csv) tool_tileset(tileset_death texture_death ${DIR_GAME_ASSETS}/characters/death/sheet.png 1 3) +tool_tileset(tileset_penny texture_penny ${DIR_GAME_ASSETS}/characters/penny/sheet.png 1 3) tool_truetype(truetype_alice ${DIR_GAME_ASSETS}/font/Alice-Regular.ttf truetype_alice 2048 2048 120) @@ -41,6 +43,7 @@ add_dependencies(${DAWN_TARGET_NAME} language_en tileset_death + tileset_penny truetype_alice diff --git a/src/dawnpokergame/game/DawnGame.cpp b/src/dawnpokergame/game/DawnGame.cpp index c834141c..74ce541e 100644 --- a/src/dawnpokergame/game/DawnGame.cpp +++ b/src/dawnpokergame/game/DawnGame.cpp @@ -4,9 +4,7 @@ // https://opensource.org/licenses/MIT #include "DawnGame.hpp" -#include "scenes/SubSceneRendererScene.hpp" #include "scenes/Scene_1.hpp" -#include "scenes/TestUIScene.hpp" using namespace Dawn; @@ -26,7 +24,7 @@ int32_t DawnGame::init() { this->renderManager.init(); this->audioManager.init(); - this->scene = new TestUIScene(this); + this->scene = new Scene_1(this); return DAWN_GAME_INIT_RESULT_SUCCESS; } diff --git a/src/dawnpokergame/prefabs/CMakeLists.txt b/src/dawnpokergame/prefabs/CMakeLists.txt new file mode 100644 index 00000000..3326c9c1 --- /dev/null +++ b/src/dawnpokergame/prefabs/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (c) 2022 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +add_subdirectory(characters) \ No newline at end of file diff --git a/src/dawnpokergame/prefabs/characters/CMakeLists.txt b/src/dawnpokergame/prefabs/characters/CMakeLists.txt new file mode 100644 index 00000000..6fdb9d64 --- /dev/null +++ b/src/dawnpokergame/prefabs/characters/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2023 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Sources +target_sources(${DAWN_TARGET_NAME} + PRIVATE + CharacterPrefab.cpp + DeathPrefab.cpp +) \ No newline at end of file diff --git a/src/dawnpokergame/prefabs/characters/CharacterPrefab.cpp b/src/dawnpokergame/prefabs/characters/CharacterPrefab.cpp new file mode 100644 index 00000000..4adc71a2 --- /dev/null +++ b/src/dawnpokergame/prefabs/characters/CharacterPrefab.cpp @@ -0,0 +1,8 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "CharacterPrefab.hpp" + +using namespace Dawn; \ No newline at end of file diff --git a/src/dawnpokergame/prefabs/characters/CharacterPrefab.hpp b/src/dawnpokergame/prefabs/characters/CharacterPrefab.hpp new file mode 100644 index 00000000..55e37b56 --- /dev/null +++ b/src/dawnpokergame/prefabs/characters/CharacterPrefab.hpp @@ -0,0 +1,82 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "prefab/SceneItemPrefab.hpp" +#include "scene/Scene.hpp" +#include "scene/components/display/MeshRenderer.hpp" +#include "scene/components/display/AnimationController.hpp" +#include "scene/components/display/MeshHost.hpp" +#include "scene/components/display/material/SimpleTexturedMaterial.hpp" +#include "scene/components/audio/AudioSource.hpp" +#include "visualnovel/components/VisualNovelCharacter.hpp" + +namespace Dawn { + template + class CharacterPrefab : public SceneItemPrefab { + protected: + /** + * Character Prefab will request you to initialize your characters' + * emotions here, including loading assets, + * + * @return struct VisualNovelCharacterEmotion + */ + virtual struct VisualNovelCharacterEmotion defineAndGetInitialEmotion( + AssetManager *assMan + ) = 0; + + + public: + static std::vector prefabAssets(AssetManager *assMan) { + return std::vector{ + assMan->get(T::getCharacterTexture()), + assMan->get(T::getCharacterTileset()) + }; + } + + // Instance + VisualNovelCharacter *vnCharacter; + AnimationController *animation; + TextureAsset *characterTexture; + TilesetAsset *characterTileset; + MeshRenderer *meshRenderer; + MeshHost *meshHost; + SimpleTexturedMaterial *material; + TiledSprite *tiledSprite; + AudioSource *audioSource; + + CharacterPrefab(Scene *s, sceneitemid_t i) : SceneItemPrefab(s, i) {} + + void prefabInit(AssetManager *man) override { + characterTexture = man->get(T::getCharacterTexture()); + characterTileset = man->get(T::getCharacterTileset()); + + // Emotions + auto emotion = this->defineAndGetInitialEmotion(man); + + // Components + meshRenderer = this->addComponent(); + meshHost = this->addComponent(); + + material = this->addComponent(); + material->texture = &characterTexture->texture; + + vnCharacter = this->addComponent(); + vnCharacter->nameKey = T::getLanguagePrefix() + ".name"; + + animation = this->addComponent(); + + tiledSprite = this->addComponent(); + tiledSprite->setTileset(&characterTileset->tileset); + float_t ratio = characterTileset->tileset.getTileWidth() / characterTileset->tileset.getTileHeight(); + tiledSprite->setSize(glm::vec2(ratio, 1.0f)); + tiledSprite->setTile(emotion.tile); + + audioSource = this->addComponent(); + + this->transform.setLocalPosition(glm::vec3(0, 0, 0)); + } + }; +} \ No newline at end of file diff --git a/src/dawnpokergame/prefabs/characters/DeathPrefab.cpp b/src/dawnpokergame/prefabs/characters/DeathPrefab.cpp new file mode 100644 index 00000000..ec7bd855 --- /dev/null +++ b/src/dawnpokergame/prefabs/characters/DeathPrefab.cpp @@ -0,0 +1,32 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "DeathPrefab.hpp" + +using namespace Dawn; + +std::string DeathPrefab::getCharacterTexture() { + return "texture_penny"; +} + +std::string DeathPrefab::getCharacterTileset() { + return "tileset_penny"; +} + +std::string DeathPrefab::getLanguagePrefix() { + return "character.death"; +} + +struct VisualNovelCharacterEmotion DeathPrefab::defineAndGetInitialEmotion( + AssetManager *man +) { + this->emotionHappy.tile = 0; + + this->emotionConcerned.tile = 1; + + this->emotionSurprised.tile = 2; + + return this->emotionHappy; +} \ No newline at end of file diff --git a/src/dawnpokergame/prefabs/characters/DeathPrefab.hpp b/src/dawnpokergame/prefabs/characters/DeathPrefab.hpp index b6092be1..ed099ea4 100644 --- a/src/dawnpokergame/prefabs/characters/DeathPrefab.hpp +++ b/src/dawnpokergame/prefabs/characters/DeathPrefab.hpp @@ -4,61 +4,25 @@ // https://opensource.org/licenses/MIT #pragma once -#include "prefab/SceneItemPrefab.hpp" -#include "asset/AssetManager.hpp" -#include "poker/PokerPlayer.hpp" -#include "scene/components/Components.hpp" -#include "visualnovel/components/VisualNovelCharacter.hpp" -#include "display/animation/TiledSpriteAnimation.hpp" -#include "scene/components/display/material/SimpleTexturedMaterial.hpp" +#include "prefabs/characters/CharacterPrefab.hpp" namespace Dawn { - class DeathPrefab : public SceneItemPrefab { + class DeathPrefab : public CharacterPrefab { + protected: + + struct VisualNovelCharacterEmotion defineAndGetInitialEmotion( + AssetManager *man + ) override; + public: - VisualNovelCharacter *vnCharacter; - AnimationController *animation; + static std::string getCharacterTexture(); + static std::string getCharacterTileset(); + static std::string getLanguagePrefix(); + + struct VisualNovelCharacterEmotion emotionHappy; + struct VisualNovelCharacterEmotion emotionConcerned; + struct VisualNovelCharacterEmotion emotionSurprised; - struct VisualNovelCharacterEmotion emotionDefault; - - static std::vector prefabAssets(AssetManager *assMan) { - return std::vector{ - assMan->get("texture_death"), - assMan->get("tileset_death"), - assMan->get("audio_test") - }; - } - - DeathPrefab(Scene *scene, sceneitemid_t id) : SceneItemPrefab(scene, id) - { - - } - - void prefabInit(AssetManager *man) override { - auto textureAsset = man->get("texture_death"); - auto tilesetAsset = man->get("tileset_death"); - auto audioAsset = man->get("audio_test"); - - // Emotions - this->emotionDefault.talkSound = audioAsset; - - auto meshRenderer = this->addComponent(); - auto meshHost = this->addComponent(); - - auto material = this->addComponent(); - material->texture = &textureAsset->texture; - - vnCharacter = this->addComponent(); - vnCharacter->nameKey = "character.death.name"; - - animation = this->addComponent(); - - auto tiledSprite = this->addComponent(); - tiledSprite->setTilesetAndSize(&tilesetAsset->tileset); - tiledSprite->setTile(0); - - this->addComponent(); - - this->transform.setLocalPosition(glm::vec3(0, 0, 0)); - } + DeathPrefab(Scene *s, sceneitemid_t i) : CharacterPrefab(s,i) {} }; } \ No newline at end of file diff --git a/src/dawnpokergame/prefabs/characters/PennyPrefab.hpp b/src/dawnpokergame/prefabs/characters/PennyPrefab.hpp index be2be74a..2f528985 100644 --- a/src/dawnpokergame/prefabs/characters/PennyPrefab.hpp +++ b/src/dawnpokergame/prefabs/characters/PennyPrefab.hpp @@ -19,19 +19,32 @@ namespace Dawn { PokerPlayer *pokerPlayer; SimpleTexturedMaterial *material; + struct VisualNovelCharacterEmotion emotionHappy; + struct VisualNovelCharacterEmotion emotionSurprised; + struct VisualNovelCharacterEmotion emotionConcerned; + static std::vector prefabAssets(AssetManager *assMan) { return std::vector{ - assMan->get("texture_death"), - assMan->get("tileset_death") + assMan->get("texture_penny"), + assMan->get("tileset_penny") }; } PennyPrefab(Scene *scene, sceneitemid_t id) : SceneItemPrefab(scene, id){} void prefabInit(AssetManager *man) override { - auto textureAsset = man->get("texture_death"); - auto tilesetAsset = man->get("tileset_death"); + // Assets + auto textureAsset = man->get("texture_penny"); + auto tilesetAsset = man->get("tileset_penny"); + // Emotions + this->emotionHappy.tile = 0; + + this->emotionSurprised.tile = 1; + + this->emotionConcerned.tile = 2; + + // Components auto meshRenderer = this->addComponent(); auto meshHost = this->addComponent(); @@ -50,11 +63,6 @@ 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; } }; } \ No newline at end of file diff --git a/src/dawnpokergame/scenes/CMakeLists.txt b/src/dawnpokergame/scenes/CMakeLists.txt index 95a37a3b..1928077e 100644 --- a/src/dawnpokergame/scenes/CMakeLists.txt +++ b/src/dawnpokergame/scenes/CMakeLists.txt @@ -6,7 +6,5 @@ # Sources target_sources(${DAWN_TARGET_NAME} PRIVATE - PixelVNScene.cpp PokerVNScene.cpp - TestUIScene.cpp ) \ No newline at end of file diff --git a/src/dawnpokergame/scenes/PixelVNScene.cpp b/src/dawnpokergame/scenes/PixelVNScene.cpp deleted file mode 100644 index 8dfa77ae..00000000 --- a/src/dawnpokergame/scenes/PixelVNScene.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// 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(1280, 720) -{ - -} - -std::vector PixelVNScene::getRequiredAssets() { - auto assMan = &this->game->assetManager; - std::vector 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(); -} \ No newline at end of file diff --git a/src/dawnpokergame/scenes/PixelVNScene.hpp b/src/dawnpokergame/scenes/PixelVNScene.hpp deleted file mode 100644 index 984403e7..00000000 --- a/src/dawnpokergame/scenes/PixelVNScene.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// 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 getRequiredAssets() override; - }; -} \ No newline at end of file diff --git a/src/dawnpokergame/scenes/PokerVNScene.cpp b/src/dawnpokergame/scenes/PokerVNScene.cpp index 4c85a96e..529604b6 100644 --- a/src/dawnpokergame/scenes/PokerVNScene.cpp +++ b/src/dawnpokergame/scenes/PokerVNScene.cpp @@ -7,20 +7,20 @@ using namespace Dawn; -PokerVNScene::PokerVNScene(DawnGame *game) : PixelVNScene(game) { +PokerVNScene::PokerVNScene(DawnGame *game) : SimpleVNScene(game) { } std::vector PokerVNScene::getRequiredAssets() { auto assMan = &this->game->assetManager; std::vector assets; - vectorAppend(&assets, PixelVNScene::getRequiredAssets()); + vectorAppend(&assets, SimpleVNScene::getRequiredAssets()); vectorAppend(&assets, PokerPlayerDisplay::getAssets(assMan)); return assets; } void PokerVNScene::vnStage() { - PixelVNScene::vnStage(); + auto pokerGameItem = this->createSceneItem(); this->pokerGame = pokerGameItem->addComponent(); diff --git a/src/dawnpokergame/scenes/PokerVNScene.hpp b/src/dawnpokergame/scenes/PokerVNScene.hpp index b4a00632..d16ba98e 100644 --- a/src/dawnpokergame/scenes/PokerVNScene.hpp +++ b/src/dawnpokergame/scenes/PokerVNScene.hpp @@ -4,14 +4,14 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "poker/PokerGame.hpp" #include "visualnovel/events/PokerBetLoopEvent.hpp" #include "visualnovel/events/PokerInitialEvent.hpp" #include "ui/PokerPlayerDisplay.hpp" namespace Dawn { - class PokerVNScene : public PixelVNScene { + class PokerVNScene : public SimpleVNScene { protected: void vnStage() override; std::vector getRequiredAssets() override; diff --git a/src/dawnpokergame/scenes/Scene_1.hpp b/src/dawnpokergame/scenes/Scene_1.hpp index 4ab8d577..ec08222f 100644 --- a/src/dawnpokergame/scenes/Scene_1.hpp +++ b/src/dawnpokergame/scenes/Scene_1.hpp @@ -4,7 +4,7 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_2.hpp" #include "prefabs/characters/DeathPrefab.hpp" #include "visualnovel/events/characters/VisualNovelFadeCharacterEvent.hpp" @@ -12,18 +12,17 @@ #include "visualnovel/events/timing/VisualNovelBatchEvent.hpp" namespace Dawn { - class Scene_1 : public PixelVNScene { + class Scene_1 : public SimpleVNScene { protected: DeathPrefab *death; void vnStage() override { - PixelVNScene::vnStage(); this->death = DeathPrefab::create(this); } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_2(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -33,13 +32,13 @@ namespace Dawn { } public: - Scene_1(DawnGame *game) : PixelVNScene(game) { + Scene_1(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { auto man = &this->game->assetManager; - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); vectorAppend(&assets, DeathPrefab::getRequiredAssets(man)); assets.push_back(man->get("audio_test")); return assets; @@ -48,7 +47,7 @@ namespace Dawn { IVisualNovelEvent * getVNEvent() override { auto start = new VisualNovelPauseEvent(vnManager, 0.1f); start - ->then(new VisualNovelTextboxEvent(vnManager, this->death->vnCharacter, this->death->emotionDefault, "scene.1.1")) + ->then(new VisualNovelTextboxEvent(vnManager, this->death->vnCharacter, this->death->emotionHappy, "scene.1.1")) // ->then(new VisualNovelCallbackEvent(vnManager, this, &Scene_1::onSceneEnded)) ; return start; diff --git a/src/dawnpokergame/scenes/Scene_10.hpp b/src/dawnpokergame/scenes/Scene_10.hpp index 54e9dd67..34b90ef8 100644 --- a/src/dawnpokergame/scenes/Scene_10.hpp +++ b/src/dawnpokergame/scenes/Scene_10.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_11.hpp" namespace Dawn { - class Scene_10 : public PixelVNScene { + class Scene_10 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_11(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,11 +25,11 @@ namespace Dawn { } public: - Scene_10(DawnGame *game) : PixelVNScene(game) { + Scene_10(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_11.hpp b/src/dawnpokergame/scenes/Scene_11.hpp index 31c5a8fa..11301b8f 100644 --- a/src/dawnpokergame/scenes/Scene_11.hpp +++ b/src/dawnpokergame/scenes/Scene_11.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_12.hpp" namespace Dawn { - class Scene_11 : public PixelVNScene { + class Scene_11 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_12(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,11 +25,11 @@ namespace Dawn { } public: - Scene_11(DawnGame *game) : PixelVNScene(game) { + Scene_11(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_12.hpp b/src/dawnpokergame/scenes/Scene_12.hpp index 26638b46..315e435a 100644 --- a/src/dawnpokergame/scenes/Scene_12.hpp +++ b/src/dawnpokergame/scenes/Scene_12.hpp @@ -26,7 +26,7 @@ namespace Dawn { } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_13(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); diff --git a/src/dawnpokergame/scenes/Scene_13.hpp b/src/dawnpokergame/scenes/Scene_13.hpp index 638e30ef..1f18dccb 100644 --- a/src/dawnpokergame/scenes/Scene_13.hpp +++ b/src/dawnpokergame/scenes/Scene_13.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_14.hpp" namespace Dawn { - class Scene_13 : public PixelVNScene { + class Scene_13 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_14(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,11 +25,11 @@ namespace Dawn { } public: - Scene_13(DawnGame *game) : PixelVNScene(game) { + Scene_13(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_14.hpp b/src/dawnpokergame/scenes/Scene_14.hpp index 208acb95..efa467ed 100644 --- a/src/dawnpokergame/scenes/Scene_14.hpp +++ b/src/dawnpokergame/scenes/Scene_14.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_15.hpp" namespace Dawn { - class Scene_14 : public PixelVNScene { + class Scene_14 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_15(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,11 +25,11 @@ namespace Dawn { } public: - Scene_14(DawnGame *game) : PixelVNScene(game) { + Scene_14(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_15.hpp b/src/dawnpokergame/scenes/Scene_15.hpp index aef4a561..714912e3 100644 --- a/src/dawnpokergame/scenes/Scene_15.hpp +++ b/src/dawnpokergame/scenes/Scene_15.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_16.hpp" namespace Dawn { - class Scene_15 : public PixelVNScene { + class Scene_15 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_16(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,11 +25,11 @@ namespace Dawn { } public: - Scene_15(DawnGame *game) : PixelVNScene(game) { + Scene_15(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_16.hpp b/src/dawnpokergame/scenes/Scene_16.hpp index 807b325f..befaaa73 100644 --- a/src/dawnpokergame/scenes/Scene_16.hpp +++ b/src/dawnpokergame/scenes/Scene_16.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_17.hpp" namespace Dawn { - class Scene_16 : public PixelVNScene { + class Scene_16 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_17(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -24,11 +24,11 @@ namespace Dawn { this->game->sceneCutover(scene); } public: - Scene_16(DawnGame *game) : PixelVNScene(game) { + Scene_16(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_17.hpp b/src/dawnpokergame/scenes/Scene_17.hpp index c87aad8b..e0e755ae 100644 --- a/src/dawnpokergame/scenes/Scene_17.hpp +++ b/src/dawnpokergame/scenes/Scene_17.hpp @@ -26,7 +26,7 @@ namespace Dawn { } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_18(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); diff --git a/src/dawnpokergame/scenes/Scene_18.hpp b/src/dawnpokergame/scenes/Scene_18.hpp index 59a023d7..acd5aabe 100644 --- a/src/dawnpokergame/scenes/Scene_18.hpp +++ b/src/dawnpokergame/scenes/Scene_18.hpp @@ -4,24 +4,24 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" namespace Dawn { - class Scene_18 : public PixelVNScene { + class Scene_18 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { } public: - Scene_18(DawnGame *game) : PixelVNScene(game) { + Scene_18(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_2.hpp b/src/dawnpokergame/scenes/Scene_2.hpp index 15637c5a..d88554f4 100644 --- a/src/dawnpokergame/scenes/Scene_2.hpp +++ b/src/dawnpokergame/scenes/Scene_2.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_3.hpp" namespace Dawn { - class Scene_2 : public PixelVNScene { + class Scene_2 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_3(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,12 +25,12 @@ namespace Dawn { } public: - Scene_2(DawnGame *game) : PixelVNScene(game) { + Scene_2(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_3.hpp b/src/dawnpokergame/scenes/Scene_3.hpp index 402d1928..b9b86270 100644 --- a/src/dawnpokergame/scenes/Scene_3.hpp +++ b/src/dawnpokergame/scenes/Scene_3.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_4.hpp" namespace Dawn { - class Scene_3 : public PixelVNScene { + class Scene_3 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_4(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,12 +25,12 @@ namespace Dawn { } public: - Scene_3(DawnGame *game) : PixelVNScene(game) { + Scene_3(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_4.hpp b/src/dawnpokergame/scenes/Scene_4.hpp index 301300e5..1e309ad3 100644 --- a/src/dawnpokergame/scenes/Scene_4.hpp +++ b/src/dawnpokergame/scenes/Scene_4.hpp @@ -26,7 +26,7 @@ namespace Dawn { } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_5(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); diff --git a/src/dawnpokergame/scenes/Scene_5.hpp b/src/dawnpokergame/scenes/Scene_5.hpp index 3aea9068..68cbe7b0 100644 --- a/src/dawnpokergame/scenes/Scene_5.hpp +++ b/src/dawnpokergame/scenes/Scene_5.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_6.hpp" namespace Dawn { - class Scene_5 : public PixelVNScene { + class Scene_5 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_6(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,12 +25,12 @@ namespace Dawn { } public: - Scene_5(DawnGame *game) : PixelVNScene(game) { + Scene_5(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_6.hpp b/src/dawnpokergame/scenes/Scene_6.hpp index 43360c5d..e56db675 100644 --- a/src/dawnpokergame/scenes/Scene_6.hpp +++ b/src/dawnpokergame/scenes/Scene_6.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_7.hpp" namespace Dawn { - class Scene_6 : public PixelVNScene { + class Scene_6 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_7(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,12 +25,12 @@ namespace Dawn { } public: - Scene_6(DawnGame *game) : PixelVNScene(game) { + Scene_6(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_7.hpp b/src/dawnpokergame/scenes/Scene_7.hpp index ce1dd75d..ee9889ae 100644 --- a/src/dawnpokergame/scenes/Scene_7.hpp +++ b/src/dawnpokergame/scenes/Scene_7.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_8.hpp" namespace Dawn { - class Scene_7 : public PixelVNScene { + class Scene_7 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_8(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,11 +25,11 @@ namespace Dawn { } public: - Scene_7(DawnGame *game) : PixelVNScene(game) { + Scene_7(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/Scene_8.hpp b/src/dawnpokergame/scenes/Scene_8.hpp index 39e458ee..45a47ed5 100644 --- a/src/dawnpokergame/scenes/Scene_8.hpp +++ b/src/dawnpokergame/scenes/Scene_8.hpp @@ -26,7 +26,7 @@ namespace Dawn { } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_9(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); diff --git a/src/dawnpokergame/scenes/Scene_9.hpp b/src/dawnpokergame/scenes/Scene_9.hpp index 5a8a14ea..f6908351 100644 --- a/src/dawnpokergame/scenes/Scene_9.hpp +++ b/src/dawnpokergame/scenes/Scene_9.hpp @@ -4,18 +4,18 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scenes/PixelVNScene.hpp" +#include "visualnovel/scene/SimpleVNScene.hpp" #include "scenes/Scene_10.hpp" namespace Dawn { - class Scene_9 : public PixelVNScene { + class Scene_9 : public SimpleVNScene { protected: void vnStage() override { - PixelVNScene::vnStage(); + } void onSceneEnded() { - auto scene = new SubSceneRendererScene(this->game); + auto scene = new Scene_10(this->game); game->assetManager.queueSwap( scene->getRequiredAssets(), this->getRequiredAssets() ); @@ -25,11 +25,11 @@ namespace Dawn { } public: - Scene_9(DawnGame *game) : PixelVNScene(game) { + Scene_9(DawnGame *game) : SimpleVNScene(game) { } std::vector getRequiredAssets() override { - std::vector assets = PixelVNScene::getRequiredAssets(); + std::vector assets = SimpleVNScene::getRequiredAssets(); return assets; } diff --git a/src/dawnpokergame/scenes/SubSceneRendererScene.hpp b/src/dawnpokergame/scenes/SubSceneRendererScene.hpp deleted file mode 100644 index 473d85b0..00000000 --- a/src/dawnpokergame/scenes/SubSceneRendererScene.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2023 Dominic Masters -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -#pragma once -#include "scene/Scene.hpp" -#include "game/DawnGame.hpp" -#include "scene/components/display/material/SimpleTexturedMaterial.hpp" - -namespace Dawn { - template - class SubSceneRendererScene : public Scene { - public: - Camera *camera; - SceneItem *sceneItem; - T subScene; - - SubSceneRendererScene(DawnGame *game) : Scene(game), subScene(game) { - - } - - std::vector getRequiredAssets() override { - return this->subScene.getRequiredAssets(); - } - - void stage() override { - // 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(); - auto renderer = this->sceneItem->addComponent(); - - auto material = this->sceneItem->addComponent(); - material->texture = this->subScene.renderTarget.getTexture(); - - auto renderTargetQuad = this->sceneItem->addComponent(); - renderTargetQuad->setRenderTarget(&this->subScene.renderTarget); - - auto subSceneController = this->sceneItem->addComponent(); - subSceneController->setSubScene(&this->subScene); - - auto subSceneCameraAlign = this->sceneItem->addComponent(); - subSceneCameraAlign->setRenderTarget(&this->subScene.renderTarget); - subSceneCameraAlign->setCamera(this->camera); - } - }; -} \ No newline at end of file diff --git a/src/dawnpokergame/scenes/TestUIScene.cpp b/src/dawnpokergame/scenes/TestUIScene.cpp deleted file mode 100644 index 8329135d..00000000 --- a/src/dawnpokergame/scenes/TestUIScene.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2023 Dominic Masters -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -#include "TestUIScene.hpp" - -using namespace Dawn; - -TestUIScene::TestUIScene(DawnGame *game) : Scene(game) { - -} - -std::vector TestUIScene::getRequiredAssets() { - std::vector assets; - AssetManager *man = &this->game->assetManager; - assets.push_back(man->get("truetype_alice")); - assets.push_back(man->get("texture_test")); - return assets; -} - -void TestUIScene::stage() { - AssetManager *man = &this->game->assetManager; - - // Camera - this->camera = Camera::create(this); - this->camera->transform->lookAt(glm::vec3(3, 3, 3), glm::vec3(0, 0, 0)); - - auto testCube = SimpleSpinningCubePrefab::create(this); - - // UI - this->canvas = UICanvas::create(this); - - // auto text = man->get("texture_test"); - // auto border = this->canvas->addElement(); - // border->texture = &text->texture; - // border->setBorderSize(glm::vec2(4, 4)); - // border->setTransform( - // UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH, - // glm::vec4(0, 0, 0, 0), - // 0.0f - // ); - - auto assetFont = man->get("truetype_alice"); - - auto grid = this->canvas->addElement(); - grid->setTransform(UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH, glm::vec4(0, 0, 0, 0), 0); - grid->setGridSize(4, 4, 8, 8); - - auto menu = new UIMenu(this->canvas, grid->getColumns(), grid->getRows()); - - for(int32_t x = 0; x < grid->getColumns(); x++) { - for(int32_t y = 0; y < grid->getRows(); y++) { - auto label = this->canvas->addElement(); - label->setFont(&assetFont->font); - label->setText("test.1"); - label->setFontSize(24); - grid->addToGrid(label, x, y, UI_COMPONENT_ALIGN_MIDDLE, UI_COMPONENT_ALIGN_MIDDLE); - - auto menuItem = new TestMenuItem; - menuItem->label = label; - menu->setItem(x, y, menuItem); - } - - menu->setPosition(0, 0); - this->canvas->setCurrentMenu(menu); - } - - this->canvas->setCurrentMenu(menu); -} \ No newline at end of file diff --git a/src/dawnpokergame/scenes/TestUIScene.hpp b/src/dawnpokergame/scenes/TestUIScene.hpp deleted file mode 100644 index 86568bb0..00000000 --- a/src/dawnpokergame/scenes/TestUIScene.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2023 Dominic Masters -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -#pragma once -#include "scene/Scene.hpp" -#include "game/DawnGame.hpp" -#include "scene/components/ui/UICanvas.hpp" -#include "ui/UILabel.hpp" -#include "ui/UIBorder.hpp" -#include "ui/UIGrid.hpp" -#include "ui/UISprite.hpp" -#include "prefabs/SimpleSpinningCubePrefab.hpp" -#include "ui/UIMenu.hpp" - -namespace Dawn { - class TestMenuItem : public UIMenuItem { - public: - UILabel *label; - void onItemSelected() { - - } - - void onItemOver() { - this->label->setText("test.2"); - } - - void onItemOff() { - this->label->setText("test.1"); - } - - bool_t canBeOvered() { - return true; - } - - bool_t canBeSelected() { - return true; - } - }; - - class TestUIScene : public Scene { - private: - Camera *camera = nullptr; - UICanvas *canvas = nullptr; - - public: - TestUIScene(DawnGame *game); - std::vector getRequiredAssets() override; - void stage() override; - }; -} \ No newline at end of file