Fixed an issue where system names were included in game name searches done in collection systems.

This commit is contained in:
Leon Styhre 2021-09-23 17:42:04 +02:00
parent afe8128cc7
commit 61dbe3cba9
3 changed files with 25 additions and 6 deletions

View file

@ -21,6 +21,7 @@
FileFilterIndex::FileFilterIndex()
: mFilterByText(false)
, mTextRemoveSystem(false)
, mFilterByFavorites(false)
, mFilterByGenre(false)
, mFilterByPlayers(false)
@ -35,7 +36,7 @@ FileFilterIndex::FileFilterIndex()
// clang-format off
FilterDataDecl filterDecls[] = {
//type //allKeys //filteredBy //filteredKeys //primaryKey //hasSecondaryKey //secondaryKey //menuLabel
//type //allKeys //filteredBy //filteredKeys //primaryKey //hasSecondaryKey //secondaryKey //menuLabel
{FAVORITES_FILTER, &mFavoritesIndexAllKeys, &mFilterByFavorites, &mFavoritesIndexFilteredKeys, "favorite", false, "", "FAVORITES"},
{GENRE_FILTER, &mGenreIndexAllKeys, &mFilterByGenre, &mGenreIndexFilteredKeys, "genre", true, "genre", "GENRE"},
{PLAYER_FILTER, &mPlayersIndexAllKeys, &mFilterByPlayers, &mPlayersIndexFilteredKeys, "players", false, "", "PLAYERS"},
@ -359,15 +360,22 @@ bool FileFilterIndex::showFile(FileData* game)
bool keepGoing = false;
// Name filters take precedence over all other filters, so if there is no match for
// the game name, then always return false.
if (mTextFilter != "" &&
!(Utils::String::toUpper(game->getName()).find(mTextFilter) != std::string::npos)) {
// the game name, then always return false. If we're in a collection system and the option
// to show the system name has been enabled, then exclude the system name that is encapsulated
// in [] from the search string.
if (mTextFilter != "" && mTextRemoveSystem &&
!(Utils::String::toUpper(game->getName().substr(0, game->getName().find_last_of("[")))
.find(mTextFilter) != std::string::npos)) {
return false;
}
else if (mTextFilter != "") {
nameMatch = true;
else if (mTextFilter != "" &&
!(Utils::String::toUpper(game->getName()).find(mTextFilter) != std::string::npos)) {
return false;
}
if (mTextFilter != "")
nameMatch = true;
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin();
it != filterDataDecl.cend(); it++) {
FilterDataDecl filterData = (*it);

View file

@ -59,6 +59,7 @@ public:
bool isFiltered();
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
std::vector<FilterDataDecl>& getFilterDataDecls() { return filterDataDecl; }
void setTextRemoveSystem(bool status) { mTextRemoveSystem = status; }
void importIndex(FileFilterIndex* indexToImport);
void resetIndex();
@ -85,6 +86,7 @@ private:
std::string mTextFilter;
bool mFilterByText;
bool mTextRemoveSystem;
bool mFilterByFavorites;
bool mFilterByGenre;

View file

@ -36,6 +36,15 @@ void GuiGamelistFilter::initializeMenu()
// Get filters from system.
mFilterIndex = mSystem->getIndex();
// If this is a collection and system names are shown per game, then let FileFilterIndex
// know about this so the system names will not be included in game name text searches.
if (ViewController::get()->getState().getSystem()->isCollection()) {
if (Settings::getInstance()->getBool("CollectionShowSystemInfo"))
mFilterIndex->setTextRemoveSystem(true);
else
mFilterIndex->setTextRemoveSystem(false);
}
ComponentListRow row;
// Show filtered menu.