First real pass at VN Event Parsing

This commit is contained in:
2023-04-22 22:50:20 -07:00
parent 23d5e13178
commit d4b4267c51
28 changed files with 485 additions and 60 deletions

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "VNEvent.hpp"
namespace Dawn {
class VNChoiceEvent : public VNEvent {
public:
std::string text;
std::string key;
std::map<std::string, std::string> choices;
int32_t choice = 0;
protected:
void onStart() override {
choice = 0;
std::cout << "CHOICE: " << text << std::endl;
for(auto& choice : choices) {
std::cout << " " << choice.first << ": " << choice.second << std::endl;
}
useEvent([&](float_t delta) {
auto im = &getScene()->game->inputManager;
if(im->isPressed(INPUT_BIND_ACCEPT)) {
auto it = choices.begin();
std::advance(it, choice);
std::string choiceMade = it->first;
std::cout << "Choice made " << choiceMade << std::endl;
this->manager->setFlag(this->key, choiceMade);
this->next();
} else if(im->isPressed(INPUT_BIND_NEGATIVE_Y)) {
choice = mathClamp<int32_t>((choice - 1), 0, choices.size() - 1);
std::cout << "Current choice: state" << choice << std::endl;
} else if(im->isPressed(INPUT_BIND_POSITIVE_Y)) {
choice = mathClamp<int32_t>((choice + 1), 0, choices.size() - 1);
std::cout << "Current choice: state" << choice << std::endl;
}
}, getScene()->eventSceneUpdate);
}
};
}

View File

@@ -0,0 +1,21 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "VNEvent.hpp"
namespace Dawn {
class VNChoiceSetEvent : public VNEvent {
public:
std::string key;
std::string value;
protected:
void onStart() override {
this->manager->setFlag(this->key, this->value);
this->next();
}
};
}

View File

@@ -10,7 +10,7 @@ namespace Dawn {
class VNDummyEvent : public VNEvent {
protected:
void onStart() override {
std::cout << "Test" << std::endl;
std::cout << "Dummy VN Event" << std::endl;
this->next();
}
};

View File

@@ -0,0 +1,28 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "VNEvent.hpp"
namespace Dawn {
class VNIfEvent : public VNEvent {
public:
std::string key;
std::string value;
VNEvent *ifTrue = nullptr;
VNEvent * getNextEvent() override {
if(this->manager.getFlag(key) == value) {
return ifTrue;
}
return VNEvent::getNextEvent();
}
protected:
void onStart() override {
this->next();
}
}
}

View File

@@ -14,7 +14,13 @@ namespace Dawn {
protected:
void onStart() override {
std::cout << "TEXT: " << text << std::endl;
this->next();
useEvent([&](float_t delta) {
if(getScene()->game->inputManager.isPressed(INPUT_BIND_ACCEPT)) {
std::cout << "Text Advance" << std::endl;
this->next();
}
}, getScene()->eventSceneUpdate);
}
};
}