Starting new VN Structure

This commit is contained in:
2023-04-18 09:55:11 -07:00
parent 26efdfe314
commit 1c21c15261
77 changed files with 929 additions and 27 deletions

View 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
)

View 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;
}
}

View 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();
};
}

View 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() {
}

View 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);
};
}