Added libarchive support to Dawn.
This commit is contained in:
@ -38,6 +38,24 @@ struct Color Color::fromString(std::string str) {
|
||||
}
|
||||
|
||||
// Hex code?
|
||||
if(lower[0] == '#') {
|
||||
// Remove the hash
|
||||
lower = lower.substr(1);
|
||||
|
||||
// Convert to RGB
|
||||
if(lower.length() == 3) {
|
||||
// Convert to 6 digit hex
|
||||
lower = lower[0] + lower[0] + lower[1] + lower[1] + lower[2] + lower[2];
|
||||
}
|
||||
|
||||
// Convert to RGB
|
||||
return {
|
||||
(float_t)std::stoi(lower.substr(0, 2), nullptr, 16) / 255.0f,
|
||||
(float_t)std::stoi(lower.substr(2, 2), nullptr, 16) / 255.0f,
|
||||
(float_t)std::stoi(lower.substr(4, 2), nullptr, 16) / 255.0f,
|
||||
1.0f
|
||||
};
|
||||
}
|
||||
|
||||
// Split by comma
|
||||
auto splitByComma = stringSplit(str, ",");
|
||||
|
@ -139,6 +139,7 @@ namespace Dawn {
|
||||
if(v.find("middle") != std::string::npos) return "UI_COMPONENT_ALIGN_MIDDLE";
|
||||
if(v.find("end") != std::string::npos) return "UI_COMPONENT_ALIGN_END";
|
||||
*error = "Invalid UIComponentAlign value: " + v;
|
||||
return "";
|
||||
}
|
||||
|
||||
static inline std::string uiComponentAlignUnitParser(std::string v, std::string *error) {
|
||||
@ -147,6 +148,16 @@ namespace Dawn {
|
||||
if(v.find("percent") != std::string::npos) return "UI_COMPONENT_ALIGN_UNIT_PERCENT";
|
||||
if(v.find("ratio") != std::string::npos) return "UI_COMPONENT_ALIGN_UNIT_RATIO";
|
||||
*error = "Invalid UIComponentAlignUnit value: " + v;
|
||||
return "";
|
||||
}
|
||||
|
||||
static inline std::string uiLabelTextAlignParser(std::string v, std::string *error) {
|
||||
v = stringToLowercase(v);
|
||||
if(v.find("left") != std::string::npos) return "UI_LABEL_TEXT_ALIGN_LEFT";
|
||||
if(v.find("center") != std::string::npos) return "UI_LABEL_TEXT_ALIGN_CENTER";
|
||||
if(v.find("right") != std::string::npos) return "UI_LABEL_TEXT_ALIGN_RIGHT";
|
||||
*error = "Invalid UILabelTextAlign value: " + v;
|
||||
return "";
|
||||
}
|
||||
|
||||
static inline std::function<std::string(std::string, std::string*)> parserFromTypeName(std::string type) {
|
||||
@ -176,6 +187,8 @@ namespace Dawn {
|
||||
parser = uiComponentAlignParser;
|
||||
} else if(type.ends_with("UIComponentAlignUnit")) {
|
||||
parser = uiComponentAlignUnitParser;
|
||||
} else if(type.ends_with("UILabelTextAlign")) {
|
||||
parser = uiLabelTextAlignParser;
|
||||
} else {
|
||||
parser = rawParser;
|
||||
}
|
||||
|
Reference in New Issue
Block a user