Merge pull request #21590 from hrydgard/ui-improvements

UI improvements: CwCheat titles/comments, easier to scroll tabs
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-04-24 15:10:46 +02:00
commit b91d768acd
4 files changed
+63 -5

No files matched your search

+7 -2
View File
@@ -344,7 +344,6 @@ bool Clickable::Key(const KeyInput &key) {
bool StickyChoice::Touch(const TouchInput &touch) {
bool contains = bounds_.Contains(touch.x, touch.y);
dragging_ = false;
if (!IsEnabled()) {
down_ = false;
return contains;
@@ -352,12 +351,18 @@ bool StickyChoice::Touch(const TouchInput &touch) {
if (touch.flags & TouchInputFlags::DOWN) {
if (contains) {
dragging_ = true;
}
}
if (touch.flags & TouchInputFlags::UP) {
if (dragging_ && contains && !(touch.flags & TouchInputFlags::CANCEL)) {
if (IsFocusMovementEnabled())
SetFocusedView(this);
down_ = true;
ClickInternal();
dragging_ = false;
return true;
}
dragging_ = false;
}
return false;
}
+24
View File
@@ -1167,3 +1167,27 @@ bool CheatsInEffect() {
return false;
return cheatEngine->HasCheats();
}
bool DetectCheatTitle(std::string_view name, std::string_view *title) {
// Use Saramagrean title convention (the most common cheats.db file).
const size_t firstOffset = name.find("_[>>>");
const size_t secondOffset = name.rfind("<<<]_");
const bool isTitle = firstOffset != std::string::npos && secondOffset != std::string::npos && firstOffset < secondOffset;
if (!isTitle) {
return false;
}
// Extract the title substring.
*title = std::string_view(name.data() + firstOffset + 5, secondOffset - (firstOffset + 5));
return true;
}
bool DetectCheatPostComment(std::string_view name, std::string_view *comment) {
const size_t firstOffset = name.find("\xE2\x86\x91[#"); // Up arrow and [#
const size_t secondOffset = name.rfind(']');
const bool isPostComment = firstOffset != std::string::npos && secondOffset != std::string::npos && secondOffset > firstOffset;
if (!isPostComment) {
return false;
}
*comment = std::string_view(name.data() + firstOffset + 5, secondOffset - (firstOffset + 5));
return true;
}
+10
View File
@@ -25,6 +25,9 @@ struct CheatLine {
uint32_t part2;
};
bool DetectCheatTitle(std::string_view name, std::string_view *title);
bool DetectCheatPostComment(std::string_view name, std::string_view *title);
struct CheatCode {
std::string name;
std::vector<CheatLine> lines;
@@ -34,6 +37,13 @@ struct CheatFileInfo {
int lineNum;
std::string name;
bool enabled;
bool IsTitle(std::string_view *title) const {
return DetectCheatTitle(name, title);
}
bool IsPostComment(std::string_view *comment) const {
return DetectCheatPostComment(name, comment);
}
};
struct CheatOperation;
+22 -3
View File
@@ -33,6 +33,7 @@
#include "UI/GameInfoCache.h"
#include "UI/CwCheatScreen.h"
#include "UI/MiscViews.h"
static const int FILE_CHECK_FRAME_INTERVAL = 53;
@@ -124,12 +125,30 @@ void CwCheatScreen::CreateContentViews(UI::ViewGroup *parent) {
rightScroll->RememberPosition(&g_Config.fCwCheatScrollPosition);
LinearLayout *rightColumn = new LinearLayoutList(ORIENT_VERTICAL, new LinearLayoutParams(200, FILL_PARENT));
rightColumn->SetSpacing(0.0f);
rightScroll->Add(rightColumn);
rightColumn->Add(new ItemHeader(cw->T("Cheats")));
bool prevIsTitle = false;
for (size_t i = 0; i < fileInfo_.size(); ++i) {
rightColumn->Add(new CheckBox(&fileInfo_[i].enabled, fileInfo_[i].name))->OnClick.Add([=](UI::EventParams &) {
OnCheckBox((int)i);
});
std::string_view text;
if (fileInfo_[i].IsTitle(&text)) {
// 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);
prevIsTitle = true;
} else if (fileInfo_[i].IsPostComment(&text)) {
rightColumn->Add(new SettingHint(text, nullptr));
prevIsTitle = false;
} else {
// Regular cheat code.
if (!prevIsTitle) {
rightColumn->Add(new Spacer(8.0f));
}
rightColumn->Add(new CheckBox(&fileInfo_[i].enabled, fileInfo_[i].name))->OnClick.Add([=](UI::EventParams &) {
OnCheckBox((int)i);
});
prevIsTitle = false;
}
}
}