Starting new VN Structure
This commit is contained in:
18
archive/visualnovel/events/CMakeLists.txt
Normal file
18
archive/visualnovel/events/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
||||
# 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
|
||||
VisualNovelFadeEvent.cpp
|
||||
VisualNovelTextboxEvent.cpp
|
||||
VisualNovelChangeSimpleBackgroundEvent.cpp
|
||||
VisualNovelEmptyEvent.cpp
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(animation)
|
||||
add_subdirectory(characters)
|
||||
add_subdirectory(timing)
|
38
archive/visualnovel/events/VisualNovelCallbackEvent.hpp
Normal file
38
archive/visualnovel/events/VisualNovelCallbackEvent.hpp
Normal file
@ -0,0 +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;
|
||||
}
|
||||
};
|
||||
}
|
@ -0,0 +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() {
|
||||
|
||||
}
|
@ -0,0 +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
|
||||
);
|
||||
};
|
||||
}
|
25
archive/visualnovel/events/VisualNovelEmptyEvent.cpp
Normal file
25
archive/visualnovel/events/VisualNovelEmptyEvent.cpp
Normal file
@ -0,0 +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() {
|
||||
}
|
19
archive/visualnovel/events/VisualNovelEmptyEvent.hpp
Normal file
19
archive/visualnovel/events/VisualNovelEmptyEvent.hpp
Normal file
@ -0,0 +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);
|
||||
};
|
||||
}
|
35
archive/visualnovel/events/VisualNovelFadeEvent.cpp
Normal file
35
archive/visualnovel/events/VisualNovelFadeEvent.cpp
Normal file
@ -0,0 +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
|
||||
);
|
||||
}
|
36
archive/visualnovel/events/VisualNovelFadeEvent.hpp
Normal file
36
archive/visualnovel/events/VisualNovelFadeEvent.hpp
Normal file
@ -0,0 +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
|
||||
);
|
||||
};
|
||||
}
|
59
archive/visualnovel/events/VisualNovelTextboxEvent.cpp
Normal file
59
archive/visualnovel/events/VisualNovelTextboxEvent.cpp
Normal file
@ -0,0 +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() {
|
||||
|
||||
}
|
42
archive/visualnovel/events/VisualNovelTextboxEvent.hpp
Normal file
42
archive/visualnovel/events/VisualNovelTextboxEvent.hpp
Normal file
@ -0,0 +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
|
||||
);
|
||||
};
|
||||
}
|
10
archive/visualnovel/events/animation/CMakeLists.txt
Normal file
10
archive/visualnovel/events/animation/CMakeLists.txt
Normal file
@ -0,0 +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
|
||||
)
|
@ -0,0 +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() {
|
||||
|
||||
}
|
@ -0,0 +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);
|
||||
};
|
||||
}
|
@ -0,0 +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;
|
||||
}
|
||||
};
|
||||
}
|
@ -0,0 +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;
|
||||
}
|
||||
};
|
||||
}
|
11
archive/visualnovel/events/characters/CMakeLists.txt
Normal file
11
archive/visualnovel/events/characters/CMakeLists.txt
Normal file
@ -0,0 +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
|
||||
)
|
@ -0,0 +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);
|
||||
}
|
||||
}
|
@ -0,0 +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
|
||||
);
|
||||
};
|
||||
}
|
@ -0,0 +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);
|
||||
}
|
@ -0,0 +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
|
||||
);
|
||||
};
|
||||
}
|
11
archive/visualnovel/events/timing/CMakeLists.txt
Normal file
11
archive/visualnovel/events/timing/CMakeLists.txt
Normal file
@ -0,0 +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
|
||||
)
|
66
archive/visualnovel/events/timing/VisualNovelBatchEvent.cpp
Normal file
66
archive/visualnovel/events/timing/VisualNovelBatchEvent.cpp
Normal file
@ -0,0 +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;
|
||||
}
|
||||
}
|
27
archive/visualnovel/events/timing/VisualNovelBatchEvent.hpp
Normal file
27
archive/visualnovel/events/timing/VisualNovelBatchEvent.hpp
Normal file
@ -0,0 +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();
|
||||
};
|
||||
}
|
28
archive/visualnovel/events/timing/VisualNovelPauseEvent.cpp
Normal file
28
archive/visualnovel/events/timing/VisualNovelPauseEvent.cpp
Normal file
@ -0,0 +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() {
|
||||
|
||||
}
|
28
archive/visualnovel/events/timing/VisualNovelPauseEvent.hpp
Normal file
28
archive/visualnovel/events/timing/VisualNovelPauseEvent.hpp
Normal file
@ -0,0 +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);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user