Progress
This commit is contained in:
@ -71,11 +71,9 @@ void TiledSprite::setSize(glm::vec2 size) {
|
||||
}
|
||||
|
||||
std::vector<SceneItemComponent*> TiledSprite::getDependencies() {
|
||||
this->renderer = this->item->getComponent<MeshRenderer>();
|
||||
this->host = this->item->getComponent<MeshHost>();
|
||||
|
||||
return std::vector<SceneItemComponent*>{
|
||||
this->renderer,
|
||||
this->host
|
||||
};
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
namespace Dawn {
|
||||
class TiledSprite : public SceneItemComponent {
|
||||
protected:
|
||||
MeshRenderer *renderer = nullptr;
|
||||
MeshHost *host = nullptr;
|
||||
Tileset *tileset = nullptr;
|
||||
flag_t flipState = TILED_SPRITE_FLIP_Y;
|
||||
|
@ -26,7 +26,7 @@ void UISprite::drawSelf(UIShader *uiShader, glm::mat4 selfTransform) {
|
||||
uiShader->setUITexture(nullptr);
|
||||
uiShader->setUIModel(selfTransform);
|
||||
uiShader->setUIModel(glm::mat4(1.0f));
|
||||
uiShader->setUIColor(COLOR_WHITE);
|
||||
uiShader->setUIColor(this->color);
|
||||
uiShader->setUITexture(this->texture);
|
||||
|
||||
this->mesh.draw(MESH_DRAW_MODE_TRIANGLES, 0, -1);
|
||||
|
@ -16,7 +16,8 @@ namespace Dawn {
|
||||
|
||||
public:
|
||||
Mesh mesh;
|
||||
Texture *texture;
|
||||
struct Color color = COLOR_WHITE;
|
||||
Texture *texture = nullptr;
|
||||
|
||||
/**
|
||||
* UI Sprite Constructor, use the UIElement / UIComponent create instead.
|
||||
|
@ -10,8 +10,6 @@ using namespace Dawn;
|
||||
VisualNovelManager::VisualNovelManager(SceneItem *item) :
|
||||
SceneItemComponent(item)
|
||||
{
|
||||
this->uiCanvas = nullptr;
|
||||
this->textBox = nullptr;
|
||||
}
|
||||
|
||||
void VisualNovelManager::onStart() {
|
||||
@ -21,7 +19,10 @@ void VisualNovelManager::onStart() {
|
||||
assertNotNull(this->uiCanvas);
|
||||
|
||||
this->textBox = this->uiCanvas->findElement<VisualNovelTextbox>();
|
||||
this->fader = this->uiCanvas->findElement<VisualNovelFader>();
|
||||
|
||||
assertNotNull(this->textBox);
|
||||
assertNotNull(this->fader);
|
||||
|
||||
this->getScene()->eventSceneUnpausedUpdate.addListener(this, &VisualNovelManager::onUnpausedUpdate);
|
||||
}
|
||||
|
@ -6,22 +6,23 @@
|
||||
#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:
|
||||
UICanvas *uiCanvas;
|
||||
IVisualNovelEvent* currentEvent = nullptr;
|
||||
|
||||
public:
|
||||
UICanvas *uiCanvas = nullptr;
|
||||
VisualNovelTextbox *textBox = nullptr;
|
||||
VisualNovelFader *fader = nullptr;
|
||||
|
||||
/** Event listener for unpaused scene updates. */
|
||||
void onUnpausedUpdate();
|
||||
|
||||
|
||||
VisualNovelTextbox *textBox;
|
||||
/**
|
||||
* Constructs a visual novel manager, scene item component.
|
||||
*
|
||||
|
34
src/dawn/visualnovel/events/VisualNovelAnimationEvent.hpp
Normal file
34
src/dawn/visualnovel/events/VisualNovelAnimationEvent.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
// 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:
|
||||
void onStart(IVisualNovelEvent *previous) override {
|
||||
|
||||
}
|
||||
|
||||
bool_t onUpdate() override {
|
||||
this->animation->tick(this->manager->getGame()->timeManager.delta);
|
||||
return this->animation->finished;
|
||||
}
|
||||
|
||||
void onEnd() override {
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
struct Animation *animation;
|
||||
|
||||
VisualNovelAnimationEvent(VisualNovelManager *manager) :
|
||||
IVisualNovelEvent(manager)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
46
src/dawn/visualnovel/events/VisualNovelFadeEvent.hpp
Normal file
46
src/dawn/visualnovel/events/VisualNovelFadeEvent.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
// 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;
|
||||
}
|
||||
};
|
||||
}
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
29
src/dawn/visualnovel/ui/VisualNovelFader.hpp
Normal file
29
src/dawn/visualnovel/ui/VisualNovelFader.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
// 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:
|
||||
static 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
|
||||
);
|
||||
return item;
|
||||
}
|
||||
|
||||
VisualNovelFader(UICanvas *canvas) : UISprite(canvas) {
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user