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