From c84290e7fb5b81d8c7fe8f6f160115c43c446fbc Mon Sep 17 00:00:00 2001 From: Cristi Mitrana <31816814+cmitu@users.noreply.github.com> Date: Thu, 11 Jul 2019 09:38:23 +0300 Subject: [PATCH] Makes the display of system's name in Collections configurable. * adds a new configuration option ("CollectionShowSystemInfo" = bool), in the 'Game Collections Settings' GUI. Defaults to previous behavior (true). * reloads the Collection when the configuration is changed. --- es-app/src/CollectionSystemManager.cpp | 1 - es-app/src/FileData.cpp | 19 +++++++++++-------- .../src/guis/GuiCollectionSystemsOptions.cpp | 10 +++++++++- es-app/src/guis/GuiCollectionSystemsOptions.h | 1 + es-core/src/Settings.cpp | 1 + 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index 0ccdd9ee1..ea3f629da 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -1032,7 +1032,6 @@ bool CollectionSystemManager::includeFileInAutoCollections(FileData* file) return file->getName() != "kodi" && file->getSystem()->isGameSystem(); } - std::string getCustomCollectionConfigPath(std::string collectionName) { return getCollectionsFolder() + "/custom-" + collectionName + ".cfg"; diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 16cdd164d..2238c60f9 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -345,14 +345,17 @@ void CollectionFileData::refreshMetadata() mDirty = true; } -const std::string& CollectionFileData::getName() -{ - if (mDirty) { - mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name")); - mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]"; - mDirty = false; - } - return mCollectionFileName; +const std::string& CollectionFileData::getName() +{ + if (mDirty) { + mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name")); + mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]"; + mDirty = false; + } + + if (Settings::getInstance()->getBool("CollectionShowSystemInfo")) + return mCollectionFileName; + return mSourceFileData->metadata.get("name"); } // returns Sort Type based on a string description diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index 27df3082e..ede6f3eb6 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -75,6 +75,10 @@ void GuiCollectionSystemsOptions::initializeMenu() sortAllSystemsSwitch->setState(Settings::getInstance()->getBool("SortAllSystems")); mMenu.addWithLabel("SORT CUSTOM COLLECTIONS AND SYSTEMS", sortAllSystemsSwitch); + toggleSystemNameInCollections = std::make_shared(mWindow); + toggleSystemNameInCollections->setState(Settings::getInstance()->getBool("CollectionShowSystemInfo")); + mMenu.addWithLabel("SHOW SYSTEM NAME IN COLLECTIONS", toggleSystemNameInCollections); + if(CollectionSystemManager::get()->isEditing()) { row.elements.clear(); @@ -170,11 +174,14 @@ void GuiCollectionSystemsOptions::applySettings() bool prevSort = Settings::getInstance()->getBool("SortAllSystems"); bool outBundle = bundleCustomCollections->getState(); bool prevBundle = Settings::getInstance()->getBool("UseCustomCollectionsSystem"); - bool needUpdateSettings = prevAuto != outAuto || prevCustom != outCustom || outSort != prevSort || outBundle != prevBundle; + bool prevShow = Settings::getInstance()->getBool("CollectionShowSystemInfo"); + bool outShow = toggleSystemNameInCollections->getState(); + bool needUpdateSettings = prevAuto != outAuto || prevCustom != outCustom || outSort != prevSort || outBundle != prevBundle || prevShow != outShow ; if (needUpdateSettings) { updateSettings(outAuto, outCustom); } + delete this; } @@ -184,6 +191,7 @@ void GuiCollectionSystemsOptions::updateSettings(std::string newAutoSettings, st Settings::getInstance()->setString("CollectionSystemsCustom", newCustomSettings); Settings::getInstance()->setBool("SortAllSystems", sortAllSystemsSwitch->getState()); Settings::getInstance()->setBool("UseCustomCollectionsSystem", bundleCustomCollections->getState()); + Settings::getInstance()->setBool("CollectionShowSystemInfo", toggleSystemNameInCollections->getState()); Settings::getInstance()->saveFile(); CollectionSystemManager::get()->loadEnabledListFromSettings(); CollectionSystemManager::get()->updateSystemsList(); diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.h b/es-app/src/guis/GuiCollectionSystemsOptions.h index fc6113e0a..dd19bf962 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.h +++ b/es-app/src/guis/GuiCollectionSystemsOptions.h @@ -30,6 +30,7 @@ private: std::shared_ptr< OptionListComponent > customOptionList; std::shared_ptr sortAllSystemsSwitch; std::shared_ptr bundleCustomCollections; + std::shared_ptr toggleSystemNameInCollections; MenuComponent mMenu; SystemData* mSystem; }; diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 13c09a84a..e4435077a 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -129,6 +129,7 @@ void Settings::setDefaults() mStringMap["OMXAudioDev"] = "both"; mStringMap["CollectionSystemsAuto"] = ""; mStringMap["CollectionSystemsCustom"] = ""; + mBoolMap["CollectionShowSystemInfo"] = true; mBoolMap["SortAllSystems"] = false; mBoolMap["UseCustomCollectionsSystem"] = true;