diff --git a/es-app/src/FileFilterIndex.cpp b/es-app/src/FileFilterIndex.cpp index b4cb21de3..75daf387f 100644 --- a/es-app/src/FileFilterIndex.cpp +++ b/es-app/src/FileFilterIndex.cpp @@ -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::const_iterator it = filterDataDecl.cbegin(); it != filterDataDecl.cend(); it++) { FilterDataDecl filterData = (*it); diff --git a/es-app/src/FileFilterIndex.h b/es-app/src/FileFilterIndex.h index 4c68b25d1..18cbf4469 100644 --- a/es-app/src/FileFilterIndex.h +++ b/es-app/src/FileFilterIndex.h @@ -59,6 +59,7 @@ public: bool isFiltered(); bool isKeyBeingFilteredBy(std::string key, FilterIndexType type); std::vector& 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; diff --git a/es-app/src/guis/GuiGamelistFilter.cpp b/es-app/src/guis/GuiGamelistFilter.cpp index 0f346866b..679e785cb 100644 --- a/es-app/src/guis/GuiGamelistFilter.cpp +++ b/es-app/src/guis/GuiGamelistFilter.cpp @@ -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.