Merge pull request #22372 from hrydgard/search-raw-filename

Game browser search: also match the filename, minus extension
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-09-28 13:36:33 -06:00
commit 6cdfbe2c0d
3 files changed
+17

No files matched your search

+2
View File
@@ -396,6 +396,8 @@ public:
virtual std::string DescribeLog() const;
// Accessible/searchable description.
virtual std::string DescribeText() const { return ""; }
// Extra text that search also matches against, available even before DescribeText is (like a filename).
virtual std::string SearchAlias() const { return ""; }
virtual void FocusChanged(FocusFlags focusFlags) {}
virtual void PersistData(PersistStatus status, std::string anonId, PersistMap &storage);
+10
View File
@@ -108,6 +108,16 @@ public:
void Draw(UIContext &dc) override;
std::string DescribeText() const override;
std::string SearchAlias() const override {
// Without the extension, or searching for "iso" would match every ISO. Only three or more
// letters counts as one, so a folder like "Game v1.2" keeps its version number.
std::string filename = gamePath_.GetFilename();
const std::string ext = gamePath_.GetFileExtension();
if (ext.size() >= 4 && ext.size() <= filename.size() && std::all_of(ext.begin() + 1, ext.end(), [](char c) { return c >= 'a' && c <= 'z'; })) {
filename.resize(filename.size() - ext.size());
}
return filename;
}
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override {
if (gridStyle_) {
w = 144 * g_Config.fGameGridScale;
+5
View File
@@ -397,6 +397,11 @@ void ViewSearch::ApplySearchFilter(UI::ViewGroup *viewGroup, bool setKeyboardFoc
if (v->CanBeFocused() && !firstMatch) {
firstMatch = v;
}
} else if (v->CanBeFocused() && NormalizeForSearch(v->SearchAlias()).find(filter) != std::string::npos) {
match = true;
if (!firstMatch) {
firstMatch = v;
}
} else {
std::string label = v->DescribeText();
// This is a bit of a hack to recognize a pending game title.