From 7daf69092f61b42543cb4c57bc8e4302ae05b701 Mon Sep 17 00:00:00 2001
From: Leon Styhre <leon@leonstyhre.com>
Date: Fri, 15 Apr 2022 21:20:43 +0200
Subject: [PATCH] Added theme support for controlling the TextListComponent
 collection indicators.

---
 es-app/src/views/GamelistBase.cpp             | 33 ++++++++++---------
 es-core/src/ThemeData.cpp                     |  1 +
 .../components/primary/TextListComponent.h    | 16 +++++++++
 3 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/es-app/src/views/GamelistBase.cpp b/es-app/src/views/GamelistBase.cpp
index 1372e6e45..78faec534 100644
--- a/es-app/src/views/GamelistBase.cpp
+++ b/es-app/src/views/GamelistBase.cpp
@@ -572,29 +572,30 @@ void GamelistBase::populateList(const std::vector<FileData*>& files, FileData* f
             if (mTextList != nullptr) {
                 TextListComponent<FileData*>::Entry textListEntry;
                 std::string indicators {mTextList->getIndicators()};
+                std::string collectionIndicators {mTextList->getCollectionIndicators()};
 
                 if (!mFirstGameEntry && (*it)->getType() == GAME)
                     mFirstGameEntry = (*it);
 
+                // Add a leading tick mark icon to the game name if it's part of the custom
+                // collection currently being edited.
+                if (isEditing && (*it)->getType() == GAME) {
+                    if (CollectionSystemsManager::getInstance()->inCustomCollection(
+                            editingCollection, (*it))) {
+                        if (collectionIndicators == "ascii")
+                            inCollectionPrefix = "! ";
+                        else
+                            inCollectionPrefix = ViewController::TICKMARK_CHAR + "  ";
+                    }
+                    else {
+                        inCollectionPrefix = "";
+                    }
+                }
+
                 if (indicators == "none") {
-                    name = (*it)->getName();
+                    name = inCollectionPrefix + (*it)->getName();
                 }
                 else {
-                    // Add a leading tick mark icon to the game name if it's part of the custom
-                    // collection currently being edited.
-                    if (isEditing && (*it)->getType() == GAME) {
-                        if (CollectionSystemsManager::getInstance()->inCustomCollection(
-                                editingCollection, (*it))) {
-                            if (indicators == "ascii")
-                                inCollectionPrefix = "! ";
-                            else
-                                inCollectionPrefix = ViewController::TICKMARK_CHAR + "  ";
-                        }
-                        else {
-                            inCollectionPrefix = "";
-                        }
-                    }
-
                     if ((*it)->getFavorite() && favoriteStar &&
                         mRoot->getSystem()->getName() != "favorites") {
                         if (indicators == "ascii")
diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp
index e7fcbf32d..09065b66b 100644
--- a/es-core/src/ThemeData.cpp
+++ b/es-core/src/ThemeData.cpp
@@ -290,6 +290,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
        {"forceUppercase", BOOLEAN}, // For backward compatibility with legacy themes.
        {"lineSpacing", FLOAT},
        {"indicators", STRING},
+       {"collectionIndicators", STRING},
        {"zIndex", FLOAT}}},
      {"gameselector",
       {{"selection", STRING},
diff --git a/es-core/src/components/primary/TextListComponent.h b/es-core/src/components/primary/TextListComponent.h
index f6b3fdbe1..b309ced6d 100644
--- a/es-core/src/components/primary/TextListComponent.h
+++ b/es-core/src/components/primary/TextListComponent.h
@@ -119,6 +119,7 @@ public:
     void setColor(unsigned int id, unsigned int color) { mColors[id] = color; }
     void setLineSpacing(float lineSpacing) { mLineSpacing = lineSpacing; }
     const std::string& getIndicators() const { return mIndicators; }
+    const std::string& getCollectionIndicators() const { return mCollectionIndicators; }
 
 protected:
     void onScroll() override
@@ -163,6 +164,7 @@ private:
 
     std::shared_ptr<Font> mFont;
     std::string mIndicators;
+    std::string mCollectionIndicators;
     bool mUppercase;
     bool mLowercase;
     bool mCapitalize;
@@ -193,6 +195,7 @@ TextListComponent<T>::TextListComponent()
     , mHorizontalMargin {0.0f}
     , mFont {Font::get(FONT_SIZE_MEDIUM)}
     , mIndicators {"symbols"}
+    , mCollectionIndicators {"symbols"}
     , mUppercase {false}
     , mLowercase {false}
     , mCapitalize {false}
@@ -612,6 +615,19 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
         }
     }
 
+    if (elem->has("collectionIndicators")) {
+        std::string collectionIndicators {elem->get<std::string>("collectionIndicators")};
+        if (collectionIndicators == "symbols" || collectionIndicators == "ascii") {
+            mCollectionIndicators = collectionIndicators;
+        }
+        else {
+            mCollectionIndicators = "symbols";
+            LOG(LogWarning) << "TextListComponent: Invalid theme configuration, property "
+                               "<collectionIndicators> defined as \""
+                            << collectionIndicators << "\"";
+        }
+    }
+
     if (elem->has("selectorImagePath")) {
         std::string path {elem->get<std::string>("selectorImagePath")};
         bool tile = elem->has("selectorImageTile") && elem->get<bool>("selectorImageTile");