Added IF Event Parsing
This commit is contained in:
@ -10,7 +10,6 @@ namespace Dawn {
|
||||
class VNDummyEvent : public VNEvent {
|
||||
protected:
|
||||
void onStart() override {
|
||||
std::cout << "Dummy VN Event" << std::endl;
|
||||
this->next();
|
||||
}
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ void VNEvent::next() {
|
||||
|
||||
this->end();
|
||||
auto next = this->getNextEvent();
|
||||
this->manager->currentEvent = next;
|
||||
this->parent->currentEvent = next;
|
||||
if(next != nullptr) next->start(this->parent, this);
|
||||
}
|
||||
|
||||
|
@ -7,22 +7,29 @@
|
||||
#include "VNEvent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class VNIfEvent : public VNEvent {
|
||||
class VNIfEvent :
|
||||
public VNEvent,
|
||||
public IVNEventParent
|
||||
{
|
||||
public:
|
||||
std::string key;
|
||||
std::string value;
|
||||
VNEvent *ifTrue = nullptr;
|
||||
|
||||
VNEvent * getNextEvent() override {
|
||||
if(this->manager.getFlag(key) == value) {
|
||||
return ifTrue;
|
||||
}
|
||||
return VNEvent::getNextEvent();
|
||||
}
|
||||
VNEvent *ifEnd = nullptr;
|
||||
|
||||
protected:
|
||||
void onStart() override {
|
||||
this->next();
|
||||
assertNotNull(ifTrue);
|
||||
assertNotNull(ifEnd);
|
||||
|
||||
if(this->manager->getFlag(key) == value) {
|
||||
useEvent([&]{
|
||||
if(ifEnd->getNextEvent() == nullptr) this->next();
|
||||
}, ifEnd->eventFinished);
|
||||
ifTrue->start(this, nullptr);
|
||||
} else {
|
||||
this->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user