From 691c1f32512eb1b2c941eb2bc71d30dfad485d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 4 May 2026 00:15:03 +0200 Subject: [PATCH] Add a way for titles to always be visible in the cheat search --- Common/UI/View.h | 9 +++++++++ UI/CwCheatScreen.cpp | 1 + UI/MiscViews.cpp | 43 ++++++++++++++++++++++++++----------------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/Common/UI/View.h b/Common/UI/View.h index 92683ca8c3..c1295a1846 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -381,6 +381,7 @@ public: // If this view covers these coordinates, it should add itself and its children to the list. virtual void Query(float x, float y, std::vector &list); + // Technical description. virtual std::string DescribeLog() const; // Accessible/searchable description. virtual std::string DescribeText() const { return ""; } @@ -475,6 +476,13 @@ public: autoResult_ = result; } + void SetAlwaysVisibleInSearch(bool alwaysVisible) { + alwaysVisibleInSearch_ = alwaysVisible; + } + bool AlwaysVisibleInSearch() const { + return alwaysVisibleInSearch_; + } + protected: // Inputs to layout std::unique_ptr layoutParams_; @@ -501,6 +509,7 @@ private: bool *enabledPtr_ = nullptr; bool enabled_ = true; bool enabledMeansDisabled_ = false; + bool alwaysVisibleInSearch_ = false; DISALLOW_COPY_AND_ASSIGN(View); }; diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 4aea3a08fb..ed20114efa 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -156,6 +156,7 @@ void CwCheatScreen::CreateContentViews(UI::ViewGroup *parent) { // Title. TextView *titleView = rightColumn->Add(new TextView(text, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT, UI::Margins(8, 8, 8, 0)))); titleView->SetTextSize(UI::TextSize::Big); + titleView->SetAlwaysVisibleInSearch(true); prevIsTitle = true; prev = nullptr; } else if (fileInfo_[i].IsPostComment(&text)) { diff --git a/UI/MiscViews.cpp b/UI/MiscViews.cpp index b3c327d635..06b388ce0f 100644 --- a/UI/MiscViews.cpp +++ b/UI/MiscViews.cpp @@ -386,24 +386,33 @@ void ViewSearch::ApplySearchFilter(UI::ViewGroup *viewGroup, bool setKeyboardFoc for (int i = 0; i < viewGroup->GetNumSubviews(); ++i) { UI::View *v = viewGroup->GetViewByIndex(i); - std::string label = v->DescribeText(); - // This is a bit of a hack to recognize a pending game title. - if (label == "...") { - searchPending = true; - // Hide anything pending while, we'll pop-in search results as they match. - // Note: we leave it at MATCH if gone before, so we don't show it again. - if (v->GetVisibility() == UI::V_VISIBLE) { - if (searchStates[i] == SearchState::MATCH) - v->SetVisibility(UI::V_GONE); - searchStates[i] = SearchState::PENDING; - } - continue; - } - label = NormalizeForSearch(label); - bool match = v->CanBeFocused() && label.find(filter) != label.npos; - if (match && !firstMatch) { - firstMatch = v; + bool match = false; + if (v->AlwaysVisibleInSearch()) { + match = true; + if (v->CanBeFocused() && !firstMatch) { + firstMatch = v; + } + } else { + std::string label = v->DescribeText(); + // This is a bit of a hack to recognize a pending game title. + if (label == "...") { + searchPending = true; + // Hide anything pending while, we'll pop-in search results as they match. + // Note: we leave it at MATCH if gone before, so we don't show it again. + if (v->GetVisibility() == UI::V_VISIBLE) { + if (searchStates[i] == SearchState::MATCH) + v->SetVisibility(UI::V_GONE); + searchStates[i] = SearchState::PENDING; + } + continue; + } + + label = NormalizeForSearch(label); + match = v->CanBeFocused() && label.find(filter) != label.npos; + if (match && !firstMatch) { + firstMatch = v; + } } if (match && searchStates[i] != SearchState::MATCH) { // It was previously visible and force hidden, so show it again.