mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
Moved a sorting function to the proper location inside the correct class.
This commit is contained in:
parent
d4f5b2d20d
commit
14e2ede448
|
@ -217,11 +217,11 @@ void CollectionSystemManager::updateSystemsList()
|
|||
|
||||
// Don't sort bundled collections unless at least one collection is enabled.
|
||||
if (!mIsEditingCustom && mHasEnabledCustomCollection) {
|
||||
FileData* rootFolder = mCustomCollectionsBundle->getRootFolder();
|
||||
// Sort the bundled custom collections.
|
||||
if (mCustomCollectionsBundle->getRootFolder()->getChildren().size() > 0) {
|
||||
mCustomCollectionsBundle->getRootFolder()->sort(getSortTypeFromString(
|
||||
mCustomCollectionsBundle->getRootFolder()->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavFirstCustom"));
|
||||
if (rootFolder->getChildren().size() > 0) {
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->
|
||||
getSortTypeString()), Settings::getInstance()->getBool("FavFirstCustom"));
|
||||
SystemData::sSystemVector.push_back(mCustomCollectionsBundle);
|
||||
}
|
||||
}
|
||||
|
@ -348,22 +348,22 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS
|
|||
}
|
||||
|
||||
if (name == "recent") {
|
||||
rootFolder->sort(getSortTypeFromString("last played, descending"));
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString("last played, descending"));
|
||||
}
|
||||
else if (sysData.decl.isCustom &&
|
||||
!Settings::getInstance()->getBool("UseCustomCollectionsSystem")) {
|
||||
rootFolder->sort(getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
mFavoritesSorting);
|
||||
}
|
||||
// If the game doesn't exist in the current system and it's a custom
|
||||
// collection, then skip the sorting.
|
||||
else if (sysData.decl.isCustom &&
|
||||
children.find(file->getFullPath()) != children.cend()) {
|
||||
rootFolder->sort(getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
mFavoritesSorting);
|
||||
}
|
||||
else if (!sysData.decl.isCustom) {
|
||||
rootFolder->sort(getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
mFavoritesSorting);
|
||||
}
|
||||
|
||||
|
@ -600,9 +600,10 @@ bool CollectionSystemManager::toggleGameInCollection(FileData* file)
|
|||
ViewController::get()->getGameListView(systemViewToUpdate)->
|
||||
onFileChanged(newGame, FILE_METADATA_CHANGED);
|
||||
if (name == "recent")
|
||||
rootFolder->sort(getSortTypeFromString("last played, descending"));
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString("last played, descending"));
|
||||
else
|
||||
rootFolder->sort(getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(
|
||||
rootFolder->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavFirstCustom"));
|
||||
|
||||
ViewController::get()->onFileChanged(systemViewToUpdate->
|
||||
|
@ -850,9 +851,9 @@ void CollectionSystemManager::populateAutoCollection(CollectionSystemData* sysDa
|
|||
}
|
||||
}
|
||||
if (rootFolder->getName() == "recent")
|
||||
rootFolder->sort(getSortTypeFromString("last played, descending"));
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString("last played, descending"));
|
||||
else
|
||||
rootFolder->sort(getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavoritesFirst"));
|
||||
|
||||
if (sysDecl.type == AUTO_LAST_PLAYED)
|
||||
|
@ -966,7 +967,8 @@ void CollectionSystemManager::addEnabledCollectionsToDisplayedSystems(
|
|||
// If this is a non-bundled custom collection, then sort it.
|
||||
if (it->second.decl.isCustom == true) {
|
||||
FileData* rootFolder = it->second.system->getRootFolder();
|
||||
rootFolder->sort(getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(
|
||||
rootFolder->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavFirstCustom"));
|
||||
// Jump to the first row of the game list, assuming it's not empty.
|
||||
IGameListView* gameList = ViewController::get()->
|
||||
|
|
|
@ -621,6 +621,18 @@ void FileData::sort(const SortType& type, bool mFavoritesOnTop)
|
|||
sort(*type.comparisonFunction, type.ascending);
|
||||
}
|
||||
|
||||
FileData::SortType FileData::getSortTypeFromString(std::string desc) {
|
||||
std::vector<FileData::SortType> SortTypes = FileSorts::SortTypes;
|
||||
|
||||
for (unsigned int i = 0; i < FileSorts::SortTypes.size(); i++) {
|
||||
const FileData::SortType& sort = FileSorts::SortTypes.at(i);
|
||||
if (sort.description == desc)
|
||||
return sort;
|
||||
}
|
||||
// If no type was found then default to "filename, ascending".
|
||||
return FileSorts::SortTypes.at(0);
|
||||
}
|
||||
|
||||
void FileData::launchGame(Window* window)
|
||||
{
|
||||
LOG(LogInfo) << "Attempting to launch game...";
|
||||
|
@ -831,16 +843,3 @@ const std::string& CollectionFileData::getName()
|
|||
|
||||
return mSourceFileData->metadata.get("name");
|
||||
}
|
||||
|
||||
// Return sort type based on a string description.
|
||||
FileData::SortType getSortTypeFromString(std::string desc) {
|
||||
std::vector<FileData::SortType> SortTypes = FileSorts::SortTypes;
|
||||
// Find it
|
||||
for (unsigned int i = 0; i < FileSorts::SortTypes.size(); i++) {
|
||||
const FileData::SortType& sort = FileSorts::SortTypes.at(i);
|
||||
if (sort.description == desc)
|
||||
return sort;
|
||||
}
|
||||
// If no type found then default to "filename, ascending".
|
||||
return FileSorts::SortTypes.at(0);
|
||||
}
|
||||
|
|
|
@ -129,6 +129,8 @@ public:
|
|||
|
||||
inline void setSortTypeString(std::string typestring) { mSortTypeString = typestring; }
|
||||
inline std::string getSortTypeString() { return mSortTypeString; }
|
||||
// Return sort type based on a string description.
|
||||
FileData::SortType getSortTypeFromString(std::string desc);
|
||||
|
||||
protected:
|
||||
FileData* mSourceFileData;
|
||||
|
@ -167,6 +169,4 @@ private:
|
|||
bool mDirty;
|
||||
};
|
||||
|
||||
FileData::SortType getSortTypeFromString(std::string desc);
|
||||
|
||||
#endif // ES_APP_FILE_DATA_H
|
||||
|
|
|
@ -60,7 +60,7 @@ SystemData::SystemData(
|
|||
|
||||
setupSystemSortType(mRootFolder);
|
||||
|
||||
mRootFolder->sort(getSortTypeFromString(mRootFolder->getSortTypeString()),
|
||||
mRootFolder->sort(mRootFolder->getSortTypeFromString(mRootFolder->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavoritesFirst"));
|
||||
|
||||
indexAllGameFilters(mRootFolder);
|
||||
|
|
|
@ -385,7 +385,7 @@ void GuiMenu::openUISettings()
|
|||
FileData* rootFolder = (*it)->getRootFolder();
|
||||
rootFolder->getSystem()->setupSystemSortType(rootFolder);
|
||||
|
||||
rootFolder->sort(getSortTypeFromString(
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(
|
||||
rootFolder->getSortTypeString()), favoritesSorting);
|
||||
ViewController::get()->reloadGameListView(*it);
|
||||
|
||||
|
@ -458,7 +458,7 @@ void GuiMenu::openUISettings()
|
|||
continue;
|
||||
|
||||
FileData* rootFolder = (*it)->getRootFolder();
|
||||
rootFolder->sort(getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavoritesFirst"));
|
||||
ViewController::get()->reloadGameListView(*it);
|
||||
|
||||
|
@ -486,7 +486,7 @@ void GuiMenu::openUISettings()
|
|||
continue;
|
||||
|
||||
FileData* rootFolder = (*it)->getRootFolder();
|
||||
rootFolder->sort(getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavoritesFirst"));
|
||||
ViewController::get()->reloadGameListView(*it);
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ void GuiMetaDataEd::save()
|
|||
// and reload the gamelist as CollectionSystemManager ignores folders.
|
||||
if (hideGameWhileHidden && mScraperParams.game->getType() == FOLDER) {
|
||||
FileData* systemRoot = mScraperParams.system->getRootFolder();
|
||||
systemRoot->sort(getSortTypeFromString(systemRoot->getSortTypeString()),
|
||||
systemRoot->sort(systemRoot->getSortTypeFromString(systemRoot->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavoritesFirst"));
|
||||
ViewController::get()->reloadGameListView(mScraperParams.system);
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
|
|||
getCursor()->getSourceFileData()->getSystem()->onMetaDataSavePoint();
|
||||
|
||||
if (!Settings::getInstance()->getBool("FoldersOnTop"))
|
||||
mRoot->sort(getSortTypeFromString(mRoot->getSortTypeString()),
|
||||
mRoot->sort(mRoot->getSortTypeFromString(mRoot->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavoritesFirst"));
|
||||
|
||||
ViewController::get()->onFileChanged(getCursor(), FILE_METADATA_CHANGED);
|
||||
|
|
Loading…
Reference in a new issue