Dawn/src/dawn/visualnovel/events/VisualNovelFadeEvent.hpp
2022-12-12 10:55:02 -08:00

46 lines
1.3 KiB
C++

// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "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 {
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
);
}
public:
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;
}
};
}