Just breaking stuff

This commit is contained in:
2023-03-14 22:27:46 -07:00
parent 374ae30b88
commit cc7091717c
156 changed files with 1156 additions and 5683 deletions

View File

@ -36,10 +36,6 @@ add_subdirectory(scene)
add_subdirectory(state)
add_subdirectory(time)
if(DAWN_VISUAL_NOVEL)
add_subdirectory(visualnovel)
endif()
# Definitions
target_compile_definitions(${DAWN_TARGET_NAME}
PUBLIC

View File

@ -5,4 +5,8 @@
# Subdirs
add_subdirectory(poker)
add_subdirectory(tictactoe)
add_subdirectory(tictactoe)
if(DAWN_VISUAL_NOVEL)
add_subdirectory(visualnovel)
endif()

View File

@ -1,85 +1,85 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelManager.hpp"
#include "visualnovel/scene/SimpleVNScene.hpp"
using namespace Dawn;
VisualNovelManager::VisualNovelManager(SceneItem *item) :
SceneItemComponent(item)
{
}
void VisualNovelManager::onStart() {
SceneItemComponent::onStart();
this->uiCanvas = getScene()->findComponent<UICanvas>();
assertNotNull(this->uiCanvas);
this->textBox = this->uiCanvas->findElement<VisualNovelTextbox>();
this->fader = this->uiCanvas->findElement<VisualNovelFader>();
assertNotNull(this->textBox);
this->getScene()->eventSceneUnpausedUpdate.addListener(this, &VisualNovelManager::onUnpausedUpdate);
// Handle queuing simple VN Manager
auto scene = this->getScene();
auto sceneAsSimple = dynamic_cast<SimpleVNScene*>(scene);
if(sceneAsSimple != nullptr) {
this->setEvent(sceneAsSimple->getVNEvent());
}
if(this->currentEvent != nullptr) this->currentEvent->start(nullptr);
}
void VisualNovelManager::onUnpausedUpdate() {
if(this->currentEvent == nullptr) return;
if(!this->currentEvent->hasStarted) this->currentEvent->start(nullptr);
if(this->currentEvent->update()) return;
this->setEvent(this->currentEvent->end());
}
VisualNovelManager::~VisualNovelManager() {
if(this->currentEvent != nullptr) {
delete this->currentEvent;
}
this->getScene()->eventSceneUnpausedUpdate.removeListener(this, &VisualNovelManager::onUnpausedUpdate);
}
// // // // // // // // // // // // // // // // // // // // // // // // // // //
IVisualNovelEvent::IVisualNovelEvent(VisualNovelManager *man) {
assertNotNull(man);
this->manager = man;
}
void IVisualNovelEvent::start(IVisualNovelEvent *previous) {
this->hasStarted = true;
this->onStart(previous);
}
bool_t IVisualNovelEvent::update() {
return this->onUpdate();
}
IVisualNovelEvent * IVisualNovelEvent::end() {
this->onEnd();
if(this->doNext != nullptr) {
auto next = this->doNext;
this->doNext = nullptr;
return next;
}
return nullptr;
}
IVisualNovelEvent::~IVisualNovelEvent() {
if(this->doNext != nullptr) delete this->doNext;
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelManager.hpp"
#include "visualnovel/scene/SimpleVNScene.hpp"
using namespace Dawn;
VisualNovelManager::VisualNovelManager(SceneItem *item) :
SceneItemComponent(item)
{
}
void VisualNovelManager::onStart() {
SceneItemComponent::onStart();
this->uiCanvas = getScene()->findComponent<UICanvas>();
assertNotNull(this->uiCanvas);
this->textBox = this->uiCanvas->findElement<VisualNovelTextbox>();
this->fader = this->uiCanvas->findElement<VisualNovelFader>();
assertNotNull(this->textBox);
this->getScene()->eventSceneUnpausedUpdate.addListener(this, &VisualNovelManager::onUnpausedUpdate);
// Handle queuing simple VN Manager
auto scene = this->getScene();
auto sceneAsSimple = dynamic_cast<SimpleVNScene*>(scene);
if(sceneAsSimple != nullptr) {
this->setEvent(sceneAsSimple->getVNEvent());
}
if(this->currentEvent != nullptr) this->currentEvent->start(nullptr);
}
void VisualNovelManager::onUnpausedUpdate() {
if(this->currentEvent == nullptr) return;
if(!this->currentEvent->hasStarted) this->currentEvent->start(nullptr);
if(this->currentEvent->update()) return;
this->setEvent(this->currentEvent->end());
}
VisualNovelManager::~VisualNovelManager() {
if(this->currentEvent != nullptr) {
delete this->currentEvent;
}
this->getScene()->eventSceneUnpausedUpdate.removeListener(this, &VisualNovelManager::onUnpausedUpdate);
}
// // // // // // // // // // // // // // // // // // // // // // // // // // //
IVisualNovelEvent::IVisualNovelEvent(VisualNovelManager *man) {
assertNotNull(man);
this->manager = man;
}
void IVisualNovelEvent::start(IVisualNovelEvent *previous) {
this->hasStarted = true;
this->onStart(previous);
}
bool_t IVisualNovelEvent::update() {
return this->onUpdate();
}
IVisualNovelEvent * IVisualNovelEvent::end() {
this->onEnd();
if(this->doNext != nullptr) {
auto next = this->doNext;
this->doNext = nullptr;
return next;
}
return nullptr;
}
IVisualNovelEvent::~IVisualNovelEvent() {
if(this->doNext != nullptr) delete this->doNext;
}

View File

@ -1,124 +1,124 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/SceneItemComponent.hpp"
#include "visualnovel/ui/VisualNovelTextbox.hpp"
#include "visualnovel/ui/VisualNovelFader.hpp"
namespace Dawn {
class IVisualNovelEvent;
class VisualNovelManager : public SceneItemComponent {
private:
IVisualNovelEvent* currentEvent = nullptr;
public:
UICanvas *uiCanvas = nullptr;
VisualNovelTextbox *textBox = nullptr;
VisualNovelFader *fader = nullptr;
AudioSource *audioBackground = nullptr;
AudioSource *audioCharacter = nullptr;
/** Event listener for unpaused scene updates. */
void onUnpausedUpdate();
/**
* Constructs a visual novel manager, scene item component.
*
* @param item Item that the VN manager belongs to.
*/
VisualNovelManager(SceneItem *item);
/**
* Sets the currently active visual novel event. This is assumed to be
* the only way to handle events (no multiples currently).
*
* @param event Event to set.
*/
template <class T>
T * setEvent(T *event) {
auto oldCurrent = this->currentEvent;
this->currentEvent = event;
if(this->hasInitialized && event != nullptr) event->start(oldCurrent);
delete oldCurrent;
return event;
}
/**
* Override to the SceneItemComponent on start event.
*
*/
void onStart() override;
/**
* Dispose / Cleanup the VN manager.
*
*/
~VisualNovelManager();
friend class IVisualNovelEvent;
};
class IVisualNovelEvent {
protected:
VisualNovelManager *manager;
IVisualNovelEvent *doNext = nullptr;
bool_t hasStarted = false;
virtual void onStart(IVisualNovelEvent *previous) = 0;
virtual bool_t onUpdate() = 0;
virtual void onEnd() = 0;
public:
IVisualNovelEvent(VisualNovelManager *manager);
/**
* Chains an event to be executed after this event has finished.
*
* @param next Event to process next.
* @return Whatever you pass in to next.
*/
template<class T>
T * then(T *next) {
this->doNext = next;
return next;
}
/**
* Begins this visual novel event, internally updates some flags and
* calls the event to do its own start logic.
*
* @param previous Previous event, this is for doing logic based chains.
*/
void start(IVisualNovelEvent *previous);
/**
* Performs a tick on this event. The event can then decide whether or not
* it has finished processing.
*
* @return True if the event is still active, otherwise false.
*/
bool_t update();
/**
* End this current event. Returns the "next event" to process. Most of
* the events can handle this with the simple ->then() chaining, but some
* events may chose to do complex if-style logic.
*
* @return Event to run next.
*/
IVisualNovelEvent * end();
/**
* Dispose the VN event.
*/
virtual ~IVisualNovelEvent();
friend class VisualNovelManager;
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/SceneItemComponent.hpp"
#include "visualnovel/ui/VisualNovelTextbox.hpp"
#include "visualnovel/ui/VisualNovelFader.hpp"
namespace Dawn {
class IVisualNovelEvent;
class VisualNovelManager : public SceneItemComponent {
private:
IVisualNovelEvent* currentEvent = nullptr;
public:
UICanvas *uiCanvas = nullptr;
VisualNovelTextbox *textBox = nullptr;
VisualNovelFader *fader = nullptr;
AudioSource *audioBackground = nullptr;
AudioSource *audioCharacter = nullptr;
/** Event listener for unpaused scene updates. */
void onUnpausedUpdate();
/**
* Constructs a visual novel manager, scene item component.
*
* @param item Item that the VN manager belongs to.
*/
VisualNovelManager(SceneItem *item);
/**
* Sets the currently active visual novel event. This is assumed to be
* the only way to handle events (no multiples currently).
*
* @param event Event to set.
*/
template <class T>
T * setEvent(T *event) {
auto oldCurrent = this->currentEvent;
this->currentEvent = event;
if(this->hasInitialized && event != nullptr) event->start(oldCurrent);
delete oldCurrent;
return event;
}
/**
* Override to the SceneItemComponent on start event.
*
*/
void onStart() override;
/**
* Dispose / Cleanup the VN manager.
*
*/
~VisualNovelManager();
friend class IVisualNovelEvent;
};
class IVisualNovelEvent {
protected:
VisualNovelManager *manager;
IVisualNovelEvent *doNext = nullptr;
bool_t hasStarted = false;
virtual void onStart(IVisualNovelEvent *previous) = 0;
virtual bool_t onUpdate() = 0;
virtual void onEnd() = 0;
public:
IVisualNovelEvent(VisualNovelManager *manager);
/**
* Chains an event to be executed after this event has finished.
*
* @param next Event to process next.
* @return Whatever you pass in to next.
*/
template<class T>
T * then(T *next) {
this->doNext = next;
return next;
}
/**
* Begins this visual novel event, internally updates some flags and
* calls the event to do its own start logic.
*
* @param previous Previous event, this is for doing logic based chains.
*/
void start(IVisualNovelEvent *previous);
/**
* Performs a tick on this event. The event can then decide whether or not
* it has finished processing.
*
* @return True if the event is still active, otherwise false.
*/
bool_t update();
/**
* End this current event. Returns the "next event" to process. Most of
* the events can handle this with the simple ->then() chaining, but some
* events may chose to do complex if-style logic.
*
* @return Event to run next.
*/
IVisualNovelEvent * end();
/**
* Dispose the VN event.
*/
virtual ~IVisualNovelEvent();
friend class VisualNovelManager;
};
}

View File

@ -1,56 +1,56 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "SimpleVisualNovelBackground.hpp"
using namespace Dawn;
SimpleVisualNovelBackground * SimpleVisualNovelBackground::create(Scene *s) {
auto item = s->createSceneItem();
// item->addComponent<MeshRenderer>();
item->addComponent<MeshHost>();
item->addComponent<SimpleTexturedMaterial>();
auto background = item->addComponent<SimpleVisualNovelBackground>();
return background;
}
SimpleVisualNovelBackground::SimpleVisualNovelBackground(SceneItem *item) :
SceneItemComponent(item)
{
}
std::vector<SceneItemComponent*> SimpleVisualNovelBackground::getDependencies(){
return std::vector<SceneItemComponent*>{
this->material = this->item->getComponent<SimpleTexturedMaterial>(),
this->meshHost = this->item->getComponent<MeshHost>()
};
}
void SimpleVisualNovelBackground::setTexture(Texture *texture) {
assertNotNull(texture);
this->material->texture = texture;
// Since we go both negative and positive, actual height is doubled
float_t aspect = (float_t)texture->getWidth() / (float_t)texture->getHeight();
float_t height = 0.5f;
QuadMesh::bufferQuadMeshWithZ(&this->meshHost->mesh,
glm::vec2(-aspect * height, -height), glm::vec2(0, 1),
glm::vec2( aspect * height, height), glm::vec2(1, 0),
0.0f, 0, 0
);
}
void SimpleVisualNovelBackground::onStart() {
assertNotNull(this->material);
assertNotNull(this->meshHost);
QuadMesh::initQuadMesh(&this->meshHost->mesh,
glm::vec2(-1, -1), glm::vec2(0, 1),
glm::vec2(1, 1), glm::vec2(1, 0),
0.0f
);
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "SimpleVisualNovelBackground.hpp"
using namespace Dawn;
SimpleVisualNovelBackground * SimpleVisualNovelBackground::create(Scene *s) {
auto item = s->createSceneItem();
// item->addComponent<MeshRenderer>();
item->addComponent<MeshHost>();
item->addComponent<SimpleTexturedMaterial>();
auto background = item->addComponent<SimpleVisualNovelBackground>();
return background;
}
SimpleVisualNovelBackground::SimpleVisualNovelBackground(SceneItem *item) :
SceneItemComponent(item)
{
}
std::vector<SceneItemComponent*> SimpleVisualNovelBackground::getDependencies(){
return std::vector<SceneItemComponent*>{
this->material = this->item->getComponent<SimpleTexturedMaterial>(),
this->meshHost = this->item->getComponent<MeshHost>()
};
}
void SimpleVisualNovelBackground::setTexture(Texture *texture) {
assertNotNull(texture);
this->material->texture = texture;
// Since we go both negative and positive, actual height is doubled
float_t aspect = (float_t)texture->getWidth() / (float_t)texture->getHeight();
float_t height = 0.5f;
QuadMesh::bufferQuadMeshWithZ(&this->meshHost->mesh,
glm::vec2(-aspect * height, -height), glm::vec2(0, 1),
glm::vec2( aspect * height, height), glm::vec2(1, 0),
0.0f, 0, 0
);
}
void SimpleVisualNovelBackground::onStart() {
assertNotNull(this->material);
assertNotNull(this->meshHost);
QuadMesh::initQuadMesh(&this->meshHost->mesh,
glm::vec2(-1, -1), glm::vec2(0, 1),
glm::vec2(1, 1), glm::vec2(1, 0),
0.0f
);
}

View File

@ -1,44 +1,44 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/components/Components.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
namespace Dawn {
class SimpleVisualNovelBackground : public SceneItemComponent {
public:
SimpleTexturedMaterial *material;
MeshHost *meshHost;
/**
* Create a simple Visual Novel Background prefab.
*
* @param scene Scene to add this background to.
* @return Created background Scene Item.
*/
static SimpleVisualNovelBackground * create(Scene *scene);
/**
* Construct a Simple Visual Novel Background. Simple Background is used
* for a quick up and running Visual Novel scene, but does not have any
* special effects or controls beyond updating a texture and mesh.
*
* @param item Scene Item this background belongs to.
*/
SimpleVisualNovelBackground(SceneItem *item);
std::vector<SceneItemComponent*> getDependencies() override;
void onStart() override;
/**
* Set the texture for the background. Auto updates the material and the
* dimensions of the internal quad.
*
* @param texture Texture to use.
*/
void setTexture(Texture *texture);
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/components/Components.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
namespace Dawn {
class SimpleVisualNovelBackground : public SceneItemComponent {
public:
SimpleTexturedMaterial *material;
MeshHost *meshHost;
/**
* Create a simple Visual Novel Background prefab.
*
* @param scene Scene to add this background to.
* @return Created background Scene Item.
*/
static SimpleVisualNovelBackground * create(Scene *scene);
/**
* Construct a Simple Visual Novel Background. Simple Background is used
* for a quick up and running Visual Novel scene, but does not have any
* special effects or controls beyond updating a texture and mesh.
*
* @param item Scene Item this background belongs to.
*/
SimpleVisualNovelBackground(SceneItem *item);
std::vector<SceneItemComponent*> getDependencies() override;
void onStart() override;
/**
* Set the texture for the background. Auto updates the material and the
* dimensions of the internal quad.
*
* @param texture Texture to use.
*/
void setTexture(Texture *texture);
};
}

View File

@ -1,25 +1,25 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelCharacter.hpp"
using namespace Dawn;
VisualNovelCharacter::VisualNovelCharacter(SceneItem *item) :
SceneItemComponent(item)
{
}
std::vector<SceneItemComponent*> VisualNovelCharacter::getDependencies() {
return std::vector<SceneItemComponent*>{
(this->material = this->item->getComponent<SimpleTexturedMaterial>()),
(this->tiledSprite = this->item->getComponent<TiledSprite>())
};
}
void VisualNovelCharacter::onStart() {
assertNotNull(this->material);
assertNotNull(this->tiledSprite);
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelCharacter.hpp"
using namespace Dawn;
VisualNovelCharacter::VisualNovelCharacter(SceneItem *item) :
SceneItemComponent(item)
{
}
std::vector<SceneItemComponent*> VisualNovelCharacter::getDependencies() {
return std::vector<SceneItemComponent*>{
(this->material = this->item->getComponent<SimpleTexturedMaterial>()),
(this->tiledSprite = this->item->getComponent<TiledSprite>())
};
}
void VisualNovelCharacter::onStart() {
assertNotNull(this->material);
assertNotNull(this->tiledSprite);
}

View File

@ -1,37 +1,37 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/SceneItemComponent.hpp"
#include "asset/assets/AudioAsset.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
#include "scene/components/display/TiledSprite.hpp"
#include "scene/components/audio/AudioSource.hpp"
namespace Dawn {
struct VisualNovelCharacterEmotion {
int32_t tile = 0;
AudioAsset *talkSound = nullptr;
AudioAsset *emotionSound = nullptr;
};
class VisualNovelCharacter : public SceneItemComponent {
public:
std::string nameKey = "character.unknown";
SimpleTexturedMaterial *material = nullptr;
TiledSprite *tiledSprite = nullptr;
/**
* Visual Novel Character Component. Mostly logic-less but provides nice
* interfaces for sibling components.
*
* @param item Item that this component belongs to.
*/
VisualNovelCharacter(SceneItem *item);
std::vector<SceneItemComponent*> getDependencies() override;
void onStart() override;
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/SceneItemComponent.hpp"
#include "asset/assets/AudioAsset.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
#include "scene/components/display/TiledSprite.hpp"
#include "scene/components/audio/AudioSource.hpp"
namespace Dawn {
struct VisualNovelCharacterEmotion {
int32_t tile = 0;
AudioAsset *talkSound = nullptr;
AudioAsset *emotionSound = nullptr;
};
class VisualNovelCharacter : public SceneItemComponent {
public:
std::string nameKey = "character.unknown";
SimpleTexturedMaterial *material = nullptr;
TiledSprite *tiledSprite = nullptr;
/**
* Visual Novel Character Component. Mostly logic-less but provides nice
* interfaces for sibling components.
*
* @param item Item that this component belongs to.
*/
VisualNovelCharacter(SceneItem *item);
std::vector<SceneItemComponent*> getDependencies() override;
void onStart() override;
};
}

View File

@ -1,38 +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;
}
};
// 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;
}
};
}

View File

@ -1,32 +1,32 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelChangeSimpleBackgroundEvent.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
VisualNovelChangeSimpleBackgroundEvent::VisualNovelChangeSimpleBackgroundEvent(
VisualNovelManager *manager, Texture *texture
) : IVisualNovelEvent(manager) {
this->texture = texture;
}
void VisualNovelChangeSimpleBackgroundEvent::onStart(IVisualNovelEvent *prev) {
auto back = this->manager->getScene()
->findComponent<SimpleVisualNovelBackground>()
;
assertNotNull(back);
back->setTexture(this->texture);
}
bool_t VisualNovelChangeSimpleBackgroundEvent::onUpdate() {
return false;
}
void VisualNovelChangeSimpleBackgroundEvent::onEnd() {
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelChangeSimpleBackgroundEvent.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
VisualNovelChangeSimpleBackgroundEvent::VisualNovelChangeSimpleBackgroundEvent(
VisualNovelManager *manager, Texture *texture
) : IVisualNovelEvent(manager) {
this->texture = texture;
}
void VisualNovelChangeSimpleBackgroundEvent::onStart(IVisualNovelEvent *prev) {
auto back = this->manager->getScene()
->findComponent<SimpleVisualNovelBackground>()
;
assertNotNull(back);
back->setTexture(this->texture);
}
bool_t VisualNovelChangeSimpleBackgroundEvent::onUpdate() {
return false;
}
void VisualNovelChangeSimpleBackgroundEvent::onEnd() {
}

View File

@ -1,25 +1,25 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/VisualNovelManager.hpp"
#include "visualnovel/components/SimpleVisualNovelBackground.hpp"
namespace Dawn {
class VisualNovelChangeSimpleBackgroundEvent : public IVisualNovelEvent {
protected:
Texture *texture = nullptr;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
VisualNovelChangeSimpleBackgroundEvent(
VisualNovelManager *manager,
Texture *texture
);
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/VisualNovelManager.hpp"
#include "visualnovel/components/SimpleVisualNovelBackground.hpp"
namespace Dawn {
class VisualNovelChangeSimpleBackgroundEvent : public IVisualNovelEvent {
protected:
Texture *texture = nullptr;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
VisualNovelChangeSimpleBackgroundEvent(
VisualNovelManager *manager,
Texture *texture
);
};
}

View File

@ -1,25 +1,25 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelEmptyEvent.hpp"
using namespace Dawn;
VisualNovelEmptyEvent::VisualNovelEmptyEvent(VisualNovelManager *man) :
IVisualNovelEvent(man)
{
}
void VisualNovelEmptyEvent::onStart(IVisualNovelEvent *prev) {
}
bool_t VisualNovelEmptyEvent::onUpdate() {
return false;
}
void VisualNovelEmptyEvent::onEnd() {
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelEmptyEvent.hpp"
using namespace Dawn;
VisualNovelEmptyEvent::VisualNovelEmptyEvent(VisualNovelManager *man) :
IVisualNovelEvent(man)
{
}
void VisualNovelEmptyEvent::onStart(IVisualNovelEvent *prev) {
}
bool_t VisualNovelEmptyEvent::onUpdate() {
return false;
}
void VisualNovelEmptyEvent::onEnd() {
}

View File

@ -1,19 +1,19 @@
// 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 {
class VisualNovelEmptyEvent : public IVisualNovelEvent {
protected:
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
VisualNovelEmptyEvent(VisualNovelManager *manager);
};
// 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 {
class VisualNovelEmptyEvent : public IVisualNovelEvent {
protected:
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
VisualNovelEmptyEvent(VisualNovelManager *manager);
};
}

View File

@ -1,35 +1,35 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelFadeEvent.hpp"
using namespace Dawn;
VisualNovelFadeEvent::VisualNovelFadeEvent(
VisualNovelManager *man,
struct Color color,
bool_t fadeIn,
easefunction_t *ease,
float_t duration
) : VisualNovelSimpleAnimationEvent(man, &duration) {
this->color = color;
this->fadeIn = fadeIn;
this->duration = duration;
this->simpleAnimation.easing = ease;
}
void VisualNovelFadeEvent::onStart(IVisualNovelEvent *previous) {
VisualNovelSimpleAnimationEvent::onStart(previous);
this->simpleAnimation = SimpleAnimation<float_t>(&this->manager->fader->color.a);
this->manager->fader->color = this->color;
this->manager->fader->color.a = this->fadeIn ? 0.0f : 1.0f;
this->simpleAnimation.addKeyframe(
0.0f, this->fadeIn ? 0.0f : 1.0f
);
this->simpleAnimation.addKeyframe(
this->duration, this->fadeIn ? 1.0f : 0.0f
);
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelFadeEvent.hpp"
using namespace Dawn;
VisualNovelFadeEvent::VisualNovelFadeEvent(
VisualNovelManager *man,
struct Color color,
bool_t fadeIn,
easefunction_t *ease,
float_t duration
) : VisualNovelSimpleAnimationEvent(man, &duration) {
this->color = color;
this->fadeIn = fadeIn;
this->duration = duration;
this->simpleAnimation.easing = ease;
}
void VisualNovelFadeEvent::onStart(IVisualNovelEvent *previous) {
VisualNovelSimpleAnimationEvent::onStart(previous);
this->simpleAnimation = SimpleAnimation<float_t>(&this->manager->fader->color.a);
this->manager->fader->color = this->color;
this->manager->fader->color.a = this->fadeIn ? 0.0f : 1.0f;
this->simpleAnimation.addKeyframe(
0.0f, this->fadeIn ? 0.0f : 1.0f
);
this->simpleAnimation.addKeyframe(
this->duration, this->fadeIn ? 1.0f : 0.0f
);
}

View File

@ -1,36 +1,36 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp"
namespace Dawn {
class VisualNovelFadeEvent : public VisualNovelSimpleAnimationEvent<float_t> {
protected:
struct Color color;
bool_t fadeIn;
float_t duration;
void onStart(IVisualNovelEvent *previous) override;
public:
/**
* Create a new visual novel event for fading the screen in/out.
*
* @param man Manager that this VN event belongs to.
* @param color Color to fade to/from.
* @param fadeIn True to make the color go from 0 to 1 opacity.
* @param ease Easing function to use.
* @param duration How long does the fade take.
*/
VisualNovelFadeEvent(
VisualNovelManager *man,
struct Color color,
bool_t fadeIn,
easefunction_t *ease,
float_t duration
);
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp"
namespace Dawn {
class VisualNovelFadeEvent : public VisualNovelSimpleAnimationEvent<float_t> {
protected:
struct Color color;
bool_t fadeIn;
float_t duration;
void onStart(IVisualNovelEvent *previous) override;
public:
/**
* Create a new visual novel event for fading the screen in/out.
*
* @param man Manager that this VN event belongs to.
* @param color Color to fade to/from.
* @param fadeIn True to make the color go from 0 to 1 opacity.
* @param ease Easing function to use.
* @param duration How long does the fade take.
*/
VisualNovelFadeEvent(
VisualNovelManager *man,
struct Color color,
bool_t fadeIn,
easefunction_t *ease,
float_t duration
);
};
}

View File

@ -1,59 +1,59 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelTextboxEvent.hpp"
using namespace Dawn;
VisualNovelTextboxEvent::VisualNovelTextboxEvent(
VisualNovelManager *manager,
VisualNovelCharacter *character,
struct VisualNovelCharacterEmotion emotion,
std::string languageKey
) : IVisualNovelEvent(manager) {
this->character = character;
this->languageKey = languageKey;
this->emotion = emotion;
}
VisualNovelTextboxEvent::VisualNovelTextboxEvent(
VisualNovelManager *manager,
std::string languageKey
) : IVisualNovelEvent(manager) {
this->character = nullptr;
this->languageKey = languageKey;
}
void VisualNovelTextboxEvent::onStart(IVisualNovelEvent *previous) {
if(this->manager->textBox == nullptr) return;
this->manager->textBox->setText(this->languageKey);
this->manager->textBox->setCharacter(this->character);
if(this->character != nullptr) {
this->character->tiledSprite->setTile(this->emotion.tile);
}
if(this->emotion.emotionSound != nullptr) {
if(this->manager->audioCharacter != nullptr) {
this->manager->audioCharacter->stop();
this->manager->audioCharacter->loop = false;
this->manager->audioCharacter->setAudioData(this->emotion.emotionSound);
this->manager->audioCharacter->play();
}
} else if(this->emotion.talkSound != nullptr) {
this->manager->textBox->setTalkingSound(this->emotion.talkSound);
}
this->manager->textBox->show();
}
bool_t VisualNovelTextboxEvent::onUpdate() {
return this->manager->textBox->isVisible();
}
void VisualNovelTextboxEvent::onEnd() {
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelTextboxEvent.hpp"
using namespace Dawn;
VisualNovelTextboxEvent::VisualNovelTextboxEvent(
VisualNovelManager *manager,
VisualNovelCharacter *character,
struct VisualNovelCharacterEmotion emotion,
std::string languageKey
) : IVisualNovelEvent(manager) {
this->character = character;
this->languageKey = languageKey;
this->emotion = emotion;
}
VisualNovelTextboxEvent::VisualNovelTextboxEvent(
VisualNovelManager *manager,
std::string languageKey
) : IVisualNovelEvent(manager) {
this->character = nullptr;
this->languageKey = languageKey;
}
void VisualNovelTextboxEvent::onStart(IVisualNovelEvent *previous) {
if(this->manager->textBox == nullptr) return;
this->manager->textBox->setText(this->languageKey);
this->manager->textBox->setCharacter(this->character);
if(this->character != nullptr) {
this->character->tiledSprite->setTile(this->emotion.tile);
}
if(this->emotion.emotionSound != nullptr) {
if(this->manager->audioCharacter != nullptr) {
this->manager->audioCharacter->stop();
this->manager->audioCharacter->loop = false;
this->manager->audioCharacter->setAudioData(this->emotion.emotionSound);
this->manager->audioCharacter->play();
}
} else if(this->emotion.talkSound != nullptr) {
this->manager->textBox->setTalkingSound(this->emotion.talkSound);
}
this->manager->textBox->show();
}
bool_t VisualNovelTextboxEvent::onUpdate() {
return this->manager->textBox->isVisible();
}
void VisualNovelTextboxEvent::onEnd() {
}

View File

@ -1,42 +1,42 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/VisualNovelManager.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
namespace Dawn {
class VisualNovelTextboxEvent : public IVisualNovelEvent {
protected:
std::string languageKey;
VisualNovelCharacter *character;
struct VisualNovelCharacterEmotion emotion;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
/**
* Create a new Textbox Event. This will queue a conversation item for the
* textbox to display.
*
* @param manager Visual Novel Manager instance for this event.
* @param character Character that is intended to be speaking.
* @param languageKey Language Key to talk.
*/
VisualNovelTextboxEvent(
VisualNovelManager *manager,
VisualNovelCharacter *character,
struct VisualNovelCharacterEmotion emotion,
std::string languageKey
);
VisualNovelTextboxEvent(
VisualNovelManager *manager,
std::string languageKey
);
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/VisualNovelManager.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
namespace Dawn {
class VisualNovelTextboxEvent : public IVisualNovelEvent {
protected:
std::string languageKey;
VisualNovelCharacter *character;
struct VisualNovelCharacterEmotion emotion;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
/**
* Create a new Textbox Event. This will queue a conversation item for the
* textbox to display.
*
* @param manager Visual Novel Manager instance for this event.
* @param character Character that is intended to be speaking.
* @param languageKey Language Key to talk.
*/
VisualNovelTextboxEvent(
VisualNovelManager *manager,
VisualNovelCharacter *character,
struct VisualNovelCharacterEmotion emotion,
std::string languageKey
);
VisualNovelTextboxEvent(
VisualNovelManager *manager,
std::string languageKey
);
};
}

View File

@ -1,10 +1,10 @@
# 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
VisualNovelAnimationEvent.cpp
# 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
VisualNovelAnimationEvent.cpp
)

View File

@ -1,27 +1,27 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelAnimationEvent.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
VisualNovelAnimationEvent::VisualNovelAnimationEvent(
VisualNovelManager *manager
) : IVisualNovelEvent(manager) {
}
void VisualNovelAnimationEvent::onStart(IVisualNovelEvent *previous) {
}
bool_t VisualNovelAnimationEvent::onUpdate() {
this->animation->tick(this->manager->getGame()->timeManager.delta);
return !this->animation->finished;
}
void VisualNovelAnimationEvent::onEnd() {
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelAnimationEvent.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
VisualNovelAnimationEvent::VisualNovelAnimationEvent(
VisualNovelManager *manager
) : IVisualNovelEvent(manager) {
}
void VisualNovelAnimationEvent::onStart(IVisualNovelEvent *previous) {
}
bool_t VisualNovelAnimationEvent::onUpdate() {
this->animation->tick(this->manager->getGame()->timeManager.delta);
return !this->animation->finished;
}
void VisualNovelAnimationEvent::onEnd() {
}

View File

@ -1,22 +1,22 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/VisualNovelManager.hpp"
#include "display/animation/Animation.hpp"
namespace Dawn {
class VisualNovelAnimationEvent : public IVisualNovelEvent {
protected:
struct Animation *animation;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
VisualNovelAnimationEvent(VisualNovelManager *manager);
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/VisualNovelManager.hpp"
#include "display/animation/Animation.hpp"
namespace Dawn {
class VisualNovelAnimationEvent : public IVisualNovelEvent {
protected:
struct Animation *animation;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
VisualNovelAnimationEvent(VisualNovelManager *manager);
};
}

View File

@ -1,26 +1,26 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "VisualNovelAnimationEvent.hpp"
#include "display/animation/SimpleAnimation.hpp"
namespace Dawn {
template<typename T>
class VisualNovelSimpleAnimationEvent : public VisualNovelAnimationEvent {
public:
struct SimpleAnimation<T> simpleAnimation;
VisualNovelSimpleAnimationEvent(
VisualNovelManager *man,
T *modifies
) :
VisualNovelAnimationEvent(man),
simpleAnimation(modifies)
{
this->animation = &this->simpleAnimation;
}
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "VisualNovelAnimationEvent.hpp"
#include "display/animation/SimpleAnimation.hpp"
namespace Dawn {
template<typename T>
class VisualNovelSimpleAnimationEvent : public VisualNovelAnimationEvent {
public:
struct SimpleAnimation<T> simpleAnimation;
VisualNovelSimpleAnimationEvent(
VisualNovelManager *man,
T *modifies
) :
VisualNovelAnimationEvent(man),
simpleAnimation(modifies)
{
this->animation = &this->simpleAnimation;
}
};
}

View File

@ -1,24 +1,24 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "VisualNovelAnimationEvent.hpp"
#include "display/animation/SimpleCallbackAnimation.hpp"
namespace Dawn {
template<typename T, class I>
class VisualNovelSimpleCallbackAnimationEvent :
public VisualNovelAnimationEvent
{
public:
struct SimpleCallbackAnimation<T, I> callbackAnimation;
VisualNovelSimpleCallbackAnimationEvent(VisualNovelManager *man) :
VisualNovelAnimationEvent(man)
{
this->animation = &callbackAnimation;
}
};
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "VisualNovelAnimationEvent.hpp"
#include "display/animation/SimpleCallbackAnimation.hpp"
namespace Dawn {
template<typename T, class I>
class VisualNovelSimpleCallbackAnimationEvent :
public VisualNovelAnimationEvent
{
public:
struct SimpleCallbackAnimation<T, I> callbackAnimation;
VisualNovelSimpleCallbackAnimationEvent(VisualNovelManager *man) :
VisualNovelAnimationEvent(man)
{
this->animation = &callbackAnimation;
}
};
}

View File

@ -1,11 +1,11 @@
# 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
VisualNovelFadeCharacterEvent.cpp
VisualNovelTransformItemEvent.cpp
# 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
VisualNovelFadeCharacterEvent.cpp
VisualNovelTransformItemEvent.cpp
)

View File

@ -1,28 +1,28 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelFadeCharacterEvent.hpp"
using namespace Dawn;
VisualNovelFadeCharacterEvent::VisualNovelFadeCharacterEvent(
VisualNovelManager *man,
VisualNovelCharacter *character,
bool_t fadeIn,
easefunction_t *ease,
float_t duration
) : VisualNovelSimpleAnimationEvent<float_t>(
man,
&character->material->color.a
) {
this->simpleAnimation.easing = ease;
if(fadeIn) {
this->simpleAnimation.addKeyframe(0.0f, 0.0f);
this->simpleAnimation.addKeyframe(duration, 1.0f);
} else {
this->simpleAnimation.addKeyframe(0.0f, 1.0f);
this->simpleAnimation.addKeyframe(duration, 0.0f);
}
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelFadeCharacterEvent.hpp"
using namespace Dawn;
VisualNovelFadeCharacterEvent::VisualNovelFadeCharacterEvent(
VisualNovelManager *man,
VisualNovelCharacter *character,
bool_t fadeIn,
easefunction_t *ease,
float_t duration
) : VisualNovelSimpleAnimationEvent<float_t>(
man,
&character->material->color.a
) {
this->simpleAnimation.easing = ease;
if(fadeIn) {
this->simpleAnimation.addKeyframe(0.0f, 0.0f);
this->simpleAnimation.addKeyframe(duration, 1.0f);
} else {
this->simpleAnimation.addKeyframe(0.0f, 1.0f);
this->simpleAnimation.addKeyframe(duration, 0.0f);
}
}

View File

@ -1,24 +1,24 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
#include "scene/components/display/Material.hpp"
namespace Dawn {
class VisualNovelFadeCharacterEvent :
public VisualNovelSimpleAnimationEvent<float_t>
{
public:
VisualNovelFadeCharacterEvent(
VisualNovelManager *man,
VisualNovelCharacter *character,
bool_t fadeIn,
easefunction_t *ease,
float_t duration
);
};
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp"
#include "visualnovel/components/VisualNovelCharacter.hpp"
#include "scene/components/display/Material.hpp"
namespace Dawn {
class VisualNovelFadeCharacterEvent :
public VisualNovelSimpleAnimationEvent<float_t>
{
public:
VisualNovelFadeCharacterEvent(
VisualNovelManager *man,
VisualNovelCharacter *character,
bool_t fadeIn,
easefunction_t *ease,
float_t duration
);
};
}

View File

@ -1,53 +1,53 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelTransformItemEvent.hpp"
using namespace Dawn;
VisualNovelTransformItemEvent::VisualNovelTransformItemEvent(
VisualNovelManager *man,
SceneItem *item,
glm::vec3 start,
glm::vec3 end,
easefunction_t *ease,
float_t duration
) : VisualNovelSimpleCallbackAnimationEvent<glm::vec3, Transform>(man) {
assertNotNull(item);
this->item = item;
this->callbackAnimation.setCallback(
&item->transform, &Transform::setLocalPosition
);
if(duration != 0) {
this->callbackAnimation.addKeyframe(0.0f, start);
}
this->callbackAnimation.addKeyframe(duration, end);
}
VisualNovelTransformItemEvent::VisualNovelTransformItemEvent(
VisualNovelManager *man,
SceneItem *item,
glm::vec3 end,
easefunction_t *ease,
float_t duration
) : VisualNovelSimpleCallbackAnimationEvent<glm::vec3, Transform>(man) {
assertNotNull(item);
this->item = item;
this->callbackAnimation.setCallback(
&item->transform, &Transform::setLocalPosition
);
if(duration != 0) this->relative = true;
this->callbackAnimation.addKeyframe(duration, end);
}
void VisualNovelTransformItemEvent::onStart(IVisualNovelEvent *previous) {
if(this->relative) {
this->callbackAnimation.addKeyframe(0.0f, this->item->transform.getLocalPosition());
}
VisualNovelSimpleCallbackAnimationEvent::onStart(previous);
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelTransformItemEvent.hpp"
using namespace Dawn;
VisualNovelTransformItemEvent::VisualNovelTransformItemEvent(
VisualNovelManager *man,
SceneItem *item,
glm::vec3 start,
glm::vec3 end,
easefunction_t *ease,
float_t duration
) : VisualNovelSimpleCallbackAnimationEvent<glm::vec3, Transform>(man) {
assertNotNull(item);
this->item = item;
this->callbackAnimation.setCallback(
&item->transform, &Transform::setLocalPosition
);
if(duration != 0) {
this->callbackAnimation.addKeyframe(0.0f, start);
}
this->callbackAnimation.addKeyframe(duration, end);
}
VisualNovelTransformItemEvent::VisualNovelTransformItemEvent(
VisualNovelManager *man,
SceneItem *item,
glm::vec3 end,
easefunction_t *ease,
float_t duration
) : VisualNovelSimpleCallbackAnimationEvent<glm::vec3, Transform>(man) {
assertNotNull(item);
this->item = item;
this->callbackAnimation.setCallback(
&item->transform, &Transform::setLocalPosition
);
if(duration != 0) this->relative = true;
this->callbackAnimation.addKeyframe(duration, end);
}
void VisualNovelTransformItemEvent::onStart(IVisualNovelEvent *previous) {
if(this->relative) {
this->callbackAnimation.addKeyframe(0.0f, this->item->transform.getLocalPosition());
}
VisualNovelSimpleCallbackAnimationEvent::onStart(previous);
}

View File

@ -1,36 +1,36 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/events/animation/VisualNovelSimpleCallbackAnimationEvent.hpp"
namespace Dawn {
class VisualNovelTransformItemEvent :
public VisualNovelSimpleCallbackAnimationEvent<glm::vec3, Transform>
{
protected:
bool_t relative = false;
SceneItem *item = nullptr;
void onStart(IVisualNovelEvent *previous) override;
public:
VisualNovelTransformItemEvent(
VisualNovelManager *man,
SceneItem *item,
glm::vec3 start,
glm::vec3 end,
easefunction_t *ease,
float_t duration
);
VisualNovelTransformItemEvent(
VisualNovelManager *man,
SceneItem *item,
glm::vec3 end,
easefunction_t *ease,
float_t duration
);
};
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/events/animation/VisualNovelSimpleCallbackAnimationEvent.hpp"
namespace Dawn {
class VisualNovelTransformItemEvent :
public VisualNovelSimpleCallbackAnimationEvent<glm::vec3, Transform>
{
protected:
bool_t relative = false;
SceneItem *item = nullptr;
void onStart(IVisualNovelEvent *previous) override;
public:
VisualNovelTransformItemEvent(
VisualNovelManager *man,
SceneItem *item,
glm::vec3 start,
glm::vec3 end,
easefunction_t *ease,
float_t duration
);
VisualNovelTransformItemEvent(
VisualNovelManager *man,
SceneItem *item,
glm::vec3 end,
easefunction_t *ease,
float_t duration
);
};
}

View File

@ -1,11 +1,11 @@
# 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
VisualNovelBatchEvent.cpp
VisualNovelPauseEvent.cpp
# 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
VisualNovelBatchEvent.cpp
VisualNovelPauseEvent.cpp
)

View File

@ -1,66 +1,66 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelBatchEvent.hpp"
using namespace Dawn;
VisualNovelBatchEvent::VisualNovelBatchEvent(
VisualNovelManager *man,
std::vector<IVisualNovelEvent*> events
) : IVisualNovelEvent(man) {
this->activeEvents = events;
}
void VisualNovelBatchEvent::onStart(IVisualNovelEvent *previous) {
auto it = this->activeEvents.begin();
while(it != this->activeEvents.end()) {
auto evt = *it;
evt->start(previous);
++it;
}
}
bool_t VisualNovelBatchEvent::onUpdate() {
bool_t result;
auto it = this->activeEvents.begin();
while(it != this->activeEvents.end()) {
auto evt = *it;
result = evt->update();
if(result) {
++it;
continue;
}
auto subNext = evt->end();
// In future I may remove this and instead immediately queue the next thing.
assertNull(subNext);
it = this->activeEvents.erase(it);
this->inactiveEvents.push_back(evt);
}
return this->activeEvents.size() > 0;
}
void VisualNovelBatchEvent::onEnd() {
}
VisualNovelBatchEvent::~VisualNovelBatchEvent() {
auto itActive = this->activeEvents.begin();
while(itActive != this->activeEvents.end()) {
auto evt = *itActive;
delete evt;
++itActive;
}
auto itInactive = this->inactiveEvents.begin();
while(itInactive != this->inactiveEvents.end()) {
auto evt = *itInactive;
delete evt;
++itInactive;
}
}
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelBatchEvent.hpp"
using namespace Dawn;
VisualNovelBatchEvent::VisualNovelBatchEvent(
VisualNovelManager *man,
std::vector<IVisualNovelEvent*> events
) : IVisualNovelEvent(man) {
this->activeEvents = events;
}
void VisualNovelBatchEvent::onStart(IVisualNovelEvent *previous) {
auto it = this->activeEvents.begin();
while(it != this->activeEvents.end()) {
auto evt = *it;
evt->start(previous);
++it;
}
}
bool_t VisualNovelBatchEvent::onUpdate() {
bool_t result;
auto it = this->activeEvents.begin();
while(it != this->activeEvents.end()) {
auto evt = *it;
result = evt->update();
if(result) {
++it;
continue;
}
auto subNext = evt->end();
// In future I may remove this and instead immediately queue the next thing.
assertNull(subNext);
it = this->activeEvents.erase(it);
this->inactiveEvents.push_back(evt);
}
return this->activeEvents.size() > 0;
}
void VisualNovelBatchEvent::onEnd() {
}
VisualNovelBatchEvent::~VisualNovelBatchEvent() {
auto itActive = this->activeEvents.begin();
while(itActive != this->activeEvents.end()) {
auto evt = *itActive;
delete evt;
++itActive;
}
auto itInactive = this->inactiveEvents.begin();
while(itInactive != this->inactiveEvents.end()) {
auto evt = *itInactive;
delete evt;
++itInactive;
}
}

View File

@ -1,27 +1,27 @@
// 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 {
class VisualNovelBatchEvent : public IVisualNovelEvent {
protected:
std::vector<IVisualNovelEvent*> activeEvents;
std::vector<IVisualNovelEvent*> inactiveEvents;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
VisualNovelBatchEvent(
VisualNovelManager *man,
std::vector<IVisualNovelEvent*> events
);
~VisualNovelBatchEvent();
};
// 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 {
class VisualNovelBatchEvent : public IVisualNovelEvent {
protected:
std::vector<IVisualNovelEvent*> activeEvents;
std::vector<IVisualNovelEvent*> inactiveEvents;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
VisualNovelBatchEvent(
VisualNovelManager *man,
std::vector<IVisualNovelEvent*> events
);
~VisualNovelBatchEvent();
};
}

View File

@ -1,28 +1,28 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelPauseEvent.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
VisualNovelPauseEvent::VisualNovelPauseEvent(
VisualNovelManager *manager, float_t duration
) : IVisualNovelEvent(manager) {
this->duration = duration;
}
void VisualNovelPauseEvent::onStart(IVisualNovelEvent *prev) {
this->time = 0;
}
bool_t VisualNovelPauseEvent::onUpdate() {
this->time += this->manager->getGame()->timeManager.delta;
return this->time < this->duration;
}
void VisualNovelPauseEvent::onEnd() {
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelPauseEvent.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
VisualNovelPauseEvent::VisualNovelPauseEvent(
VisualNovelManager *manager, float_t duration
) : IVisualNovelEvent(manager) {
this->duration = duration;
}
void VisualNovelPauseEvent::onStart(IVisualNovelEvent *prev) {
this->time = 0;
}
bool_t VisualNovelPauseEvent::onUpdate() {
this->time += this->manager->getGame()->timeManager.delta;
return this->time < this->duration;
}
void VisualNovelPauseEvent::onEnd() {
}

View File

@ -1,28 +1,28 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/VisualNovelManager.hpp"
namespace Dawn {
class VisualNovelPauseEvent : public IVisualNovelEvent {
protected:
float_t time;
float_t duration;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
/**
* Create a new Visual Novel Pause Event.
*
* @param manager Manager this event belongs to.
* @param duration Duration to pause for.
*/
VisualNovelPauseEvent(VisualNovelManager *manager, float_t duration);
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "visualnovel/VisualNovelManager.hpp"
namespace Dawn {
class VisualNovelPauseEvent : public IVisualNovelEvent {
protected:
float_t time;
float_t duration;
void onStart(IVisualNovelEvent *previous) override;
bool_t onUpdate() override;
void onEnd() override;
public:
/**
* Create a new Visual Novel Pause Event.
*
* @param manager Manager this event belongs to.
* @param duration Duration to pause for.
*/
VisualNovelPauseEvent(VisualNovelManager *manager, float_t duration);
};
}

View File

@ -1,10 +1,10 @@
# 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
SimpleVNScene.cpp
# 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
SimpleVNScene.cpp
)

View File

@ -1,11 +1,11 @@
# 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
VisualNovelFader.cpp
VisualNovelTextbox.cpp
# 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
VisualNovelFader.cpp
VisualNovelTextbox.cpp
)

View File

@ -1,25 +1,25 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelFader.hpp"
using namespace Dawn;
VisualNovelFader::VisualNovelFader(UICanvas *canvas) : UISprite(canvas) {
}
VisualNovelFader * VisualNovelFader::create(UICanvas *canvas) {
assertNotNull(canvas);
auto item = canvas->addElement<VisualNovelFader>();
item->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH,
glm::vec4(0, 0, 0, 0),
0.0f
);
item->color = COLOR_BLACK_TRANSPARENT;
return item;
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VisualNovelFader.hpp"
using namespace Dawn;
VisualNovelFader::VisualNovelFader(UICanvas *canvas) : UISprite(canvas) {
}
VisualNovelFader * VisualNovelFader::create(UICanvas *canvas) {
assertNotNull(canvas);
auto item = canvas->addElement<VisualNovelFader>();
item->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH,
glm::vec4(0, 0, 0, 0),
0.0f
);
item->color = COLOR_BLACK_TRANSPARENT;
return item;
}

View File

@ -1,32 +1,32 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "ui/UISprite.hpp"
#include "ui/UIEmpty.hpp"
namespace Dawn {
class VisualNovelFader : public UISprite {
private:
public:
/**
* Quickly create a visual novel fader.
*
* @param canvas Canvas the fader belongs to.
* @return Created VN Fader.
*/
static VisualNovelFader * create(UICanvas *canvas);
/**
* Construct a new Visual Novel Fader. VN Fader is just a sprite that is
* easily found by the VN Manager for the purpose of adding transitions to
* a VN scene.
*
* @param canvas Canvas for this component.
*/
VisualNovelFader(UICanvas *canvas);
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "ui/UISprite.hpp"
#include "ui/UIEmpty.hpp"
namespace Dawn {
class VisualNovelFader : public UISprite {
private:
public:
/**
* Quickly create a visual novel fader.
*
* @param canvas Canvas the fader belongs to.
* @return Created VN Fader.
*/
static VisualNovelFader * create(UICanvas *canvas);
/**
* Construct a new Visual Novel Fader. VN Fader is just a sprite that is
* easily found by the VN Manager for the purpose of adding transitions to
* a VN scene.
*
* @param canvas Canvas for this component.
*/
VisualNovelFader(UICanvas *canvas);
};
}

View File

@ -1,30 +0,0 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Build Project
add_executable(${DAWN_TARGET_NAME})
# Includes
target_include_directories(${DAWN_TARGET_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
# Subdirs
add_subdirectory(components)
add_subdirectory(game)
add_subdirectory(save)
# Assets
set(DIR_GAME_ASSETS games/platformergame)
tool_language(language_en ${DIR_GAME_ASSETS}/locale/en.csv)
tool_texture(texture_test texture_test.png)
tool_tileset(tileset_aqua texture_aqua ${DIR_GAME_ASSETS}/tileset/s4m_ur4i_minivania_tilemap_aqua.png 32 32)
add_dependencies(${DAWN_TARGET_NAME}
language_en
texture_test
tileset_aqua
)

View File

@ -1,10 +0,0 @@
# 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
PlayerController.cpp
)

View File

@ -1,35 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "PlayerController.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
PlayerController::PlayerController(SceneItem *i) : SceneItemComponent(i) {}
void PlayerController::onSceneUpdate() {
auto im = &getGame()->inputManager;
auto delta = getGame()->timeManager.delta;
glm::vec2 iMove = im->getAxis2D(
INPUT_BIND_NEGATIVE_X, INPUT_BIND_POSITIVE_X,
INPUT_BIND_NEGATIVE_Y, INPUT_BIND_POSITIVE_Y
);
glm::vec2 pos = this->transform->getLocalPosition();
this->transform->setLocalPosition(
this->transform->getLocalPosition() + glm::vec3(iMove * delta * 20.0f, 0)
);
}
void PlayerController::onStart() {
assertNotNull(this->camera);
getScene()->eventSceneUnpausedUpdate.addListener(this, &PlayerController::onSceneUpdate);
}
PlayerController::~PlayerController() {
getScene()->eventSceneUnpausedUpdate.removeListener(this, &PlayerController::onSceneUpdate);
}

View File

@ -1,23 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/components/Components.hpp"
namespace Dawn {
class PlayerController : public SceneItemComponent {
protected:
void onSceneUpdate();
public:
Camera *camera = nullptr;
PlayerController(SceneItem *item);
void onStart() override;
~PlayerController();
};
}

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
DawnGame.cpp
)

View File

@ -1,40 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnGame.hpp"
#include "scenes/TestScene.hpp"
using namespace Dawn;
DawnGame::DawnGame(DawnHost *host) :
host(host),
renderManager(this),
inputManager(this),
localeManager(this),
saveManager(this)
{
}
int32_t DawnGame::init() {
this->assetManager.init();
this->localeManager.init();
this->renderManager.init();
this->scene = new TestScene(this);
return DAWN_GAME_INIT_RESULT_SUCCESS;
}
int32_t DawnGame::update(float_t delta) {
this->assetManager.update();
this->inputManager.update();
this->timeManager.update(delta);
if(this->scene != nullptr) this->scene->update();
this->renderManager.update();
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
}

View File

@ -1,27 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "game/_DawnGame.hpp"
#include "scene/components/Components.hpp"
#include "save/DawnGameSaveManager.hpp"
namespace Dawn {
class DawnGame : public IDawnGame {
public:
DawnHost *host;
RenderManager renderManager;
AssetManager assetManager;
InputManager inputManager;
TimeManager timeManager;
LocaleManager localeManager;
DawnGameSaveManager saveManager;
PhysicsManager physicsManager;
DawnGame(DawnHost *host);
int32_t init() override;
int32_t update(float_t delta) override;
};
}

View File

@ -1,14 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "input/InputManager.hpp"
#define INPUT_BIND(n) ((inputbind_t)n)
#define INPUT_BIND_ACCEPT INPUT_BIND(1)
#define INPUT_BIND_NEGATIVE_X INPUT_BIND(2)
#define INPUT_BIND_POSITIVE_X INPUT_BIND(3)
#define INPUT_BIND_NEGATIVE_Y INPUT_BIND(4)
#define INPUT_BIND_POSITIVE_Y INPUT_BIND(5)

View File

@ -1,46 +0,0 @@
// 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/components/Components.hpp"
#include "components/PlayerController.hpp"
namespace Dawn {
class PlayerPrefab : public SceneItemPrefab<PlayerPrefab> {
public:
static std::vector<Asset*> prefabAssets(AssetManager *man) {
std::vector<Asset*> assets;
assets.push_back(man->get<TilesetAsset>("tileset_aqua"));
assets.push_back(man->get<TextureAsset>("texture_aqua"));
return assets;
}
//
MeshHost *meshHost;
TiledSprite *tiledSprite;
Material *material;
MeshRenderer *meshRenderer;
PlayerController *playerController;
PlayerPrefab(Scene *s, sceneitemid_t i) : SceneItemPrefab(s, i) {}
void prefabInit(AssetManager *man) override {
auto tileset = man->get<TilesetAsset>("tileset_aqua");
auto texture = man->get<TextureAsset>("texture_aqua");
meshHost = addComponent<MeshHost>();
tiledSprite = addComponent<TiledSprite>();
material = addComponent<Material>();
meshRenderer = addComponent<MeshRenderer>();
playerController = addComponent<PlayerController>();
tiledSprite->setTilesetAndSize(&tileset->tileset);
tiledSprite->setTile(896);
material->textureValues[material->getShader()->getParameterByName("u_Text")] = &texture->texture;
}
};
}

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
DawnGameSaveManager.cpp
)

View File

@ -1,28 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnGameSaveManager.hpp"
using namespace Dawn;
DawnGameSaveManager::DawnGameSaveManager(DawnGame *game) : SaveManager(game) {
}
bool_t DawnGameSaveManager::validateSave(struct SaveFile raw) {
if(!raw.has(POKER_SAVE_KEY_EXAMPLE)) return true;
this->currentSave.copy(raw, POKER_SAVE_KEY_EXAMPLE);
return false;
}
void DawnGameSaveManager::setExample(int32_t val) {
savedata_t value;
value.i32 = val;
this->currentSave.set(POKER_SAVE_KEY_EXAMPLE, value);
}
int32_t DawnGameSaveManager::getExample() {
return this->currentSave.get(POKER_SAVE_KEY_EXAMPLE).i32;
}

View File

@ -1,22 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "save/SaveManager.hpp"
#define POKER_SAVE_KEY_EXAMPLE "poker.example"
namespace Dawn {
class DawnGameSaveManager : public SaveManager {
protected:
virtual bool_t validateSave(struct SaveFile raw) override;
public:
DawnGameSaveManager(DawnGame *game);
void setExample(int32_t value);
int32_t getExample();
};
}

View File

@ -1,33 +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 "prefabs/PlayerPrefab.hpp"
namespace Dawn {
class TestScene : public Scene {
protected:
void stage() override {
auto camera = Camera::create(this);
camera->type = CAMERA_TYPE_ORTHONOGRAPHIC;
camera->item->addComponent<PixelPerfectCamera>();
camera->transform->lookAt(glm::vec3(0, 0, 10), glm::vec3(0, 0, 0));
auto player = PlayerPrefab::create(this);
player->playerController->camera = camera;
}
std::vector<Asset*> getRequiredAssets() override {
auto assMan = &this->game->assetManager;
std::vector<Asset*> assets;
vectorAppend(&assets, PlayerPrefab::getRequiredAssets(assMan));
return assets;
}
public:
TestScene(DawnGame *game) : Scene(game) {}
};
}

View File

@ -1,34 +0,0 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Add Common Engine Parts
set(DAWN_VISUAL_NOVEL true CACHE INTERNAL ${DAWN_CACHE_TARGET})
# Build Project
add_executable(${DAWN_TARGET_NAME})
# Includes
target_include_directories(${DAWN_TARGET_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
# Subdirs
add_subdirectory(game)
add_subdirectory(ui)
add_subdirectory(visualnovel)
add_subdirectory(prefabs)
add_subdirectory(save)
add_subdirectory(scenes)
# Assets
set(DIR_GAME_ASSETS games/pokergame)
tool_texture(texture_test texture_test.png)
tool_language(locale_poker ${DIR_GAME_ASSETS}/locale/locale.xml)
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_bizudp ${DIR_GAME_ASSETS}/font/BIZUDPGothic-Regular.ttf truetype_bizudp 2048 2048 120)
tool_audio(audio_test borrowed/sample_short.wav)
tool_vnscene(Scene_1 ${DIR_GAME_ASSETS}/vn/Scene_1.xml)

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
DawnGame.cpp
)

View File

@ -1,59 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnGame.hpp"
#include "scenes/Scene_1.hpp"
using namespace Dawn;
DawnGame::DawnGame(DawnHost *host) :
host(host),
renderManager(this),
inputManager(this),
localeManager(this),
saveManager(this),
audioManager(this)
{
}
int32_t DawnGame::init() {
this->assetManager.init();
this->localeManager.init();
this->renderManager.init();
this->audioManager.init();
this->scene = new Scene_1(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);
if(this->scene != nullptr) this->scene->update();
this->renderManager.update();
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
}
void DawnGame::sceneCutover(Scene *scene) {
if(scene == nullptr) scene = this->scene;
this->sceneToCutTo = scene;
}

View File

@ -1,31 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "game/_DawnGame.hpp"
#include "scene/components/Components.hpp"
#include "save/PokerSaveManager.hpp"
namespace Dawn {
class DawnGame : public IDawnGame {
private:
Scene *sceneToCutTo = nullptr;
public:
DawnHost *host;
RenderManager renderManager;
AssetManager assetManager;
InputManager inputManager;
TimeManager timeManager;
LocaleManager localeManager;
PokerSaveManager saveManager;
AudioManager audioManager;
DawnGame(DawnHost *host);
int32_t init() override;
int32_t update(float_t delta) override;
void sceneCutover(Scene *scene) override;
};
}

View File

@ -1,15 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "input/InputManager.hpp"
#define dbind(n) ((inputbind_t)n)
#define INPUT_BIND_ACCEPT dbind(1)
#define INPUT_BIND_NEGATIVE_X dbind(2)
#define INPUT_BIND_POSITIVE_X dbind(3)
#define INPUT_BIND_NEGATIVE_Y dbind(4)
#define INPUT_BIND_POSITIVE_Y dbind(5)

View File

@ -1,6 +0,0 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
add_subdirectory(characters)

View File

@ -1,11 +0,0 @@
# 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
)

View File

@ -1,8 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "CharacterPrefab.hpp"
using namespace Dawn;

View File

@ -1,82 +0,0 @@
// 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 O>
class CharacterPrefab : public SceneItemPrefab<O> {
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<Asset*> prefabAssets(AssetManager *assMan) {
return std::vector<Asset*>{
assMan->get<TextureAsset>(O::getCharacterTexture()),
assMan->get<TilesetAsset>(O::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<O>(s, i) {}
void prefabInit(AssetManager *man) override {
characterTexture = man->get<TextureAsset>(O::getCharacterTexture());
characterTileset = man->get<TilesetAsset>(O::getCharacterTileset());
// Emotions
auto emotion = this->defineAndGetInitialEmotion(man);
// Components
meshRenderer = this->template addComponent<MeshRenderer>();
meshHost = this->template addComponent<MeshHost>();
material = this->template addComponent<SimpleTexturedMaterial>();
material->texture = &characterTexture->texture;
vnCharacter = this->template addComponent<VisualNovelCharacter>();
vnCharacter->nameKey = O::getLanguagePrefix() + ".name";
animation = this->template addComponent<AnimationController>();
tiledSprite = this->template addComponent<TiledSprite>();
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->template addComponent<AudioSource>();
this->transform.setLocalPosition(glm::vec3(0, 0, 0));
}
};
}

View File

@ -1,32 +0,0 @@
// 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_death";
}
std::string DeathPrefab::getCharacterTileset() {
return "tileset_death";
}
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;
}

View File

@ -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 "prefabs/characters/CharacterPrefab.hpp"
namespace Dawn {
class DeathPrefab : public CharacterPrefab<DeathPrefab> {
protected:
struct VisualNovelCharacterEmotion defineAndGetInitialEmotion(
AssetManager *man
) override;
public:
static std::string getCharacterTexture();
static std::string getCharacterTileset();
static std::string getLanguagePrefix();
struct VisualNovelCharacterEmotion emotionHappy;
struct VisualNovelCharacterEmotion emotionConcerned;
struct VisualNovelCharacterEmotion emotionSurprised;
struct VisualNovelCharacterEmotion emotionUnset;
DeathPrefab(Scene *s, sceneitemid_t i) : CharacterPrefab(s,i) {}
};
}

View File

@ -1,68 +0,0 @@
// 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"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
namespace Dawn {
class PennyPrefab : public SceneItemPrefab<PennyPrefab> {
public:
VisualNovelCharacter *vnCharacter;
PokerPlayer *pokerPlayer;
SimpleTexturedMaterial *material;
struct VisualNovelCharacterEmotion emotionHappy;
struct VisualNovelCharacterEmotion emotionSurprised;
struct VisualNovelCharacterEmotion emotionConcerned;
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 {
// Assets
auto textureAsset = man->get<TextureAsset>("texture_penny");
auto tilesetAsset = man->get<TilesetAsset>("tileset_penny");
// Emotions
this->emotionHappy.tile = 0;
this->emotionSurprised.tile = 1;
this->emotionConcerned.tile = 2;
// Components
auto meshRenderer = this->addComponent<MeshRenderer>();
auto meshHost = this->addComponent<MeshHost>();
material = this->addComponent<SimpleTexturedMaterial>();
material->texture = &textureAsset->texture;
auto animation = this->addComponent<AnimationController>();
pokerPlayer = this->addComponent<PokerPlayer>();
vnCharacter = this->addComponent<VisualNovelCharacter>();
vnCharacter->nameKey = "character.penny.name";
auto tiledSprite = this->addComponent<TiledSprite>();
tiledSprite->setTilesetAndSize(&tilesetAsset->tileset);
tiledSprite->setTile(0);
this->transform.setLocalPosition(glm::vec3(0, 0, 0));
}
};
}

View File

@ -1,25 +0,0 @@
// 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(4, 4));
}
};
}

View File

@ -1,43 +0,0 @@
// 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_bizudp"));
vectorAppend(&assets, UIBorderPrefab::getRequiredAssets(man));
return assets;
}
static void prefabApply(AssetManager *man, VisualNovelTextbox *textbox) {
auto assetFont = man->get<TrueTypeAsset>("truetype_bizudp");
UIBorderPrefab::apply(&textbox->border);
textbox->setFont(&assetFont->font);
textbox->setFontSize(36.0f);
textbox->setLabelPadding(glm::vec2(2, 2));
textbox->label.textColor = COLOR_WHITE;
textbox->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_END,
glm::vec4(
0,
(assetFont->font.getLineHeight(textbox->getFontSize()) * 4) +
(textbox->border.getBorderSize().y * 2.0f) +
(textbox->getLabelPadding().y * 2.0f),
0, 0
),
0.0f
);
}
};
}

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
PokerSaveManager.cpp
)

View File

@ -1,28 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "PokerSaveManager.hpp"
using namespace Dawn;
PokerSaveManager::PokerSaveManager(DawnGame *game) : SaveManager(game) {
}
bool_t PokerSaveManager::validateSave(struct SaveFile raw) {
if(!raw.has(POKER_SAVE_KEY_EXAMPLE)) return true;
this->currentSave.copy(raw, POKER_SAVE_KEY_EXAMPLE);
return false;
}
void PokerSaveManager::setExample(int32_t val) {
savedata_t value;
value.i32 = val;
this->currentSave.set(POKER_SAVE_KEY_EXAMPLE, value);
}
int32_t PokerSaveManager::getExample() {
return this->currentSave.get(POKER_SAVE_KEY_EXAMPLE).i32;
}

View File

@ -1,22 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "save/SaveManager.hpp"
#define POKER_SAVE_KEY_EXAMPLE "poker.example"
namespace Dawn {
class PokerSaveManager : public SaveManager {
protected:
virtual bool_t validateSave(struct SaveFile raw) override;
public:
PokerSaveManager(DawnGame *game);
void setExample(int32_t value);
int32_t getExample();
};
}

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
PokerVNScene.cpp
)

View File

@ -1,39 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "PokerVNScene.hpp"
using namespace Dawn;
PokerVNScene::PokerVNScene(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> PokerVNScene::getRequiredAssets() {
auto assMan = &this->game->assetManager;
std::vector<Asset*> assets;
vectorAppend(&assets, SimpleVNScene::getRequiredAssets());
vectorAppend(&assets, PokerPlayerDisplay::getAssets(assMan));
return assets;
}
void PokerVNScene::vnStage() {
auto pokerGameItem = this->createSceneItem();
this->pokerGame = pokerGameItem->addComponent<PokerGame>();
this->pokerPlayers = this->getPokerPlayers();
auto it = this->pokerPlayers.begin();
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);
++it;
++i;
}
}

View File

@ -1,39 +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"
#include "poker/PokerGame.hpp"
#include "visualnovel/events/PokerBetLoopEvent.hpp"
#include "visualnovel/events/PokerInitialEvent.hpp"
#include "ui/PokerPlayerDisplay.hpp"
namespace Dawn {
class PokerVNScene : public SimpleVNScene {
protected:
void vnStage() override;
std::vector<Asset*> getRequiredAssets() override;
/**
* Returns the Poker Players that are in this poker scene.
*
* @return List of Poker Players.
*/
virtual std::vector<PokerPlayer*> getPokerPlayers() = 0;
public:
PokerGame *pokerGame;
std::vector<PokerPlayer*> pokerPlayers;
std::map<PokerPlayer*, PokerPlayerDisplay*> pokerPlayerDisplays;
/**
* 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.
*/
PokerVNScene(DawnGame *game);
};
}

View File

@ -1,45 +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"
#include "scenes/Scene_11.hpp"
namespace Dawn {
class Scene_10 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_11(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_10(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.10.1"))
->then(new VisualNovelCallbackEvent<Scene_10>(vnManager, this, &Scene_10::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,45 +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"
#include "scenes/Scene_12.hpp"
namespace Dawn {
class Scene_11 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_12(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_11(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.11.1"))
->then(new VisualNovelCallbackEvent<Scene_11>(vnManager, this, &Scene_11::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,66 +0,0 @@
// 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_13.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 Scene_13(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), 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>()
};
}
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;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, "scene.12.1");
start
->then(new VisualNovelCallbackEvent<Scene_12>(vnManager, this, &Scene_12::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,45 +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"
#include "scenes/Scene_14.hpp"
namespace Dawn {
class Scene_13 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_14(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_13(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.13.1"))
->then(new VisualNovelCallbackEvent<Scene_13>(vnManager, this, &Scene_13::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,45 +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"
#include "scenes/Scene_15.hpp"
namespace Dawn {
class Scene_14 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_15(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_14(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.14.1"))
->then(new VisualNovelCallbackEvent<Scene_14>(vnManager, this, &Scene_14::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,45 +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"
#include "scenes/Scene_16.hpp"
namespace Dawn {
class Scene_15 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_16(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_15(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.15.1"))
->then(new VisualNovelCallbackEvent<Scene_15>(vnManager, this, &Scene_15::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,45 +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"
#include "scenes/Scene_17.hpp"
namespace Dawn {
class Scene_16 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_17(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_16(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.16.1"))
->then(new VisualNovelCallbackEvent<Scene_16>(vnManager, this, &Scene_16::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,66 +0,0 @@
// 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_18.hpp"
namespace Dawn {
class Scene_17 : 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 Scene_18(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), 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>()
};
}
public:
Scene_17(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;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, "scene.17.1");
start
->then(new VisualNovelCallbackEvent<Scene_17>(vnManager, this, &Scene_17::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,37 +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_18 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
}
public:
Scene_18(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.18.1"))
->then(new VisualNovelCallbackEvent<Scene_18>(vnManager, this, &Scene_18::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,46 +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"
#include "scenes/Scene_3.hpp"
namespace Dawn {
class Scene_2 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_3(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_2(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.2.1"))
->then(new VisualNovelCallbackEvent<Scene_2>(vnManager, this, &Scene_2::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,46 +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"
#include "scenes/Scene_4.hpp"
namespace Dawn {
class Scene_3 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_4(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_3(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.3.1"))
->then(new VisualNovelCallbackEvent<Scene_3>(vnManager, this, &Scene_3::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,66 +0,0 @@
// 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 Scene_5(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), 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>()
};
}
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;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, "scene.4.1");
start
->then(new VisualNovelCallbackEvent<Scene_4>(vnManager, this, &Scene_4::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,46 +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"
#include "scenes/Scene_6.hpp"
namespace Dawn {
class Scene_5 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_6(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_5(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.5.1"))
->then(new VisualNovelCallbackEvent<Scene_5>(vnManager, this, &Scene_5::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,46 +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"
#include "scenes/Scene_7.hpp"
namespace Dawn {
class Scene_6 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_7(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_6(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.6.1"))
->then(new VisualNovelCallbackEvent<Scene_6>(vnManager, this, &Scene_6::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,45 +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"
#include "scenes/Scene_8.hpp"
namespace Dawn {
class Scene_7 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_8(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_7(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.7.1"))
->then(new VisualNovelCallbackEvent<Scene_7>(vnManager, this, &Scene_7::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,66 +0,0 @@
// 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 Scene_9(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), 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>()
};
}
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;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelTextboxEvent(vnManager, "scene.8.1");
start
->then(new VisualNovelCallbackEvent<Scene_8>(vnManager, this, &Scene_8::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,45 +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"
#include "scenes/Scene_10.hpp"
namespace Dawn {
class Scene_9 : public SimpleVNScene {
protected:
void vnStage() override {
}
void onSceneEnded() {
auto scene = new Scene_10(this->game);
game->assetManager.queueSwap(
scene->getRequiredAssets(), this->getRequiredAssets()
);
game->assetManager.syncLoad();
scene->stage();
this->game->sceneCutover(scene);
}
public:
Scene_9(DawnGame *game) : SimpleVNScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
std::vector<Asset*> assets = SimpleVNScene::getRequiredAssets();
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto start = new VisualNovelPauseEvent(vnManager, 0.1f);
start
->then(new VisualNovelTextboxEvent(vnManager, "scene.9.1"))
->then(new VisualNovelCallbackEvent<Scene_9>(vnManager, this, &Scene_9::onSceneEnded))
;
return start;
}
};
}

View File

@ -1,57 +0,0 @@
// Copyright (c) 2022 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 TestScene : 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();
}
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>()
};
}
public:
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, PennyPrefab::getRequiredAssets(assMan));
assets.push_back(assMan->get<TextureAsset>("texture_tavern_night"));
return assets;
}
IVisualNovelEvent * getVNEvent() override {
auto texture = this->game->assetManager.get<TextureAsset>("texture_tavern_night");
auto start = new VisualNovelChangeSimpleBackgroundEvent(
vnManager, &texture->texture
);
start->then(new VisualNovelTextboxEvent(vnManager, penny->getComponent<VisualNovelCharacter>(), "1234"));
return start;
}
};
}

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
PokerPlayerDisplay.cpp
)

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 "ui/UIBorder.hpp"
#include "asset/assets/TextureAsset.hpp"
#include "game/DawnGame.hpp"
namespace Dawn {
class PokerGameBorder {
public:
static std::vector<Asset*> getAssets(AssetManager *man) {
return std::vector<Asset*>{
man->get<TextureAsset>("texture_test")
};
}
static void apply(UIBorder *border) {
auto text = border->getGame()->assetManager.get<TextureAsset>("texture_test");
border->texture = &text->texture;
border->setBorderSize(glm::vec2(16, 16));
}
static UIBorder * create(UICanvas *canvas) {
auto border = canvas->addElement<UIBorder>();
PokerGameBorder::apply(border);
return border;
}
};
}

View File

@ -1,46 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "ui/PokerGameBorder.hpp"
#include "visualnovel/ui/VisualNovelTextbox.hpp"
#include "asset/assets/TrueTypeAsset.hpp"
namespace Dawn {
class PokerGameTextbox {
public:
static std::vector<Asset*> getAssets(AssetManager *man) {
assertNotNull(man);
std::vector<Asset*> assets;
vectorAppend(&assets, &PokerGameBorder::getAssets(man));
assets.push_back(man->get<TrueTypeAsset>("truetype_ark"));
return assets;
}
static void apply(VisualNovelTextbox *textbox) {
assertNotNull(textbox);
auto assetFont = textbox->getGame()->assetManager.get<TrueTypeAsset>("truetype_ark");
PokerGameBorder::apply(&textbox->border);
textbox->setFont(&assetFont->font);
textbox->setFontSize(40);
textbox->setLabelPadding(glm::vec2(10, 8));
}
static VisualNovelTextbox * create(UICanvas *canvas) {
assertNotNull(canvas);
auto textbox = canvas->addElement<VisualNovelTextbox>();
PokerGameTextbox::apply(textbox);
textbox->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_END,
glm::vec4(0, 238, 0, 0),
0.0f
);
return textbox;
}
};
}

View File

@ -1,101 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "PokerPlayerDisplay.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
PokerPlayerDisplay::PokerPlayerDisplay(UICanvas *canvas) :
UIEmpty(canvas),
labelName(canvas),
labelChips(canvas),
borderInner(canvas),
border(canvas),
animChips(&animChipsValue)
{
this->font = getGame()->assetManager.get<TrueTypeAsset>("truetype_ark");
// Border
this->addChild(&this->border);
PokerGameBorder::apply(&this->border);
this->border.setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH,
glm::vec4(0, 0, 0, 0),
0.0f
);
// Border Inner
this->addChild(&this->borderInner);
this->borderInner.setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH,
glm::vec4(this->border.getBorderSize(), this->border.getBorderSize()),
0.0f
);
// Player Name
this->borderInner.addChild(&this->labelName);
this->labelName.setText("undefined");
this->labelName.setFont(&this->font->font);
this->labelName.setFontSize(40);
this->labelName.setTransform(
UI_COMPONENT_ALIGN_START, UI_COMPONENT_ALIGN_START,
glm::vec4(0, 0, 0, 0),
0.0f
);
// Chips label
this->borderInner.addChild(&this->labelChips);
this->labelChips.setFont(&this->font->font);
this->labelChips.setFontSize(40);
this->labelChips.setTransform(
UI_COMPONENT_ALIGN_START, UI_COMPONENT_ALIGN_START,
glm::vec4(0, this->labelName.getContentHeight(), 0, 0),
0.0f
);
// Anim
this->animChips.easing = &easeOutQuart;
// Events
getScene()->eventSceneUnpausedUpdate.addListener(this, &PokerPlayerDisplay::onSceneUpdate);
}
void PokerPlayerDisplay::setPlayer(PokerPlayer *player) {
assertNull(this->player);
this->player = player;
player->eventChipsChanged.addListener(this, &PokerPlayerDisplay::onPlayerChipsChanged);
this->labelName.setText("undefined");
this->animChips.clear();
this->animChips.restart();
this->animChipsValue = player->chips;
this->updatePositions();
}
void PokerPlayerDisplay::onSceneUpdate() {
this->animChips.tick(getGame()->timeManager.delta);
// std::stringstream stream;
// stream.precision(0);
// stream << "$";
// stream << this->animChipsValue;
this->labelChips.setText("undefined");
}
void PokerPlayerDisplay::onPlayerChipsChanged() {
std::cout << "Chips" << player->chips << std::endl;
this->animChips.clear();
this->animChips.addKeyframe(0.0f, this->animChipsValue);
this->animChips.addKeyframe(1.0f, this->player->chips);
this->animChips.restart();
}
PokerPlayerDisplay::~PokerPlayerDisplay() {
this->canvas->getScene()->eventSceneUnpausedUpdate.removeListener(this, &PokerPlayerDisplay::onSceneUpdate);
}

View File

@ -1,48 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "ui/UILabel.hpp"
#include "ui/UIEmpty.hpp"
#include "ui/UIBorder.hpp"
#include "poker/PokerPlayer.hpp"
#include "asset/AssetManager.hpp"
#include "asset/assets/TrueTypeAsset.hpp"
#include "display/animation/SimpleAnimation.hpp"
#include "ui/PokerGameBorder.hpp"
namespace Dawn {
class PokerPlayerDisplay : public UIEmpty {
private:
SimpleAnimation<int32_t> animChips;
int32_t animChipsValue;
protected:
PokerPlayer *player = nullptr;
UILabel labelName;
UILabel labelChips;
UIEmpty borderInner;
UIBorder border;
TrueTypeAsset *font;
void onPlayerChipsChanged();
void onSceneUpdate();
public:
static std::vector<Asset*> getAssets(AssetManager *assMan) {
std::vector<Asset*> assets;
assets = PokerGameBorder::getAssets(assMan);
assets.push_back(assMan->get<TrueTypeAsset>("truetype_alice"));
return assets;
}
PokerPlayerDisplay(UICanvas *canvas);
void setPlayer(PokerPlayer *player);
~PokerPlayerDisplay();
};
}

View File

@ -1,13 +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
)
# Subdirs
add_subdirectory(events)

Some files were not shown because too many files have changed in this diff Show More