Game browser search: also match the filename, minus extension

Works before the game's metadata has loaded.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-28 11:50:28 -06:00
1 parent 547d032995
commit ce3d8d37c5
3 files changed
+17

No files matched your search

+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.