Dawn/src/dawntools/vnscenetool/VNSceneEventsParser.cpp

55 lines
1.3 KiB
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VNSceneEventsParser.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") {
VNTextEventParser parser;
event.type = VN_SCENE_EVENT_TYPE_TEXT;
ret = (VNTextEventParser()).parse(child, &event.text, error);
if(ret != 0) return ret;
} else if(child->node == "position") {
VNPositionEventParser parser;
event.type = VN_SCENE_EVENT_TYPE_POSITION;
ret = (VNPositionEventParser()).parse(child, &event.position, 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;
}