2017-06-12 16:38:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "FileData.h"
|
|
|
|
#include "Window.h"
|
|
|
|
#include "MetaData.h"
|
|
|
|
#include "PlatformId.h"
|
|
|
|
#include "ThemeData.h"
|
|
|
|
#include "FileFilterIndex.h"
|
|
|
|
#include "SystemData.h"
|
|
|
|
#include "views/ViewController.h"
|
|
|
|
|
|
|
|
enum CollectionSystemType
|
|
|
|
{
|
|
|
|
AUTO_ALL_GAMES,
|
|
|
|
AUTO_LAST_PLAYED,
|
|
|
|
AUTO_FAVORITES,
|
|
|
|
CUSTOM_COLLECTION
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CollectionSystemDecl
|
|
|
|
{
|
|
|
|
CollectionSystemType type; // type of system
|
|
|
|
std::string name;
|
|
|
|
std::string longName;
|
|
|
|
std::string defaultSort;
|
|
|
|
std::string themeFolder;
|
|
|
|
bool isCustom;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CollectionSystemData
|
|
|
|
{
|
|
|
|
SystemData* system;
|
|
|
|
CollectionSystemDecl decl;
|
|
|
|
bool isEnabled;
|
2017-07-18 09:45:50 +00:00
|
|
|
bool isPopulated;
|
|
|
|
bool needsSave;
|
2017-06-12 16:38:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CollectionSystemManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CollectionSystemManager(Window* window);
|
|
|
|
~CollectionSystemManager();
|
2017-07-18 09:45:50 +00:00
|
|
|
|
2017-06-12 16:38:59 +00:00
|
|
|
static CollectionSystemManager* get();
|
2017-07-18 09:45:50 +00:00
|
|
|
static void init(Window* window);
|
|
|
|
static void deinit();
|
|
|
|
void saveCustomCollection(SystemData* sys);
|
|
|
|
|
2017-06-12 16:38:59 +00:00
|
|
|
void loadCollectionSystems();
|
2017-07-18 09:45:50 +00:00
|
|
|
void loadEnabledListFromSettings();
|
2017-06-12 16:38:59 +00:00
|
|
|
void updateSystemsList();
|
2017-07-18 09:45:50 +00:00
|
|
|
|
|
|
|
void refreshCollectionSystems(FileData* file);
|
|
|
|
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 SystemData* getCustomCollectionsBundle() { return mCustomCollectionsBundle; };
|
|
|
|
std::vector<std::string> getUnusedSystemsFromTheme();
|
|
|
|
SystemData* addNewCustomCollection(std::string name);
|
|
|
|
|
|
|
|
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();
|
|
|
|
inline bool isEditing() { return mIsEditingCustom; };
|
2017-08-22 23:21:33 +00:00
|
|
|
inline std::string getEditingCollection() { return mEditingCollection; };
|
2017-07-18 09:45:50 +00:00
|
|
|
bool toggleGameInCollection(FileData* file);
|
|
|
|
|
|
|
|
SystemData* getSystemToView(SystemData* sys);
|
|
|
|
void updateCollectionFolderMetadata(SystemData* sys);
|
2017-06-12 16:38:59 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static CollectionSystemManager* sInstance;
|
|
|
|
SystemEnvironmentData* mCollectionEnvData;
|
2017-07-18 09:45:50 +00:00
|
|
|
std::map<std::string, CollectionSystemDecl> mCollectionSystemDeclsIndex;
|
|
|
|
std::map<std::string, CollectionSystemData> mAutoCollectionSystemsData;
|
|
|
|
std::map<std::string, CollectionSystemData> mCustomCollectionSystemsData;
|
|
|
|
Window* mWindow;
|
|
|
|
bool mIsEditingCustom;
|
|
|
|
std::string mEditingCollection;
|
|
|
|
CollectionSystemData* mEditingCollectionSystemData;
|
|
|
|
|
|
|
|
void initAutoCollectionSystems();
|
|
|
|
void initCustomCollectionSystems();
|
|
|
|
SystemData* getAllGamesCollection();
|
|
|
|
SystemData* createNewCollectionEntry(std::string name, CollectionSystemDecl sysDecl, bool index = true);
|
|
|
|
void populateAutoCollection(CollectionSystemData* sysData);
|
|
|
|
void populateCustomCollection(CollectionSystemData* sysData);
|
|
|
|
|
|
|
|
void removeCollectionsFromDisplayedSystems();
|
|
|
|
void addEnabledCollectionsToDisplayedSystems(std::map<std::string, CollectionSystemData>* colSystemData);
|
|
|
|
|
2017-06-12 16:38:59 +00:00
|
|
|
std::vector<std::string> getSystemsFromConfig();
|
|
|
|
std::vector<std::string> getSystemsFromTheme();
|
2017-07-18 09:45:50 +00:00
|
|
|
std::vector<std::string> getCollectionsFromConfigFolder();
|
|
|
|
std::vector<std::string> getCollectionThemeFolders(bool custom);
|
|
|
|
std::vector<std::string> getUserCollectionThemeFolders();
|
|
|
|
|
2017-06-12 16:38:59 +00:00
|
|
|
bool themeFolderExists(std::string folder);
|
2017-07-18 09:45:50 +00:00
|
|
|
|
2017-06-12 16:38:59 +00:00
|
|
|
bool includeFileInAutoCollections(FileData* file);
|
2017-07-18 09:45:50 +00:00
|
|
|
|
|
|
|
SystemData* mCustomCollectionsBundle;
|
2017-06-12 16:38:59 +00:00
|
|
|
};
|
2017-07-18 09:45:50 +00:00
|
|
|
|
|
|
|
std::string getCustomCollectionConfigPath(std::string collectionName);
|
|
|
|
std::string getCollectionsFolder();
|
|
|
|
bool systemSort(SystemData* sys1, SystemData* sys2);
|