// SPDX-License-Identifier: MIT // // EmulationStation Desktop Edition // FileFilterIndex.h // // Gamelist filters. // #ifndef ES_APP_FILE_FILTER_INDEX_H #define ES_APP_FILE_FILTER_INDEX_H #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include #endif #include #include #include class FileData; enum FilterIndexType { NONE, FAVORITES_FILTER, GENRE_FILTER, PLAYER_FILTER, PUBDEV_FILTER, RATINGS_FILTER, KIDGAME_FILTER, COMPLETED_FILTER, BROKEN_FILTER, HIDDEN_FILTER }; struct FilterDataDecl { FilterIndexType type; // Type of filter. std::map* allIndexKeys; // All possible filters for this type. bool* filteredByRef; // Is it filtered by this type? std::vector* 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* values); void setTextFilter(std::string textFilter); std::string getTextFilter() { return mTextFilter; }; void clearAllFilters(); void debugPrintIndexes(); bool showFile(FileData* game); bool isFiltered(); bool isKeyBeingFilteredBy(std::string key, FilterIndexType type); std::vector& getFilterDataDecls(); void importIndex(FileFilterIndex* indexToImport); void resetIndex(); void resetFilters(); void setKidModeFilters(); private: std::vector filterDataDecl; std::string getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary); void manageFavoritesEntryInIndex(FileData* game, bool remove = false); 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); void manageCompletedEntryInIndex(FileData* game, bool remove = false); void manageBrokenEntryInIndex(FileData* game, bool remove = false); void manageHiddenEntryInIndex(FileData* game, bool remove = false); void manageIndexEntry(std::map* index, std::string key, bool remove); void clearIndex(std::map indexMap); std::string mTextFilter; bool mFilterByText; bool mFilterByFavorites; bool mFilterByGenre; bool mFilterByPlayers; bool mFilterByPubDev; bool mFilterByRatings; bool mFilterByKidGame; bool mFilterByCompleted; bool mFilterByBroken; bool mFilterByHidden; std::map mFavoritesIndexAllKeys; std::map mGenreIndexAllKeys; std::map mPlayersIndexAllKeys; std::map mPubDevIndexAllKeys; std::map mRatingsIndexAllKeys; std::map mKidGameIndexAllKeys; std::map mCompletedIndexAllKeys; std::map mBrokenIndexAllKeys; std::map mHiddenIndexAllKeys; std::vector mFavoritesIndexFilteredKeys; std::vector mGenreIndexFilteredKeys; std::vector mPlayersIndexFilteredKeys; std::vector mPubDevIndexFilteredKeys; std::vector mRatingsIndexFilteredKeys; std::vector mKidGameIndexFilteredKeys; std::vector mCompletedIndexFilteredKeys; std::vector mBrokenIndexFilteredKeys; std::vector mHiddenIndexFilteredKeys; FileData* mRootFolder; }; #endif // ES_APP_FILE_FILTER_INDEX_H