About to break VN Scene Parser
This commit is contained in:
@@ -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
|
||||
|
49
src/dawntools/util/parser/SceneParser.cpp
Normal file
49
src/dawntools/util/parser/SceneParser.cpp
Normal 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;
|
||||
}
|
28
src/dawntools/util/parser/SceneParser.hpp
Normal file
28
src/dawntools/util/parser/SceneParser.hpp
Normal 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;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user