About to break VN Scene Parser

This commit is contained in:
2023-05-17 21:52:24 -07:00
parent 3b0ef97f89
commit 5a60c10049
11 changed files with 34 additions and 15 deletions

View File

@@ -8,6 +8,7 @@ set(D ${CMAKE_CURRENT_LIST_DIR})
set(
DAWN_TOOL_SOURCES
${DAWN_TOOL_SOURCES}
${D}/SceneParser.cpp
${D}/SceneItemParser.cpp
${D}/SceneAssetParser.cpp
${D}/SceneItemComponentParser.cpp

View File

@@ -0,0 +1,49 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "SceneParser.hpp"
using namespace Dawn;
std::vector<std::string> SceneParser::getRequiredAttributes() {
return { "name" };
}
std::map<std::string, std::string> SceneParser::getOptionalAttributes() {
return {
{ "extend", "" }
};
}
int32_t SceneParser::onParse(
Xml *node,
std::map<std::string, std::string> values,
struct Scene *out,
std::string *error
) {
int32_t ret;
//Create the scene item
out->name = values["name"];
out->extend = values["extend"];
//Parse the children
auto itChildren = node->children.begin();
while(itChildren != node->children.end()) {
Xml *child = *itChildren;
if(child->node == "item") {
struct SceneItem item;
item.registry = out->registry;
ret = (SceneItemParser()).parse(child, &item, error);
if(ret != 0) return 1;
out->items.push_back(item);
}
++itChildren;
}
return 0;
}

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 "util/parser/SceneItemParser.hpp"
namespace Dawn {
struct Scene {
std::string name;
std::string extend;
std::vector<struct SceneItem> items;
struct SceneItemComponentRegistry *registry;
};
class SceneParser : public XmlParser<struct Scene> {
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 Scene *out,
std::string *error
) override;
};
}