mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-31 04:25:40 +00:00
Made it possible to filter the 'Controller badge' metadata field.
This commit is contained in:
parent
5247a9f5fe
commit
0cf52c2d71
|
@ -33,6 +33,7 @@ FileFilterIndex::FileFilterIndex()
|
||||||
, mFilterByKidGame(false)
|
, mFilterByKidGame(false)
|
||||||
, mFilterByHidden(false)
|
, mFilterByHidden(false)
|
||||||
, mFilterByBroken(false)
|
, mFilterByBroken(false)
|
||||||
|
, mFilterByController(false)
|
||||||
, mFilterByAltemulator(false)
|
, mFilterByAltemulator(false)
|
||||||
{
|
{
|
||||||
clearAllFilters();
|
clearAllFilters();
|
||||||
|
@ -50,6 +51,7 @@ FileFilterIndex::FileFilterIndex()
|
||||||
{KIDGAME_FILTER, &mKidGameIndexAllKeys, &mFilterByKidGame, &mKidGameIndexFilteredKeys, "kidgame", false, "", "KIDGAME"},
|
{KIDGAME_FILTER, &mKidGameIndexAllKeys, &mFilterByKidGame, &mKidGameIndexFilteredKeys, "kidgame", false, "", "KIDGAME"},
|
||||||
{HIDDEN_FILTER, &mHiddenIndexAllKeys, &mFilterByHidden, &mHiddenIndexFilteredKeys, "hidden", false, "", "HIDDEN"},
|
{HIDDEN_FILTER, &mHiddenIndexAllKeys, &mFilterByHidden, &mHiddenIndexFilteredKeys, "hidden", false, "", "HIDDEN"},
|
||||||
{BROKEN_FILTER, &mBrokenIndexAllKeys, &mFilterByBroken, &mBrokenIndexFilteredKeys, "broken", false, "", "BROKEN"},
|
{BROKEN_FILTER, &mBrokenIndexAllKeys, &mFilterByBroken, &mBrokenIndexFilteredKeys, "broken", false, "", "BROKEN"},
|
||||||
|
{CONTROLLER_FILTER, &mControllerIndexAllKeys, &mFilterByController, &mControllerIndexFilteredKeys, "controller", false, "", "CONTROLLER BADGE"},
|
||||||
{ALTEMULATOR_FILTER, &mAltemulatorIndexAllKeys, &mFilterByAltemulator, &mAltemulatorIndexFilteredKeys, "altemulator", false, "", "ALTERNATIVE EMULATOR"}
|
{ALTEMULATOR_FILTER, &mAltemulatorIndexAllKeys, &mFilterByAltemulator, &mAltemulatorIndexFilteredKeys, "altemulator", false, "", "ALTERNATIVE EMULATOR"}
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -82,6 +84,7 @@ void FileFilterIndex::importIndex(FileFilterIndex* indexToImport)
|
||||||
{&mKidGameIndexAllKeys, &(indexToImport->mKidGameIndexAllKeys)},
|
{&mKidGameIndexAllKeys, &(indexToImport->mKidGameIndexAllKeys)},
|
||||||
{&mHiddenIndexAllKeys, &(indexToImport->mHiddenIndexAllKeys)},
|
{&mHiddenIndexAllKeys, &(indexToImport->mHiddenIndexAllKeys)},
|
||||||
{&mBrokenIndexAllKeys, &(indexToImport->mBrokenIndexAllKeys)},
|
{&mBrokenIndexAllKeys, &(indexToImport->mBrokenIndexAllKeys)},
|
||||||
|
{&mControllerIndexAllKeys, &(indexToImport->mControllerIndexAllKeys)},
|
||||||
{&mAltemulatorIndexAllKeys, &(indexToImport->mAltemulatorIndexAllKeys)},
|
{&mAltemulatorIndexAllKeys, &(indexToImport->mAltemulatorIndexAllKeys)},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,6 +122,7 @@ void FileFilterIndex::resetIndex()
|
||||||
clearIndex(mKidGameIndexAllKeys);
|
clearIndex(mKidGameIndexAllKeys);
|
||||||
clearIndex(mHiddenIndexAllKeys);
|
clearIndex(mHiddenIndexAllKeys);
|
||||||
clearIndex(mBrokenIndexAllKeys);
|
clearIndex(mBrokenIndexAllKeys);
|
||||||
|
clearIndex(mControllerIndexAllKeys);
|
||||||
clearIndex(mAltemulatorIndexAllKeys);
|
clearIndex(mAltemulatorIndexAllKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +219,12 @@ std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
key = Utils::String::toUpper(game->metadata.get("broken"));
|
key = Utils::String::toUpper(game->metadata.get("broken"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CONTROLLER_FILTER: {
|
||||||
|
if (getSecondary)
|
||||||
|
break;
|
||||||
|
key = Utils::String::toUpper(game->metadata.get("controller"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ALTEMULATOR_FILTER: {
|
case ALTEMULATOR_FILTER: {
|
||||||
if (getSecondary)
|
if (getSecondary)
|
||||||
break;
|
break;
|
||||||
|
@ -231,8 +241,8 @@ std::string FileFilterIndex::getIndexableKey(FileData* game,
|
||||||
type == PUBLISHER_FILTER) &&
|
type == PUBLISHER_FILTER) &&
|
||||||
Utils::String::toUpper(key) == UNKNOWN_LABEL)
|
Utils::String::toUpper(key) == UNKNOWN_LABEL)
|
||||||
key = ViewController::CROSSEDCIRCLE_CHAR + " UNKNOWN";
|
key = ViewController::CROSSEDCIRCLE_CHAR + " UNKNOWN";
|
||||||
else if (type == ALTEMULATOR_FILTER && key.empty())
|
else if ((type == CONTROLLER_FILTER || type == ALTEMULATOR_FILTER) && key.empty())
|
||||||
key = ViewController::CROSSEDCIRCLE_CHAR + " NONE DEFINED";
|
key = ViewController::CROSSEDCIRCLE_CHAR + " NONE SELECTED";
|
||||||
else if (key.empty() || (type == RATINGS_FILTER && key == "0 STARS"))
|
else if (key.empty() || (type == RATINGS_FILTER && key == "0 STARS"))
|
||||||
key = UNKNOWN_LABEL;
|
key = UNKNOWN_LABEL;
|
||||||
|
|
||||||
|
@ -251,6 +261,7 @@ void FileFilterIndex::addToIndex(FileData* game)
|
||||||
manageKidGameEntryInIndex(game);
|
manageKidGameEntryInIndex(game);
|
||||||
manageHiddenEntryInIndex(game);
|
manageHiddenEntryInIndex(game);
|
||||||
manageBrokenEntryInIndex(game);
|
manageBrokenEntryInIndex(game);
|
||||||
|
manageControllerEntryInIndex(game);
|
||||||
manageAltemulatorEntryInIndex(game);
|
manageAltemulatorEntryInIndex(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +277,7 @@ void FileFilterIndex::removeFromIndex(FileData* game)
|
||||||
manageKidGameEntryInIndex(game, true);
|
manageKidGameEntryInIndex(game, true);
|
||||||
manageHiddenEntryInIndex(game, true);
|
manageHiddenEntryInIndex(game, true);
|
||||||
manageBrokenEntryInIndex(game, true);
|
manageBrokenEntryInIndex(game, true);
|
||||||
|
manageControllerEntryInIndex(game, true);
|
||||||
manageAltemulatorEntryInIndex(game, true);
|
manageAltemulatorEntryInIndex(game, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,6 +377,9 @@ void FileFilterIndex::debugPrintIndexes()
|
||||||
for (auto x : mBrokenIndexAllKeys) {
|
for (auto x : mBrokenIndexAllKeys) {
|
||||||
LOG(LogInfo) << "Broken Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "Broken Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
|
for (auto x : mControllerIndexAllKeys) {
|
||||||
|
LOG(LogInfo) << "Controller Index: " << x.first << ": " << x.second;
|
||||||
|
}
|
||||||
for (auto x : mAltemulatorIndexAllKeys) {
|
for (auto x : mAltemulatorIndexAllKeys) {
|
||||||
LOG(LogInfo) << "Altemulator Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "Altemulator Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
|
@ -444,28 +459,29 @@ bool FileFilterIndex::isFiltered()
|
||||||
if (UIModeController::getInstance()->isUIModeKid()) {
|
if (UIModeController::getInstance()->isUIModeKid()) {
|
||||||
return (mFilterByText || mFilterByRatings || mFilterByDeveloper || mFilterByPublisher ||
|
return (mFilterByText || mFilterByRatings || mFilterByDeveloper || mFilterByPublisher ||
|
||||||
mFilterByGenre || mFilterByPlayers || mFilterByFavorites || mFilterByCompleted ||
|
mFilterByGenre || mFilterByPlayers || mFilterByFavorites || mFilterByCompleted ||
|
||||||
mFilterByHidden || mFilterByBroken || mFilterByAltemulator);
|
mFilterByHidden || mFilterByBroken || mFilterByController || mFilterByAltemulator);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (mFilterByText || mFilterByRatings || mFilterByDeveloper || mFilterByPublisher ||
|
return (mFilterByText || mFilterByRatings || mFilterByDeveloper || mFilterByPublisher ||
|
||||||
mFilterByGenre || mFilterByPlayers || mFilterByFavorites || mFilterByCompleted ||
|
mFilterByGenre || mFilterByPlayers || mFilterByFavorites || mFilterByCompleted ||
|
||||||
mFilterByKidGame || mFilterByHidden || mFilterByBroken || mFilterByAltemulator);
|
mFilterByKidGame || mFilterByHidden || mFilterByBroken || mFilterByController ||
|
||||||
|
mFilterByAltemulator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
|
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
|
||||||
{
|
{
|
||||||
const FilterIndexType filterTypes[11] = {RATINGS_FILTER, DEVELOPER_FILTER, PUBLISHER_FILTER,
|
const FilterIndexType filterTypes[12] = {
|
||||||
GENRE_FILTER, PLAYER_FILTER, FAVORITES_FILTER,
|
RATINGS_FILTER, DEVELOPER_FILTER, PUBLISHER_FILTER, GENRE_FILTER,
|
||||||
COMPLETED_FILTER, KIDGAME_FILTER, HIDDEN_FILTER,
|
PLAYER_FILTER, FAVORITES_FILTER, COMPLETED_FILTER, KIDGAME_FILTER,
|
||||||
BROKEN_FILTER, ALTEMULATOR_FILTER};
|
HIDDEN_FILTER, BROKEN_FILTER, CONTROLLER_FILTER, ALTEMULATOR_FILTER};
|
||||||
std::vector<std::string> filterKeysList[11] = {
|
std::vector<std::string> filterKeysList[12] = {
|
||||||
mRatingsIndexFilteredKeys, mDeveloperIndexFilteredKeys, mPublisherIndexFilteredKeys,
|
mRatingsIndexFilteredKeys, mDeveloperIndexFilteredKeys, mPublisherIndexFilteredKeys,
|
||||||
mGenreIndexFilteredKeys, mPlayersIndexFilteredKeys, mFavoritesIndexFilteredKeys,
|
mGenreIndexFilteredKeys, mPlayersIndexFilteredKeys, mFavoritesIndexFilteredKeys,
|
||||||
mCompletedIndexFilteredKeys, mKidGameIndexFilteredKeys, mHiddenIndexFilteredKeys,
|
mCompletedIndexFilteredKeys, mKidGameIndexFilteredKeys, mHiddenIndexFilteredKeys,
|
||||||
mBrokenIndexFilteredKeys, mAltemulatorIndexFilteredKeys};
|
mBrokenIndexFilteredKeys, mControllerIndexFilteredKeys, mAltemulatorIndexFilteredKeys};
|
||||||
|
|
||||||
for (int i = 0; i < 11; i++) {
|
for (int i = 0; i < 12; 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++) {
|
||||||
|
@ -611,6 +627,12 @@ void FileFilterIndex::manageBrokenEntryInIndex(FileData* game, bool remove)
|
||||||
manageIndexEntry(&mBrokenIndexAllKeys, key, remove);
|
manageIndexEntry(&mBrokenIndexAllKeys, key, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileFilterIndex::manageControllerEntryInIndex(FileData* game, bool remove)
|
||||||
|
{
|
||||||
|
std::string key = getIndexableKey(game, CONTROLLER_FILTER, false);
|
||||||
|
manageIndexEntry(&mControllerIndexAllKeys, key, remove);
|
||||||
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageAltemulatorEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::manageAltemulatorEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
std::string key = getIndexableKey(game, ALTEMULATOR_FILTER, false);
|
std::string key = getIndexableKey(game, ALTEMULATOR_FILTER, false);
|
||||||
|
|
|
@ -31,6 +31,7 @@ enum FilterIndexType {
|
||||||
KIDGAME_FILTER,
|
KIDGAME_FILTER,
|
||||||
HIDDEN_FILTER,
|
HIDDEN_FILTER,
|
||||||
BROKEN_FILTER,
|
BROKEN_FILTER,
|
||||||
|
CONTROLLER_FILTER,
|
||||||
ALTEMULATOR_FILTER
|
ALTEMULATOR_FILTER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,6 +83,7 @@ private:
|
||||||
void manageKidGameEntryInIndex(FileData* game, bool remove = false);
|
void manageKidGameEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageHiddenEntryInIndex(FileData* game, bool remove = false);
|
void manageHiddenEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageBrokenEntryInIndex(FileData* game, bool remove = false);
|
void manageBrokenEntryInIndex(FileData* game, bool remove = false);
|
||||||
|
void manageControllerEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageAltemulatorEntryInIndex(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);
|
||||||
|
@ -102,6 +104,7 @@ private:
|
||||||
bool mFilterByKidGame;
|
bool mFilterByKidGame;
|
||||||
bool mFilterByHidden;
|
bool mFilterByHidden;
|
||||||
bool mFilterByBroken;
|
bool mFilterByBroken;
|
||||||
|
bool mFilterByController;
|
||||||
bool mFilterByAltemulator;
|
bool mFilterByAltemulator;
|
||||||
|
|
||||||
std::map<std::string, int> mRatingsIndexAllKeys;
|
std::map<std::string, int> mRatingsIndexAllKeys;
|
||||||
|
@ -114,6 +117,7 @@ private:
|
||||||
std::map<std::string, int> mKidGameIndexAllKeys;
|
std::map<std::string, int> mKidGameIndexAllKeys;
|
||||||
std::map<std::string, int> mHiddenIndexAllKeys;
|
std::map<std::string, int> mHiddenIndexAllKeys;
|
||||||
std::map<std::string, int> mBrokenIndexAllKeys;
|
std::map<std::string, int> mBrokenIndexAllKeys;
|
||||||
|
std::map<std::string, int> mControllerIndexAllKeys;
|
||||||
std::map<std::string, int> mAltemulatorIndexAllKeys;
|
std::map<std::string, int> mAltemulatorIndexAllKeys;
|
||||||
|
|
||||||
std::vector<std::string> mRatingsIndexFilteredKeys;
|
std::vector<std::string> mRatingsIndexFilteredKeys;
|
||||||
|
@ -126,6 +130,7 @@ private:
|
||||||
std::vector<std::string> mKidGameIndexFilteredKeys;
|
std::vector<std::string> mKidGameIndexFilteredKeys;
|
||||||
std::vector<std::string> mHiddenIndexFilteredKeys;
|
std::vector<std::string> mHiddenIndexFilteredKeys;
|
||||||
std::vector<std::string> mBrokenIndexFilteredKeys;
|
std::vector<std::string> mBrokenIndexFilteredKeys;
|
||||||
|
std::vector<std::string> mControllerIndexFilteredKeys;
|
||||||
std::vector<std::string> mAltemulatorIndexFilteredKeys;
|
std::vector<std::string> mAltemulatorIndexFilteredKeys;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,11 @@
|
||||||
#include "guis/GuiGamelistFilter.h"
|
#include "guis/GuiGamelistFilter.h"
|
||||||
|
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
|
#include "components/BadgeComponent.h"
|
||||||
#include "components/OptionListComponent.h"
|
#include "components/OptionListComponent.h"
|
||||||
#include "guis/GuiTextEditKeyboardPopup.h"
|
#include "guis/GuiTextEditKeyboardPopup.h"
|
||||||
#include "guis/GuiTextEditPopup.h"
|
#include "guis/GuiTextEditPopup.h"
|
||||||
|
#include "utils/StringUtil.h"
|
||||||
#include "views/UIModeController.h"
|
#include "views/UIModeController.h"
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
|
|
||||||
|
@ -185,8 +187,21 @@ void GuiGamelistFilter::addFiltersToMenu()
|
||||||
optionList->setOverrideMultiText("NOTHING TO FILTER");
|
optionList->setOverrideMultiText("NOTHING TO FILTER");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it : *allKeys)
|
if (type == CONTROLLER_FILTER) {
|
||||||
optionList->add(it.first, it.first, mFilterIndex->isKeyBeingFilteredBy(it.first, type));
|
for (auto it : *allKeys) {
|
||||||
|
std::string displayName =
|
||||||
|
BadgeComponent::getDisplayName(Utils::String::toLower(it.first));
|
||||||
|
if (displayName == "unknown")
|
||||||
|
displayName = it.first;
|
||||||
|
optionList->add(displayName, it.first,
|
||||||
|
mFilterIndex->isKeyBeingFilteredBy(it.first, type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (auto it : *allKeys)
|
||||||
|
optionList->add(it.first, it.first,
|
||||||
|
mFilterIndex->isKeyBeingFilteredBy(it.first, type));
|
||||||
|
}
|
||||||
|
|
||||||
if (allKeys->size() == 0)
|
if (allKeys->size() == 0)
|
||||||
optionList->add("", "", false);
|
optionList->add("", "", false);
|
||||||
|
|
Loading…
Reference in a new issue