From d7372df031f7573a4fa3ca9854636b0ed3f9bbfe Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 18 Oct 2020 19:14:34 +0200 Subject: [PATCH] Greatly simplified the handling of hidden games. --- es-app/src/FileData.cpp | 31 +++---------------------------- es-app/src/Gamelist.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index aad8b0b35..588d42447 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -71,11 +71,11 @@ FileData::~FileData() if (mType == GAME) mSystem->getIndex()->removeFromIndex(this); - if (mParent) - mParent->removeChild(this); - while (mChildren.size() > 0) delete (mChildren.front()); + + if (mParent) + mParent->removeChild(this); } std::string FileData::getDisplayName() const @@ -447,23 +447,6 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending, std::vector mChildrenFolders; std::vector mChildrenOthers; - // Only run this section of code if the setting to show hidden games has been disabled, - // in order to avoid unnecessary processing. - if (!Settings::getInstance()->getBool("ShowHiddenGames")) { - std::vector mChildrenShown; - for (unsigned int i = 0; i < mChildren.size(); i++) { - if (mChildren[i]->getHidden()) { - LOG(LogDebug) << "FileData::sort(): Skipping hidden game '" << - mChildren[i]->getName() << "'" << " (" << mChildren[i]->getPath() << ")."; - continue; - } - mChildrenShown.push_back(mChildren[i]); - } - mChildren.erase(mChildren.begin(), mChildren.end()); - mChildren.reserve(mChildrenShown.size()); - mChildren.insert(mChildren.end(), mChildrenShown.begin(), mChildrenShown.end()); - } - if (foldersOnTop) { for (unsigned int i = 0; i < mChildren.size(); i++) { if (mChildren[i]->getType() == FOLDER) { @@ -559,18 +542,10 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending std::vector mChildrenFavoritesFolders; std::vector mChildrenFavorites; std::vector mChildrenOthers; - bool showHiddenGames = Settings::getInstance()->getBool("ShowHiddenGames"); bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop"); bool hasFolders = false; for (unsigned int i = 0; i < mChildren.size(); i++) { - // Exclude game if it's marked as hidden and the hide setting has been set. - if (!showHiddenGames && mChildren[i]->getHidden()) { - LOG(LogDebug) << "FileData::sortFavoritesOnTop(): Skipping hidden game '" << - mChildren[i]->getName() << "'" << " (" << mChildren[i]->getPath() << ")."; - continue; - } - // Game count, which will be displayed in the system view. if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) { if (!mChildren[i]->getFavorite()) diff --git a/es-app/src/Gamelist.cpp b/es-app/src/Gamelist.cpp index be990a7fc..69073291d 100644 --- a/es-app/src/Gamelist.cpp +++ b/es-app/src/Gamelist.cpp @@ -158,6 +158,15 @@ void parseGamelist(SystemData* system) file->metadata.resetChangedFlag(); } + // If the game is flagged as hidden and the option has not been set to show hidden + // games, then delete the entry. This leaves no trace of the entry at all in ES + // but that is fine as the option to show hidden files is defined as requiring an + // application restart. + if (!Settings::getInstance()->getBool("ShowHiddenGames") && file->getHidden()) { + LOG(LogDebug) << "Gamelist::parseGamelist(): Skipping hidden entry '" << + file->getName() << "'" << " (" << file->getPath() << ")."; + delete file; + } } } }