From 605aa4ba8e55d88fafaf8fa7ebb575fd3e5c4f5d Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 16 Dec 2020 21:19:48 +0100 Subject: [PATCH] Moved the favorite and folder character constants to a more logical location. --- es-app/src/FileData.h | 3 --- es-app/src/SystemScreensaver.cpp | 2 +- es-app/src/guis/GuiGamelistOptions.cpp | 24 +++++++++---------- es-app/src/guis/GuiGamelistOptions.h | 3 --- es-app/src/views/ViewController.cpp | 2 ++ es-app/src/views/ViewController.h | 3 +++ .../src/views/gamelist/BasicGameListView.cpp | 7 ++---- .../views/gamelist/ISimpleGameListView.cpp | 6 ++--- es-core/src/Sound.cpp | 2 +- 9 files changed, 23 insertions(+), 29 deletions(-) diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index b12ff0125..1469f3373 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -130,9 +130,6 @@ public: // Return sort type based on a string description. FileData::SortType getSortTypeFromString(std::string desc); - const std::string FAVORITE_CHAR = "\uF005"; - const std::string FOLDER_CHAR = "\uF07C"; - protected: FileData* mSourceFileData; FileData* mParent; diff --git a/es-app/src/SystemScreensaver.cpp b/es-app/src/SystemScreensaver.cpp index f6980c349..7698171db 100644 --- a/es-app/src/SystemScreensaver.cpp +++ b/es-app/src/SystemScreensaver.cpp @@ -595,7 +595,7 @@ void SystemScreensaver::generateOverlayInfo() std::string favoriteChar; if (mCurrentGame->getFavorite()) - favoriteChar = " " + mCurrentGame->FAVORITE_CHAR; + favoriteChar = " " + ViewController::FAVORITE_CHAR; const std::string gameName = Utils::String::toUpper(mGameName) + favoriteChar; const std::string systemName = Utils::String::toUpper(mSystemName); diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index 005109488..84751aeb7 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -41,8 +41,6 @@ GuiGamelistOptions::GuiGamelistOptions( // Check that it's not a placeholder folder - if it is, only show "Filter Options". FileData* file = getGamelist()->getCursor(); - FAVORITE_CHAR = file->FAVORITE_CHAR; - FOLDER_CHAR = file->FOLDER_CHAR; fromPlaceholder = file->isPlaceHolder(); ComponentListRow row; @@ -77,19 +75,21 @@ GuiGamelistOptions::GuiGamelistOptions( // Don't include the folder name starting characters if folders are sorted on top // unless the list only contains folders. if (!mOnlyHasFolders && mFoldersOnTop && file->getType() == FOLDER) { - mCurrentFirstCharacter = FOLDER_CHAR; + mCurrentFirstCharacter = ViewController::FOLDER_CHAR; } else { // Check if the currently selected game is a favorite. bool isFavorite = false; - if (mFirstLetterIndex.size() == 1 && mFirstLetterIndex.front() == FAVORITE_CHAR) + if (mFirstLetterIndex.size() == 1 && mFirstLetterIndex.front() == + ViewController::FAVORITE_CHAR) isFavorite = true; - else if (mFirstLetterIndex.size() > 1 && (mFirstLetterIndex.front() == FAVORITE_CHAR || - mFirstLetterIndex[1] == FAVORITE_CHAR)) + else if (mFirstLetterIndex.size() > 1 && (mFirstLetterIndex.front() == + ViewController::FAVORITE_CHAR || mFirstLetterIndex[1] == + ViewController::FAVORITE_CHAR)) isFavorite = true; if (mFavoritesSorting && file->getFavorite() && isFavorite) - mCurrentFirstCharacter = FAVORITE_CHAR; + mCurrentFirstCharacter = ViewController::FAVORITE_CHAR; else mCurrentFirstCharacter = toupper(file->getSortName().front()); } @@ -237,8 +237,8 @@ GuiGamelistOptions::~GuiGamelistOptions() // Has the user changed the letter using the quick selector? if (mCurrentFirstCharacter != mJumpToLetterList->getSelected()) { - if (mJumpToLetterList->getSelected() == FAVORITE_CHAR || - mJumpToLetterList->getSelected() == FOLDER_CHAR) + if (mJumpToLetterList->getSelected() == ViewController::FAVORITE_CHAR || + mJumpToLetterList->getSelected() == ViewController::FOLDER_CHAR) jumpToFirstRow(); else jumpToLetter(); @@ -395,8 +395,8 @@ void GuiGamelistOptions::jumpToLetter() getParent()->getChildrenListToDisplay(); for (unsigned int i = 0; i < files.size(); i++) { - if (mFavoritesSorting && (mFirstLetterIndex.front() == FAVORITE_CHAR || - mFirstLetterIndex.front() == FOLDER_CHAR)) { + if (mFavoritesSorting && (mFirstLetterIndex.front() == ViewController::FAVORITE_CHAR || + mFirstLetterIndex.front() == ViewController::FOLDER_CHAR)) { if (static_cast(toupper(files.at(i)->getSortName().front())) == letter && !files.at(i)->getFavorite()) { if (!mOnlyHasFolders && mFoldersOnTop && files.at(i)->getType() == FOLDER) { @@ -424,7 +424,7 @@ void GuiGamelistOptions::jumpToLetter() void GuiGamelistOptions::jumpToFirstRow() { - if (mFoldersOnTop && mJumpToLetterList->getSelected() == FAVORITE_CHAR) { + if (mFoldersOnTop && mJumpToLetterList->getSelected() == ViewController::FAVORITE_CHAR) { // Get the gamelist. const std::vector& files = getGamelist()->getCursor()-> getParent()->getChildrenListToDisplay(); diff --git a/es-app/src/guis/GuiGamelistOptions.h b/es-app/src/guis/GuiGamelistOptions.h index df8d78346..070cf2de1 100644 --- a/es-app/src/guis/GuiGamelistOptions.h +++ b/es-app/src/guis/GuiGamelistOptions.h @@ -61,9 +61,6 @@ private: bool isCustomCollectionGroup; std::vector mFirstLetterIndex; std::string mCurrentFirstCharacter; - std::string FAVORITE_CHAR; - std::string FOLDER_CHAR; - }; #endif // ES_APP_GUIS_GUI_GAME_LIST_OPTIONS_H diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index e020ab8e1..0db0f24ac 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -33,6 +33,8 @@ #include "Window.h" ViewController* ViewController::sInstance = nullptr; +const std::string ViewController::FAVORITE_CHAR = "\uF005"; +const std::string ViewController::FOLDER_CHAR = "\uF07C"; ViewController* ViewController::get() { diff --git a/es-app/src/views/ViewController.h b/es-app/src/views/ViewController.h index 7f0154817..638d3cb28 100644 --- a/es-app/src/views/ViewController.h +++ b/es-app/src/views/ViewController.h @@ -104,6 +104,9 @@ public: std::shared_ptr getSystemListView(); void removeGameListView(SystemData* system); + static const std::string FAVORITE_CHAR; + static const std::string FOLDER_CHAR; + private: ViewController(Window* window); static ViewController* sInstance; diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index e6a300bf7..075db9218 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -18,9 +18,6 @@ BasicGameListView::BasicGameListView(Window* window, FileData* root) : ISimpleGameListView(window, root), mList(window) { - FAVORITE_CHAR = root->FAVORITE_CHAR; - FOLDER_CHAR = root->FOLDER_CHAR; - mList.setSize(mSize.x(), mSize.y() * 0.8f); mList.setPosition(0, mSize.y() * 0.2f); mList.setDefaultZIndex(20); @@ -87,12 +84,12 @@ void BasicGameListView::populateList(const std::vector& files, FileDa } if ((*it)->getFavorite() && favoriteStar && mRoot->getSystem()->getName() != "favorites") { - mList.add(inCollectionPrefix + FAVORITE_CHAR + " " + (*it)->getName(), + mList.add(inCollectionPrefix + ViewController::FAVORITE_CHAR + " " + (*it)->getName(), *it, ((*it)->getType() == FOLDER)); } else if ((*it)->getType() == FOLDER && mRoot->getSystem()->getName() != "collections") { - mList.add(FOLDER_CHAR + " " + (*it)->getName(), *it, true); + mList.add(ViewController::FOLDER_CHAR + " " + (*it)->getName(), *it, true); } else { mList.add(inCollectionPrefix + (*it)->getName(), *it, ((*it)->getType() == FOLDER)); diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index 6a6fbd502..c7352bd68 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -389,8 +389,6 @@ void ISimpleGameListView::generateGamelistInfo(FileData* cursor, FileData* first void ISimpleGameListView::generateFirstLetterIndex(const std::vector& files) { - const std::string favoriteChar = mRoot->FAVORITE_CHAR; - const std::string folderChar = mRoot->FOLDER_CHAR; std::string firstChar; bool onlyFavorites = true; @@ -443,8 +441,8 @@ void ISimpleGameListView::generateFirstLetterIndex(const std::vector& // If there are any favorites and/or folders in the list, insert their respective // Unicode characters at the beginning of the vector. if (hasFavorites) - mFirstLetterIndex.insert(mFirstLetterIndex.begin(), favoriteChar); + mFirstLetterIndex.insert(mFirstLetterIndex.begin(), ViewController::FAVORITE_CHAR); if (hasFolders) - mFirstLetterIndex.insert(mFirstLetterIndex.begin(), folderChar); + mFirstLetterIndex.insert(mFirstLetterIndex.begin(), ViewController::FOLDER_CHAR); } diff --git a/es-core/src/Sound.cpp b/es-core/src/Sound.cpp index e3530f653..283884326 100644 --- a/es-core/src/Sound.cpp +++ b/es-core/src/Sound.cpp @@ -17,7 +17,7 @@ NavigationSounds* NavigationSounds::sInstance = nullptr; -std::map< std::string, std::shared_ptr > Sound::sMap; +std::map> Sound::sMap; std::shared_ptr Sound::get(const std::string& path) {