UI: Add button to show CRC on feedback screen.

This commit is contained in:
Unknown W. Brackets committed 2021-02-16 19:29:37 -08:00
1 parent 04a077e2f5
commit 4d0dea3506
4 files changed
+54 -5

No files matched your search

+10 -3
View File
@@ -146,8 +146,6 @@ namespace Reporting
}
bool HasCRC(const std::string &gamePath) {
QueueCRC(gamePath);
std::lock_guard<std::mutex> guard(crcLock);
return crcResults.find(gamePath) != crcResults.end();
}
@@ -167,6 +165,15 @@ namespace Reporting
return it->second;
}
static uint32_t RetrieveCRCUnlessPowerSaving(const std::string &gamePath) {
// It's okay to use it if we have it already.
if (Core_GetPowerSaving() && !HasCRC(gamePath)) {
return 0;
}
return RetrieveCRC(gamePath);
}
// Returns the full host (e.g. report.ppsspp.org:80.)
std::string ServerHost()
{
@@ -472,7 +479,7 @@ namespace Reporting
postdata.Add("graphics", StringFromFormat("%d", payload.int1));
postdata.Add("speed", StringFromFormat("%d", payload.int2));
postdata.Add("gameplay", StringFromFormat("%d", payload.int3));
postdata.Add("crc", StringFromFormat("%08x", Core_GetPowerSaving() ? 0 : RetrieveCRC(PSP_CoreParameter().fileToStart)));
postdata.Add("crc", StringFromFormat("%08x", RetrieveCRCUnlessPowerSaving(PSP_CoreParameter().fileToStart)));
postdata.Add("suggestions", payload.string1 != "perfect" && payload.string1 != "playable" ? "1" : "0");
AddScreenshotData(postdata, payload.string2);
payload.string1.clear();
+4 -1
View File
@@ -87,7 +87,10 @@ namespace Reporting
// Get the latest compatibility result. Only valid when GetStatus() is not BUSY.
std::vector<std::string> CompatibilitySuggestions();
// Queues game for CRC hash if needed, and returns true if the hash is available.
// Queues game for CRC hash if needed.
void QueueCRC(const std::string &gamePath);
// Returns true if the hash is available, does not queue if not.
bool HasCRC(const std::string &gamePath);
// Blocks until the CRC hash is available for game, and returns it.
+35 -1
View File
@@ -195,6 +195,7 @@ void ReportScreen::update() {
}
}
UIDialogScreenWithGameBackground::update();
UpdateCRCInfo();
}
void ReportScreen::resized() {
@@ -269,7 +270,7 @@ void ReportScreen::CreateViews() {
}
#ifdef MOBILE_DEVICE
if (!Core_GetPowerSaving()) {
if (!Core_GetPowerSaving() && !Reporting::HasCRC(gamePath_)) {
auto crcWarning = new TextView(rp->T("FeedbackIncludeCRC", "Note: Battery will be used to send a disc CRC"), FLAG_WRAP_TEXT, false, new LinearLayoutParams(Margins(12, 5, 0, 5)));
crcWarning->SetShadow(true);
crcWarning->SetEnabledPtr(&enableReporting_);
@@ -277,6 +278,11 @@ void ReportScreen::CreateViews() {
}
#endif
crcInfo_ = new TextView("", FLAG_WRAP_TEXT, false, new LinearLayoutParams(Margins(12, 5, 0, 5)));
crcInfo_->SetShadow(true);
crcInfo_->SetVisibility(V_GONE);
leftColumnItems->Add(crcInfo_);
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, nullptr, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, Margins(12, 0))));
@@ -300,6 +306,8 @@ 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);
UpdateSubmit();
@@ -314,12 +322,32 @@ void ReportScreen::CreateViews() {
leftColumn->Add(leftColumnItems);
rightColumn->Add(rightColumnItems);
UpdateCRCInfo();
}
void ReportScreen::UpdateSubmit() {
submit_->SetEnabled(enableReporting_ && overall_ != ReportingOverallScore::INVALID && graphics_ >= 0 && speed_ >= 0 && gameplay_ >= 0);
}
void ReportScreen::UpdateCRCInfo() {
auto rp = GetI18NCategory("Reporting");
std::string updated;
if (Reporting::HasCRC(gamePath_)) {
std::string crc = StringFromFormat("%08X", Reporting::RetrieveCRC(gamePath_));
updated = ReplaceAll(rp->T("FeedbackCRCValue", "Disc CRC: [VALUE]"), "[VALUE]", crc);
} else if (showCRC_) {
updated = rp->T("FeedbackCRCCalculating", "Disc CRC: Calculating...");
}
if (!updated.empty()) {
crcInfo_->SetText(updated);
crcInfo_->SetVisibility(V_VISIBLE);
showCrcButton_->SetEnabled(false);
}
}
void ReportScreen::UpdateOverallDescription() {
auto rp = GetI18NCategory("Reporting");
const char *desc;
@@ -366,6 +394,12 @@ EventReturn ReportScreen::HandleBrowser(EventParams &e) {
return EVENT_DONE;
}
EventReturn ReportScreen::HandleShowCRC(EventParams &e) {
Reporting::QueueCRC(gamePath_);
showCRC_ = true;
return EVENT_DONE;
}
ReportFinishScreen::ReportFinishScreen(const std::string &gamePath, ReportingOverallScore score)
: UIDialogScreenWithGameBackground(gamePath), score_(score) {
}
+5
View File
@@ -42,17 +42,21 @@ protected:
void resized() override;
void CreateViews() override;
void UpdateSubmit();
void UpdateCRCInfo();
void UpdateOverallDescription();
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;
UI::View *screenshot_ = nullptr;
UI::TextView *reportingNotice_ = nullptr;
UI::TextView *overallDescription_ = nullptr;
UI::TextView *crcInfo_ = nullptr;
UI::Choice *showCrcButton_ = nullptr;
std::string screenshotFilename_;
ReportingOverallScore overall_ = ReportingOverallScore::INVALID;
@@ -63,6 +67,7 @@ protected:
bool ratingEnabled_;
bool tookScreenshot_ = false;
bool includeScreenshot_ = true;
bool showCRC_ = false;
};
class ReportFinishScreen : public UIDialogScreenWithGameBackground {