add badges definition to theme interpreter

This commit is contained in:
Sophia Hadash 2021-09-04 21:15:14 +02:00 committed by SophiaHadash
parent 7193d09845
commit 6b727e3883
2 changed files with 22 additions and 2 deletions
es-core/src
themes/rbsimple-DE

View file

@ -146,6 +146,15 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
{"unfilledPath", PATH}, {"unfilledPath", PATH},
{"visible", BOOLEAN}, {"visible", BOOLEAN},
{"zIndex", FLOAT}}}, {"zIndex", FLOAT}}},
{"badges",
{{"pos", NORMALIZED_PAIR},
{"size", NORMALIZED_PAIR},
{"origin", NORMALIZED_PAIR},
{"direction", STRING},
{"slots", STRING},
{"customBadgeIcon", PATH},
{"visible", BOOLEAN},
{"zIndex", FLOAT}}},
{"sound", {{"path", PATH}}}, {"sound", {{"path", PATH}}},
{"helpsystem", {"helpsystem",
{{"pos", NORMALIZED_PAIR}, {{"pos", NORMALIZED_PAIR},
@ -503,8 +512,8 @@ void ThemeData::parseElement(const pugi::xml_node& root,
""); "");
} }
// Special parsing instruction for customButtonIcon -> save node as it's button // Special parsing instruction for recurring options.
// attribute to prevent nodes overwriting each other. // Store as it's attribute to prevent nodes overwriting each other.
if (strcmp(node.name(), "customButtonIcon") == 0) { if (strcmp(node.name(), "customButtonIcon") == 0) {
const auto btn = node.attribute("button").as_string(""); const auto btn = node.attribute("button").as_string("");
if (strcmp(btn, "") == 0) if (strcmp(btn, "") == 0)
@ -513,6 +522,13 @@ void ThemeData::parseElement(const pugi::xml_node& root,
else else
element.properties[btn] = path; element.properties[btn] = path;
} }
else if (strcmp(node.name(), "customBadgeIcon") == 0) {
const auto btn = node.attribute("badge").as_string("");
if (strcmp(btn, "") == 0)
LOG(LogError) << "<customBadgeIcon> element requires the `badge` property.";
else
element.properties[btn] = path;
}
else else
element.properties[node.name()] = path; element.properties[node.name()] = path;

View file

@ -242,6 +242,10 @@ based on: 'recalbox-multi' by the Recalbox community
<origin>0 0</origin> <origin>0 0</origin>
<direction>row</direction> <direction>row</direction>
<slots>favorite completed kids broken</slots> <slots>favorite completed kids broken</slots>
<customBadgeIcon badge="favorite">:/graphics/star_filled.svg</customBadgeIcon>
<customBadgeIcon badge="completed">:/graphics/star_filled.svg</customBadgeIcon>
<customBadgeIcon badge="kids">:/graphics/star_filled.svg</customBadgeIcon>
<customBadgeIcon badge="broken">:/graphics/star_filled.svg</customBadgeIcon>
</badges> </badges>
<!-- This block prevents additional elements from interfering when mixing layouts. --> <!-- This block prevents additional elements from interfering when mixing layouts. -->
<image name="backframe4" extra="false"></image> <image name="backframe4" extra="false"></image>