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-11-26 17:53:00 +00:00
|
|
|
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
2020-08-17 17:15:05 +00:00
|
|
|
#include <sstream>
|
|
|
|
#endif
|
|
|
|
|
2017-03-18 17:54:39 +00:00
|
|
|
#include <map>
|
2020-11-28 21:27:00 +00:00
|
|
|
#include <string>
|
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,
|
2021-09-25 18:15:13 +00:00
|
|
|
RATINGS_FILTER,
|
2021-09-25 17:30:44 +00:00
|
|
|
DEVELOPER_FILTER,
|
|
|
|
PUBLISHER_FILTER,
|
2021-09-25 18:15:13 +00:00
|
|
|
GENRE_FILTER,
|
|
|
|
PLAYER_FILTER,
|
|
|
|
FAVORITES_FILTER,
|
2020-10-27 19:58:42 +00:00
|
|
|
COMPLETED_FILTER,
|
2021-09-25 18:15:13 +00:00
|
|
|
KIDGAME_FILTER,
|
2021-09-25 14:16:25 +00:00
|
|
|
HIDDEN_FILTER,
|
2021-09-25 18:15:13 +00:00
|
|
|
BROKEN_FILTER,
|
2021-10-24 11:05:44 +00:00
|
|
|
CONTROLLER_FILTER,
|
2021-09-25 14:16:25 +00:00
|
|
|
ALTEMULATOR_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);
|
2021-07-07 18:03:42 +00:00
|
|
|
std::string getTextFilter() { return mTextFilter; }
|
2020-06-22 15:27:53 +00:00
|
|
|
void clearAllFilters();
|
|
|
|
void debugPrintIndexes();
|
|
|
|
bool showFile(FileData* game);
|
2021-01-05 09:45:32 +00:00
|
|
|
bool isFiltered();
|
2020-06-22 15:27:53 +00:00
|
|
|
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
|
2021-07-07 18:03:42 +00:00
|
|
|
std::vector<FilterDataDecl>& getFilterDataDecls() { return filterDataDecl; }
|
2020-06-22 15:27:53 +00:00
|
|
|
|
|
|
|
void importIndex(FileFilterIndex* indexToImport);
|
|
|
|
void resetIndex();
|
|
|
|
void resetFilters();
|
2021-01-05 09:45:32 +00:00
|
|
|
void setKidModeFilters();
|
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);
|
|
|
|
|
2021-09-25 18:15:13 +00:00
|
|
|
void manageRatingsEntryInIndex(FileData* game, bool remove = false);
|
2021-09-25 17:30:44 +00:00
|
|
|
void manageDeveloperEntryInIndex(FileData* game, bool remove = false);
|
|
|
|
void managePublisherEntryInIndex(FileData* game, bool remove = false);
|
2021-09-25 18:15:13 +00:00
|
|
|
void manageGenreEntryInIndex(FileData* game, bool remove = false);
|
|
|
|
void managePlayerEntryInIndex(FileData* game, bool remove = false);
|
|
|
|
void manageFavoritesEntryInIndex(FileData* game, bool remove = false);
|
2020-10-27 19:58:42 +00:00
|
|
|
void manageCompletedEntryInIndex(FileData* game, bool remove = false);
|
2021-09-25 18:15:13 +00:00
|
|
|
void manageKidGameEntryInIndex(FileData* game, bool remove = false);
|
2020-10-27 19:58:42 +00:00
|
|
|
void manageHiddenEntryInIndex(FileData* game, bool remove = false);
|
2021-09-25 18:15:13 +00:00
|
|
|
void manageBrokenEntryInIndex(FileData* game, bool remove = false);
|
2021-10-24 11:05:44 +00:00
|
|
|
void manageControllerEntryInIndex(FileData* game, bool remove = false);
|
2021-09-25 14:16:25 +00:00
|
|
|
void manageAltemulatorEntryInIndex(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);
|
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
void clearIndex(std::map<std::string, int>& indexMap) { indexMap.clear(); }
|
2020-06-22 15:27:53 +00:00
|
|
|
|
2020-11-08 15:34:33 +00:00
|
|
|
std::string mTextFilter;
|
|
|
|
bool mFilterByText;
|
|
|
|
|
2021-09-25 18:15:13 +00:00
|
|
|
bool mFilterByRatings;
|
2021-09-25 17:30:44 +00:00
|
|
|
bool mFilterByDeveloper;
|
|
|
|
bool mFilterByPublisher;
|
2021-09-25 18:15:13 +00:00
|
|
|
bool mFilterByGenre;
|
|
|
|
bool mFilterByPlayers;
|
|
|
|
bool mFilterByFavorites;
|
2020-11-08 15:47:51 +00:00
|
|
|
bool mFilterByCompleted;
|
2021-09-25 18:15:13 +00:00
|
|
|
bool mFilterByKidGame;
|
2020-11-08 15:47:51 +00:00
|
|
|
bool mFilterByHidden;
|
2021-09-25 18:15:13 +00:00
|
|
|
bool mFilterByBroken;
|
2021-10-24 11:05:44 +00:00
|
|
|
bool mFilterByController;
|
2021-09-25 14:16:25 +00:00
|
|
|
bool mFilterByAltemulator;
|
2020-11-08 15:47:51 +00:00
|
|
|
|
2021-09-25 18:15:13 +00:00
|
|
|
std::map<std::string, int> mRatingsIndexAllKeys;
|
2021-09-25 17:30:44 +00:00
|
|
|
std::map<std::string, int> mDeveloperIndexAllKeys;
|
|
|
|
std::map<std::string, int> mPublisherIndexAllKeys;
|
2021-09-25 18:15:13 +00:00
|
|
|
std::map<std::string, int> mGenreIndexAllKeys;
|
|
|
|
std::map<std::string, int> mPlayersIndexAllKeys;
|
|
|
|
std::map<std::string, int> mFavoritesIndexAllKeys;
|
2020-11-08 15:47:51 +00:00
|
|
|
std::map<std::string, int> mCompletedIndexAllKeys;
|
2021-09-25 18:15:13 +00:00
|
|
|
std::map<std::string, int> mKidGameIndexAllKeys;
|
2020-11-08 15:47:51 +00:00
|
|
|
std::map<std::string, int> mHiddenIndexAllKeys;
|
2021-09-25 18:15:13 +00:00
|
|
|
std::map<std::string, int> mBrokenIndexAllKeys;
|
2021-10-24 11:05:44 +00:00
|
|
|
std::map<std::string, int> mControllerIndexAllKeys;
|
2021-09-25 14:16:25 +00:00
|
|
|
std::map<std::string, int> mAltemulatorIndexAllKeys;
|
2020-11-08 15:47:51 +00:00
|
|
|
|
2021-09-25 18:15:13 +00:00
|
|
|
std::vector<std::string> mRatingsIndexFilteredKeys;
|
2021-09-25 17:30:44 +00:00
|
|
|
std::vector<std::string> mDeveloperIndexFilteredKeys;
|
|
|
|
std::vector<std::string> mPublisherIndexFilteredKeys;
|
2021-09-25 18:15:13 +00:00
|
|
|
std::vector<std::string> mGenreIndexFilteredKeys;
|
|
|
|
std::vector<std::string> mPlayersIndexFilteredKeys;
|
|
|
|
std::vector<std::string> mFavoritesIndexFilteredKeys;
|
2020-11-08 15:47:51 +00:00
|
|
|
std::vector<std::string> mCompletedIndexFilteredKeys;
|
2021-09-25 18:15:13 +00:00
|
|
|
std::vector<std::string> mKidGameIndexFilteredKeys;
|
2020-11-08 15:47:51 +00:00
|
|
|
std::vector<std::string> mHiddenIndexFilteredKeys;
|
2021-09-25 18:15:13 +00:00
|
|
|
std::vector<std::string> mBrokenIndexFilteredKeys;
|
2021-10-24 11:05:44 +00:00
|
|
|
std::vector<std::string> mControllerIndexFilteredKeys;
|
2021-09-25 14:16:25 +00:00
|
|
|
std::vector<std::string> mAltemulatorIndexFilteredKeys;
|
2017-10-31 17:12:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ES_APP_FILE_FILTER_INDEX_H
|