GameScreen ćrc-related crashfix

This commit is contained in:
Henrik Rydgård 2024-10-10 14:36:43 +02:00
parent 662b0847c9
commit bf9973e17d

View File

@ -80,8 +80,10 @@ void GameScreen::update() {
if (Reporting::HasCRC(gamePath_)) {
uint32_t crcvalue = Reporting::RetrieveCRC(gamePath_);
CRC32string = int2hexstr(crcvalue);
if (tvCRC_) {
tvCRC_->SetVisibility(UI::V_VISIBLE);
tvCRC_->SetText(CRC32string);
}
if (tvCRCCopy_) {
tvCRCCopy_->SetVisibility(UI::V_VISIBLE);
}
@ -114,6 +116,21 @@ void GameScreen::CreateViews() {
ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f));
root_->Add(leftColumn);
bool fileTypeSupportCRC = false;
if (info) {
switch (info->fileType) {
case IdentifiedFileType::PSP_PBP:
case IdentifiedFileType::PSP_PBP_DIRECTORY:
case IdentifiedFileType::PSP_ISO_NP:
case IdentifiedFileType::PSP_ISO:
fileTypeSupportCRC = true;
break;
default:
break;
}
}
leftColumn->Add(new Choice(di->T("Back"), "", false, new AnchorLayoutParams(150, WRAP_CONTENT, 10, NONE, NONE, 10)))->OnClick.Handle(this, &GameScreen::OnSwitchBack);
if (info->Ready(GameInfoFlags::PARAM_SFO)) {
ViewGroup *badgeHolder = new LinearLayout(ORIENT_HORIZONTAL, new AnchorLayoutParams(10, 10, 110, NONE));
@ -151,6 +168,9 @@ void GameScreen::CreateViews() {
tvPlayTime_->SetVisibility(V_GONE);
LinearLayout *crcHoriz = infoLayout->Add(new LinearLayout(ORIENT_HORIZONTAL));
if (fileTypeSupportCRC) {
// CRC button makes sense.
tvCRC_ = crcHoriz->Add(new TextView("", ALIGN_LEFT, true, new LinearLayoutParams(0.0, G_VCENTER)));
tvCRC_->SetShadow(true);
Visibility crcVisibility = Reporting::HasCRC(gamePath_) ? V_VISIBLE : V_GONE;
@ -171,6 +191,7 @@ void GameScreen::CreateViews() {
} 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);
@ -269,21 +290,6 @@ void GameScreen::CreateViews() {
btnSetBackground_->OnClick.Handle(this, &GameScreen::OnSetBackground);
btnSetBackground_->SetVisibility(V_GONE);
bool fileTypeSupportCRC = false;
if (info) {
switch (info->fileType) {
case IdentifiedFileType::PSP_PBP:
case IdentifiedFileType::PSP_PBP_DIRECTORY:
case IdentifiedFileType::PSP_ISO_NP:
case IdentifiedFileType::PSP_ISO:
fileTypeSupportCRC = true;
break;
default:
break;
}
}
isHomebrew_ = info && info->region > GAMEREGION_MAX;
if (fileTypeSupportCRC && !isHomebrew_ && !Reporting::HasCRC(gamePath_) ) {
btnCalcCRC_ = rightColumnItems->Add(new ChoiceWithValueDisplay(&CRC32string, ga->T("Calculate CRC"), I18NCat::NONE));