mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Changed to case insensitive sorting of the custom collections.
This commit is contained in:
parent
ab87063770
commit
127d900212
|
@ -92,7 +92,7 @@ CollectionSystemManager::~CollectionSystemManager()
|
|||
removeCollectionsFromDisplayedSystems();
|
||||
|
||||
// Delete all custom collections.
|
||||
for (std::map<std::string, CollectionSystemData>::const_iterator
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator
|
||||
it = mCustomCollectionSystemsData.cbegin();
|
||||
it != mCustomCollectionSystemsData.cend() ; it++)
|
||||
delete it->second.system;
|
||||
|
@ -232,7 +232,7 @@ void CollectionSystemManager::loadEnabledListFromSettings()
|
|||
Settings::getInstance()->getString("CollectionSystemsAuto"), true);
|
||||
|
||||
// Iterate the map.
|
||||
for (std::map<std::string, CollectionSystemData>::iterator
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::iterator
|
||||
it = mAutoCollectionSystemsData.begin();
|
||||
it != mAutoCollectionSystemsData.end() ; it++ ) {
|
||||
|
||||
|
@ -247,7 +247,7 @@ void CollectionSystemManager::loadEnabledListFromSettings()
|
|||
Settings::getInstance()->getString("CollectionSystemsCustom"), true);
|
||||
|
||||
// Iterate the map.
|
||||
for (std::map<std::string, CollectionSystemData>::iterator
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::iterator
|
||||
it = mCustomCollectionSystemsData.begin();
|
||||
it != mCustomCollectionSystemsData.end() ; it++ ) {
|
||||
|
||||
|
@ -719,7 +719,7 @@ SystemData* CollectionSystemManager::getSystemToView(SystemData* sys)
|
|||
// Loads Automatic Collection systems (All, Favorites, Last Played).
|
||||
void CollectionSystemManager::initAutoCollectionSystems()
|
||||
{
|
||||
for (std::map<std::string, CollectionSystemDecl>::const_iterator
|
||||
for (std::map<std::string, CollectionSystemDecl, stringComparator>::const_iterator
|
||||
it = mCollectionSystemDeclsIndex.cbegin();
|
||||
it != mCollectionSystemDeclsIndex.cend() ; it++ ) {
|
||||
CollectionSystemDecl sysDecl = it->second;
|
||||
|
@ -824,8 +824,8 @@ SystemData* CollectionSystemManager::addNewCustomCollection(std::string name)
|
|||
SystemData* CollectionSystemManager::createNewCollectionEntry(
|
||||
std::string name, CollectionSystemDecl sysDecl, bool index, bool custom)
|
||||
{
|
||||
SystemData* newSys = new SystemData(
|
||||
name, sysDecl.longName, mCollectionEnvData, sysDecl.themeFolder, true, custom);
|
||||
SystemData* newSys = new SystemData(name, sysDecl.longName,
|
||||
mCollectionEnvData, sysDecl.themeFolder, true, custom);
|
||||
|
||||
CollectionSystemData newCollectionData;
|
||||
newCollectionData.system = newSys;
|
||||
|
@ -976,10 +976,10 @@ void CollectionSystemManager::removeCollectionsFromDisplayedSystems()
|
|||
}
|
||||
|
||||
void CollectionSystemManager::addEnabledCollectionsToDisplayedSystems(
|
||||
std::map<std::string, CollectionSystemData>* colSystemData)
|
||||
std::map<std::string, CollectionSystemData, stringComparator>* colSystemData)
|
||||
{
|
||||
// Add auto enabled collections.
|
||||
for (std::map<std::string, CollectionSystemData>::iterator
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::iterator
|
||||
it = colSystemData->begin() ; it != colSystemData->end() ; it++ ) {
|
||||
if (it->second.isEnabled) {
|
||||
// Check if populated, otherwise populate.
|
||||
|
@ -1155,7 +1155,7 @@ std::vector<std::string> CollectionSystemManager::getCollectionsFromConfigFolder
|
|||
std::vector<std::string> CollectionSystemManager::getCollectionThemeFolders(bool custom)
|
||||
{
|
||||
std::vector<std::string> systems;
|
||||
for (std::map<std::string, CollectionSystemDecl>::const_iterator
|
||||
for (std::map<std::string, CollectionSystemDecl, stringComparator>::const_iterator
|
||||
it = mCollectionSystemDeclsIndex.cbegin();
|
||||
it != mCollectionSystemDeclsIndex.cend() ; it++ ) {
|
||||
CollectionSystemDecl sysDecl = it->second;
|
||||
|
@ -1169,7 +1169,7 @@ std::vector<std::string> CollectionSystemManager::getCollectionThemeFolders(bool
|
|||
std::vector<std::string> CollectionSystemManager::getUserCollectionThemeFolders()
|
||||
{
|
||||
std::vector<std::string> systems;
|
||||
for (std::map<std::string, CollectionSystemData>::const_iterator
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator
|
||||
it = mCustomCollectionSystemsData.cbegin();
|
||||
it != mCustomCollectionSystemsData.cend() ; it++ )
|
||||
systems.push_back(it->second.decl.themeFolder);
|
||||
|
@ -1213,7 +1213,7 @@ bool systemSort(SystemData* sys1, SystemData* sys2)
|
|||
bool CollectionSystemManager::getIsCustomCollection(SystemData* system)
|
||||
{
|
||||
// Iterate the map.
|
||||
for (std::map<std::string, CollectionSystemData>::const_iterator
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator
|
||||
it = mCustomCollectionSystemsData.cbegin();
|
||||
it != mCustomCollectionSystemsData.cend() ; it++) {
|
||||
if (it->second.system == system)
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#ifndef ES_APP_COLLECTION_SYSTEM_MANAGER_H
|
||||
#define ES_APP_COLLECTION_SYSTEM_MANAGER_H
|
||||
|
||||
#include "utils/StringUtil.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -53,6 +55,13 @@ struct CollectionSystemData {
|
|||
bool isPopulated;
|
||||
};
|
||||
|
||||
struct stringComparator {
|
||||
bool operator()(const std::string& a, const std::string& b) const
|
||||
{
|
||||
return Utils::String::toUpper(a) < Utils::String::toUpper(b);
|
||||
}
|
||||
};
|
||||
|
||||
class CollectionSystemManager
|
||||
{
|
||||
public:
|
||||
|
@ -72,10 +81,10 @@ public:
|
|||
void updateCollectionSystem(FileData* file, CollectionSystemData sysData);
|
||||
void deleteCollectionFiles(FileData* file);
|
||||
|
||||
inline std::map<std::string, CollectionSystemData> getAutoCollectionSystems()
|
||||
{ return mAutoCollectionSystemsData; };
|
||||
inline std::map<std::string, CollectionSystemData> getCustomCollectionSystems()
|
||||
{ return mCustomCollectionSystemsData; };
|
||||
inline std::map<std::string, CollectionSystemData, stringComparator>
|
||||
getAutoCollectionSystems() { return mAutoCollectionSystemsData; };
|
||||
inline std::map<std::string, CollectionSystemData, stringComparator>
|
||||
getCustomCollectionSystems() { return mCustomCollectionSystemsData; };
|
||||
inline SystemData* getCustomCollectionsBundle() { return mCustomCollectionsBundle; };
|
||||
std::vector<std::string> getUnusedSystemsFromTheme();
|
||||
SystemData* addNewCustomCollection(std::string name);
|
||||
|
@ -98,9 +107,9 @@ public:
|
|||
private:
|
||||
static CollectionSystemManager* sInstance;
|
||||
SystemEnvironmentData* mCollectionEnvData;
|
||||
std::map<std::string, CollectionSystemDecl> mCollectionSystemDeclsIndex;
|
||||
std::map<std::string, CollectionSystemData> mAutoCollectionSystemsData;
|
||||
std::map<std::string, CollectionSystemData> mCustomCollectionSystemsData;
|
||||
std::map<std::string, CollectionSystemDecl, stringComparator> mCollectionSystemDeclsIndex;
|
||||
std::map<std::string, CollectionSystemData, stringComparator> mAutoCollectionSystemsData;
|
||||
std::map<std::string, CollectionSystemData, stringComparator> mCustomCollectionSystemsData;
|
||||
Window* mWindow;
|
||||
bool mIsEditingCustom;
|
||||
bool mHasEnabledCustomCollection;
|
||||
|
@ -117,7 +126,7 @@ private:
|
|||
|
||||
void removeCollectionsFromDisplayedSystems();
|
||||
void addEnabledCollectionsToDisplayedSystems(std::map<std::string,
|
||||
CollectionSystemData>* colSystemData);
|
||||
CollectionSystemData, stringComparator>* colSystemData);
|
||||
|
||||
std::vector<std::string> getSystemsFromConfig();
|
||||
std::vector<std::string> getSystemsFromTheme();
|
||||
|
|
|
@ -447,11 +447,9 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending,
|
|||
std::vector<FileData*> mChildrenFolders;
|
||||
std::vector<FileData*> mChildrenOthers;
|
||||
|
||||
// For grouped custom collections, always sort the collection list as 'filename, ascending'.
|
||||
// The main custom collections view is sorted during startup in CollectionSystemManager.
|
||||
// The individual collections are however sorted as any normal systems/folders.
|
||||
if (mSystem->isCollection() && mSystem->getFullName() == "collections") {
|
||||
std::stable_sort(mChildren.begin(), mChildren.end(),
|
||||
getSortTypeFromString("filename, ascending").comparisonFunction);
|
||||
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) {
|
||||
// Build mFirstLetterIndex.
|
||||
const char firstChar = toupper((*it)->getSortName().front());
|
||||
|
@ -564,11 +562,9 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending
|
|||
bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop");
|
||||
bool hasFolders = false;
|
||||
|
||||
// For grouped custom collections, always sort the collection list as 'filename, ascending'.
|
||||
// The main custom collections view is sorted during startup in CollectionSystemManager.
|
||||
// The individual collections are however sorted as any normal systems/folders.
|
||||
if (mSystem->isCollection() && mSystem->getFullName() == "collections") {
|
||||
std::stable_sort(mChildren.begin(), mChildren.end(),
|
||||
getSortTypeFromString("filename, ascending").comparisonFunction);
|
||||
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) {
|
||||
// Build mFirstLetterIndex.
|
||||
const char firstChar = toupper((*it)->getSortName().front());
|
||||
|
|
|
@ -140,8 +140,8 @@ void GuiCollectionSystemsOptions::createCollection(std::string inName) {
|
|||
customOptionList->add(name, name, true);
|
||||
std::string outAuto = Utils::String::vectorToCommaString(
|
||||
autoOptionList->getSelectedObjects());
|
||||
std::string outCustom = Utils::String::vectorToCommaString(
|
||||
customOptionList->getSelectedObjects());
|
||||
std::vector<std::string> customSystems = customOptionList->getSelectedObjects();
|
||||
std::string outCustom = Utils::String::vectorToCommaString(customSystems, true);
|
||||
updateSettings(outAuto, outCustom);
|
||||
ViewController::get()->goToSystemView(newSys);
|
||||
|
||||
|
@ -164,27 +164,27 @@ GuiCollectionSystemsOptions::~GuiCollectionSystemsOptions()
|
|||
|
||||
void GuiCollectionSystemsOptions::addSystemsToMenu()
|
||||
{
|
||||
std::map<std::string, CollectionSystemData> autoSystems =
|
||||
std::map<std::string, CollectionSystemData, stringComparator> autoSystems =
|
||||
CollectionSystemManager::get()->getAutoCollectionSystems();
|
||||
|
||||
autoOptionList = std::make_shared<OptionListComponent<std::string>>
|
||||
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
||||
|
||||
// Add automatic systems.
|
||||
for (std::map<std::string, CollectionSystemData>::const_iterator it = autoSystems.cbegin();
|
||||
it != autoSystems.cend() ; it++ )
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator
|
||||
it = autoSystems.cbegin(); it != autoSystems.cend() ; it++)
|
||||
autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
|
||||
mMenu.addWithLabel("AUTOMATIC GAME COLLECTIONS", autoOptionList);
|
||||
|
||||
std::map<std::string, CollectionSystemData> customSystems =
|
||||
std::map<std::string, CollectionSystemData, stringComparator> customSystems =
|
||||
CollectionSystemManager::get()->getCustomCollectionSystems();
|
||||
|
||||
customOptionList = std::make_shared<OptionListComponent<std::string>>
|
||||
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
||||
|
||||
// Add custom systems.
|
||||
for (std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin();
|
||||
it != customSystems.cend() ; it++ )
|
||||
for (std::map<std::string, CollectionSystemData, stringComparator>::const_iterator
|
||||
it = customSystems.cbegin(); it != customSystems.cend() ; it++)
|
||||
customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
|
||||
mMenu.addWithLabel("CUSTOM GAME COLLECTIONS", customOptionList);
|
||||
}
|
||||
|
@ -194,8 +194,8 @@ void GuiCollectionSystemsOptions::applySettings()
|
|||
std::string outAuto = Utils::String::vectorToCommaString(
|
||||
autoOptionList->getSelectedObjects());
|
||||
std::string prevAuto = Settings::getInstance()->getString("CollectionSystemsAuto");
|
||||
std::string outCustom = Utils::String::vectorToCommaString(
|
||||
customOptionList->getSelectedObjects());
|
||||
std::vector<std::string> customSystems = customOptionList->getSelectedObjects();
|
||||
std::string outCustom = Utils::String::vectorToCommaString(customSystems, true);
|
||||
std::string prevCustom = Settings::getInstance()->getString("CollectionSystemsCustom");
|
||||
bool outSort = sortFavFirstCustomSwitch->getState();
|
||||
bool prevSort = Settings::getInstance()->getBool("FavFirstCustom");
|
||||
|
|
|
@ -144,7 +144,7 @@ GuiGamelistOptions::GuiGamelistOptions(
|
|||
}
|
||||
}
|
||||
|
||||
std::map<std::string, CollectionSystemData> customCollections =
|
||||
std::map<std::string, CollectionSystemData, stringComparator> customCollections =
|
||||
CollectionSystemManager::get()->getCustomCollectionSystems();
|
||||
|
||||
if (UIModeController::getInstance()->isUIModeFull() &&
|
||||
|
|
Loading…
Reference in a new issue