This commit is contained in:
2023-01-06 21:01:06 -08:00
parent d13984dddc
commit d6b7895cab
21 changed files with 190 additions and 190 deletions

View File

@ -17,7 +17,6 @@ target_include_directories(${DAWN_TARGET_NAME}
# Subdirs
add_subdirectory(game)
add_subdirectory(prefabs)
add_subdirectory(ui)
add_subdirectory(visualnovel)
add_subdirectory(save)

View File

@ -5,7 +5,7 @@
#include "DawnGame.hpp"
#include "scenes/Scene_1_1.hpp"
#include "scenes/PrefabTestingScene.hpp"
#include "scenes/TestScene.hpp"
using namespace Dawn;
@ -23,7 +23,7 @@ int32_t DawnGame::init() {
this->localeManager.init();
this->renderManager.init();
this->scene = new PrefabTestingScene(this);
this->scene = new TestScene(this);
return DAWN_GAME_INIT_RESULT_SUCCESS;
}

View File

@ -1,10 +0,0 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
# target_sources(${DAWN_TARGET_NAME}
# PRIVATE
# VNPlayer.cpp
# )

View File

@ -1,52 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "asset/AssetManager.hpp"
#include "poker/PokerPlayer.hpp"
#include "scene/components/Components.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
#include "display/animation/TiledSpriteAnimation.hpp"
namespace Dawn {
class VNPenny {
public:
static std::vector<Asset*> getAssets(AssetManager *assMan) {
return std::vector<Asset*>{
assMan->get<TextureAsset>("texture_penny"),
assMan->get<TilesetAsset>("tileset_penny")
};
}
static SceneItem * create(Scene *scene) {
auto item = scene->createSceneItem();
auto textureAsset = scene->game->assetManager.get<TextureAsset>("texture_penny");
auto tilesetAsset = scene->game->assetManager.get<TilesetAsset>("tileset_penny");
auto meshRenderer = item->addComponent<MeshRenderer>();
auto material = item->addComponent<Material>();
auto meshHost = item->addComponent<MeshHost>();
auto tiledSprite = item->addComponent<TiledSprite>();
auto animation = item->addComponent<AnimationController>();
auto pokerPlayer = item->addComponent<PokerPlayer>();
auto vnCharacter = item->addComponent<VisualNovelCharacter>();
vnCharacter->nameKey = "character.penny.name";
auto param = material->getShader()->getParameterByName("u_Text");
material->textureValues[param] = &textureAsset->texture;
tiledSprite->setTilesetAndSize(&tilesetAsset->tileset);
auto anim = new TiledSpriteAnimation(tiledSprite);
anim->addSequentialKeyframes(0.1f, 0, 22);
anim->loop = true;
animation->animation = anim;
return item;
}
};
}

View File

@ -0,0 +1,53 @@
// 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 "asset/AssetManager.hpp"
#include "poker/PokerPlayer.hpp"
#include "scene/components/Components.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
#include "display/animation/TiledSpriteAnimation.hpp"
namespace Dawn {
class PennyPrefab : public SceneItemPrefab<PennyPrefab> {
public:
static std::vector<Asset*> prefabAssets(AssetManager *assMan) {
return std::vector<Asset*>{
assMan->get<TextureAsset>("texture_penny"),
assMan->get<TilesetAsset>("tileset_penny")
};
}
PennyPrefab(Scene *scene, sceneitemid_t id) : SceneItemPrefab(scene, id){}
void prefabInit(AssetManager *man) override {
auto textureAsset = man->get<TextureAsset>("texture_penny");
auto tilesetAsset = man->get<TilesetAsset>("tileset_penny");
auto meshRenderer = this->addComponent<MeshRenderer>();
auto material = this->addComponent<Material>();
auto meshHost = this->addComponent<MeshHost>();
auto tiledSprite = this->addComponent<TiledSprite>();
auto animation = this->addComponent<AnimationController>();
auto pokerPlayer = this->addComponent<PokerPlayer>();
auto vnCharacter = this->addComponent<VisualNovelCharacter>();
vnCharacter->nameKey = "character.penny.name";
auto param = material->getShader()->getParameterByName("u_Text");
material->textureValues[param] = &textureAsset->texture;
tiledSprite->setTilesetAndSize(&tilesetAsset->tileset);
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;
}
};
}

View File

@ -0,0 +1,25 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "prefab/UIPrefab.hpp"
#include "ui/UIBorder.hpp"
namespace Dawn {
class UIBorderPrefab : public UIPrefab<UIBorder, UIBorderPrefab> {
public:
static std::vector<Asset*> prefabAssets(AssetManager *man) {
std::vector<Asset*> assets;
assets.push_back(man->get<TextureAsset>("texture_test"));
return assets;
}
static void prefabApply(AssetManager *man, UIBorder *border) {
auto text = man->get<TextureAsset>("texture_test");
border->texture = &text->texture;
border->setBorderSize(glm::vec2(16, 16));
}
};
}

View File

@ -0,0 +1,34 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "prefabs/ui/UIBorderPrefab.hpp"
#include "visualnovel/ui/VisualNovelTextbox.hpp"
namespace Dawn {
class VisualNovelTextboxPrefab :
public UIPrefab<VisualNovelTextbox, VisualNovelTextboxPrefab>
{
public:
static std::vector<Asset*> prefabAssets(AssetManager *man) {
std::vector<Asset*> assets;
assets.push_back(man->get<TrueTypeAsset>("truetype_ark"));
return assets;
}
static void prefabApply(AssetManager *man, VisualNovelTextbox *textbox) {
auto assetFont = man->get<TrueTypeAsset>("truetype_ark");
UIBorderPrefab::apply(&textbox->border);
textbox->setFont(&assetFont->font);
textbox->setFontSize(40);
textbox->setLabelPadding(glm::vec2(10, 8));
textbox->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_END,
glm::vec4(0, 238, 0, 0),
0.0f
);
}
};
}

View File

@ -14,7 +14,7 @@ PokerVNScene::PokerVNScene(DawnGame *game) : SimpleVNScene(game) {
std::vector<Asset*> PokerVNScene::getRequiredAssets() {
auto assMan = &this->game->assetManager;
std::vector<Asset*> assets, l;
vectorAppend(&assets, &(l = SimpleVNScene::getRequiredAssets()));
vectorAppend(&assets,SimpleVNScene::getRequiredAssets());
vectorAppend(&assets, &(l = PokerPlayerDisplay::getAssets(assMan)));
return assets;
}
@ -29,9 +29,9 @@ void PokerVNScene::vnStage() {
int32_t i = 0;
while(it != this->pokerPlayers.end()) {
auto player = *it;
auto uiPlayer = canvas->addElement<PokerPlayerDisplay>();
uiPlayer->setTransform(UI_COMPONENT_ALIGN_START, UI_COMPONENT_ALIGN_START, glm::vec4(i * 220, 0, 220, 200), 0);
uiPlayer->setPlayer(player);
// auto uiPlayer = canvas->addElement<PokerPlayerDisplay>();
// uiPlayer->setTransform(UI_COMPONENT_ALIGN_START, UI_COMPONENT_ALIGN_START, glm::vec4(i * 220, 0, 220, 200), 0);
// uiPlayer->setPlayer(player);
++it;
++i;
}

View File

@ -1,32 +0,0 @@
// Copyright (c) 2022 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 "prefabs/display/SimpleCubePrefab.hpp"
namespace Dawn {
class PrefabTestingScene : public Scene {
protected:
SimpleCubePrefab *cube = nullptr;
Camera *camera = nullptr;
public:
PrefabTestingScene(DawnGame *game) : Scene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
return std::vector<Asset*>();
}
void stage() override {
camera = Camera::create(this);
camera->transform->lookAt(glm::vec3(5, 5, 5), glm::vec3(0, 0, 0));
cube = SimpleCubePrefab::create(this);
}
};
}

View File

@ -5,21 +5,21 @@
#pragma once
#include "PokerVNScene.hpp"
#include "prefabs/VNPenny.hpp"
#include "prefabs/characters/PennyPrefab.hpp"
namespace Dawn {
class TestScene : public PokerVNScene {
protected:
SceneItem *penny;
SceneItem *julie;
SceneItem *sammy;
SceneItem *lucy;
PennyPrefab *penny;
PennyPrefab *julie;
PennyPrefab *sammy;
PennyPrefab *lucy;
void vnStage() override {
penny = VNPenny::create(this);
julie = VNPenny::create(this);
sammy = VNPenny::create(this);
lucy = VNPenny::create(this);
penny = PennyPrefab::create(this);
julie = PennyPrefab::create(this);
sammy = PennyPrefab::create(this);
lucy = PennyPrefab::create(this);
PokerVNScene::vnStage();
}
@ -39,27 +39,19 @@ namespace Dawn {
auto start = new VisualNovelChangeSimpleBackgroundEvent(
vnManager, &texture->texture
);
start
->then(new VisualNovelTextboxEvent(vnManager, penny->getComponent<VisualNovelCharacter>(), "scene.1.1"))
// ->then(new PokerNewGameEvent(vnManager))
->then(new VisualNovelTextboxEvent(vnManager, penny->getComponent<VisualNovelCharacter>(), "undefined"))
// ->then(new PokerInitialEvent(vnManager))
;
start->then(new VisualNovelTextboxEvent(vnManager, penny->getComponent<VisualNovelCharacter>(), "scene.1.1"));
return start;
}
public:
TestScene(DawnGame *game) : PokerVNScene(game) {
}
TestScene(DawnGame *game) : PokerVNScene(game) {}
std::vector<Asset*> getRequiredAssets() override {
auto assMan = &this->game->assetManager;
std::vector<Asset*> assets;
vectorAppend(&assets, &PokerVNScene::getRequiredAssets());
vectorAppend(&assets, &VNPenny::getAssets(assMan));
vectorAppend(&assets, PokerVNScene::getRequiredAssets());
vectorAppend(&assets, PennyPrefab::getRequiredAssets(assMan));
assets.push_back(assMan->get<TextureAsset>("texture_tavern_night"));
return assets;
}