ReportScreen: Calculate the disc CRC while filling out the form.

Prevents a temporary hang after the refactor.
This commit is contained in:
Henrik Rydgård 2024-10-29 11:24:36 +01:00
parent 14bb7a6062
commit dc122f8595
3 changed files with 8 additions and 25 deletions

View File

@ -23,7 +23,6 @@
// If http isn't loaded (seems unlikely), most functions should return SCE_KERNEL_ERROR_LIBRARY_NOTFOUND
// Could come in handy someday if we ever implement sceHttp* for real.
enum PSPHttpMethod {
PSP_HTTP_METHOD_GET,
@ -36,15 +35,6 @@ class HTTPTemplate {
char useragent[512];
};
class HTTPConnection {
};
class HTTPRequest {
};
int sceHttpSetResolveRetry(int connectionID, int retryCount) {
ERROR_LOG(Log::sceNet, "UNIMPL sceHttpSetResolveRetry(%d, %d)", connectionID, retryCount);
return 0;

View File

@ -160,10 +160,13 @@ void CompatRatingChoice::SetupChoices() {
AddChoice(4, rp->T("Nothing"));
}
ReportScreen::ReportScreen(const Path &gamePath) // unused gamePath, after removing the background
ReportScreen::ReportScreen(const Path &gamePath)
: UIDialogScreen(), gamePath_(gamePath) {
enableReporting_ = Reporting::IsEnabled();
ratingEnabled_ = enableReporting_;
// Start computing a CRC immediately, we'll need it on submit.
// We won't enable the submit button until it's done.
Reporting::QueueCRC(gamePath_);
}
ScreenRenderFlags ReportScreen::render(ScreenRenderMode mode) {
@ -296,7 +299,7 @@ void ReportScreen::CreateViews() {
if (tookScreenshot_ && !screenshotFilename_.empty()) {
leftColumnItems->Add(new CheckBox(&includeScreenshot_, rp->T("FeedbackIncludeScreen", "Include a screenshot")))->SetEnabledPtr(&enableReporting_);
screenshot_ = leftColumnItems->Add(new AsyncImageFileView(screenshotFilename_, IS_KEEP_ASPECT, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, Margins(12, 0))));
screenshot_ = leftColumnItems->Add(new AsyncImageFileView(screenshotFilename_, IS_KEEP_ASPECT, new LinearLayoutParams(300, WRAP_CONTENT, Margins(12, 0))));
} else {
if (tookScreenshot_) {
includeScreenshot_ = false;
@ -317,10 +320,9 @@ void ReportScreen::CreateViews() {
rightColumnItems->SetSpacing(0.0f);
rightColumnItems->Add(new Choice(rp->T("Open Browser")))->OnClick.Handle(this, &ReportScreen::HandleBrowser);
showCrcButton_ = new Choice(rp->T("Show disc CRC"));
rightColumnItems->Add(showCrcButton_)->OnClick.Handle(this, &ReportScreen::HandleShowCRC);
submit_ = new Choice(rp->T("Submit Feedback"));
rightColumnItems->Add(submit_)->OnClick.Handle(this, &ReportScreen::HandleSubmit);
submit_->SetEnabled(false); // Waiting for CRC
UpdateSubmit();
UpdateOverallDescription();
@ -348,14 +350,14 @@ void ReportScreen::UpdateCRCInfo() {
if (Reporting::HasCRC(gamePath_)) {
std::string crc = StringFromFormat("%08X", Reporting::RetrieveCRC(gamePath_));
updated = ApplySafeSubstitutions(rp->T("FeedbackCRCValue", "Disc CRC: %1"), crc);
} else if (showCRC_) {
submit_->SetEnabled(true);
} else {
updated = rp->T("FeedbackCRCCalculating", "Disc CRC: Calculating...");
}
if (!updated.empty()) {
crcInfo_->SetText(updated);
crcInfo_->SetVisibility(V_VISIBLE);
showCrcButton_->SetEnabled(false);
}
}
@ -405,12 +407,6 @@ EventReturn ReportScreen::HandleBrowser(EventParams &e) {
return EVENT_DONE;
}
EventReturn ReportScreen::HandleShowCRC(EventParams &e) {
Reporting::QueueCRC(gamePath_);
showCRC_ = true;
return EVENT_DONE;
}
ReportFinishScreen::ReportFinishScreen(const Path &gamePath, ReportingOverallScore score)
: UIDialogScreen(), gamePath_(gamePath), score_(score) {
}

View File

@ -54,7 +54,6 @@ protected:
UI::EventReturn HandleChoice(UI::EventParams &e);
UI::EventReturn HandleSubmit(UI::EventParams &e);
UI::EventReturn HandleBrowser(UI::EventParams &e);
UI::EventReturn HandleShowCRC(UI::EventParams &e);
UI::EventReturn HandleReportingChange(UI::EventParams &e);
UI::Choice *submit_ = nullptr;
@ -62,7 +61,6 @@ protected:
UI::TextView *reportingNotice_ = nullptr;
UI::TextView *overallDescription_ = nullptr;
UI::TextView *crcInfo_ = nullptr;
UI::Choice *showCrcButton_ = nullptr;
Path gamePath_;
Path screenshotFilename_;
@ -74,7 +72,6 @@ protected:
bool ratingEnabled_;
bool tookScreenshot_ = false;
bool includeScreenshot_ = true;
bool showCRC_ = false;
};
class ReportFinishScreen : public UIDialogScreen {