89 lines
2.6 KiB
C++
89 lines
2.6 KiB
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "VNSceneEventsParser.hpp"
|
|
#include "VNParallelEventParser.hpp"
|
|
|
|
using namespace Dawn;
|
|
|
|
std::vector<std::string> VNSceneEventsParser::getRequiredAttributes() {
|
|
return { };
|
|
}
|
|
|
|
std::map<std::string, std::string> VNSceneEventsParser::getOptionalAttributes() {
|
|
return { };
|
|
}
|
|
|
|
int32_t VNSceneEventsParser::onParse(
|
|
Xml *node,
|
|
std::map<std::string, std::string> values,
|
|
struct VNSceneEventList *out,
|
|
std::string *error
|
|
) {
|
|
int32_t ret;
|
|
|
|
auto itChildren = node->children.begin();
|
|
while(itChildren != node->children.end()) {
|
|
Xml *child = *itChildren;
|
|
struct VNSceneEvent event;
|
|
|
|
// Parse event(s)
|
|
if(child->node == "text") {
|
|
event.type = VN_SCENE_EVENT_TYPE_TEXT;
|
|
ret = (VNTextEventParser()).parse(child, &event.text, error);
|
|
if(ret != 0) return ret;
|
|
|
|
} else if(child->node == "position") {
|
|
event.type = VN_SCENE_EVENT_TYPE_POSITION;
|
|
ret = (VNPositionEventParser()).parse(child, &event.position, error);
|
|
if(ret != 0) return ret;
|
|
|
|
} else if(child->node == "set") {
|
|
event.type = VN_SCENE_EVENT_TYPE_SET;
|
|
ret = (VNSetEventParser()).parse(child, &event.set, error);
|
|
if(ret != 0) return ret;
|
|
|
|
} else if(child->node == "wait") {
|
|
event.type = VN_SCENE_EVENT_TYPE_WAIT;
|
|
ret = (VNWaitEventParser()).parse(child, &event.wait, error);
|
|
if(ret != 0) return ret;
|
|
|
|
} else if(child->node == "parallel") {
|
|
event.type = VN_SCENE_EVENT_TYPE_PARALLEL;
|
|
ret = (VNParallelEventParser()).parse(child, &event.parallel, error);
|
|
if(ret != 0) return ret;
|
|
|
|
} else if(child->node == "marker") {
|
|
event.type = VN_SCENE_EVENT_TYPE_MARKER;
|
|
ret = (VNMarkerParser()).parse(child, &event.marker, error);
|
|
if(ret != 0) return ret;
|
|
|
|
} else if(child->node == "goto-marker") {
|
|
event.type = VN_SCENE_EVENT_TYPE_GOTO_MARKER;
|
|
ret = (VNGoToMarkerEventParser()).parse(child, &event.gotoMarker, error);
|
|
if(ret != 0) return ret;
|
|
|
|
} else if(child->node == "choices") {
|
|
event.type = VN_SCENE_EVENT_TYPE_CHOICES;
|
|
ret = (VNChoicesEventParser()).parse(child, &event.choices, error);
|
|
if(ret != 0) return ret;
|
|
|
|
} else if(child->node == "choice-set") {
|
|
event.type = VN_SCENE_EVENT_TYPE_CHOICE_SET;
|
|
ret = (VNChoiceSetEventParser()).parse(child, &event.choiceSet, error);
|
|
if(ret != 0) return ret;
|
|
|
|
} else {
|
|
*error = "Unknown child node '" + child->node + "'";
|
|
return -1;
|
|
}
|
|
|
|
if(ret != 0) return ret;
|
|
out->events.push_back(event);
|
|
itChildren++;
|
|
}
|
|
|
|
return 0;
|
|
} |