mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 09:35:39 +00:00
Added support for using unsigned integers for theme properties.
This commit is contained in:
parent
0d799575ca
commit
31c5b200d1
|
@ -88,8 +88,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"path", PATH},
|
{"path", PATH},
|
||||||
{"default", PATH},
|
{"default", PATH},
|
||||||
{"tile", BOOLEAN},
|
|
||||||
{"imageType", STRING},
|
{"imageType", STRING},
|
||||||
|
{"tile", BOOLEAN},
|
||||||
{"interpolation", STRING},
|
{"interpolation", STRING},
|
||||||
{"color", COLOR},
|
{"color", COLOR},
|
||||||
{"colorEnd", COLOR},
|
{"colorEnd", COLOR},
|
||||||
|
@ -141,8 +141,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"horizontalAlignment", STRING},
|
{"horizontalAlignment", STRING},
|
||||||
{"alignment", STRING}, // For backward compatibility with legacy themes.
|
{"alignment", STRING}, // For backward compatibility with legacy themes.
|
||||||
{"direction", STRING},
|
{"direction", STRING},
|
||||||
{"lines", FLOAT},
|
{"lines", UNSIGNED_INTEGER},
|
||||||
{"itemsPerLine", FLOAT},
|
{"itemsPerLine", UNSIGNED_INTEGER},
|
||||||
{"itemMargin", NORMALIZED_PAIR},
|
{"itemMargin", NORMALIZED_PAIR},
|
||||||
{"slots", STRING},
|
{"slots", STRING},
|
||||||
{"controllerPos", NORMALIZED_PAIR},
|
{"controllerPos", NORMALIZED_PAIR},
|
||||||
|
@ -245,7 +245,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"logoHorizontalAlignment", STRING},
|
{"logoHorizontalAlignment", STRING},
|
||||||
{"logoVerticalAlignment", STRING},
|
{"logoVerticalAlignment", STRING},
|
||||||
{"logoAlignment", STRING}, // For backward compatibility with legacy themes.
|
{"logoAlignment", STRING}, // For backward compatibility with legacy themes.
|
||||||
{"maxLogoCount", FLOAT},
|
{"maxLogoCount", UNSIGNED_INTEGER},
|
||||||
{"text", STRING},
|
{"text", STRING},
|
||||||
{"textColor", COLOR},
|
{"textColor", COLOR},
|
||||||
{"textBackgroundColor", COLOR},
|
{"textBackgroundColor", COLOR},
|
||||||
|
@ -1208,6 +1208,11 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case UNSIGNED_INTEGER: {
|
||||||
|
unsigned int integerVal {static_cast<unsigned int>(strtoul(str.c_str(), 0, 0))};
|
||||||
|
element.properties[node.name()] = integerVal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case FLOAT: {
|
case FLOAT: {
|
||||||
float floatVal {static_cast<float>(strtod(str.c_str(), 0))};
|
float floatVal {static_cast<float>(strtod(str.c_str(), 0))};
|
||||||
element.properties[node.name()] = floatVal;
|
element.properties[node.name()] = floatVal;
|
||||||
|
|
|
@ -217,6 +217,7 @@ public:
|
||||||
PATH,
|
PATH,
|
||||||
STRING,
|
STRING,
|
||||||
COLOR,
|
COLOR,
|
||||||
|
UNSIGNED_INTEGER,
|
||||||
FLOAT,
|
FLOAT,
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
};
|
};
|
||||||
|
|
|
@ -229,25 +229,25 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("lines")) {
|
if (elem->has("lines")) {
|
||||||
const float lines {elem->get<float>("lines")};
|
const unsigned int lines {elem->get<unsigned int>("lines")};
|
||||||
if (lines < 1.0f || lines > 10.0f) {
|
if (lines < 1 || lines > 10) {
|
||||||
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <lines> set to \""
|
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <lines> set to \""
|
||||||
<< lines << "\"";
|
<< lines << "\"";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mFlexboxComponent.setLines(static_cast<unsigned int>(lines));
|
mFlexboxComponent.setLines(lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("itemsPerLine")) {
|
if (elem->has("itemsPerLine")) {
|
||||||
const float itemsPerLine {elem->get<float>("itemsPerLine")};
|
const unsigned int itemsPerLine {elem->get<unsigned int>("itemsPerLine")};
|
||||||
if (itemsPerLine < 1.0f || itemsPerLine > 10.0f) {
|
if (itemsPerLine < 1 || itemsPerLine > 10) {
|
||||||
LOG(LogWarning)
|
LOG(LogWarning)
|
||||||
<< "BadgeComponent: Invalid theme configuration, <itemsPerLine> set to \""
|
<< "BadgeComponent: Invalid theme configuration, <itemsPerLine> set to \""
|
||||||
<< itemsPerLine << "\"";
|
<< itemsPerLine << "\"";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mFlexboxComponent.setItemsPerLine(static_cast<unsigned int>(itemsPerLine));
|
mFlexboxComponent.setItemsPerLine(itemsPerLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -379,7 +379,7 @@ void CarouselComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
if (elem->has("maxLogoCount"))
|
if (elem->has("maxLogoCount"))
|
||||||
mMaxLogoCount =
|
mMaxLogoCount =
|
||||||
glm::clamp(static_cast<int>(std::round(elem->get<float>("maxLogoCount"))), 2, 30);
|
glm::clamp(static_cast<int>(elem->get<unsigned int>("maxLogoCount")), 2, 30);
|
||||||
|
|
||||||
if (elem->has("logoRotation"))
|
if (elem->has("logoRotation"))
|
||||||
mLogoRotation = elem->get<float>("logoRotation");
|
mLogoRotation = elem->get<float>("logoRotation");
|
||||||
|
|
Loading…
Reference in a new issue