2017-03-18 17:54:39 +00:00
|
|
|
#pragma once
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_APP_FILE_FILTER_INDEX_H
|
|
|
|
#define ES_APP_FILE_FILTER_INDEX_H
|
2017-03-18 17:54:39 +00:00
|
|
|
|
|
|
|
#include <map>
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class FileData;
|
2017-03-18 17:54:39 +00:00
|
|
|
|
|
|
|
enum FilterIndexType
|
|
|
|
{
|
|
|
|
NONE,
|
|
|
|
GENRE_FILTER,
|
|
|
|
PLAYER_FILTER,
|
|
|
|
PUBDEV_FILTER,
|
2017-06-12 16:38:59 +00:00
|
|
|
RATINGS_FILTER,
|
|
|
|
FAVORITES_FILTER
|
2017-03-18 17:54:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FilterDataDecl
|
|
|
|
{
|
|
|
|
FilterIndexType type; // type of filter
|
|
|
|
std::map<std::string, int>* allIndexKeys; // all possible filters for this type
|
|
|
|
bool* filteredByRef; // is it filtered by this type
|
|
|
|
std::vector<std::string>* currentFilteredKeys; // current keys being filtered for
|
|
|
|
std::string primaryKey; // primary key in metadata
|
|
|
|
bool hasSecondaryKey; // has secondary key for comparison
|
|
|
|
std::string secondaryKey; // what's the secondary key
|
|
|
|
std::string menuLabel; // text to show in menu
|
|
|
|
};
|
|
|
|
|
|
|
|
class FileFilterIndex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FileFilterIndex();
|
|
|
|
~FileFilterIndex();
|
|
|
|
void addToIndex(FileData* game);
|
|
|
|
void removeFromIndex(FileData* game);
|
|
|
|
void setFilter(FilterIndexType type, std::vector<std::string>* values);
|
2017-05-18 10:16:57 +00:00
|
|
|
void clearAllFilters();
|
2017-03-18 17:54:39 +00:00
|
|
|
void debugPrintIndexes();
|
|
|
|
bool showFile(FileData* game);
|
2017-06-12 16:38:59 +00:00
|
|
|
bool isFiltered() { return (filterByGenre || filterByPlayers || filterByPubDev || filterByRatings || filterByFavorites); };
|
2017-03-18 17:54:39 +00:00
|
|
|
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
|
|
|
|
std::vector<FilterDataDecl>& getFilterDataDecls();
|
2017-07-18 09:45:50 +00:00
|
|
|
|
|
|
|
void importIndex(FileFilterIndex* indexToImport);
|
|
|
|
void resetIndex();
|
2017-03-18 17:54:39 +00:00
|
|
|
private:
|
|
|
|
std::vector<FilterDataDecl> filterDataDecl;
|
|
|
|
std::string getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary);
|
2017-05-18 10:16:57 +00:00
|
|
|
|
2017-03-18 17:54:39 +00:00
|
|
|
void manageGenreEntryInIndex(FileData* game, bool remove = false);
|
|
|
|
void managePlayerEntryInIndex(FileData* game, bool remove = false);
|
|
|
|
void managePubDevEntryInIndex(FileData* game, bool remove = false);
|
|
|
|
void manageRatingsEntryInIndex(FileData* game, bool remove = false);
|
2017-06-12 16:38:59 +00:00
|
|
|
void manageFavoritesEntryInIndex(FileData* game, bool remove = false);
|
2017-03-18 17:54:39 +00:00
|
|
|
|
|
|
|
void manageIndexEntry(std::map<std::string, int>* index, std::string key, bool remove);
|
|
|
|
|
|
|
|
void clearIndex(std::map<std::string, int> indexMap);
|
|
|
|
|
|
|
|
bool filterByGenre;
|
|
|
|
bool filterByPlayers;
|
|
|
|
bool filterByPubDev;
|
|
|
|
bool filterByRatings;
|
2017-06-12 16:38:59 +00:00
|
|
|
bool filterByFavorites;
|
2017-03-18 17:54:39 +00:00
|
|
|
|
|
|
|
std::map<std::string, int> genreIndexAllKeys;
|
|
|
|
std::map<std::string, int> playersIndexAllKeys;
|
|
|
|
std::map<std::string, int> pubDevIndexAllKeys;
|
|
|
|
std::map<std::string, int> ratingsIndexAllKeys;
|
2017-06-12 16:38:59 +00:00
|
|
|
std::map<std::string, int> favoritesIndexAllKeys;
|
2017-03-18 17:54:39 +00:00
|
|
|
|
|
|
|
std::vector<std::string> genreIndexFilteredKeys;
|
|
|
|
std::vector<std::string> playersIndexFilteredKeys;
|
|
|
|
std::vector<std::string> pubDevIndexFilteredKeys;
|
|
|
|
std::vector<std::string> ratingsIndexFilteredKeys;
|
2017-06-12 16:38:59 +00:00
|
|
|
std::vector<std::string> favoritesIndexFilteredKeys;
|
2017-03-18 17:54:39 +00:00
|
|
|
|
|
|
|
FileData* mRootFolder;
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_APP_FILE_FILTER_INDEX_H
|