mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-21 02:09:05 +02:00
CwCheat screen: Detect titles and display them as large text instead of checkboxes
This commit is contained in:
1 parent
a1a073bd2c
commit
c97007adfe
3 files changed
+30
-3
No files matched your search
@@ -1167,3 +1167,16 @@ 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.find("<<<]_");
|
||||
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;
|
||||
}
|
||||
@@ -25,6 +25,8 @@ struct CheatLine {
|
||||
uint32_t part2;
|
||||
};
|
||||
|
||||
bool DetectCheatTitle(std::string_view name, std::string_view *title);
|
||||
|
||||
struct CheatCode {
|
||||
std::string name;
|
||||
std::vector<CheatLine> lines;
|
||||
@@ -34,6 +36,10 @@ struct CheatFileInfo {
|
||||
int lineNum;
|
||||
std::string name;
|
||||
bool enabled;
|
||||
|
||||
bool IsTitle(std::string_view *title) {
|
||||
return DetectCheatTitle(name, title);
|
||||
}
|
||||
};
|
||||
|
||||
struct CheatOperation;
|
||||
|
||||
+11
-3
@@ -127,9 +127,17 @@ void CwCheatScreen::CreateContentViews(UI::ViewGroup *parent) {
|
||||
rightScroll->Add(rightColumn);
|
||||
rightColumn->Add(new ItemHeader(cw->T("Cheats")));
|
||||
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 title;
|
||||
if (fileInfo_[i].IsTitle(&title)) {
|
||||
// Title.
|
||||
TextView *titleView = rightColumn->Add(new TextView(title, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT, UI::Margins(8, 0))));
|
||||
titleView->SetTextSize(UI::TextSize::Big);
|
||||
} else {
|
||||
// Regular cheat code.
|
||||
rightColumn->Add(new CheckBox(&fileInfo_[i].enabled, fileInfo_[i].name))->OnClick.Add([=](UI::EventParams &) {
|
||||
OnCheckBox((int)i);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user