diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index f4332207d6..a4f58b002f 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -400,14 +400,16 @@ namespace Reporting return true; } - void Enable(bool flag, std::string host) + bool Enable(bool flag, std::string host) { if (IsSupported() && IsEnabled() != flag) { // "" means explicitly disabled. Don't ever turn on by default. // "default" means it's okay to turn it on by default. g_Config.sReportHost = flag ? host : ""; + return true; } + return false; } void EnableDefault() diff --git a/Core/Reporting.h b/Core/Reporting.h index 4f908ae28e..378cd51c12 100644 --- a/Core/Reporting.h +++ b/Core/Reporting.h @@ -57,7 +57,8 @@ namespace Reporting bool IsSupported(); // Set the current enabled state of the reporting system and desired reporting server host. - void Enable(bool flag, std::string host); + // Returns if anything was changed. + bool Enable(bool flag, std::string host); // Use the default reporting setting (per compiled settings) of host and enabled state. void EnableDefault(); diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index e7ce2c46a5..2f1339089a 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -333,7 +333,7 @@ void GamePauseScreen::CreateViews() { // TODO, also might be nice to show overall compat rating here? // Based on their platform or even cpu/gpu/config. Would add an API for it. - if (Reporting::IsEnabled() && gameId.size() && gameId != "_") { + if (Reporting::IsSupported() && gameId.size() && gameId != "_") { I18NCategory *rp = GetI18NCategory("Reporting"); rightColumnItems->Add(new Choice(rp->T("ReportButton", "Report Feedback")))->OnClick.Handle(this, &GamePauseScreen::OnReportFeedback); } diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index 0cfd41282f..72170e3bfa 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -153,7 +153,9 @@ void CompatRatingChoice::SetupChoices() { ReportScreen::ReportScreen(const std::string &gamePath) : UIScreenWithGameBackground(gamePath), overall_(-1), graphics_(-1), speed_(-1), gameplay_(-1), - ratingEnabled_(true), includeScreenshot_(true) { + includeScreenshot_(true) { + enableReporting_ = Reporting::IsEnabled(); + ratingEnabled_ = enableReporting_; } void ReportScreen::update(InputState &input) { @@ -179,32 +181,58 @@ EventReturn ReportScreen::HandleChoice(EventParams &e) { gameplay_ = -1; ratingEnabled_ = true; } - submit_->SetEnabled(overall_ >= 0 && graphics_ >= 0 && speed_ >= 0 && gameplay_ >= 0); + UpdateSubmit(); + return EVENT_DONE; +} + +EventReturn ReportScreen::HandleReportingChange(EventParams &e) { + if (overall_ == 4) { + ratingEnabled_ = false; + } else { + ratingEnabled_ = enableReporting_; + } + if (reportingNotice_) { + reportingNotice_->SetTextColor(enableReporting_ ? 0xFFFFFFFF : 0xFF3030FF); + } + UpdateSubmit(); return EVENT_DONE; } void ReportScreen::CreateViews() { I18NCategory *rp = GetI18NCategory("Reporting"); I18NCategory *di = GetI18NCategory("Dialog"); - Margins actionMenuMargins(0, 100, 15, 0); - ViewGroup *leftColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, FILL_PARENT, 0.4f)); + I18NCategory *sy = GetI18NCategory("System"); + + Margins actionMenuMargins(0, 20, 15, 0); + Margins contentMargins(0, 20, 5, 5); + ViewGroup *leftColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, FILL_PARENT, 0.4f, contentMargins)); LinearLayout *leftColumnItems = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(WRAP_CONTENT, FILL_PARENT)); ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL); - leftColumnItems->Add(new InfoItem(rp->T("FeedbackDesc", "How's the emulation? Let us and the community know!"), "")); + leftColumnItems->Add(new TextView(rp->T("FeedbackDesc", "How's the emulation? Let us and the community know!"), new LinearLayoutParams(Margins(12, 5, 0, 5)))); + if (!Reporting::IsEnabled()) { + reportingNotice_ = leftColumnItems->Add(new TextView(rp->T("FeedbackDisabled", "Compatibility server reports must be enabled."), new LinearLayoutParams(Margins(12, 5, 0, 5)))); + reportingNotice_->SetShadow(true); + reportingNotice_->SetTextColor(0xFF3030FF); + CheckBox *reporting = leftColumnItems->Add(new CheckBox(&enableReporting_, sy->T("Enable Compatibility Server Reports"))); + reporting->SetEnabled(Reporting::IsSupported()); + reporting->OnClick.Handle(this, &ReportScreen::HandleReportingChange); + } else { + reportingNotice_ = nullptr; + } screenshotFilename_ = GetSysDirectory(DIRECTORY_SCREENSHOT) + ".reporting.jpg"; int shotWidth = 0, shotHeight = 0; if (TakeGameScreenshot(screenshotFilename_.c_str(), SCREENSHOT_JPG, SCREENSHOT_RENDER, &shotWidth, &shotHeight, 4)) { float scale = 340.0f * (1.0f / g_dpi_scale) * (1.0f / shotHeight); - leftColumnItems->Add(new CheckBox(&includeScreenshot_, rp->T("FeedbackIncludeScreen", "Include a screenshot"))); + leftColumnItems->Add(new CheckBox(&includeScreenshot_, rp->T("FeedbackIncludeScreen", "Include a screenshot")))->SetEnabledPtr(&enableReporting_); screenshot_ = leftColumnItems->Add(new AsyncImageFileView(screenshotFilename_, IS_DEFAULT, nullptr, new LinearLayoutParams(shotWidth * scale, shotHeight * scale, Margins(12, 0)))); } else { includeScreenshot_ = false; } - leftColumnItems->Add(new CompatRatingChoice("Overall", &overall_))->OnChoice.Handle(this, &ReportScreen::HandleChoice); + leftColumnItems->Add(new CompatRatingChoice("Overall", &overall_))->SetEnabledPtr(&enableReporting_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); leftColumnItems->Add(new RatingChoice("Graphics", &graphics_))->SetEnabledPtr(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); leftColumnItems->Add(new RatingChoice("Speed", &speed_))->SetEnabledPtr(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); leftColumnItems->Add(new RatingChoice("Gameplay", &gameplay_))->SetEnabledPtr(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); @@ -213,7 +241,7 @@ void ReportScreen::CreateViews() { rightColumnItems->Add(new Choice(rp->T("Open Browser")))->OnClick.Handle(this, &ReportScreen::HandleBrowser); submit_ = new Choice(rp->T("Submit Feedback")); rightColumnItems->Add(submit_)->OnClick.Handle(this, &ReportScreen::HandleSubmit); - submit_->SetEnabled(overall_ >= 0 && graphics_ >= 0 && speed_ >= 0 && gameplay_ >= 0); + UpdateSubmit(); rightColumnItems->Add(new Spacer(25.0)); rightColumnItems->Add(new Choice(di->T("Back"), "", false, new AnchorLayoutParams(150, WRAP_CONTENT, 10, NONE, NONE, 10)))->OnClick.Handle(this, &UIScreen::OnBack); @@ -226,6 +254,10 @@ void ReportScreen::CreateViews() { rightColumn->Add(rightColumnItems); } +void ReportScreen::UpdateSubmit() { + submit_->SetEnabled(enableReporting_ && overall_ >= 0 && graphics_ >= 0 && speed_ >= 0 && gameplay_ >= 0); +} + EventReturn ReportScreen::HandleSubmit(EventParams &e) { const char *compat; switch (overall_) { @@ -237,6 +269,11 @@ EventReturn ReportScreen::HandleSubmit(EventParams &e) { default: compat = "unknown"; break; } + if (Reporting::Enable(enableReporting_, "report.ppsspp.org")) { + Reporting::UpdateConfig(); + g_Config.Save(); + } + std::string filename = includeScreenshot_ ? screenshotFilename_ : ""; Reporting::ReportCompatibility(compat, graphics_ + 1, speed_ + 1, gameplay_ + 1, filename); screenManager()->finishDialog(this, DR_OK); diff --git a/UI/ReportScreen.h b/UI/ReportScreen.h index 7893b35ac0..1ded022967 100644 --- a/UI/ReportScreen.h +++ b/UI/ReportScreen.h @@ -28,21 +28,24 @@ public: protected: void update(InputState &input) override; + void CreateViews() override; + void UpdateSubmit(); UI::EventReturn HandleChoice(UI::EventParams &e); UI::EventReturn HandleSubmit(UI::EventParams &e); UI::EventReturn HandleBrowser(UI::EventParams &e); - - virtual void CreateViews(); + UI::EventReturn HandleReportingChange(UI::EventParams &e); UI::Choice *submit_; UI::View *screenshot_; + UI::TextView *reportingNotice_; std::string screenshotFilename_; int overall_; int graphics_; int speed_; int gameplay_; + bool enableReporting_; bool ratingEnabled_; bool includeScreenshot_; };