From 01cf401d8fd64574dcc3821ea3d3ece26db605b0 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 25 Oct 2020 21:29:54 +0100 Subject: [PATCH] Added menu options to disable the favorite star markings. --- USERGUIDE.md | 9 ++- es-app/src/CollectionSystemManager.cpp | 66 +++++++++++++------ .../src/guis/GuiCollectionSystemsOptions.cpp | 10 ++- es-app/src/guis/GuiCollectionSystemsOptions.h | 1 + es-app/src/guis/GuiMenu.cpp | 11 ++++ .../src/views/gamelist/BasicGameListView.cpp | 12 +++- es-core/src/Settings.cpp | 2 + 7 files changed, 87 insertions(+), 24 deletions(-) diff --git a/USERGUIDE.md b/USERGUIDE.md index 6722a96fa..521730bea 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -620,6 +620,9 @@ Whether to place all folders on top of the gamelists. If done so, the folders wi Whether to sort your favorite games above your other games in the gamelists. +**Add star markings to favorite games** +With this setting enabled, there is a star symbol added at the beginning of the game name in the gamelist views. It's strongly recommended to keep this setting enabled if the option to sort favorite games above non-favorites has been enabled. If not, favorite games would be sorted on top of the gamelist with no visual indication that they are favorites, which would be very confusing. + **Gamelist filters** Activating or deactivating the ability to filter your gamelists. Can normally be left on. @@ -756,7 +759,11 @@ This lets you create a completely custom collection with a name that you choose. **Sort favorites on top for custom collections** -Whether to sort your favorite games above your other games. This is disabled by default, as for collections you normally want to be able to mix all games regardless of whether they are favorites or not. +Whether to sort your favorite games above your other games. This is disabled by default, as for collections you probably want to be able to mix all games regardless of whether they are favorites or not. + +**Display star markings for custom collections** + +With this option enabled, there is a star marking added to each favorite game name. It works identically to the setting 'Add star markings to favorite games' but is applied specifically to custom collections. It's disabled by default. **Group unthemed custom collections** diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index 661d1c090..25792da31 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -760,27 +760,51 @@ FileData* CollectionSystemManager::updateCollectionFolderMetadata(SystemData* sy } if (gameCount > 0) { - switch (gameCount) { - case 1: - desc = "This collection contains 1 game: '" + gamesList[0]->metadata.get("name") + - " [" + gamesList[0]->getSourceFileData()->getSystem()->getName() + "]'."; - break; - case 2: - desc = "This collection contains 2 games: '" + gamesList[0]->metadata.get("name") + - " [" + gamesList[0]->getSourceFileData()->getSystem()->getName() + - "]' and '" + gamesList[1]->metadata.get("name") + " [" + - gamesList[1]->getSourceFileData()->getSystem()->getName() + "]'."; - break; - default: - desc = "This collection contains " + std::to_string(gameCount) + - " games: '" + gamesList[0]->metadata.get("name") + - " [" + gamesList[0]->getSourceFileData()->getSystem()->getName() + - "]', '" + gamesList[1]->metadata.get("name") + " [" + - gamesList[1]->getSourceFileData()->getSystem()->getName() + "]' and '" + - gamesList[2]->metadata.get("name") + " [" + - gamesList[2]->getSourceFileData()->getSystem()->getName() + "]'"; - desc += (gameCount == 3 ? "." : ", among others."); - break; + if (Settings::getInstance()->getBool("CollectionShowSystemInfo")) { + switch (gameCount) { + case 1: + desc = "This collection contains 1 game: '" + + gamesList[0]->metadata.get("name") + " [" + + gamesList[0]->getSourceFileData()->getSystem()->getName() + "]'."; + break; + case 2: + desc = "This collection contains 2 games: '" + + gamesList[0]->metadata.get("name") + " [" + + gamesList[0]->getSourceFileData()->getSystem()->getName() + + "]' and '" + gamesList[1]->metadata.get("name") + " [" + + gamesList[1]->getSourceFileData()->getSystem()->getName() + "]'."; + break; + default: + desc = "This collection contains " + std::to_string(gameCount) + + " games: '" + gamesList[0]->metadata.get("name") + + " [" + gamesList[0]->getSourceFileData()->getSystem()->getName() + + "]', '" + gamesList[1]->metadata.get("name") + " [" + + gamesList[1]->getSourceFileData()->getSystem()->getName() + "]' and '" + + gamesList[2]->metadata.get("name") + " [" + + gamesList[2]->getSourceFileData()->getSystem()->getName() + "]'"; + desc += (gameCount == 3 ? "." : ", among others."); + break; + } + } + else { + switch (gameCount) { + case 1: + desc = "This collection contains 1 game: '" + + gamesList[0]->metadata.get("name") + " '."; + break; + case 2: + desc = "This collection contains 2 games: '" + + gamesList[0]->metadata.get("name") + + "' and '" + gamesList[1]->metadata.get("name") + "'."; + break; + default: + desc = "This collection contains " + std::to_string(gameCount) + + " games: '" + gamesList[0]->metadata.get("name") + + "', '" + gamesList[1]->metadata.get("name") + "' and '" + + gamesList[2]->metadata.get("name") + "'"; + desc += (gameCount == 3 ? "." : ", among others."); + break; + } } } diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index e489cbcfb..a6546a92a 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -89,6 +89,10 @@ void GuiCollectionSystemsOptions::initializeMenu() sortFavFirstCustomSwitch->setState(Settings::getInstance()->getBool("FavFirstCustom")); mMenu.addWithLabel("SORT FAVORITES ON TOP FOR CUSTOM COLLECTIONS", sortFavFirstCustomSwitch); + favoriteStarCustomSwitch = std::make_shared(mWindow); + favoriteStarCustomSwitch->setState(Settings::getInstance()->getBool("FavStarCustom")); + mMenu.addWithLabel("DISPLAY STAR MARKINGS FOR CUSTOM COLLECTIONS", favoriteStarCustomSwitch); + bundleCustomCollections = std::make_shared(mWindow); bundleCustomCollections->setState(Settings::getInstance()-> getBool("UseCustomCollectionsSystem")); @@ -199,12 +203,14 @@ void GuiCollectionSystemsOptions::applySettings() std::string prevCustom = Settings::getInstance()->getString("CollectionSystemsCustom"); bool outSort = sortFavFirstCustomSwitch->getState(); bool prevSort = Settings::getInstance()->getBool("FavFirstCustom"); + bool outFavStar = favoriteStarCustomSwitch->getState(); + bool prevFavStar = Settings::getInstance()->getBool("FavStarCustom"); bool outBundle = bundleCustomCollections->getState(); bool prevBundle = Settings::getInstance()->getBool("UseCustomCollectionsSystem"); bool prevShow = Settings::getInstance()->getBool("CollectionShowSystemInfo"); bool outShow = toggleSystemNameInCollections->getState(); bool needUpdateSettings = prevAuto != outAuto || prevCustom != outCustom || outSort != - prevSort || outBundle != prevBundle || prevShow != outShow ; + prevSort || outFavStar != prevFavStar || outBundle != prevBundle || prevShow != outShow; if (needUpdateSettings) updateSettings(outAuto, outCustom); @@ -218,6 +224,7 @@ void GuiCollectionSystemsOptions::updateSettings(std::string newAutoSettings, Settings::getInstance()->setString("CollectionSystemsAuto", newAutoSettings); Settings::getInstance()->setString("CollectionSystemsCustom", newCustomSettings); Settings::getInstance()->setBool("FavFirstCustom", sortFavFirstCustomSwitch->getState()); + Settings::getInstance()->setBool("FavStarCustom", favoriteStarCustomSwitch->getState()); Settings::getInstance()->setBool("UseCustomCollectionsSystem", bundleCustomCollections->getState()); Settings::getInstance()->setBool("CollectionShowSystemInfo", @@ -227,6 +234,7 @@ void GuiCollectionSystemsOptions::updateSettings(std::string newAutoSettings, CollectionSystemManager::get()->updateSystemsList(); ViewController::get()->goToStart(); ViewController::get()->reloadAll(); + mWindow->invalidateCachedBackground(); } bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input) diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.h b/es-app/src/guis/GuiCollectionSystemsOptions.h index 64f34b1f5..fbac6ba82 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.h +++ b/es-app/src/guis/GuiCollectionSystemsOptions.h @@ -40,6 +40,7 @@ private: std::shared_ptr> customOptionList; std::shared_ptr bundleCustomCollections; std::shared_ptr sortFavFirstCustomSwitch; + std::shared_ptr favoriteStarCustomSwitch; std::shared_ptr toggleSystemNameInCollections; MenuComponent mMenu; SystemData* mSystem; diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 8c88c43b6..e75634c3e 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -482,6 +482,17 @@ void GuiMenu::openUISettings() } }); + // Enable gamelist star markings for favorite games. + auto favorites_stars = std::make_shared(mWindow); + favorites_stars->setState(Settings::getInstance()->getBool("FavoritesStar")); + s->addWithLabel("ADD STAR MARKINGS TO FAVORITE GAMES", favorites_stars); + s->addSaveFunc([favorites_stars] { + if (Settings::getInstance()->getBool("FavoritesStar") != favorites_stars->getState()) { + Settings::getInstance()->setBool("FavoritesStar", favorites_stars->getState()); + ViewController::get()->reloadAll(); + } + }); + // Enable filters (ForceDisableFilters). auto enable_filter = std::make_shared(mWindow); enable_filter->setState(!Settings::getInstance()->getBool("ForceDisableFilters")); diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index 9e7fede87..7f3d39663 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -52,6 +52,16 @@ void BasicGameListView::onFileChanged(FileData* file, FileChangeType change) void BasicGameListView::populateList(const std::vector& files) { firstGameEntry = nullptr; + bool favoriteStar = true; + + // Read the settings that control whether a unicode star character should be added + // as a prefix to the game name. + if (files.size() > 0) { + if (files.front()->getSystem()->isCustomCollection()) + favoriteStar = Settings::getInstance()->getBool("FavStarCustom"); + else + favoriteStar = Settings::getInstance()->getBool("FavoritesStar"); + } mList.clear(); mHeaderText.setText(mRoot->getSystem()->getFullName()); @@ -60,7 +70,7 @@ void BasicGameListView::populateList(const std::vector& files) if (!firstGameEntry && (*it)->getType() == GAME) firstGameEntry = (*it); - if ((*it)->getFavorite() && + if ((*it)->getFavorite() && favoriteStar && mRoot->getSystem()->getName() != "favorites") { mList.add(FAVORITE_CHAR + " " + (*it)->getName(), *it, ((*it)->getType() == FOLDER)); diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 2c38459d8..945ff2fd1 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -91,6 +91,7 @@ void Settings::setDefaults() mBoolMap["GamelistVideoScanlines"] = true; mBoolMap["FoldersOnTop"] = true; mBoolMap["FavoritesFirst"] = true; + mBoolMap["FavoritesStar"] = true; mBoolMap["ForceDisableFilters"] = false; mBoolMap["QuickSystemSelect"] = true; mBoolMap["ShowHelpPrompts"] = true; @@ -151,6 +152,7 @@ void Settings::setDefaults() mStringMap["CollectionSystemsCustom"] = ""; mBoolMap["UseCustomCollectionsSystem"] = true; mBoolMap["FavFirstCustom"] = false; + mBoolMap["FavStarCustom"] = false; mBoolMap["CollectionShowSystemInfo"] = true; // Scraper.