Add a way for titles to always be visible in the cheat search

This commit is contained in:
Henrik Rydgård committed 2026-05-04 00:15:03 +02:00
1 parent 17fc029b5a
commit 691c1f3251
3 files changed
+36 -17

No files matched your search

+9
View File
@@ -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<View *> &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> layoutParams_;
@@ -501,6 +509,7 @@ private:
bool *enabledPtr_ = nullptr;
bool enabled_ = true;
bool enabledMeansDisabled_ = false;
bool alwaysVisibleInSearch_ = false;
DISALLOW_COPY_AND_ASSIGN(View);
};
+1
View File
@@ -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)) {
+26 -17
View File
@@ -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.