This commit is contained in:
2023-01-06 21:01:06 -08:00
parent c29eb885c8
commit 1d024aaad4
22 changed files with 194 additions and 191 deletions

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