mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Added filter support for completed and broken games.
Also fixed an issue with filtering ratings.
This commit is contained in:
parent
df0c88d1b1
commit
6e33122df7
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "FileFilterIndex.h"
|
#include "FileFilterIndex.h"
|
||||||
|
|
||||||
|
#include "math/Misc.h"
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
#include "views/UIModeController.h"
|
#include "views/UIModeController.h"
|
||||||
#include "FileData.h"
|
#include "FileData.h"
|
||||||
|
@ -20,23 +21,27 @@
|
||||||
FileFilterIndex::FileFilterIndex()
|
FileFilterIndex::FileFilterIndex()
|
||||||
: filterByFavorites(false),
|
: filterByFavorites(false),
|
||||||
filterByGenre(false),
|
filterByGenre(false),
|
||||||
filterByHidden(false),
|
|
||||||
filterByKidGame(false),
|
|
||||||
filterByPlayers(false),
|
filterByPlayers(false),
|
||||||
filterByPubDev(false),
|
filterByPubDev(false),
|
||||||
filterByRatings(false)
|
filterByRatings(false),
|
||||||
|
filterByKidGame(false),
|
||||||
|
filterByCompleted(false),
|
||||||
|
filterByBroken(false),
|
||||||
|
filterByHidden(false)
|
||||||
{
|
{
|
||||||
clearAllFilters();
|
clearAllFilters();
|
||||||
|
|
||||||
FilterDataDecl filterDecls[] = {
|
FilterDataDecl filterDecls[] = {
|
||||||
//type //allKeys //filteredBy //filteredKeys //primaryKey //hasSecondaryKey //secondaryKey //menuLabel
|
//type //allKeys //filteredBy //filteredKeys //primaryKey //hasSecondaryKey //secondaryKey //menuLabel
|
||||||
{ FAVORITES_FILTER, &favoritesIndexAllKeys, &filterByFavorites, &favoritesIndexFilteredKeys,"favorite", false, "", "FAVORITES" },
|
{ FAVORITES_FILTER, &favoritesIndexAllKeys, &filterByFavorites, &favoritesIndexFilteredKeys, "favorite", false, "", "FAVORITES" },
|
||||||
{ GENRE_FILTER, &genreIndexAllKeys, &filterByGenre, &genreIndexFilteredKeys, "genre", true, "genre", "GENRE" },
|
{ GENRE_FILTER, &genreIndexAllKeys, &filterByGenre, &genreIndexFilteredKeys, "genre", true, "genre", "GENRE" },
|
||||||
{ PLAYER_FILTER, &playersIndexAllKeys, &filterByPlayers, &playersIndexFilteredKeys, "players", false, "", "PLAYERS" },
|
{ PLAYER_FILTER, &playersIndexAllKeys, &filterByPlayers, &playersIndexFilteredKeys, "players", false, "", "PLAYERS" },
|
||||||
{ PUBDEV_FILTER, &pubDevIndexAllKeys, &filterByPubDev, &pubDevIndexFilteredKeys, "developer", true, "publisher", "PUBLISHER / DEVELOPER" },
|
{ PUBDEV_FILTER, &pubDevIndexAllKeys, &filterByPubDev, &pubDevIndexFilteredKeys, "developer", true, "publisher", "PUBLISHER / DEVELOPER" },
|
||||||
{ RATINGS_FILTER, &ratingsIndexAllKeys, &filterByRatings, &ratingsIndexFilteredKeys, "rating", false, "", "RATING" },
|
{ RATINGS_FILTER, &ratingsIndexAllKeys, &filterByRatings, &ratingsIndexFilteredKeys, "rating", false, "", "RATING" },
|
||||||
{ KIDGAME_FILTER, &kidGameIndexAllKeys, &filterByKidGame, &kidGameIndexFilteredKeys, "kidgame", false, "", "KIDGAME" },
|
{ KIDGAME_FILTER, &kidGameIndexAllKeys, &filterByKidGame, &kidGameIndexFilteredKeys, "kidgame", false, "", "KIDGAME" },
|
||||||
{ HIDDEN_FILTER, &hiddenIndexAllKeys, &filterByHidden, &hiddenIndexFilteredKeys, "hidden", false, "", "HIDDEN" }
|
{ COMPLETED_FILTER, &completedIndexAllKeys, &filterByCompleted, &completedIndexFilteredKeys, "completed", false, "", "COMPLETED" },
|
||||||
|
{ BROKEN_FILTER, &brokenIndexAllKeys, &filterByBroken, &brokenIndexFilteredKeys, "broken", false, "", "BROKEN" },
|
||||||
|
{ HIDDEN_FILTER, &hiddenIndexAllKeys, &filterByHidden, &hiddenIndexFilteredKeys, "hidden", false, "", "HIDDEN" }
|
||||||
};
|
};
|
||||||
|
|
||||||
filterDataDecl = std::vector<FilterDataDecl>(filterDecls, filterDecls +
|
filterDataDecl = std::vector<FilterDataDecl>(filterDecls, filterDecls +
|
||||||
|
@ -61,13 +66,15 @@ void FileFilterIndex::importIndex(FileFilterIndex* indexToImport)
|
||||||
};
|
};
|
||||||
|
|
||||||
IndexImportStructure indexStructDecls[] = {
|
IndexImportStructure indexStructDecls[] = {
|
||||||
|
{ &favoritesIndexAllKeys, &(indexToImport->favoritesIndexAllKeys) },
|
||||||
{ &genreIndexAllKeys, &(indexToImport->genreIndexAllKeys) },
|
{ &genreIndexAllKeys, &(indexToImport->genreIndexAllKeys) },
|
||||||
{ &playersIndexAllKeys, &(indexToImport->playersIndexAllKeys) },
|
{ &playersIndexAllKeys, &(indexToImport->playersIndexAllKeys) },
|
||||||
{ &pubDevIndexAllKeys, &(indexToImport->pubDevIndexAllKeys) },
|
{ &pubDevIndexAllKeys, &(indexToImport->pubDevIndexAllKeys) },
|
||||||
{ &ratingsIndexAllKeys, &(indexToImport->ratingsIndexAllKeys) },
|
{ &ratingsIndexAllKeys, &(indexToImport->ratingsIndexAllKeys) },
|
||||||
{ &favoritesIndexAllKeys, &(indexToImport->favoritesIndexAllKeys) },
|
|
||||||
{ &hiddenIndexAllKeys, &(indexToImport->hiddenIndexAllKeys) },
|
|
||||||
{ &kidGameIndexAllKeys, &(indexToImport->kidGameIndexAllKeys) },
|
{ &kidGameIndexAllKeys, &(indexToImport->kidGameIndexAllKeys) },
|
||||||
|
{ &completedIndexAllKeys, &(indexToImport->completedIndexAllKeys) },
|
||||||
|
{ &brokenIndexAllKeys, &(indexToImport->brokenIndexAllKeys) },
|
||||||
|
{ &hiddenIndexAllKeys, &(indexToImport->hiddenIndexAllKeys) },
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<IndexImportStructure> indexImportDecl =
|
std::vector<IndexImportStructure> indexImportDecl =
|
||||||
|
@ -93,13 +100,15 @@ void FileFilterIndex::importIndex(FileFilterIndex* indexToImport)
|
||||||
void FileFilterIndex::resetIndex()
|
void FileFilterIndex::resetIndex()
|
||||||
{
|
{
|
||||||
clearAllFilters();
|
clearAllFilters();
|
||||||
|
clearIndex(favoritesIndexAllKeys);
|
||||||
clearIndex(genreIndexAllKeys);
|
clearIndex(genreIndexAllKeys);
|
||||||
clearIndex(playersIndexAllKeys);
|
clearIndex(playersIndexAllKeys);
|
||||||
clearIndex(pubDevIndexAllKeys);
|
clearIndex(pubDevIndexAllKeys);
|
||||||
clearIndex(ratingsIndexAllKeys);
|
clearIndex(ratingsIndexAllKeys);
|
||||||
clearIndex(favoritesIndexAllKeys);
|
|
||||||
clearIndex(hiddenIndexAllKeys);
|
|
||||||
clearIndex(kidGameIndexAllKeys);
|
clearIndex(kidGameIndexAllKeys);
|
||||||
|
clearIndex(completedIndexAllKeys);
|
||||||
|
clearIndex(brokenIndexAllKeys);
|
||||||
|
clearIndex(hiddenIndexAllKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FileFilterIndex::getIndexableKey(FileData* game,
|
std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
|
@ -107,6 +116,12 @@ std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
{
|
{
|
||||||
std::string key = "";
|
std::string key = "";
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case FAVORITES_FILTER: {
|
||||||
|
if (game->getType() != GAME)
|
||||||
|
return "FALSE";
|
||||||
|
key = Utils::String::toUpper(game->metadata.get("favorite"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GENRE_FILTER: {
|
case GENRE_FILTER: {
|
||||||
key = Utils::String::toUpper(game->metadata.get("genre"));
|
key = Utils::String::toUpper(game->metadata.get("genre"));
|
||||||
key = Utils::String::trim(key);
|
key = Utils::String::trim(key);
|
||||||
|
@ -144,11 +159,21 @@ std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
std::string ratingString = game->metadata.get("rating");
|
std::string ratingString = game->metadata.get("rating");
|
||||||
if (!ratingString.empty()) {
|
if (!ratingString.empty()) {
|
||||||
try {
|
try {
|
||||||
ratingNumber = (int)((std::stod(ratingString)*5)+0.5);
|
// Round up fractional values such as 0.75 to 0.8.
|
||||||
|
// These values should only exist if a third party application has
|
||||||
|
// been used for scraping the ratings, or if the gamelist.xml file
|
||||||
|
// has been manually edited.
|
||||||
|
ratingNumber = static_cast<int>(
|
||||||
|
(Math::ceilf(stof(ratingString) / 0.1) / 10) * 5);
|
||||||
|
|
||||||
if (ratingNumber < 0)
|
if (ratingNumber < 0)
|
||||||
ratingNumber = 0;
|
ratingNumber = 0;
|
||||||
|
|
||||||
key = std::to_string(ratingNumber) + " STARS";
|
if (ratingNumber == 5)
|
||||||
|
key = "5 STARS";
|
||||||
|
else
|
||||||
|
key = std::to_string(ratingNumber) + " - " +
|
||||||
|
std::to_string(ratingNumber) + ".5 STARS";
|
||||||
}
|
}
|
||||||
catch (int e) {
|
catch (int e) {
|
||||||
LOG(LogError) << "Error parsing Rating (invalid value, exception nr.): " <<
|
LOG(LogError) << "Error parsing Rating (invalid value, exception nr.): " <<
|
||||||
|
@ -158,10 +183,22 @@ std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FAVORITES_FILTER: {
|
case KIDGAME_FILTER: {
|
||||||
if (game->getType() != GAME)
|
if (game->getType() != GAME)
|
||||||
return "FALSE";
|
return "FALSE";
|
||||||
key = Utils::String::toUpper(game->metadata.get("favorite"));
|
key = Utils::String::toUpper(game->metadata.get("kidgame"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMPLETED_FILTER: {
|
||||||
|
if (game->getType() != GAME)
|
||||||
|
return "FALSE";
|
||||||
|
key = Utils::String::toUpper(game->metadata.get("completed"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BROKEN_FILTER: {
|
||||||
|
if (game->getType() != GAME)
|
||||||
|
return "FALSE";
|
||||||
|
key = Utils::String::toUpper(game->metadata.get("broken"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HIDDEN_FILTER: {
|
case HIDDEN_FILTER: {
|
||||||
|
@ -170,12 +207,6 @@ std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
key = Utils::String::toUpper(game->metadata.get("hidden"));
|
key = Utils::String::toUpper(game->metadata.get("hidden"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KIDGAME_FILTER: {
|
|
||||||
if (game->getType() != GAME)
|
|
||||||
return "FALSE";
|
|
||||||
key = Utils::String::toUpper(game->metadata.get("kidgame"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -188,24 +219,28 @@ std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
|
|
||||||
void FileFilterIndex::addToIndex(FileData* game)
|
void FileFilterIndex::addToIndex(FileData* game)
|
||||||
{
|
{
|
||||||
|
manageFavoritesEntryInIndex(game);
|
||||||
manageGenreEntryInIndex(game);
|
manageGenreEntryInIndex(game);
|
||||||
managePlayerEntryInIndex(game);
|
managePlayerEntryInIndex(game);
|
||||||
managePubDevEntryInIndex(game);
|
managePubDevEntryInIndex(game);
|
||||||
manageRatingsEntryInIndex(game);
|
manageRatingsEntryInIndex(game);
|
||||||
manageFavoritesEntryInIndex(game);
|
|
||||||
manageHiddenEntryInIndex(game);
|
|
||||||
manageKidGameEntryInIndex(game);
|
manageKidGameEntryInIndex(game);
|
||||||
|
manageCompletedEntryInIndex(game);
|
||||||
|
manageBrokenEntryInIndex(game);
|
||||||
|
manageHiddenEntryInIndex(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::removeFromIndex(FileData* game)
|
void FileFilterIndex::removeFromIndex(FileData* game)
|
||||||
{
|
{
|
||||||
|
manageFavoritesEntryInIndex(game, true);
|
||||||
manageGenreEntryInIndex(game, true);
|
manageGenreEntryInIndex(game, true);
|
||||||
managePlayerEntryInIndex(game, true);
|
managePlayerEntryInIndex(game, true);
|
||||||
managePubDevEntryInIndex(game, true);
|
managePubDevEntryInIndex(game, true);
|
||||||
manageRatingsEntryInIndex(game, true);
|
manageRatingsEntryInIndex(game, true);
|
||||||
manageFavoritesEntryInIndex(game, true);
|
|
||||||
manageHiddenEntryInIndex(game, true);
|
|
||||||
manageKidGameEntryInIndex(game, true);
|
manageKidGameEntryInIndex(game, true);
|
||||||
|
manageCompletedEntryInIndex(game, true);
|
||||||
|
manageBrokenEntryInIndex(game, true);
|
||||||
|
manageHiddenEntryInIndex(game, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>* values)
|
void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>* values)
|
||||||
|
@ -223,7 +258,7 @@ void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>*
|
||||||
filterData.currentFilteredKeys->clear();
|
filterData.currentFilteredKeys->clear();
|
||||||
for (std::vector<std::string>::const_iterator vit =
|
for (std::vector<std::string>::const_iterator vit =
|
||||||
values->cbegin(); vit != values->cend(); ++vit ) {
|
values->cbegin(); vit != values->cend(); ++vit ) {
|
||||||
// Check if exists.
|
// Check if it exists.
|
||||||
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->cend()) {
|
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->cend()) {
|
||||||
filterData.currentFilteredKeys->push_back(std::string(*vit));
|
filterData.currentFilteredKeys->push_back(std::string(*vit));
|
||||||
}
|
}
|
||||||
|
@ -270,27 +305,33 @@ void FileFilterIndex::setUIModeFilters()
|
||||||
void FileFilterIndex::debugPrintIndexes()
|
void FileFilterIndex::debugPrintIndexes()
|
||||||
{
|
{
|
||||||
LOG(LogInfo) << "Printing Indexes...";
|
LOG(LogInfo) << "Printing Indexes...";
|
||||||
for (auto x: playersIndexAllKeys) {
|
for (auto x: favoritesIndexAllKeys) {
|
||||||
LOG(LogInfo) << "Multiplayer Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "Favorites Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
for (auto x: genreIndexAllKeys) {
|
for (auto x: genreIndexAllKeys) {
|
||||||
LOG(LogInfo) << "Genre Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "Genre Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
for (auto x: ratingsIndexAllKeys) {
|
for (auto x: playersIndexAllKeys) {
|
||||||
LOG(LogInfo) << "Ratings Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "Multiplayer Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
for (auto x: pubDevIndexAllKeys) {
|
for (auto x: pubDevIndexAllKeys) {
|
||||||
LOG(LogInfo) << "PubDev Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "PubDev Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
for (auto x: favoritesIndexAllKeys) {
|
for (auto x: ratingsIndexAllKeys) {
|
||||||
LOG(LogInfo) << "Favorites Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "Ratings Index: " << x.first << ": " << x.second;
|
||||||
}
|
|
||||||
for (auto x : hiddenIndexAllKeys) {
|
|
||||||
LOG(LogInfo) << "Hidden Index: " << x.first << ": " << x.second;
|
|
||||||
}
|
}
|
||||||
for (auto x : kidGameIndexAllKeys) {
|
for (auto x : kidGameIndexAllKeys) {
|
||||||
LOG(LogInfo) << "KidGames Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "KidGames Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
|
for (auto x : completedIndexAllKeys) {
|
||||||
|
LOG(LogInfo) << "Completed Index: " << x.first << ": " << x.second;
|
||||||
|
}
|
||||||
|
for (auto x : brokenIndexAllKeys) {
|
||||||
|
LOG(LogInfo) << "Broken Index: " << x.first << ": " << x.second;
|
||||||
|
}
|
||||||
|
for (auto x : hiddenIndexAllKeys) {
|
||||||
|
LOG(LogInfo) << "Hidden Index: " << x.first << ": " << x.second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileFilterIndex::showFile(FileData* game)
|
bool FileFilterIndex::showFile(FileData* game)
|
||||||
|
@ -341,13 +382,15 @@ bool FileFilterIndex::showFile(FileData* game)
|
||||||
|
|
||||||
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
|
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
|
||||||
{
|
{
|
||||||
const FilterIndexType filterTypes[7] = { FAVORITES_FILTER, GENRE_FILTER,
|
const FilterIndexType filterTypes[9] = { FAVORITES_FILTER, GENRE_FILTER,
|
||||||
PLAYER_FILTER, PUBDEV_FILTER, RATINGS_FILTER,HIDDEN_FILTER, KIDGAME_FILTER };
|
PLAYER_FILTER, PUBDEV_FILTER, RATINGS_FILTER, KIDGAME_FILTER,
|
||||||
std::vector<std::string> filterKeysList[7] = { favoritesIndexFilteredKeys,
|
COMPLETED_FILTER, BROKEN_FILTER, HIDDEN_FILTER };
|
||||||
|
std::vector<std::string> filterKeysList[9] = { favoritesIndexFilteredKeys,
|
||||||
genreIndexFilteredKeys, playersIndexFilteredKeys, pubDevIndexFilteredKeys,
|
genreIndexFilteredKeys, playersIndexFilteredKeys, pubDevIndexFilteredKeys,
|
||||||
ratingsIndexFilteredKeys, hiddenIndexFilteredKeys, kidGameIndexFilteredKeys };
|
ratingsIndexFilteredKeys, kidGameIndexFilteredKeys, completedIndexFilteredKeys,
|
||||||
|
brokenIndexFilteredKeys, hiddenIndexFilteredKeys };
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
if (filterTypes[i] == type) {
|
if (filterTypes[i] == type) {
|
||||||
for (std::vector<std::string>::const_iterator it = filterKeysList[i].cbegin();
|
for (std::vector<std::string>::const_iterator it = filterKeysList[i].cbegin();
|
||||||
it != filterKeysList[i].cend(); ++it ) {
|
it != filterKeysList[i].cend(); ++it ) {
|
||||||
|
@ -360,9 +403,21 @@ bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileFilterIndex::manageFavoritesEntryInIndex(FileData* game, bool remove)
|
||||||
|
{
|
||||||
|
// Flag for including unknowns.
|
||||||
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
|
std::string key = getIndexableKey(game, FAVORITES_FILTER, false);
|
||||||
|
|
||||||
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
|
// No valid favorites info found.
|
||||||
|
return;
|
||||||
|
|
||||||
|
manageIndexEntry(&favoritesIndexAllKeys, key, remove);
|
||||||
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageGenreEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::manageGenreEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string key = getIndexableKey(game, GENRE_FILTER, false);
|
std::string key = getIndexableKey(game, GENRE_FILTER, false);
|
||||||
|
|
||||||
// Flag for including unknowns.
|
// Flag for including unknowns.
|
||||||
|
@ -444,17 +499,43 @@ void FileFilterIndex::manageRatingsEntryInIndex(FileData* game, bool remove)
|
||||||
manageIndexEntry(&ratingsIndexAllKeys, key, remove);
|
manageIndexEntry(&ratingsIndexAllKeys, key, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageFavoritesEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::manageKidGameEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
// Flag for including unknowns.
|
// Flag for including unknowns.
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
std::string key = getIndexableKey(game, FAVORITES_FILTER, false);
|
std::string key = getIndexableKey(game, KIDGAME_FILTER, false);
|
||||||
|
|
||||||
if (!includeUnknown && key == UNKNOWN_LABEL)
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
// No valid favorites info found.
|
// No valid kidgame info found.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
manageIndexEntry(&favoritesIndexAllKeys, key, remove);
|
manageIndexEntry(&kidGameIndexAllKeys, key, remove);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileFilterIndex::manageCompletedEntryInIndex(FileData* game, bool remove)
|
||||||
|
{
|
||||||
|
// Flag for including unknowns.
|
||||||
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
|
std::string key = getIndexableKey(game, COMPLETED_FILTER, false);
|
||||||
|
|
||||||
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
|
// No valid completed info found.
|
||||||
|
return;
|
||||||
|
|
||||||
|
manageIndexEntry(&completedIndexAllKeys, key, remove);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileFilterIndex::manageBrokenEntryInIndex(FileData* game, bool remove)
|
||||||
|
{
|
||||||
|
// Flag for including unknowns.
|
||||||
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
|
std::string key = getIndexableKey(game, BROKEN_FILTER, false);
|
||||||
|
|
||||||
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
|
// No valid broken info found.
|
||||||
|
return;
|
||||||
|
|
||||||
|
manageIndexEntry(&brokenIndexAllKeys, key, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageHiddenEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::manageHiddenEntryInIndex(FileData* game, bool remove)
|
||||||
|
@ -470,19 +551,6 @@ void FileFilterIndex::manageHiddenEntryInIndex(FileData* game, bool remove)
|
||||||
manageIndexEntry(&hiddenIndexAllKeys, key, remove);
|
manageIndexEntry(&hiddenIndexAllKeys, key, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageKidGameEntryInIndex(FileData* game, bool remove)
|
|
||||||
{
|
|
||||||
// Flag for including unknowns.
|
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
|
||||||
std::string key = getIndexableKey(game, KIDGAME_FILTER, false);
|
|
||||||
|
|
||||||
if (!includeUnknown && key == UNKNOWN_LABEL)
|
|
||||||
// No valid kidgame info found.
|
|
||||||
return;
|
|
||||||
|
|
||||||
manageIndexEntry(&kidGameIndexAllKeys, key, remove);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index,
|
void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index,
|
||||||
std::string key, bool remove)
|
std::string key, bool remove)
|
||||||
{
|
{
|
||||||
|
@ -493,12 +561,9 @@ void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index,
|
||||||
if (remove) {
|
if (remove) {
|
||||||
// Removing entry.
|
// Removing entry.
|
||||||
if (index->find(key) == index->cend()) {
|
if (index->find(key) == index->cend()) {
|
||||||
// Disabled for now, actually this WILL happen as default values are assigned
|
// Disabled for now as this could happen because default values are assigned as
|
||||||
// as filters, such as 'FALSE' for favorites and kidgames for non-game entries.
|
// filters, for example 'FALSE' for favorites and kidgames for non-game entries.
|
||||||
// This whole logic needs to be rewritten later on, but for now this is a
|
// LOG(LogDebug) << "Couldn't find entry in index! " << key;
|
||||||
// workaround to get rid of the annoying log messages.
|
|
||||||
// // This shouldn't happen.
|
|
||||||
// LOG(LogInfo) << "Couldn't find entry in index! " << key;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(index->at(key))--;
|
(index->at(key))--;
|
||||||
|
|
|
@ -20,13 +20,15 @@ class FileData;
|
||||||
|
|
||||||
enum FilterIndexType {
|
enum FilterIndexType {
|
||||||
NONE,
|
NONE,
|
||||||
|
FAVORITES_FILTER,
|
||||||
GENRE_FILTER,
|
GENRE_FILTER,
|
||||||
PLAYER_FILTER,
|
PLAYER_FILTER,
|
||||||
PUBDEV_FILTER,
|
PUBDEV_FILTER,
|
||||||
RATINGS_FILTER,
|
RATINGS_FILTER,
|
||||||
FAVORITES_FILTER,
|
KIDGAME_FILTER,
|
||||||
HIDDEN_FILTER,
|
COMPLETED_FILTER,
|
||||||
KIDGAME_FILTER
|
BROKEN_FILTER,
|
||||||
|
HIDDEN_FILTER
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FilterDataDecl {
|
struct FilterDataDecl {
|
||||||
|
@ -51,8 +53,9 @@ public:
|
||||||
void clearAllFilters();
|
void clearAllFilters();
|
||||||
void debugPrintIndexes();
|
void debugPrintIndexes();
|
||||||
bool showFile(FileData* game);
|
bool showFile(FileData* game);
|
||||||
bool isFiltered() { return (filterByGenre || filterByPlayers || filterByPubDev ||
|
bool isFiltered() { return (filterByFavorites || filterByGenre || filterByPlayers ||
|
||||||
filterByRatings || filterByFavorites || filterByHidden || filterByKidGame); };
|
filterByPubDev || filterByRatings || filterByKidGame || filterByCompleted ||
|
||||||
|
filterByBroken || filterByHidden ); };
|
||||||
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
|
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
|
||||||
std::vector<FilterDataDecl>& getFilterDataDecls();
|
std::vector<FilterDataDecl>& getFilterDataDecls();
|
||||||
|
|
||||||
|
@ -65,41 +68,49 @@ private:
|
||||||
std::vector<FilterDataDecl> filterDataDecl;
|
std::vector<FilterDataDecl> filterDataDecl;
|
||||||
std::string getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary);
|
std::string getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary);
|
||||||
|
|
||||||
|
void manageFavoritesEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageGenreEntryInIndex(FileData* game, bool remove = false);
|
void manageGenreEntryInIndex(FileData* game, bool remove = false);
|
||||||
void managePlayerEntryInIndex(FileData* game, bool remove = false);
|
void managePlayerEntryInIndex(FileData* game, bool remove = false);
|
||||||
void managePubDevEntryInIndex(FileData* game, bool remove = false);
|
void managePubDevEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageRatingsEntryInIndex(FileData* game, bool remove = false);
|
void manageRatingsEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageFavoritesEntryInIndex(FileData* game, bool remove = false);
|
|
||||||
void manageHiddenEntryInIndex(FileData* game, bool remove = false);
|
|
||||||
void manageKidGameEntryInIndex(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<std::string, int>* index, std::string key, bool remove);
|
void manageIndexEntry(std::map<std::string, int>* index, std::string key, bool remove);
|
||||||
|
|
||||||
void clearIndex(std::map<std::string, int> indexMap);
|
void clearIndex(std::map<std::string, int> indexMap);
|
||||||
|
|
||||||
|
bool filterByFavorites;
|
||||||
bool filterByGenre;
|
bool filterByGenre;
|
||||||
bool filterByPlayers;
|
bool filterByPlayers;
|
||||||
bool filterByPubDev;
|
bool filterByPubDev;
|
||||||
bool filterByRatings;
|
bool filterByRatings;
|
||||||
bool filterByFavorites;
|
|
||||||
bool filterByHidden;
|
|
||||||
bool filterByKidGame;
|
bool filterByKidGame;
|
||||||
|
bool filterByCompleted;
|
||||||
|
bool filterByBroken;
|
||||||
|
bool filterByHidden;
|
||||||
|
|
||||||
|
std::map<std::string, int> favoritesIndexAllKeys;
|
||||||
std::map<std::string, int> genreIndexAllKeys;
|
std::map<std::string, int> genreIndexAllKeys;
|
||||||
std::map<std::string, int> playersIndexAllKeys;
|
std::map<std::string, int> playersIndexAllKeys;
|
||||||
std::map<std::string, int> pubDevIndexAllKeys;
|
std::map<std::string, int> pubDevIndexAllKeys;
|
||||||
std::map<std::string, int> ratingsIndexAllKeys;
|
std::map<std::string, int> ratingsIndexAllKeys;
|
||||||
std::map<std::string, int> favoritesIndexAllKeys;
|
|
||||||
std::map<std::string, int> hiddenIndexAllKeys;
|
|
||||||
std::map<std::string, int> kidGameIndexAllKeys;
|
std::map<std::string, int> kidGameIndexAllKeys;
|
||||||
|
std::map<std::string, int> completedIndexAllKeys;
|
||||||
|
std::map<std::string, int> brokenIndexAllKeys;
|
||||||
|
std::map<std::string, int> hiddenIndexAllKeys;
|
||||||
|
|
||||||
|
std::vector<std::string> favoritesIndexFilteredKeys;
|
||||||
std::vector<std::string> genreIndexFilteredKeys;
|
std::vector<std::string> genreIndexFilteredKeys;
|
||||||
std::vector<std::string> playersIndexFilteredKeys;
|
std::vector<std::string> playersIndexFilteredKeys;
|
||||||
std::vector<std::string> pubDevIndexFilteredKeys;
|
std::vector<std::string> pubDevIndexFilteredKeys;
|
||||||
std::vector<std::string> ratingsIndexFilteredKeys;
|
std::vector<std::string> ratingsIndexFilteredKeys;
|
||||||
std::vector<std::string> favoritesIndexFilteredKeys;
|
|
||||||
std::vector<std::string> hiddenIndexFilteredKeys;
|
|
||||||
std::vector<std::string> kidGameIndexFilteredKeys;
|
std::vector<std::string> kidGameIndexFilteredKeys;
|
||||||
|
std::vector<std::string> completedIndexFilteredKeys;
|
||||||
|
std::vector<std::string> brokenIndexFilteredKeys;
|
||||||
|
std::vector<std::string> hiddenIndexFilteredKeys;
|
||||||
|
|
||||||
FileData* mRootFolder;
|
FileData* mRootFolder;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue