Add Copy button for calculated CRCs on game info screen

This commit is contained in:
Henrik Rydgård committed 2024-09-02 22:48:47 +02:00
1 parent ff195a92b0
commit d6b4a76e98
7 files changed
+34 -3

No files matched your search

+27 -2
View File
@@ -81,6 +81,9 @@ void GameScreen::update() {
CRC32string = int2hexstr(crcvalue);
tvCRC_->SetVisibility(UI::V_VISIBLE);
tvCRC_->SetText(CRC32string);
if (tvCRCCopy_) {
tvCRCCopy_->SetVisibility(UI::V_VISIBLE);
}
if (btnCalcCRC_) {
btnCalcCRC_->SetVisibility(UI::V_GONE);
}
@@ -145,9 +148,27 @@ void GameScreen::CreateViews() {
tvPlayTime_ = infoLayout->Add(new TextView("", ALIGN_LEFT, true, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
tvPlayTime_->SetShadow(true);
tvPlayTime_->SetVisibility(V_GONE);
tvCRC_ = infoLayout->Add(new TextView("", ALIGN_LEFT, true, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
LinearLayout *crcHoriz = infoLayout->Add(new LinearLayout(ORIENT_HORIZONTAL));
tvCRC_ = crcHoriz->Add(new TextView("", ALIGN_LEFT, true, new LinearLayoutParams(0.0, G_VCENTER)));
tvCRC_->SetShadow(true);
tvCRC_->SetVisibility(Reporting::HasCRC(gamePath_) ? V_VISIBLE : V_GONE);
Visibility crcVisibility = Reporting::HasCRC(gamePath_) ? V_VISIBLE : V_GONE;
tvCRC_->SetVisibility(crcVisibility);
if (System_GetPropertyBool(SYSPROP_HAS_TEXT_CLIPBOARD)) {
tvCRCCopy_ = crcHoriz->Add(new Button(di->T("Copy to clipboard"), new LinearLayoutParams(0.0, G_VCENTER)));
tvCRCCopy_->OnClick.Add([this](UI::EventParams &) {
u32 crc = Reporting::RetrieveCRC(gamePath_);
char buffer[16];
snprintf(buffer, sizeof(buffer), "%08X", crc);
System_CopyStringToClipboard(buffer);
return UI::EVENT_DONE;
});
tvCRCCopy_->SetVisibility(crcVisibility);
tvCRCCopy_->SetScale(0.82f);
} else {
tvCRCCopy_ = nullptr;
}
tvVerified_ = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("Click \"Calculate CRC\" to verify ISO"), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
tvVerified_->SetVisibility(UI::V_GONE);
tvVerified_->SetSquishy(true);
@@ -170,6 +191,7 @@ void GameScreen::CreateViews() {
tvRegion_ = nullptr;
tvPlayTime_ = nullptr;
tvCRC_ = nullptr;
tvCRCCopy_ = nullptr;
tvVerified_ = nullptr;
}
@@ -360,6 +382,9 @@ ScreenRenderFlags GameScreen::render(ScreenRenderMode mode) {
std::string crc = StringFromFormat("%08X", crcVal);
tvCRC_->SetText(ReplaceAll(rp->T("FeedbackCRCValue", "Disc CRC: %1"), "%1", crc));
tvCRC_->SetVisibility(UI::V_VISIBLE);
if (tvCRCCopy_) {
tvCRCCopy_->SetVisibility(UI::V_VISIBLE);
}
// Let's check the CRC in the game database, looking up the ID and also matching the crc.
std::vector<GameDBInfo> dbInfos;