mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 17:45:38 +00:00
Added a filter for the 'Alternative emulator' field.
This commit is contained in:
parent
966d2616be
commit
c85700571d
|
@ -31,6 +31,7 @@ FileFilterIndex::FileFilterIndex()
|
||||||
, mFilterByCompleted(false)
|
, mFilterByCompleted(false)
|
||||||
, mFilterByBroken(false)
|
, mFilterByBroken(false)
|
||||||
, mFilterByHidden(false)
|
, mFilterByHidden(false)
|
||||||
|
, mFilterByAltemulator(false)
|
||||||
{
|
{
|
||||||
clearAllFilters();
|
clearAllFilters();
|
||||||
|
|
||||||
|
@ -45,7 +46,8 @@ FileFilterIndex::FileFilterIndex()
|
||||||
{KIDGAME_FILTER, &mKidGameIndexAllKeys, &mFilterByKidGame, &mKidGameIndexFilteredKeys, "kidgame", false, "", "KIDGAME"},
|
{KIDGAME_FILTER, &mKidGameIndexAllKeys, &mFilterByKidGame, &mKidGameIndexFilteredKeys, "kidgame", false, "", "KIDGAME"},
|
||||||
{COMPLETED_FILTER, &mCompletedIndexAllKeys, &mFilterByCompleted, &mCompletedIndexFilteredKeys, "completed", false, "", "COMPLETED"},
|
{COMPLETED_FILTER, &mCompletedIndexAllKeys, &mFilterByCompleted, &mCompletedIndexFilteredKeys, "completed", false, "", "COMPLETED"},
|
||||||
{BROKEN_FILTER, &mBrokenIndexAllKeys, &mFilterByBroken, &mBrokenIndexFilteredKeys, "broken", false, "", "BROKEN"},
|
{BROKEN_FILTER, &mBrokenIndexAllKeys, &mFilterByBroken, &mBrokenIndexFilteredKeys, "broken", false, "", "BROKEN"},
|
||||||
{HIDDEN_FILTER, &mHiddenIndexAllKeys, &mFilterByHidden, &mHiddenIndexFilteredKeys, "hidden", false, "", "HIDDEN"}
|
{HIDDEN_FILTER, &mHiddenIndexAllKeys, &mFilterByHidden, &mHiddenIndexFilteredKeys, "hidden", false, "", "HIDDEN"},
|
||||||
|
{ALTEMULATOR_FILTER, &mAltemulatorIndexAllKeys, &mFilterByAltemulator, &mAltemulatorIndexFilteredKeys, "altemulator", false, "", "ALTERNATIVE EMULATOR"}
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -76,6 +78,7 @@ void FileFilterIndex::importIndex(FileFilterIndex* indexToImport)
|
||||||
{&mCompletedIndexAllKeys, &(indexToImport->mCompletedIndexAllKeys)},
|
{&mCompletedIndexAllKeys, &(indexToImport->mCompletedIndexAllKeys)},
|
||||||
{&mBrokenIndexAllKeys, &(indexToImport->mBrokenIndexAllKeys)},
|
{&mBrokenIndexAllKeys, &(indexToImport->mBrokenIndexAllKeys)},
|
||||||
{&mHiddenIndexAllKeys, &(indexToImport->mHiddenIndexAllKeys)},
|
{&mHiddenIndexAllKeys, &(indexToImport->mHiddenIndexAllKeys)},
|
||||||
|
{&mAltemulatorIndexAllKeys, &(indexToImport->mAltemulatorIndexAllKeys)},
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<IndexImportStructure> indexImportDecl = std::vector<IndexImportStructure>(
|
std::vector<IndexImportStructure> indexImportDecl = std::vector<IndexImportStructure>(
|
||||||
|
@ -111,6 +114,7 @@ void FileFilterIndex::resetIndex()
|
||||||
clearIndex(mCompletedIndexAllKeys);
|
clearIndex(mCompletedIndexAllKeys);
|
||||||
clearIndex(mBrokenIndexAllKeys);
|
clearIndex(mBrokenIndexAllKeys);
|
||||||
clearIndex(mHiddenIndexAllKeys);
|
clearIndex(mHiddenIndexAllKeys);
|
||||||
|
clearIndex(mAltemulatorIndexAllKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FileFilterIndex::getIndexableKey(FileData* game,
|
std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
|
@ -142,14 +146,12 @@ std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
case PLAYER_FILTER: {
|
case PLAYER_FILTER: {
|
||||||
if (getSecondary)
|
if (getSecondary)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
key = Utils::String::toUpper(game->metadata.get("players"));
|
key = Utils::String::toUpper(game->metadata.get("players"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PUBDEV_FILTER: {
|
case PUBDEV_FILTER: {
|
||||||
key = Utils::String::toUpper(game->metadata.get("publisher"));
|
key = Utils::String::toUpper(game->metadata.get("publisher"));
|
||||||
key = Utils::String::trim(key);
|
key = Utils::String::trim(key);
|
||||||
|
|
||||||
if ((getSecondary && !key.empty()) || (!getSecondary && key.empty()))
|
if ((getSecondary && !key.empty()) || (!getSecondary && key.empty()))
|
||||||
key = Utils::String::toUpper(game->metadata.get("developer"));
|
key = Utils::String::toUpper(game->metadata.get("developer"));
|
||||||
else
|
else
|
||||||
|
@ -210,6 +212,12 @@ 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 ALTEMULATOR_FILTER: {
|
||||||
|
if (getSecondary)
|
||||||
|
break;
|
||||||
|
key = Utils::String::toUpper(game->metadata.get("altemulator"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -231,6 +239,7 @@ void FileFilterIndex::addToIndex(FileData* game)
|
||||||
manageCompletedEntryInIndex(game);
|
manageCompletedEntryInIndex(game);
|
||||||
manageBrokenEntryInIndex(game);
|
manageBrokenEntryInIndex(game);
|
||||||
manageHiddenEntryInIndex(game);
|
manageHiddenEntryInIndex(game);
|
||||||
|
manageAltemulatorEntryInIndex(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::removeFromIndex(FileData* game)
|
void FileFilterIndex::removeFromIndex(FileData* game)
|
||||||
|
@ -244,6 +253,7 @@ void FileFilterIndex::removeFromIndex(FileData* game)
|
||||||
manageCompletedEntryInIndex(game, true);
|
manageCompletedEntryInIndex(game, true);
|
||||||
manageBrokenEntryInIndex(game, true);
|
manageBrokenEntryInIndex(game, true);
|
||||||
manageHiddenEntryInIndex(game, true);
|
manageHiddenEntryInIndex(game, true);
|
||||||
|
manageAltemulatorEntryInIndex(game, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>* values)
|
void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>* values)
|
||||||
|
@ -339,6 +349,9 @@ void FileFilterIndex::debugPrintIndexes()
|
||||||
for (auto x : mHiddenIndexAllKeys) {
|
for (auto x : mHiddenIndexAllKeys) {
|
||||||
LOG(LogInfo) << "Hidden Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "Hidden Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
|
for (auto x : mAltemulatorIndexAllKeys) {
|
||||||
|
LOG(LogInfo) << "Altemulator Index: " << x.first << ": " << x.second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileFilterIndex::showFile(FileData* game)
|
bool FileFilterIndex::showFile(FileData* game)
|
||||||
|
@ -415,26 +428,27 @@ bool FileFilterIndex::isFiltered()
|
||||||
if (UIModeController::getInstance()->isUIModeKid()) {
|
if (UIModeController::getInstance()->isUIModeKid()) {
|
||||||
return (mFilterByText || mFilterByFavorites || mFilterByGenre || mFilterByPlayers ||
|
return (mFilterByText || mFilterByFavorites || mFilterByGenre || mFilterByPlayers ||
|
||||||
mFilterByPubDev || mFilterByRatings || mFilterByCompleted || mFilterByBroken ||
|
mFilterByPubDev || mFilterByRatings || mFilterByCompleted || mFilterByBroken ||
|
||||||
mFilterByHidden);
|
mFilterByHidden || mFilterByAltemulator);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (mFilterByText || mFilterByFavorites || mFilterByGenre || mFilterByPlayers ||
|
return (mFilterByText || mFilterByFavorites || mFilterByGenre || mFilterByPlayers ||
|
||||||
mFilterByPubDev || mFilterByRatings || mFilterByKidGame || mFilterByCompleted ||
|
mFilterByPubDev || mFilterByRatings || mFilterByKidGame || mFilterByCompleted ||
|
||||||
mFilterByBroken || mFilterByHidden);
|
mFilterByBroken || mFilterByHidden | mFilterByAltemulator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
|
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
|
||||||
{
|
{
|
||||||
const FilterIndexType filterTypes[9] = {FAVORITES_FILTER, GENRE_FILTER, PLAYER_FILTER,
|
const FilterIndexType filterTypes[10] = {
|
||||||
PUBDEV_FILTER, RATINGS_FILTER, KIDGAME_FILTER,
|
FAVORITES_FILTER, GENRE_FILTER, PLAYER_FILTER, PUBDEV_FILTER, RATINGS_FILTER,
|
||||||
COMPLETED_FILTER, BROKEN_FILTER, HIDDEN_FILTER};
|
KIDGAME_FILTER, COMPLETED_FILTER, BROKEN_FILTER, HIDDEN_FILTER, ALTEMULATOR_FILTER};
|
||||||
std::vector<std::string> filterKeysList[9] = {
|
std::vector<std::string> filterKeysList[10] = {
|
||||||
mFavoritesIndexFilteredKeys, mGenreIndexFilteredKeys, mPlayersIndexFilteredKeys,
|
mFavoritesIndexFilteredKeys, mGenreIndexFilteredKeys, mPlayersIndexFilteredKeys,
|
||||||
mPubDevIndexFilteredKeys, mRatingsIndexFilteredKeys, mKidGameIndexFilteredKeys,
|
mPubDevIndexFilteredKeys, mRatingsIndexFilteredKeys, mKidGameIndexFilteredKeys,
|
||||||
mCompletedIndexFilteredKeys, mBrokenIndexFilteredKeys, mHiddenIndexFilteredKeys};
|
mCompletedIndexFilteredKeys, mBrokenIndexFilteredKeys, mHiddenIndexFilteredKeys,
|
||||||
|
mAltemulatorIndexFilteredKeys};
|
||||||
|
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 10; 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++) {
|
||||||
|
@ -467,7 +481,6 @@ void FileFilterIndex::manageGenreEntryInIndex(FileData* game, bool remove)
|
||||||
// Flag for including unknowns.
|
// Flag for including unknowns.
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
|
|
||||||
// Only add unknown in pubdev IF both dev and pub are empty.
|
|
||||||
if (!includeUnknown && (key == UNKNOWN_LABEL || key == "BIOS"))
|
if (!includeUnknown && (key == UNKNOWN_LABEL || key == "BIOS"))
|
||||||
// No valid genre info found.
|
// No valid genre info found.
|
||||||
return;
|
return;
|
||||||
|
@ -485,7 +498,6 @@ void FileFilterIndex::managePlayerEntryInIndex(FileData* game, bool remove)
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
std::string key = getIndexableKey(game, PLAYER_FILTER, false);
|
std::string key = getIndexableKey(game, PLAYER_FILTER, false);
|
||||||
|
|
||||||
// Only add unknown in pubdev IF both dev and pub are empty.
|
|
||||||
if (!includeUnknown && key == UNKNOWN_LABEL)
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
// No valid player info found.
|
// No valid player info found.
|
||||||
return;
|
return;
|
||||||
|
@ -595,6 +607,12 @@ void FileFilterIndex::manageHiddenEntryInIndex(FileData* game, bool remove)
|
||||||
manageIndexEntry(&mHiddenIndexAllKeys, key, remove);
|
manageIndexEntry(&mHiddenIndexAllKeys, key, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileFilterIndex::manageAltemulatorEntryInIndex(FileData* game, bool remove)
|
||||||
|
{
|
||||||
|
std::string key = getIndexableKey(game, ALTEMULATOR_FILTER, false);
|
||||||
|
manageIndexEntry(&mAltemulatorIndexAllKeys, key, remove);
|
||||||
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index,
|
void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index,
|
||||||
std::string key,
|
std::string key,
|
||||||
bool remove)
|
bool remove)
|
||||||
|
|
|
@ -29,7 +29,8 @@ enum FilterIndexType {
|
||||||
KIDGAME_FILTER,
|
KIDGAME_FILTER,
|
||||||
COMPLETED_FILTER,
|
COMPLETED_FILTER,
|
||||||
BROKEN_FILTER,
|
BROKEN_FILTER,
|
||||||
HIDDEN_FILTER
|
HIDDEN_FILTER,
|
||||||
|
ALTEMULATOR_FILTER
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FilterDataDecl {
|
struct FilterDataDecl {
|
||||||
|
@ -79,6 +80,7 @@ private:
|
||||||
void manageCompletedEntryInIndex(FileData* game, bool remove = false);
|
void manageCompletedEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageBrokenEntryInIndex(FileData* game, bool remove = false);
|
void manageBrokenEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageHiddenEntryInIndex(FileData* game, bool remove = false);
|
void manageHiddenEntryInIndex(FileData* game, bool remove = false);
|
||||||
|
void manageAltemulatorEntryInIndex(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);
|
||||||
|
|
||||||
|
@ -97,6 +99,7 @@ private:
|
||||||
bool mFilterByCompleted;
|
bool mFilterByCompleted;
|
||||||
bool mFilterByBroken;
|
bool mFilterByBroken;
|
||||||
bool mFilterByHidden;
|
bool mFilterByHidden;
|
||||||
|
bool mFilterByAltemulator;
|
||||||
|
|
||||||
std::map<std::string, int> mFavoritesIndexAllKeys;
|
std::map<std::string, int> mFavoritesIndexAllKeys;
|
||||||
std::map<std::string, int> mGenreIndexAllKeys;
|
std::map<std::string, int> mGenreIndexAllKeys;
|
||||||
|
@ -107,6 +110,7 @@ private:
|
||||||
std::map<std::string, int> mCompletedIndexAllKeys;
|
std::map<std::string, int> mCompletedIndexAllKeys;
|
||||||
std::map<std::string, int> mBrokenIndexAllKeys;
|
std::map<std::string, int> mBrokenIndexAllKeys;
|
||||||
std::map<std::string, int> mHiddenIndexAllKeys;
|
std::map<std::string, int> mHiddenIndexAllKeys;
|
||||||
|
std::map<std::string, int> mAltemulatorIndexAllKeys;
|
||||||
|
|
||||||
std::vector<std::string> mFavoritesIndexFilteredKeys;
|
std::vector<std::string> mFavoritesIndexFilteredKeys;
|
||||||
std::vector<std::string> mGenreIndexFilteredKeys;
|
std::vector<std::string> mGenreIndexFilteredKeys;
|
||||||
|
@ -117,6 +121,7 @@ private:
|
||||||
std::vector<std::string> mCompletedIndexFilteredKeys;
|
std::vector<std::string> mCompletedIndexFilteredKeys;
|
||||||
std::vector<std::string> mBrokenIndexFilteredKeys;
|
std::vector<std::string> mBrokenIndexFilteredKeys;
|
||||||
std::vector<std::string> mHiddenIndexFilteredKeys;
|
std::vector<std::string> mHiddenIndexFilteredKeys;
|
||||||
|
std::vector<std::string> mAltemulatorIndexFilteredKeys;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_FILE_FILTER_INDEX_H
|
#endif // ES_APP_FILE_FILTER_INDEX_H
|
||||||
|
|
Loading…
Reference in a new issue