From 6b727e3883e9ca456dd02e95b6267c55c2a39ae2 Mon Sep 17 00:00:00 2001
From: Sophia Hadash <sophiahadash@gmail.com>
Date: Sat, 4 Sep 2021 21:15:14 +0200
Subject: [PATCH] add badges definition to theme interpreter

---
 es-core/src/ThemeData.cpp    | 20 ++++++++++++++++++--
 themes/rbsimple-DE/theme.xml |  4 ++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp
index 5de869eb5..13ec5fc4c 100644
--- a/es-core/src/ThemeData.cpp
+++ b/es-core/src/ThemeData.cpp
@@ -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;
 
diff --git a/themes/rbsimple-DE/theme.xml b/themes/rbsimple-DE/theme.xml
index 70d5797a8..6e26b63b5 100644
--- a/themes/rbsimple-DE/theme.xml
+++ b/themes/rbsimple-DE/theme.xml
@@ -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>