Prefab tool more-or-less done

This commit is contained in:
2023-03-22 21:44:31 -07:00
parent f32d6ba35c
commit b4a5913587
4 changed files with 264 additions and 3 deletions

View File

@ -6,8 +6,28 @@
#pragma once
#include "util/DawnTool.hpp"
#include "util/File.hpp"
#include "util/XmlParser.hpp"
#include "util/CodeGen.hpp"
namespace Dawn {
struct PrefabComponentParserRuleset {
std::string include;
std::map<std::string, std::function<std::string(std::string)>> optional;
};
struct PrefabComponent {
std::string include;
std::string type;
std::map<std::string, std::string> values;
std::string ref;
};
struct Prefab {
std::string name;
std::string type;
std::vector<struct PrefabComponent> components;
};
class PrefabTool : public DawnTool {
protected:
std::vector<std::string> getRequiredFlags() override;
@ -16,4 +36,37 @@ namespace Dawn {
public:
int32_t start();
};
class PrefabParser : public XmlParser<struct Prefab> {
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 Prefab *out,
std::string *error
) override;
};
class PrefabComponentParser : public XmlParser<struct PrefabComponent> {
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 PrefabComponent *out,
std::string *error
) override;
};
class PrefabGen : public CodeGen {
public:
static void generate(
std::vector<std::string> *out,
struct Prefab *prefab,
std::string tabs
);
};
}