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,67 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "label.hpp"
namespace Dawn {
struct ChildInfo;
struct ChildrenInfo {
std::vector<struct ChildInfo> children;
};
struct ChildInfo {
enum ChildType type;
struct ChildrenInfo children;
std::string ref;
bool_t hasRef = false;
struct LabelInfo label;
};
class ChildrenParser : public XmlParser<struct ChildrenInfo> {
protected:
std::vector<std::string> getRequiredAttributes() {
return std::vector<std::string>();
}
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 ChildrenInfo *out,
std::string *error
) {
// Parse children of self.
int32_t ret = 0;
auto itChildren = node->children.begin();
while(itChildren != node->children.end()) {
auto c = *itChildren;
struct ChildInfo child;
if(c->node == "label") {
child.type = CHILD_TYPE_LABEL;
ret = (LabelParser()).parse(c, &child.label, error);
} else {
*error = "Unrecognized UI Element " + c->node;
return 1;
}
if(ret != 0) return ret;
// Now Parse children of children
ret = (ChildrenParser()).parse(c, &child.children, error);
if(ret != 0) return ret;
++itChildren;
}
return ret;
}
};
}

View File

@ -0,0 +1,31 @@
// 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 {
enum AlignType {
UI_COMPONENT_ALIGN_START,
UI_COMPONENT_ALIGN_MIDDLE,
UI_COMPONENT_ALIGN_END,
UI_COMPONENT_ALIGN_STRETCH
};
struct Alignment {
float_t x0 = 0;
float_t y0 = 0;
float_t x1 = 0;
float_t y1 = 0;
enum AlignType xAlign = UI_COMPONENT_ALIGN_START;
enum AlignType yAlign = UI_COMPONENT_ALIGN_START;
};
enum ChildType {
CHILD_TYPE_LABEL
};
}

View File

@ -0,0 +1,46 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "common.hpp"
namespace Dawn {
struct LabelInfo {
std::string text = "";
std::string fontSize = "";
};
class LabelParser : public XmlParser<struct LabelInfo> {
protected:
std::vector<std::string> getRequiredAttributes() {
return std::vector<std::string>();
}
std::map<std::string, std::string> getOptionalAttributes() {
return {
{ "fontSize", "" }
};
}
int32_t onParse(
Xml *node,
std::map<std::string, std::string> values,
struct LabelInfo *out,
std::string *error
) {
int32_t ret = 0;
if(values["fontSize"].size() > 0) {
out->fontSize = values["fontSize"];
}
if(node->value.size() > 0) {
out->text = node->value;
}
return ret;
}
};
}