Just breaking stuff

This commit is contained in:
2023-03-14 22:27:46 -07:00
parent 795e69237c
commit 09cb20271b
156 changed files with 4218 additions and 4389 deletions

View File

@ -0,0 +1,77 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "util/XmlParser.hpp"
#include "util/CodeGen.hpp"
namespace Dawn {
struct CharacterInformation {
std::string clazz;
std::string name;
};
class CharacterParser : public XmlParser<struct CharacterInformation> {
protected:
std::vector<std::string> getRequiredAttributes() {
return std::vector<std::string>{
"class",
"name"
};
}
std::map<std::string, std::string> getOptionalAttributes() {
return std::map<std::string, std::string>();
}
int32_t onParse(
Xml *node,
std::map<std::string, std::string> values,
struct CharacterInformation *out,
std::string *error
) {
out->clazz = values["class"];
out->name = values["name"];
if(out->clazz.size() == 0) {
*error = "Character class cannot be empty.";
return 1;
}
if(out->name.size() == 0) {
*error = "Character name cannot be empty.";
return 1;
}
return 0;
}
};
class CharacterGen : public CodeGen {
public:
static void generateProperty(
std::vector<std::string> *out,
struct CharacterInformation info,
std::string tabs
) {
line(out, info.clazz + " *" + info.name + ";", tabs);
}
static void generateInitializer(
std::vector<std::string> *out,
struct CharacterInformation info,
std::string tabs
) {
line(out, "this->" + info.name + " = " + info.clazz + "::create(this);", tabs);
}
static void generateAssets(
std::vector<std::string> *out,
struct CharacterInformation info,
std::string tabs
) {
line(out, "vectorAppend(&assets, " + info.clazz + "::getRequiredAssets(man));", "");
}
};
}