diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index 47664ea1e..ebd4edda5 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -84,8 +84,6 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions( setNeedsSaving(); setNeedsReloading(); setNeedsCollectionsUpdate(); - if (!mAddedCustomCollection) - setNeedsGoToSystem(SystemData::sSystemVector.front()); } }); @@ -130,7 +128,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions( addedCustomSystems.push_back(system); } } - if (!addedCustomSystems.empty()) { + if (!mAddedCustomCollection && !addedCustomSystems.empty()) { for (std::string system : addedCustomSystems) CollectionSystemsManager::get()-> repopulateCollection(customSystems.find(system)->second.system); @@ -138,8 +136,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions( setNeedsSaving(); setNeedsReloading(); setNeedsCollectionsUpdate(); - if (!mAddedCustomCollection) - setNeedsGoToSystem(SystemData::sSystemVector.front()); + setNeedsGoToGroupedCollections(); } } }); @@ -259,6 +256,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions( Settings::getInstance()->setString("CollectionSystemsCustom", collectionsConfigEntry); setNeedsSaving(); + setNeedsGoToStart(); setNeedsGoToSystem(SystemData::sSystemVector.front()); } CollectionSystemsManager::get()->deleteCustomCollection(name); @@ -356,7 +354,12 @@ void GuiCollectionSystemsOptions::createCustomCollection(std::string inName) collection_systems_custom->add(collectionName, collectionName, true); mAddedCustomCollection = true; - setNeedsGoToSystem(newCollection); + setNeedsGoToStart(); + + if (Settings::getInstance()->getBool("UseCustomCollectionsSystem")) + setNeedsGoToGroupedCollections(); + else + setNeedsGoToSystem(newCollection); Window* window = mWindow; while (window->peekGui() && window->peekGui() != ViewController::get()) diff --git a/es-app/src/guis/GuiSettings.cpp b/es-app/src/guis/GuiSettings.cpp index 4bc9a7ac3..caba5800b 100644 --- a/es-app/src/guis/GuiSettings.cpp +++ b/es-app/src/guis/GuiSettings.cpp @@ -30,7 +30,8 @@ GuiSettings::GuiSettings( mNeedsSortingCollections(false), mGoToSystem(nullptr), mNeedsGoToStart(false), - mNeedsGoToSystem(false) + mNeedsGoToSystem(false), + mNeedsGoToGroupedCollections(false) { addChild(&mMenu); mMenu.addButton("BACK", "back", [this] { delete this; }); @@ -82,6 +83,38 @@ void GuiSettings::save() if (mNeedsGoToSystem) ViewController::get()->goToSystem(mGoToSystem, false); + if (mNeedsGoToGroupedCollections) { + for (SystemData* system : SystemData::sSystemVector) { + if (system->getThemeFolder() == "custom-collections") { + ViewController::get()->goToSystem(system, false); + continue; + } + } + } + + if (mNeedsCollectionsUpdate) { + auto state = ViewController::get()->getState(); + // If we're in any view other than the grouped custom collections, always jump to the + // system view in case of any collection updates. This is overkill in some instances but + // these views can behave a bit strange during collection changes so it's better to be on + // the safe side. + if (state.getSystem()->isCollection() && + state.getSystem()->getThemeFolder() != "custom-collections") { + ViewController::get()->goToStart(); + ViewController::get()->goToSystem(SystemData::sSystemVector.front(), false); + // We don't want to invalidate the cached background when there has been a collection + // systen change as that may show a black screen in some circumstances. + return; + } + // If the last displayed custom collection was just disabled, then go to start (to the + // system view). + if (std::find(SystemData::sSystemVector.begin(), SystemData::sSystemVector.end(), + state.getSystem()) == SystemData::sSystemVector.end()) { + ViewController::get()->goToStart(); + return; + } + } + if (mNeedsSaving || mNeedsCollectionsUpdate || mNeedsReloading || mNeedsSorting || mNeedsGoToStart || mNeedsGoToSystem) mWindow->invalidateCachedBackground(); diff --git a/es-app/src/guis/GuiSettings.h b/es-app/src/guis/GuiSettings.h index 9cc934b80..cda601c1d 100644 --- a/es-app/src/guis/GuiSettings.h +++ b/es-app/src/guis/GuiSettings.h @@ -41,6 +41,7 @@ public: void setNeedsGoToStart() { mNeedsGoToStart = true; }; void setNeedsGoToSystem(SystemData* goToSystem) { mNeedsGoToSystem = true; mGoToSystem = goToSystem; }; + void setNeedsGoToGroupedCollections() { mNeedsGoToGroupedCollections = true; }; bool input(InputConfig* config, Input input) override; std::vector getHelpPrompts() override; @@ -56,6 +57,7 @@ private: bool mNeedsSortingCollections; bool mNeedsGoToStart; bool mNeedsGoToSystem; + bool mNeedsGoToGroupedCollections; SystemData* mGoToSystem; };