mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Merge pull request #22372 from hrydgard/search-raw-filename
Game browser search: also match the filename, minus extension
This commit is contained in:
3 files changed
+17
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user