diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index c02d54abc..2acffb969 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -152,17 +152,6 @@ const std::vector FileData::getChildrenRecursive() const return childrenRecursive; } -bool FileData::viewHasOnlyFolders() -{ - bool onlyFolders = true; - std::vector entrySiblings = this->getParent()->getChildren(); - for (auto it = entrySiblings.cbegin(); it != entrySiblings.cend(); it++) { - if ((*it)->getType() != FOLDER) - onlyFolders = false; - } - return onlyFolders; -} - const std::string FileData::getROMDirectory() { std::string romDirSetting = Settings::getInstance()->getString("ROMDirectory"); @@ -440,6 +429,7 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending, std::pair& gameCount) { mOnlyFolders = true; + mHasFolders = false; bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop"); std::vector mChildrenFolders; std::vector mChildrenOthers; @@ -517,6 +507,8 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending, if ((*it)->getType() != FOLDER) mOnlyFolders = false; + else + mHasFolders = true; // Iterate through any child folders. if ((*it)->getChildren().size() > 0) @@ -531,6 +523,7 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending std::pair& gameCount) { mOnlyFolders = true; + mHasFolders = false; std::vector mChildrenFolders; std::vector mChildrenFavoritesFolders; std::vector mChildrenFavorites; @@ -579,6 +572,8 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending if (mChildren[i]->getType() != FOLDER) mOnlyFolders = false; + else + mHasFolders = true; } if (mSystem->isGroupedCustomCollection()) diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 4d4f8b4c0..3573381db 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -56,7 +56,7 @@ public: inline SystemData* getSystem() const { return mSystem; } inline SystemEnvironmentData* getSystemEnvData() const { return mEnvData; } const bool getOnlyFoldersFlag() { return mOnlyFolders; } - bool viewHasOnlyFolders(); + const bool getHasFoldersFlag() { return mHasFolders; } static const std::string getROMDirectory(); static const std::string getMediaDirectory(); const std::string getMediafilePath(std::string subdirectory, std::string mediatype) const; @@ -149,6 +149,7 @@ private: // The pair includes non-favorite games, and favorite games. std::pair mGameCount; bool mOnlyFolders; + bool mHasFolders; // Used for flagging a game for deletion from its gamelist.xml file. bool mDeletionFlag; diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index d88111c7c..caef63b2e 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -198,7 +198,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) // are not sorted on top, this way the logic should work exactly as for mixed // lists or files-only lists. if (getCursor()->getType() == FOLDER && foldersOnTop == true) - foldersOnTop = !getCursor()->viewHasOnlyFolders(); + foldersOnTop = !getCursor()->getParent()->getOnlyFoldersFlag(); if (mRoot->getSystem()->isCustomCollection()) favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom");