diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 77de87fcc..c841d2882 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -15,6 +15,7 @@ #include "utils/FileSystemUtil.h" #include "utils/StringUtil.h" #include "views/UIModeController.h" +#include "views/ViewController.h" #include "CollectionSystemManager.h" #include "FileFilterIndex.h" #include "FileSorts.h" @@ -613,6 +614,28 @@ FileData* SystemData::getRandomGame(const FileData* currentGame) return gameList.at(target); } +void SystemData::sortSystem(bool reloadGamelist) +{ + if (getName() == "recent") + return; + + bool favoritesSorting; + + if (CollectionSystemManager::get()->getIsCustomCollection(this)) + favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom"); + else + favoritesSorting = Settings::getInstance()->getBool("FavoritesFirst"); + + FileData* rootFolder = getRootFolder(); + setupSystemSortType(rootFolder); + + rootFolder->sort(rootFolder->getSortTypeFromString( + rootFolder->getSortTypeString()), favoritesSorting); + + if (reloadGamelist) + ViewController::get()->reloadGameListView(this, false); +} + std::pair SystemData::getDisplayedGameCount() const { // Return all games for the system which are marked as 'countasgame'. As this flag is set diff --git a/es-app/src/SystemData.h b/es-app/src/SystemData.h index 26f276d08..d729eb63a 100644 --- a/es-app/src/SystemData.h +++ b/es-app/src/SystemData.h @@ -93,6 +93,8 @@ public: static FileData* getRandomCollectionFolder(const FileData* currentFolder); FileData* getRandomGame(const FileData* currentGame = nullptr); + void sortSystem(bool reloadGamelist = true); + // Load or re-load theme. void loadTheme(); diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index f0f30710a..91ef90ae1 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -372,22 +372,7 @@ void GuiMenu::openUISettings() for (auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++) { - bool favoritesSorting; - - if ((*it)->getName() == "recent") - continue; - - if (CollectionSystemManager::get()->getIsCustomCollection(*it)) - favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom"); - else - favoritesSorting = Settings::getInstance()->getBool("FavoritesFirst"); - - FileData* rootFolder = (*it)->getRootFolder(); - rootFolder->getSystem()->setupSystemSortType(rootFolder); - - rootFolder->sort(rootFolder->getSortTypeFromString( - rootFolder->getSortTypeString()), favoritesSorting); - ViewController::get()->reloadGameListView(*it); + (*it)->sortSystem(); // Jump to the first row of the gamelist. IGameListView* gameList = ViewController::get()->getGameListView((*it)).get();