mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Minor code standardization for CollectionSystemManager.
This commit is contained in:
parent
7b30e0172b
commit
6bc30a68cb
|
@ -204,9 +204,6 @@ void CollectionSystemManager::saveCustomCollection(SystemData* sys)
|
|||
}
|
||||
}
|
||||
|
||||
// Functions below to load all collections into memory, and to enable the active ones.
|
||||
|
||||
// Load all collection systems.
|
||||
void CollectionSystemManager::loadCollectionSystems()
|
||||
{
|
||||
initAutoCollectionSystems();
|
||||
|
@ -225,7 +222,6 @@ void CollectionSystemManager::loadCollectionSystems()
|
|||
}
|
||||
}
|
||||
|
||||
// Load settings.
|
||||
void CollectionSystemManager::loadEnabledListFromSettings()
|
||||
{
|
||||
// We parse the auto collection settings list.
|
||||
|
@ -259,7 +255,6 @@ void CollectionSystemManager::loadEnabledListFromSettings()
|
|||
}
|
||||
}
|
||||
|
||||
// Update enabled system list in System View.
|
||||
void CollectionSystemManager::updateSystemsList()
|
||||
{
|
||||
// Remove all collection systems.
|
||||
|
@ -294,9 +289,6 @@ void CollectionSystemManager::updateSystemsList()
|
|||
}
|
||||
}
|
||||
|
||||
// Functions below to manage collection files related to a source FileData.
|
||||
|
||||
// Update all collection files related to the source file.
|
||||
void CollectionSystemManager::refreshCollectionSystems(FileData* file)
|
||||
{
|
||||
if (!file->getSystem()->isGameSystem() || file->getType() != GAME)
|
||||
|
@ -463,7 +455,6 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS
|
|||
}
|
||||
}
|
||||
|
||||
// Delete all collection files from collection systems related to the source file.
|
||||
void CollectionSystemManager::deleteCollectionFiles(FileData* file)
|
||||
{
|
||||
// Collection files use the full path as key, to avoid clashes.
|
||||
|
@ -494,7 +485,6 @@ void CollectionSystemManager::deleteCollectionFiles(FileData* file)
|
|||
}
|
||||
}
|
||||
|
||||
// Return whether the current theme is compatible with Automatic or Custom Collections.
|
||||
bool CollectionSystemManager::isThemeGenericCollectionCompatible(bool genericCustomCollections)
|
||||
{
|
||||
std::vector<std::string> cfgSys = getCollectionThemeFolders(genericCustomCollections);
|
||||
|
@ -629,7 +619,6 @@ bool CollectionSystemManager::inCustomCollection(
|
|||
return false;
|
||||
}
|
||||
|
||||
// Add or remove a game from a specific collection.
|
||||
bool CollectionSystemManager::toggleGameInCollection(FileData* file)
|
||||
{
|
||||
if (file->getType() == GAME) {
|
||||
|
@ -732,7 +721,6 @@ SystemData* CollectionSystemManager::getSystemToView(SystemData* sys)
|
|||
return systemToView;
|
||||
}
|
||||
|
||||
// Used to generate a description of the collection, all other metadata fields are hidden.
|
||||
FileData* CollectionSystemManager::updateCollectionFolderMetadata(SystemData* sys)
|
||||
{
|
||||
FileData* rootFolder = sys->getRootFolder();
|
||||
|
@ -820,7 +808,6 @@ FileData* CollectionSystemManager::updateCollectionFolderMetadata(SystemData* sy
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// Return the unused folders from current theme path.
|
||||
std::vector<std::string> CollectionSystemManager::getUnusedSystemsFromTheme()
|
||||
{
|
||||
// Get used systems in es_systems.cfg.
|
||||
|
@ -893,10 +880,6 @@ void CollectionSystemManager::deleteCustomCollection(std::string collectionName)
|
|||
}
|
||||
}
|
||||
|
||||
// Functions below to Handle loading of collection systems, creating empty ones,
|
||||
// and populating on demand.
|
||||
|
||||
// Loads Automatic Collection systems (All, Favorites, Last Played).
|
||||
void CollectionSystemManager::initAutoCollectionSystems()
|
||||
{
|
||||
for (std::map<std::string, CollectionSystemDecl, stringComparator>::const_iterator
|
||||
|
@ -926,7 +909,6 @@ SystemData* CollectionSystemManager::getAllGamesCollection()
|
|||
return allSysData->system;
|
||||
}
|
||||
|
||||
// Create a new empty collection system based on the name and declaration.
|
||||
SystemData* CollectionSystemManager::createNewCollectionEntry(
|
||||
std::string name, CollectionSystemDecl sysDecl, bool index, bool custom)
|
||||
{
|
||||
|
@ -949,7 +931,6 @@ SystemData* CollectionSystemManager::createNewCollectionEntry(
|
|||
return newSys;
|
||||
}
|
||||
|
||||
// Populate an automatic collection system.
|
||||
void CollectionSystemManager::populateAutoCollection(CollectionSystemData* sysData)
|
||||
{
|
||||
SystemData* newSys = sysData->system;
|
||||
|
@ -1009,7 +990,6 @@ void CollectionSystemManager::populateAutoCollection(CollectionSystemData* sysDa
|
|||
sysData->isPopulated = true;
|
||||
}
|
||||
|
||||
// Populate a custom collection system.
|
||||
void CollectionSystemManager::populateCustomCollection(CollectionSystemData* sysData)
|
||||
{
|
||||
SystemData* newSys = sysData->system;
|
||||
|
@ -1064,8 +1044,6 @@ void CollectionSystemManager::populateCustomCollection(CollectionSystemData* sys
|
|||
}
|
||||
}
|
||||
|
||||
// Functions below to handle System View removal and insertion of collections.
|
||||
|
||||
void CollectionSystemManager::removeCollectionsFromDisplayedSystems()
|
||||
{
|
||||
// Remove all collection Systems.
|
||||
|
@ -1135,8 +1113,6 @@ void CollectionSystemManager::addEnabledCollectionsToDisplayedSystems(
|
|||
}
|
||||
}
|
||||
|
||||
// Auxiliary functions below to get available custom collection possibilities.
|
||||
|
||||
std::vector<std::string> CollectionSystemManager::getSystemsFromConfig()
|
||||
{
|
||||
std::vector<std::string> systems;
|
||||
|
@ -1209,7 +1185,6 @@ std::vector<std::string> CollectionSystemManager::getSystemsFromTheme()
|
|||
return systems;
|
||||
}
|
||||
|
||||
// Return which collection config files exist in the user folder.
|
||||
std::vector<std::string> CollectionSystemManager::getCollectionsFromConfigFolder()
|
||||
{
|
||||
std::vector<std::string> systems;
|
||||
|
@ -1240,8 +1215,6 @@ std::vector<std::string> CollectionSystemManager::getCollectionsFromConfigFolder
|
|||
return systems;
|
||||
}
|
||||
|
||||
// Return the theme folders for automatic collections (All, Favorites, Last Played)
|
||||
// or a generic custom collections folder.
|
||||
std::vector<std::string> CollectionSystemManager::getCollectionThemeFolders(bool custom)
|
||||
{
|
||||
std::vector<std::string> systems;
|
||||
|
@ -1255,7 +1228,6 @@ std::vector<std::string> CollectionSystemManager::getCollectionThemeFolders(bool
|
|||
return systems;
|
||||
}
|
||||
|
||||
// Return the theme folders in use for the user-defined custom collections.
|
||||
std::vector<std::string> CollectionSystemManager::getUserCollectionThemeFolders()
|
||||
{
|
||||
std::vector<std::string> systems;
|
||||
|
@ -1276,7 +1248,6 @@ void CollectionSystemManager::trimCollectionCount(FileData* rootFolder, int limi
|
|||
}
|
||||
}
|
||||
|
||||
// Return whether a specific folder exists in the theme.
|
||||
bool CollectionSystemManager::themeFolderExists(std::string folder)
|
||||
{
|
||||
std::vector<std::string> themeSys = getSystemsFromTheme();
|
||||
|
|
|
@ -73,14 +73,42 @@ public:
|
|||
static void deinit();
|
||||
void saveCustomCollection(SystemData* sys);
|
||||
|
||||
// Functions to load all collections into memory, and enable the active ones:
|
||||
// Load all collection systems.
|
||||
void loadCollectionSystems();
|
||||
// Load settings.
|
||||
void loadEnabledListFromSettings();
|
||||
// Update enabled system list in System View.
|
||||
void updateSystemsList();
|
||||
|
||||
// Functions to manage collection files related to a source FileData:
|
||||
// Update all collection files related to the source file.
|
||||
void refreshCollectionSystems(FileData* file);
|
||||
// Update the collections, such as when marking or unmarking a game as favorite.
|
||||
void updateCollectionSystem(FileData* file, CollectionSystemData sysData);
|
||||
// Delete all collection files from all collection systems related to the source file.
|
||||
void deleteCollectionFiles(FileData* file);
|
||||
|
||||
// Return whether the current theme is compatible with Automatic or Custom Collections.
|
||||
bool isThemeGenericCollectionCompatible(bool genericCustomCollections);
|
||||
bool isThemeCustomCollectionCompatible(std::vector<std::string> stringVector);
|
||||
std::string getValidNewCollectionName(std::string name, int index = 0);
|
||||
|
||||
void setEditMode(std::string collectionName);
|
||||
void exitEditMode();
|
||||
bool inCustomCollection(const std::string& collectionName, FileData* gameFile);
|
||||
// Add or remove a game from a specific collection.
|
||||
bool toggleGameInCollection(FileData* file);
|
||||
|
||||
SystemData* getSystemToView(SystemData* sys);
|
||||
// Used to generate a description of the collection (all other metadata fields are hidden).
|
||||
FileData* updateCollectionFolderMetadata(SystemData* sys);
|
||||
// Return the unused folders from current theme path.
|
||||
std::vector<std::string> getUnusedSystemsFromTheme();
|
||||
|
||||
SystemData* addNewCustomCollection(std::string name);
|
||||
void deleteCustomCollection(std::string collectionName);
|
||||
|
||||
inline std::map<std::string, CollectionSystemData, stringComparator>
|
||||
getAutoCollectionSystems() { return mAutoCollectionSystemsData; };
|
||||
inline std::map<std::string, CollectionSystemData, stringComparator>
|
||||
|
@ -89,22 +117,6 @@ public:
|
|||
inline bool isEditing() { return mIsEditingCustom; };
|
||||
inline std::string getEditingCollection() { return mEditingCollection; };
|
||||
|
||||
bool isThemeGenericCollectionCompatible(bool genericCustomCollections);
|
||||
bool isThemeCustomCollectionCompatible(std::vector<std::string> stringVector);
|
||||
std::string getValidNewCollectionName(std::string name, int index = 0);
|
||||
|
||||
void setEditMode(std::string collectionName);
|
||||
void exitEditMode();
|
||||
bool inCustomCollection(const std::string& collectionName, FileData* gameFile);
|
||||
bool toggleGameInCollection(FileData* file);
|
||||
|
||||
SystemData* getSystemToView(SystemData* sys);
|
||||
FileData* updateCollectionFolderMetadata(SystemData* sys);
|
||||
std::vector<std::string> getUnusedSystemsFromTheme();
|
||||
|
||||
SystemData* addNewCustomCollection(std::string name);
|
||||
void deleteCustomCollection(std::string collectionName);
|
||||
|
||||
private:
|
||||
static CollectionSystemManager* sInstance;
|
||||
SystemEnvironmentData* mCollectionEnvData;
|
||||
|
@ -118,25 +130,36 @@ private:
|
|||
CollectionSystemData* mEditingCollectionSystemData;
|
||||
SystemData* mCustomCollectionsBundle;
|
||||
|
||||
// Functions to handle the initialization and loading of collection systems:
|
||||
// Loads Automatic Collection systems (All, Favorites, Last Played).
|
||||
void initAutoCollectionSystems();
|
||||
void initCustomCollectionSystems();
|
||||
SystemData* getAllGamesCollection();
|
||||
// Create a new empty collection system based on the name and declaration.
|
||||
SystemData* createNewCollectionEntry(std::string name,
|
||||
CollectionSystemDecl sysDecl, bool index = true, bool custom = false);
|
||||
// Populate an automatic collection system.
|
||||
void populateAutoCollection(CollectionSystemData* sysData);
|
||||
// Populate a custom collection system.
|
||||
void populateCustomCollection(CollectionSystemData* sysData);
|
||||
|
||||
// Functions to handle System View removal and insertion of collections:
|
||||
void removeCollectionsFromDisplayedSystems();
|
||||
void addEnabledCollectionsToDisplayedSystems(std::map<std::string,
|
||||
CollectionSystemData, stringComparator>* colSystemData);
|
||||
|
||||
// Auxiliary functions:
|
||||
std::vector<std::string> getSystemsFromConfig();
|
||||
std::vector<std::string> getSystemsFromTheme();
|
||||
// Return which collection config files exist in the user folder.
|
||||
std::vector<std::string> getCollectionsFromConfigFolder();
|
||||
// Return the theme folders for automatic collections (All, Favorites and Last Played)
|
||||
// or a generic custom collections folder.
|
||||
std::vector<std::string> getCollectionThemeFolders(bool custom);
|
||||
// Return the theme folders in use for the user-defined custom collections.
|
||||
std::vector<std::string> getUserCollectionThemeFolders();
|
||||
|
||||
void trimCollectionCount(FileData* rootFolder, int limit);
|
||||
// Return whether a specific folder exists in the theme.
|
||||
bool themeFolderExists(std::string folder);
|
||||
bool includeFileInAutoCollections(FileData* file);
|
||||
|
||||
|
|
Loading…
Reference in a new issue