Added IF Event Parsing

This commit is contained in:
2023-04-25 23:06:23 -07:00
parent aec17f614e
commit e1f615c774
9 changed files with 121 additions and 13 deletions

View File

@ -16,4 +16,5 @@ target_sources(vnscenetool
VNGoToMarkerEventParser.cpp
VNChoiceEventParser.cpp
VNChoiceSetEventParser.cpp
VNIfEventParser.cpp
)

View File

@ -0,0 +1,30 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VNIfEventParser.hpp"
#include "VNSceneEventsParser.hpp"
using namespace Dawn;
std::vector<std::string> VNIfEventParser::getRequiredAttributes() {
return { "key", "value" };
}
std::map<std::string, std::string> VNIfEventParser::getOptionalAttributes() {
return {};
}
int32_t VNIfEventParser::onParse(
Xml *node,
std::map<std::string, std::string> values,
struct VNIfEvent *out,
std::string *error
) {
//Get the key and value
out->key = values["key"];
out->value = values["value"];
return (VNSceneEventsParser()).parse(node, &out->events, error);
}

View File

@ -0,0 +1,23 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "util/XmlParser.hpp"
namespace Dawn {
struct VNIfEvent;
class VNIfEventParser : public XmlParser<struct VNIfEvent> {
protected:
std::vector<std::string> getRequiredAttributes() override;
std::map<std::string, std::string> getOptionalAttributes() override;
int32_t onParse(
Xml *node,
std::map<std::string, std::string> values,
struct VNIfEvent *out,
std::string *error
) override;
};
}

View File

@ -75,6 +75,11 @@ int32_t VNSceneEventsParser::onParse(
ret = (VNChoiceSetEventParser()).parse(child, &event.choiceSet, error);
if(ret != 0) return ret;
} else if(child->node == "if") {
event.type = VN_SCENE_EVENT_TYPE_IF;
ret = (VNIfEventParser()).parse(child, &event.ifEvent, error);
if(ret != 0) return ret;
} else {
*error = "Unknown child node '" + child->node + "'";
return -1;

View File

@ -13,6 +13,7 @@
#include "VNGoToMarkerEventParser.hpp"
#include "VNChoiceEventParser.hpp"
#include "VNChoiceSetEventParser.hpp"
#include "VNIfEventParser.hpp"
namespace Dawn {
struct VNSceneEvent;
@ -30,12 +31,19 @@ namespace Dawn {
VN_SCENE_EVENT_TYPE_MARKER,
VN_SCENE_EVENT_TYPE_GOTO_MARKER,
VN_SCENE_EVENT_TYPE_CHOICES,
VN_SCENE_EVENT_TYPE_CHOICE_SET
VN_SCENE_EVENT_TYPE_CHOICE_SET,
VN_SCENE_EVENT_TYPE_IF
};
struct VNParallelEvent {
struct VNSceneEventList events;
};
struct VNIfEvent {
std::string key;
std::string value;
struct VNSceneEventList events;
};
struct VNSceneEvent {
enum VNSceneEventType type;
@ -49,6 +57,7 @@ namespace Dawn {
struct VNGoToMarkerEvent gotoMarker;
struct VNChoiceEvent choices;
struct VNChoiceSetEvent choiceSet;
struct VNIfEvent ifEvent;
};
class VNSceneEventsParser : public XmlParser<struct VNSceneEventList> {