2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-22 15:27:53 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-22 15:27:53 +00:00
|
|
|
// FileFilterIndex.h
|
|
|
|
//
|
|
|
|
// Gamelist filters.
|
|
|
|
//
|
|
|
|
|
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
|
|
|
|
2020-08-17 17:15:05 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
#include <sstream>
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2020-06-22 15:27:53 +00:00
|
|
|
enum FilterIndexType {
|
|
|
|
NONE,
|
2020-10-27 19:58:42 +00:00
|
|
|
FAVORITES_FILTER,
|
2020-06-22 15:27:53 +00:00
|
|
|
GENRE_FILTER,
|
|
|
|
PLAYER_FILTER,
|
|
|
|
PUBDEV_FILTER,
|
|
|
|
RATINGS_FILTER,
|
2020-10-27 19:58:42 +00:00
|
|
|
KIDGAME_FILTER,
|
|
|
|
COMPLETED_FILTER,
|
|
|
|
BROKEN_FILTER,
|
|
|
|
HIDDEN_FILTER
|
2017-03-18 17:54:39 +00:00
|
|
|
};
|
|
|
|
|
2020-06-22 15:27:53 +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.
|
2017-03-18 17:54:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class FileFilterIndex
|
|
|
|
{
|
|
|
|
public:
|
2020-06-22 15:27:53 +00:00
|
|
|
FileFilterIndex();
|
|
|
|
~FileFilterIndex();
|
|
|
|
void addToIndex(FileData* game);
|
|
|
|
void removeFromIndex(FileData* game);
|
|
|
|
void setFilter(FilterIndexType type, std::vector<std::string>* values);
|
2020-11-08 15:34:33 +00:00
|
|
|
void setTextFilter(std::string textFilter);
|
|
|
|
std::string getTextFilter() { return mTextFilter; };
|
2020-06-22 15:27:53 +00:00
|
|
|
void clearAllFilters();
|
|
|
|
void debugPrintIndexes();
|
|
|
|
bool showFile(FileData* game);
|
2020-11-08 15:34:33 +00:00
|
|
|
bool isFiltered() { return (mFilterByText || filterByFavorites || filterByGenre ||
|
|
|
|
filterByPlayers || filterByPubDev || filterByRatings || filterByKidGame ||
|
|
|
|
filterByCompleted || filterByBroken || filterByHidden ); };
|
2020-06-22 15:27:53 +00:00
|
|
|
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
|
|
|
|
std::vector<FilterDataDecl>& getFilterDataDecls();
|
|
|
|
|
|
|
|
void importIndex(FileFilterIndex* indexToImport);
|
|
|
|
void resetIndex();
|
|
|
|
void resetFilters();
|
|
|
|
void setUIModeFilters();
|
2017-09-08 13:20:07 +00:00
|
|
|
|
2017-03-18 17:54:39 +00:00
|
|
|
private:
|
2020-06-22 15:27:53 +00:00
|
|
|
std::vector<FilterDataDecl> filterDataDecl;
|
|
|
|
std::string getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary);
|
|
|
|
|
2020-10-27 19:58:42 +00:00
|
|
|
void manageFavoritesEntryInIndex(FileData* game, bool remove = false);
|
2020-06-22 15:27:53 +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);
|
|
|
|
void manageKidGameEntryInIndex(FileData* game, bool remove = false);
|
2020-10-27 19:58:42 +00:00
|
|
|
void manageCompletedEntryInIndex(FileData* game, bool remove = false);
|
|
|
|
void manageBrokenEntryInIndex(FileData* game, bool remove = false);
|
|
|
|
void manageHiddenEntryInIndex(FileData* game, bool remove = false);
|
2020-06-22 15:27:53 +00:00
|
|
|
|
|
|
|
void manageIndexEntry(std::map<std::string, int>* index, std::string key, bool remove);
|
|
|
|
|
|
|
|
void clearIndex(std::map<std::string, int> indexMap);
|
|
|
|
|
2020-11-08 15:34:33 +00:00
|
|
|
std::string mTextFilter;
|
|
|
|
bool mFilterByText;
|
|
|
|
|
2020-10-27 19:58:42 +00:00
|
|
|
bool filterByFavorites;
|
2020-06-22 15:27:53 +00:00
|
|
|
bool filterByGenre;
|
|
|
|
bool filterByPlayers;
|
|
|
|
bool filterByPubDev;
|
|
|
|
bool filterByRatings;
|
|
|
|
bool filterByKidGame;
|
2020-10-27 19:58:42 +00:00
|
|
|
bool filterByCompleted;
|
|
|
|
bool filterByBroken;
|
|
|
|
bool filterByHidden;
|
2020-06-22 15:27:53 +00:00
|
|
|
|
2020-10-27 19:58:42 +00:00
|
|
|
std::map<std::string, int> favoritesIndexAllKeys;
|
2020-06-22 15:27:53 +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;
|
|
|
|
std::map<std::string, int> kidGameIndexAllKeys;
|
2020-10-27 19:58:42 +00:00
|
|
|
std::map<std::string, int> completedIndexAllKeys;
|
|
|
|
std::map<std::string, int> brokenIndexAllKeys;
|
|
|
|
std::map<std::string, int> hiddenIndexAllKeys;
|
2020-06-22 15:27:53 +00:00
|
|
|
|
2020-10-27 19:58:42 +00:00
|
|
|
std::vector<std::string> favoritesIndexFilteredKeys;
|
2020-06-22 15:27:53 +00:00
|
|
|
std::vector<std::string> genreIndexFilteredKeys;
|
|
|
|
std::vector<std::string> playersIndexFilteredKeys;
|
|
|
|
std::vector<std::string> pubDevIndexFilteredKeys;
|
|
|
|
std::vector<std::string> ratingsIndexFilteredKeys;
|
|
|
|
std::vector<std::string> kidGameIndexFilteredKeys;
|
2020-10-27 19:58:42 +00:00
|
|
|
std::vector<std::string> completedIndexFilteredKeys;
|
|
|
|
std::vector<std::string> brokenIndexFilteredKeys;
|
|
|
|
std::vector<std::string> hiddenIndexFilteredKeys;
|
2020-06-22 15:27:53 +00:00
|
|
|
|
|
|
|
FileData* mRootFolder;
|
2017-03-18 17:54:39 +00:00
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_APP_FILE_FILTER_INDEX_H
|