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

View file

@ -146,6 +146,15 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
{"unfilledPath", PATH},
{"visible", BOOLEAN},
{"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}}},
{"helpsystem",
{{"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
// attribute to prevent nodes overwriting each other.
// Special parsing instruction for recurring options.
// Store as it's attribute to prevent nodes overwriting each other.
if (strcmp(node.name(), "customButtonIcon") == 0) {
const auto btn = node.attribute("button").as_string("");
if (strcmp(btn, "") == 0)
@ -513,6 +522,13 @@ void ThemeData::parseElement(const pugi::xml_node& root,
else
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
element.properties[node.name()] = path;

View file

@ -242,6 +242,10 @@ based on: 'recalbox-multi' by the Recalbox community
<origin>0 0</origin>
<direction>row</direction>
<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>
<!-- This block prevents additional elements from interfering when mixing layouts. -->
<image name="backframe4" extra="false"></image>