From 64c2cf808227454eace35b87a3d30a6f359bfbd5 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Tue, 26 Jul 2022 19:18:21 +0800 Subject: [PATCH] Work but not good --- UI/GameScreen.cpp | 23 ++++++++++++++++++++--- UI/GameScreen.h | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index d1f96503f4..dbc7c63fb3 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -44,6 +44,7 @@ #include "UI/MainScreen.h" #include "UI/BackgroundAudio.h" #include "Core/Reporting.h" +#include "UI/mmd5.h" GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { g_BackgroundAudio.SetGame(gamePath); @@ -77,6 +78,12 @@ void GameScreen::update() { btnCalcCRC_->SetVisibility(UI::V_GONE); } } + if (MD5string == "...") { + tvCRC_->SetText(MD5string); + btnCalcMD5_->SetVisibility(UI::V_GONE); + + } + } void GameScreen::CreateViews() { @@ -200,12 +207,13 @@ void GameScreen::CreateViews() { if (fileTypeSupportCRC && !isHomebrew && !Reporting::HasCRC(gamePath_) ) { btnCalcCRC_ = rightColumnItems->Add(new ChoiceWithValueDisplay(&CRC32string, ga->T("Calculate CRC"), (const char*)nullptr)); btnCalcCRC_->OnClick.Handle(this, &GameScreen::OnDoCRC32); - btnCalcMD5_ = rightColumnItems->Add(new ChoiceWithValueDisplay(&CRC32string, ga->T("Calculate MD5"), (const char*)nullptr)); - btnCalcMD5_->OnClick.Handle(this, &GameScreen::OnDoCRC32); } else { btnCalcCRC_ = nullptr; - btnCalcMD5_ = nullptr; + //btnCalcMD5_ = nullptr; } + btnCalcMD5_ = rightColumnItems->Add(new ChoiceWithValueDisplay(&MD5string, ga->T("Calculate MD5"), (const char*)nullptr)); + btnCalcMD5_->OnClick.Handle(this, &GameScreen::OnDoMD5); + } UI::Choice *GameScreen::AddOtherChoice(UI::Choice *choice) { @@ -346,6 +354,15 @@ UI::EventReturn GameScreen::OnDoCRC32(UI::EventParams& e) { return UI::EVENT_DONE; } +UI::EventReturn GameScreen::OnDoMD5(UI::EventParams& e) { + MD5string = "..."; + //Reporting::QueueCRC(gamePath_); + //MD5string = md5file(gamePath_); + auto chrs = gamePath_.c_str(); + MD5string = md5file(chrs); + btnCalcMD5_->SetEnabled(false); + return UI::EVENT_DONE; +} UI::EventReturn GameScreen::OnSwitchBack(UI::EventParams &e) { TriggerFinish(DR_OK); diff --git a/UI/GameScreen.h b/UI/GameScreen.h index b44213a0a9..81e450dec8 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -64,6 +64,7 @@ private: UI::EventReturn OnCwCheat(UI::EventParams &e); UI::EventReturn OnSetBackground(UI::EventParams &e); UI::EventReturn OnDoCRC32(UI::EventParams& e); + UI::EventReturn OnDoMD5(UI::EventParams& e); // As we load metadata in the background, we need to be able to update these after the fact. UI::TextView *tvTitle_ = nullptr; @@ -72,6 +73,7 @@ private: UI::TextView *tvInstallDataSize_ = nullptr; UI::TextView *tvRegion_ = nullptr; UI::TextView *tvCRC_ = nullptr; + UI::TextView *tvmd5_ = nullptr; UI::TextView *tvID_ = nullptr; UI::Choice *btnGameSettings_ = nullptr; @@ -86,4 +88,5 @@ private: std::vector otherChoices_; std::vector saveDirs; std::string CRC32string; + std::string MD5string; };