Just breaking stuff
This commit is contained in:
@ -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
|
||||
|
@ -5,4 +5,8 @@
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(poker)
|
||||
add_subdirectory(tictactoe)
|
||||
add_subdirectory(tictactoe)
|
||||
|
||||
if(DAWN_VISUAL_NOVEL)
|
||||
add_subdirectory(visualnovel)
|
||||
endif()
|
@ -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;
|
||||
}
|
@ -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;
|
||||
};
|
||||
}
|
@ -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
|
||||
);
|
||||
}
|
@ -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);
|
||||
};
|
||||
}
|
@ -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);
|
||||
}
|
@ -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;
|
||||
};
|
||||
}
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
@ -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() {
|
||||
|
||||
}
|
@ -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
|
||||
);
|
||||
};
|
||||
}
|
@ -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() {
|
||||
}
|
@ -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);
|
||||
};
|
||||
}
|
@ -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
|
||||
);
|
||||
}
|
@ -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
|
||||
);
|
||||
};
|
||||
}
|
@ -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() {
|
||||
|
||||
}
|
@ -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
|
||||
);
|
||||
};
|
||||
}
|
@ -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
|
||||
)
|
@ -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() {
|
||||
|
||||
}
|
@ -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);
|
||||
};
|
||||
}
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
@ -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
|
||||
)
|
@ -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);
|
||||
}
|
||||
}
|
@ -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
|
||||
);
|
||||
};
|
||||
}
|
@ -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);
|
||||
}
|
@ -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
|
||||
);
|
||||
};
|
||||
}
|
@ -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
|
||||
)
|
@ -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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
};
|
||||
}
|
@ -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() {
|
||||
|
||||
}
|
@ -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);
|
||||
};
|
||||
}
|
@ -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
|
||||
)
|
@ -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
|
||||
)
|
@ -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;
|
||||
}
|
@ -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);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user