From 1aa360598dd7cce846055e96c38d036c52728f02 Mon Sep 17 00:00:00 2001
From: Leon Styhre <leon@leonstyhre.com>
Date: Sat, 23 Oct 2021 20:28:07 +0200
Subject: [PATCH] Renamed BadgesComponent to BadgeComponent.

---
 es-app/src/guis/GuiMetaDataEd.cpp             | 10 ++---
 es-app/src/guis/GuiMetaDataEd.h               |  2 +-
 .../views/gamelist/DetailedGameListView.cpp   |  4 +-
 .../src/views/gamelist/DetailedGameListView.h |  4 +-
 es-app/src/views/gamelist/GridGameListView.h  |  4 +-
 .../src/views/gamelist/VideoGameListView.cpp  |  4 +-
 es-app/src/views/gamelist/VideoGameListView.h |  4 +-
 es-core/CMakeLists.txt                        |  4 +-
 ...BadgesComponent.cpp => BadgeComponent.cpp} | 41 +++++++++----------
 .../{BadgesComponent.h => BadgeComponent.h}   | 12 +++---
 10 files changed, 44 insertions(+), 45 deletions(-)
 rename es-core/src/components/{BadgesComponent.cpp => BadgeComponent.cpp} (89%)
 rename es-core/src/components/{BadgesComponent.h => BadgeComponent.h} (86%)

diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp
index 24e755f6a..e46c1bb62 100644
--- a/es-app/src/guis/GuiMetaDataEd.cpp
+++ b/es-app/src/guis/GuiMetaDataEd.cpp
@@ -53,7 +53,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
     , mMediaFilesUpdated{false}
     , mInvalidEmulatorEntry{false}
 {
-    mGameControllers = BadgesComponent::getGameControllers();
+    mGameControllers = BadgeComponent::getGameControllers();
 
     // Remove the last "unknown" controller entry.
     if (mGameControllers.size() > 1)
@@ -200,7 +200,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
                 // OK callback (apply new value to ed).
                 auto updateVal = [ed, originalValue](const std::string& newVal) {
                     ed->setValue(newVal);
-                    if (newVal == BadgesComponent::getDisplayName(originalValue))
+                    if (newVal == BadgeComponent::getDisplayName(originalValue))
                         ed->setColor(DEFAULT_TEXTCOLOR);
                     else
                         ed->setColor(TEXTCOLOR_USERMARKED);
@@ -478,7 +478,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
             ed->setValue(ViewController::EXCLAMATION_CHAR + " " + originalValue);
         }
         else if (iter->type == MD_CONTROLLER && mMetaData->get(iter->key) != "") {
-            std::string displayName = BadgesComponent::getDisplayName(mMetaData->get(iter->key));
+            std::string displayName = BadgeComponent::getDisplayName(mMetaData->get(iter->key));
             if (displayName != "unknown")
                 ed->setValue(displayName);
             else
@@ -618,7 +618,7 @@ void GuiMetaDataEd::save()
             continue;
 
         if (mMetaDataDecl.at(i).key == "controller" && mEditors.at(i)->getValue() != "") {
-            std::string shortName = BadgesComponent::getShortName(mEditors.at(i)->getValue());
+            std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
             if (shortName != "unknown")
                 mMetaData->set(mMetaDataDecl.at(i).key, shortName);
             continue;
@@ -769,7 +769,7 @@ void GuiMetaDataEd::close()
             continue;
 
         if (mMetaDataDecl.at(i).key == "controller" && mEditors.at(i)->getValue() != "") {
-            std::string shortName = BadgesComponent::getShortName(mEditors.at(i)->getValue());
+            std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
             if (shortName == "unknown" || mMetaDataValue == shortName)
                 continue;
         }
diff --git a/es-app/src/guis/GuiMetaDataEd.h b/es-app/src/guis/GuiMetaDataEd.h
index 054c112f3..a4833c257 100644
--- a/es-app/src/guis/GuiMetaDataEd.h
+++ b/es-app/src/guis/GuiMetaDataEd.h
@@ -13,7 +13,7 @@
 
 #include "GuiComponent.h"
 #include "MetaData.h"
-#include "components/BadgesComponent.h"
+#include "components/BadgeComponent.h"
 #include "components/ComponentGrid.h"
 #include "components/NinePatchComponent.h"
 #include "components/ScrollIndicatorComponent.h"
diff --git a/es-app/src/views/gamelist/DetailedGameListView.cpp b/es-app/src/views/gamelist/DetailedGameListView.cpp
index 9fc1d6805..5a0846ff0 100644
--- a/es-app/src/views/gamelist/DetailedGameListView.cpp
+++ b/es-app/src/views/gamelist/DetailedGameListView.cpp
@@ -410,9 +410,9 @@ void DetailedGameListView::updateInfoPanel()
         mPlayers.setValue(file->metadata.get("players"));
 
         // Populate the badge slots based on game metadata.
-        std::vector<BadgesComponent::BadgeInfo> badgeSlots;
+        std::vector<BadgeComponent::BadgeInfo> badgeSlots;
         for (auto badge : mBadges.getBadgeTypes()) {
-            BadgesComponent::BadgeInfo badgeInfo;
+            BadgeComponent::BadgeInfo badgeInfo;
             badgeInfo.badgeType = badge;
             if (badge == "controller") {
                 if (file->metadata.get("controller").compare("") != 0) {
diff --git a/es-app/src/views/gamelist/DetailedGameListView.h b/es-app/src/views/gamelist/DetailedGameListView.h
index a6033b2f6..ed4db80c2 100644
--- a/es-app/src/views/gamelist/DetailedGameListView.h
+++ b/es-app/src/views/gamelist/DetailedGameListView.h
@@ -9,7 +9,7 @@
 #ifndef ES_APP_VIEWS_GAME_LIST_DETAILED_GAME_LIST_VIEW_H
 #define ES_APP_VIEWS_GAME_LIST_DETAILED_GAME_LIST_VIEW_H
 
-#include "components/BadgesComponent.h"
+#include "components/BadgeComponent.h"
 #include "components/DateTimeComponent.h"
 #include "components/RatingComponent.h"
 #include "components/ScrollableContainer.h"
@@ -56,7 +56,7 @@ private:
     DateTimeComponent mLastPlayed;
     TextComponent mPlayCount;
     TextComponent mName;
-    BadgesComponent mBadges;
+    BadgeComponent mBadges;
 
     std::vector<TextComponent*> getMDLabels();
     std::vector<GuiComponent*> getMDValues();
diff --git a/es-app/src/views/gamelist/GridGameListView.h b/es-app/src/views/gamelist/GridGameListView.h
index 2c2f50458..f84d52cf7 100644
--- a/es-app/src/views/gamelist/GridGameListView.h
+++ b/es-app/src/views/gamelist/GridGameListView.h
@@ -9,7 +9,7 @@
 #ifndef ES_APP_VIEWS_GAME_LIST_GRID_GAME_LIST_VIEW_H
 #define ES_APP_VIEWS_GAME_LIST_GRID_GAME_LIST_VIEW_H
 
-#include "components/BadgesComponent.h"
+#include "components/BadgeComponent.h"
 #include "components/DateTimeComponent.h"
 #include "components/ImageGridComponent.h"
 #include "components/RatingComponent.h"
@@ -89,7 +89,7 @@ private:
     TextComponent mLblLastPlayed;
     TextComponent mLblPlayCount;
 
-    BadgesComponent mBadges;
+    BadgeComponent mBadges;
     RatingComponent mRating;
     DateTimeComponent mReleaseDate;
     TextComponent mDeveloper;
diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp
index 8965def88..ef76d29e0 100644
--- a/es-app/src/views/gamelist/VideoGameListView.cpp
+++ b/es-app/src/views/gamelist/VideoGameListView.cpp
@@ -450,9 +450,9 @@ void VideoGameListView::updateInfoPanel()
         mPlayers.setValue(file->metadata.get("players"));
 
         // Populate the badge slots based on game metadata.
-        std::vector<BadgesComponent::BadgeInfo> badgeSlots;
+        std::vector<BadgeComponent::BadgeInfo> badgeSlots;
         for (auto badge : mBadges.getBadgeTypes()) {
-            BadgesComponent::BadgeInfo badgeInfo;
+            BadgeComponent::BadgeInfo badgeInfo;
             badgeInfo.badgeType = badge;
             if (badge == "controller") {
                 if (file->metadata.get("controller").compare("") != 0) {
diff --git a/es-app/src/views/gamelist/VideoGameListView.h b/es-app/src/views/gamelist/VideoGameListView.h
index f5cae00d0..06d1c1034 100644
--- a/es-app/src/views/gamelist/VideoGameListView.h
+++ b/es-app/src/views/gamelist/VideoGameListView.h
@@ -9,7 +9,7 @@
 #ifndef ES_APP_VIEWS_GAME_LIST_VIDEO_GAME_LIST_VIEW_H
 #define ES_APP_VIEWS_GAME_LIST_VIDEO_GAME_LIST_VIEW_H
 
-#include "components/BadgesComponent.h"
+#include "components/BadgeComponent.h"
 #include "components/DateTimeComponent.h"
 #include "components/RatingComponent.h"
 #include "components/ScrollableContainer.h"
@@ -60,7 +60,7 @@ private:
     DateTimeComponent mLastPlayed;
     TextComponent mPlayCount;
     TextComponent mName;
-    BadgesComponent mBadges;
+    BadgeComponent mBadges;
 
     std::vector<TextComponent*> getMDLabels();
     std::vector<GuiComponent*> getMDValues();
diff --git a/es-core/CMakeLists.txt b/es-core/CMakeLists.txt
index 6949f2a32..d579317c6 100644
--- a/es-core/CMakeLists.txt
+++ b/es-core/CMakeLists.txt
@@ -34,7 +34,7 @@ set(CORE_HEADERS
 
     # GUI components
     ${CMAKE_CURRENT_SOURCE_DIR}/src/components/AnimatedImageComponent.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BadgesComponent.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BadgeComponent.h
     ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BusyComponent.h
     ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ButtonComponent.h
     ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ComponentGrid.h
@@ -112,7 +112,7 @@ set(CORE_SOURCES
 
     # GUI components
     ${CMAKE_CURRENT_SOURCE_DIR}/src/components/AnimatedImageComponent.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BadgesComponent.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BadgeComponent.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BusyComponent.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ButtonComponent.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ComponentGrid.cpp
diff --git a/es-core/src/components/BadgesComponent.cpp b/es-core/src/components/BadgeComponent.cpp
similarity index 89%
rename from es-core/src/components/BadgesComponent.cpp
rename to es-core/src/components/BadgeComponent.cpp
index 8236593a0..5402b62a9 100644
--- a/es-core/src/components/BadgesComponent.cpp
+++ b/es-core/src/components/BadgeComponent.cpp
@@ -1,7 +1,7 @@
 //  SPDX-License-Identifier: MIT
 //
 //  EmulationStation Desktop Edition
-//  BadgesComponent.cpp
+//  BadgeComponent.cpp
 //
 //  Game badges icons.
 //  Used by the gamelist views.
@@ -14,13 +14,13 @@
 #define SLOT_CONTROLLER "controller"
 #define SLOT_ALTEMULATOR "altemulator"
 
-#include "components/BadgesComponent.h"
+#include "components/BadgeComponent.h"
 
 #include "Log.h"
 #include "ThemeData.h"
 #include "utils/StringUtil.h"
 
-std::vector<GameControllers> BadgesComponent::sGameControllers;
+std::vector<GameControllers> BadgeComponent::sGameControllers;
 
 // clang-format off
 
@@ -55,7 +55,7 @@ GameControllers sControllerDefinitions [] = {
 
 // clang-format on
 
-BadgesComponent::BadgesComponent(Window* window)
+BadgeComponent::BadgeComponent(Window* window)
     : GuiComponent{window}
     , mFlexboxItems{}
     , mFlexboxComponent{window, mFlexboxItems}
@@ -70,14 +70,14 @@ BadgesComponent::BadgesComponent(Window* window)
     mBadgeIcons[SLOT_ALTEMULATOR] = ":/graphics/badge_altemulator.svg";
 }
 
-void BadgesComponent::populateGameControllers()
+void BadgeComponent::populateGameControllers()
 {
     sGameControllers.clear();
     for (auto controller : sControllerDefinitions)
         sGameControllers.push_back(controller);
 }
 
-void BadgesComponent::setBadges(const std::vector<BadgeInfo>& badges)
+void BadgeComponent::setBadges(const std::vector<BadgeInfo>& badges)
 {
     std::map<std::string, bool> prevVisibility;
     std::map<std::string, std::string> prevPlayers;
@@ -124,7 +124,7 @@ void BadgesComponent::setBadges(const std::vector<BadgeInfo>& badges)
     }
 }
 
-const std::string BadgesComponent::getShortName(const std::string& displayName)
+const std::string BadgeComponent::getShortName(const std::string& displayName)
 {
     auto it = std::find_if(sGameControllers.begin(), sGameControllers.end(),
                            [displayName](GameControllers gameController) {
@@ -136,7 +136,7 @@ const std::string BadgesComponent::getShortName(const std::string& displayName)
         return "unknown";
 }
 
-const std::string BadgesComponent::getDisplayName(const std::string& shortName)
+const std::string BadgeComponent::getDisplayName(const std::string& shortName)
 {
     auto it = std::find_if(sGameControllers.begin(), sGameControllers.end(),
                            [shortName](GameControllers gameController) {
@@ -148,7 +148,7 @@ const std::string BadgesComponent::getDisplayName(const std::string& shortName)
         return "unknown";
 }
 
-void BadgesComponent::render(const glm::mat4& parentTrans)
+void BadgeComponent::render(const glm::mat4& parentTrans)
 {
     if (!isVisible())
         return;
@@ -163,10 +163,10 @@ void BadgesComponent::render(const glm::mat4& parentTrans)
     }
 }
 
-void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
-                                 const std::string& view,
-                                 const std::string& element,
-                                 unsigned int properties)
+void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
+                                const std::string& view,
+                                const std::string& element,
+                                unsigned int properties)
 {
     populateGameControllers();
 
@@ -179,7 +179,7 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
     if (elem->has("alignment")) {
         const std::string alignment{elem->get<std::string>("alignment")};
         if (alignment != "left" && alignment != "right") {
-            LOG(LogWarning) << "BadgesComponent: Invalid theme configuration, <alignment> set to \""
+            LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <alignment> set to \""
                             << alignment << "\"";
         }
         else {
@@ -191,7 +191,7 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
         const float itemsPerRow{elem->get<float>("itemsPerRow")};
         if (itemsPerRow < 1.0f || itemsPerRow > 10.0f) {
             LOG(LogWarning)
-                << "BadgesComponent: Invalid theme configuration, <itemsPerRow> set to \""
+                << "BadgeComponent: Invalid theme configuration, <itemsPerRow> set to \""
                 << itemsPerRow << "\"";
         }
         else {
@@ -202,7 +202,7 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
     if (elem->has("rows")) {
         const float rows{elem->get<float>("rows")};
         if (rows < 1.0f || rows > 10.0f) {
-            LOG(LogWarning) << "BadgesComponent: Invalid theme configuration, <rows> set to \""
+            LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <rows> set to \""
                             << rows << "\"";
         }
         else {
@@ -215,9 +215,8 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
         if ((itemMargin.x != -1.0 && itemMargin.y != -1.0) &&
             (itemMargin.x < 0.0f || itemMargin.x > 0.2f || itemMargin.y < 0.0f ||
              itemMargin.y > 0.2f)) {
-            LOG(LogWarning)
-                << "BadgesComponent: Invalid theme configuration, <itemMargin> set to \""
-                << itemMargin.x << " " << itemMargin.y << "\"";
+            LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <itemMargin> set to \""
+                            << itemMargin.x << " " << itemMargin.y << "\"";
         }
         else {
             mFlexboxComponent.setItemMargin(itemMargin);
@@ -229,7 +228,7 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
         if (controllerPos.x < -1.0f || controllerPos.x > 2.0f || controllerPos.y < -1.0f ||
             controllerPos.y > 2.0f) {
             LOG(LogWarning)
-                << "BadgesComponent: Invalid theme configuration, <controllerPos> set to \""
+                << "BadgeComponent: Invalid theme configuration, <controllerPos> set to \""
                 << controllerPos.x << " " << controllerPos.y << "\"";
         }
         else {
@@ -241,7 +240,7 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
         const float controllerSize = elem->get<float>("controllerSize");
         if (controllerSize < 0.1f || controllerSize > 2.0f) {
             LOG(LogWarning)
-                << "BadgesComponent: Invalid theme configuration, <controllerSize> set to \""
+                << "BadgeComponent: Invalid theme configuration, <controllerSize> set to \""
                 << controllerSize << "\"";
         }
         else {
diff --git a/es-core/src/components/BadgesComponent.h b/es-core/src/components/BadgeComponent.h
similarity index 86%
rename from es-core/src/components/BadgesComponent.h
rename to es-core/src/components/BadgeComponent.h
index a87c34e2b..2f998b9da 100644
--- a/es-core/src/components/BadgesComponent.h
+++ b/es-core/src/components/BadgeComponent.h
@@ -1,14 +1,14 @@
 //  SPDX-License-Identifier: MIT
 //
 //  EmulationStation Desktop Edition
-//  BadgesComponent.h
+//  BadgeComponent.h
 //
 //  Game badges icons.
 //  Used by the gamelist views.
 //
 
-#ifndef ES_CORE_COMPONENTS_BADGES_COMPONENT_H
-#define ES_CORE_COMPONENTS_BADGES_COMPONENT_H
+#ifndef ES_CORE_COMPONENTS_BADGE_COMPONENT_H
+#define ES_CORE_COMPONENTS_BADGE_COMPONENT_H
 
 #include "FlexboxComponent.h"
 #include "GuiComponent.h"
@@ -19,10 +19,10 @@ struct GameControllers {
     std::string fileName;
 };
 
-class BadgesComponent : public GuiComponent
+class BadgeComponent : public GuiComponent
 {
 public:
-    BadgesComponent(Window* window);
+    BadgeComponent(Window* window);
 
     struct BadgeInfo {
         std::string badgeType;
@@ -60,4 +60,4 @@ private:
     std::map<std::string, std::string> mBadgeIcons;
 };
 
-#endif // ES_CORE_COMPONENTS_BADGES_COMPONENT_H
+#endif // ES_CORE_COMPONENTS_BADGE_COMPONENT_H