diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index d862abd7c..6279c004b 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -31,26 +31,30 @@ GuiGamelistOptions::GuiGamelistOptions( : GuiComponent(window), mSystem(system), mMenu(window, "OPTIONS"), - fromPlaceholder(false), mFiltersChanged(false), mCancelled(false), - isCustomCollection(false), - isCustomCollectionGroup(false) + mIsCustomCollection(false), + mIsCustomCollectionGroup(false), + mCustomCollectionSystem(nullptr) { addChild(&mMenu); - // Check that it's not a placeholder folder - if it is, only show "Filter Options". FileData* file = getGamelist()->getCursor(); - fromPlaceholder = file->isPlaceHolder(); + // Check if it's a placeholder, which would limit the menu entries presented. + file->isPlaceHolder(); + mFromPlaceholder = file->isPlaceHolder(); ComponentListRow row; // There is some special logic required for custom collections. if (file->getSystem()->isCustomCollection() && file->getPath() != file->getSystem()->getName()) - isCustomCollection = true; + mIsCustomCollection = true; else if (file->getSystem()->isCustomCollection() && file->getPath() == file->getSystem()->getName()) - isCustomCollectionGroup = true; + mIsCustomCollectionGroup = true; + + if (mFromPlaceholder && file->getSystem()->isGroupedCustomCollection()) + mCustomCollectionSystem = file->getSystem(); // Read the setting for whether folders are sorted on top of the gamelists. // Also check if the gamelist only contains folders, as generated by the FileData sorting. @@ -60,12 +64,12 @@ GuiGamelistOptions::GuiGamelistOptions( // Read the applicable favorite sorting setting depending on whether the // system is a custom collection or not. - if (isCustomCollection) + if (mIsCustomCollection) mFavoritesSorting = Settings::getInstance()->getBool("FavFirstCustom"); else mFavoritesSorting = Settings::getInstance()->getBool("FavoritesFirst"); - if (!fromPlaceholder) { + if (!mFromPlaceholder) { // Jump to letter quick selector. row.elements.clear(); @@ -108,11 +112,11 @@ GuiGamelistOptions::GuiGamelistOptions( mMenu.addWithLabel("JUMP TO..", mJumpToLetterList); // Add the sorting entry, unless this is the grouped custom collections list. - if (!isCustomCollectionGroup) { + if (!mIsCustomCollectionGroup) { // Sort list by selected sort type (persistent throughout the program session). mListSort = std::make_shared(mWindow, getHelpStyle(), "SORT GAMES BY", false); FileData* root; - if (isCustomCollection) + if (mIsCustomCollection) root = getGamelist()->getCursor()->getSystem()->getRootFolder(); else root = mSystem->getRootFolder(); @@ -133,7 +137,7 @@ GuiGamelistOptions::GuiGamelistOptions( } // Add the filters entry, unless this is the grouped custom collections list. - if (!isCustomCollectionGroup) { + if (!mIsCustomCollectionGroup) { if (system->getName() != "recent" && Settings::getInstance()->getBool("GamelistFilters")) { row.elements.clear(); row.addElement(std::make_shared @@ -151,7 +155,7 @@ GuiGamelistOptions::GuiGamelistOptions( customSystem = system->getName(); if (UIModeController::getInstance()->isUIModeFull() && - (isCustomCollection || isCustomCollectionGroup)) { + (mIsCustomCollection || mIsCustomCollectionGroup)) { if (CollectionSystemsManager::get()->getEditingCollection() != customSystem) { row.elements.clear(); row.addElement(std::make_shared( @@ -174,7 +178,7 @@ GuiGamelistOptions::GuiGamelistOptions( } if (file->getType() == FOLDER) { - if (UIModeController::getInstance()->isUIModeFull() && !fromPlaceholder && + if (UIModeController::getInstance()->isUIModeFull() && !mFromPlaceholder && !(mSystem->isCollection() && file->getType() == FOLDER)) { row.elements.clear(); row.addElement(std::make_shared(mWindow, @@ -185,7 +189,7 @@ GuiGamelistOptions::GuiGamelistOptions( } } else { - if (UIModeController::getInstance()->isUIModeFull() && !fromPlaceholder && + if (UIModeController::getInstance()->isUIModeFull() && !mFromPlaceholder && !(mSystem->isCollection() && file->getType() == FOLDER)) { row.elements.clear(); row.addElement(std::make_shared(mWindow, @@ -214,18 +218,35 @@ GuiGamelistOptions::~GuiGamelistOptions() // the menu has been closed. ViewController::get()->stopScrolling(); + if (mFiltersChanged) { + if (!mCustomCollectionSystem) { + ViewController::get()->reloadGameListView(mSystem); + } + else { + if (!mFromPlaceholder) { + ViewController::get()->reloadGameListView(mSystem); + } + else if (!mCustomCollectionSystem->getRootFolder()-> + getChildrenListToDisplay().empty()) { + ViewController::get()->reloadGameListView(mSystem); + getGamelist()->setCursor(mCustomCollectionSystem-> + getRootFolder()->getChildrenListToDisplay().front()); + } + } + } + if (mCancelled) return; - if (!fromPlaceholder) { + if (!mFromPlaceholder) { FileData* root; - if (isCustomCollection) + if (mIsCustomCollection) root = getGamelist()->getCursor()->getSystem()->getRootFolder(); else root = mSystem->getRootFolder(); // If a new sorting type was selected, then sort and update mSortTypeString for the system. - if (!isCustomCollectionGroup && + if (!mIsCustomCollectionGroup && (*mListSort->getSelected()).description != root->getSortTypeString()) { // This will also recursively sort children. root->sort(*mListSort->getSelected(), mFavoritesSorting); @@ -245,12 +266,6 @@ GuiGamelistOptions::~GuiGamelistOptions() } } - if (mFiltersChanged) { - // Only reload full view if we came from a placeholder as we need to - // re-display the remaining elements for whatever new game is selected. - ViewController::get()->reloadGameListView(mSystem); - } - NavigationSounds::getInstance()->playThemeNavigationSound(SCROLLSOUND); } @@ -259,7 +274,7 @@ void GuiGamelistOptions::openGamelistFilter() GuiGamelistFilter* ggf; mFiltersChanged = true; - if (isCustomCollection) + if (mIsCustomCollection) ggf = new GuiGamelistFilter(mWindow, getGamelist()->getCursor()->getSystem()); else ggf = new GuiGamelistFilter(mWindow, mSystem); diff --git a/es-app/src/guis/GuiGamelistOptions.h b/es-app/src/guis/GuiGamelistOptions.h index 070cf2de1..edb9eb693 100644 --- a/es-app/src/guis/GuiGamelistOptions.h +++ b/es-app/src/guis/GuiGamelistOptions.h @@ -54,11 +54,12 @@ private: bool mFoldersOnTop; bool mFavoritesSorting; bool mOnlyHasFolders; - bool fromPlaceholder; + bool mFromPlaceholder; bool mFiltersChanged; bool mCancelled; - bool isCustomCollection; - bool isCustomCollectionGroup; + bool mIsCustomCollection; + bool mIsCustomCollectionGroup; + SystemData* mCustomCollectionSystem; std::vector mFirstLetterIndex; std::string mCurrentFirstCharacter; };