diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index 5de5c56560..c7e2b05f32 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -34,6 +34,7 @@ #include "net/resolve.h" #include "net/url.h" +#include "base/stringutil.h" #include "base/buffer.h" #include "thread/thread.h" #include "file/zip_read.h" @@ -62,6 +63,7 @@ namespace Reporting enum RequestType { MESSAGE, + COMPAT, }; struct Payload @@ -69,6 +71,9 @@ namespace Reporting RequestType type; std::string string1; std::string string2; + int int1; + int int2; + int int3; }; static Payload payloadBuffer[PAYLOAD_BUFFER_SIZE]; static int payloadBufferPos = 0; @@ -153,7 +158,7 @@ namespace Reporting if (http.Resolve(ServerHostname(), ServerPort())) { http.Connect(); - http.POST("/report/message", data, mimeType, output); + http.POST(uri, data, mimeType, output); http.Disconnect(); result = true; } @@ -289,7 +294,7 @@ namespace Reporting { Payload &payload = payloadBuffer[pos]; - MultipartFormDataEncoder postdata; + UrlEncoder postdata; AddSystemInfo(postdata); AddGameInfo(postdata); AddConfigInfo(postdata); @@ -306,6 +311,17 @@ namespace Reporting postdata.Finish(); SendReportRequest("/report/message", postdata.ToString(), postdata.GetMimeType()); break; + + case COMPAT: + postdata.Add("compat", payload.string1); + postdata.Add("graphics", StringFromFormat("%d", payload.int1)); + postdata.Add("speed", StringFromFormat("%d", payload.int2)); + postdata.Add("gameplay", StringFromFormat("%d", payload.int3)); + payload.string1.clear(); + + postdata.Finish(); + SendReportRequest("/report/compat", postdata.ToString(), postdata.GetMimeType()); + break; } return 0; @@ -387,4 +403,21 @@ namespace Reporting th.detach(); } + void ReportCompatibility(const char *compat, int graphics, int speed, int gameplay) + { + if (!IsEnabled()) + return; + + int pos = payloadBufferPos++ % PAYLOAD_BUFFER_SIZE; + Payload &payload = payloadBuffer[pos]; + payload.type = COMPAT; + payload.string1 = compat; + payload.int1 = graphics; + payload.int2 = speed; + payload.int3 = gameplay; + + std::thread th(Process, pos); + th.detach(); + } + } diff --git a/Core/Reporting.h b/Core/Reporting.h index 95c6aca4e7..a59ad9d7be 100644 --- a/Core/Reporting.h +++ b/Core/Reporting.h @@ -65,6 +65,9 @@ namespace Reporting // Report a message string, using the format string as a key. void ReportMessage(const char *message, ...); + // Report the compatibility of the current game / configuration. + void ReportCompatibility(const char *compat, int graphics, int speed, int gameplay); + // Returns true if that identifier has not been logged yet. bool ShouldLogOnce(const char *identifier); } \ No newline at end of file diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 81ba581525..510021cf0a 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1177,13 +1177,12 @@ void GamePauseScreen::CreateViews() { if (g_Config.bEnableCheats) { rightColumnItems->Add(new Choice(i->T("Cheats")))->OnClick.Handle(this, &GamePauseScreen::OnCwCheat); } -#if 0 // 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()) { I18NCategory *rp = GetI18NCategory("Reporting"); rightColumnItems->Add(new Choice(rp->T("ReportButton", "Report Feedback")))->OnClick.Handle(this, &GamePauseScreen::OnReportFeedback); } -#endif rightColumnItems->Add(new Spacer(25.0)); rightColumnItems->Add(new Choice(i->T("Exit to menu")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu); diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index 71dfe64c05..bd3a3db497 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -90,7 +90,8 @@ EventReturn RatingChoice::OnChoiceClick(EventParams &e) { e2.v = e.v; e2.a = *value_; // Dispatch immediately (we're already on the UI thread as we're in an event handler). - return OnChoice.Dispatch(e2); + OnChoice.Dispatch(e2); + return EVENT_DONE; } class CompatRatingChoice : public RatingChoice { @@ -112,11 +113,11 @@ CompatRatingChoice::CompatRatingChoice(const char *captionKey, int *value, Layou void CompatRatingChoice::SetupChoices() { I18NCategory *rp = GetI18NCategory("Reporting"); group_->Clear(); - AddChoice(1, rp->T("Perfect")); - AddChoice(2, rp->T("Plays")); - AddChoice(3, rp->T("In-game")); - AddChoice(4, rp->T("Menu/Intro")); - AddChoice(5, rp->T("Nothing")); + AddChoice(0, rp->T("Perfect")); + AddChoice(1, rp->T("Plays")); + AddChoice(2, rp->T("In-game")); + AddChoice(3, rp->T("Menu/Intro")); + AddChoice(4, rp->T("Nothing")); } ReportScreen::ReportScreen(const std::string &gamePath) @@ -146,11 +147,9 @@ void ReportScreen::CreateViews() { leftColumnItems->Add(new RatingChoice("Gameplay", &gameplay_))->OnChoice.Handle(this, &ReportScreen::HandleChoice); rightColumnItems->SetSpacing(0.0f); - // TODO: Handle. - rightColumnItems->Add(new Choice(rp->T("Open Browser"))); + rightColumnItems->Add(new Choice(rp->T("Open Browser")))->OnClick.Handle(this, &ReportScreen::HandleBrowser); submit_ = new Choice(rp->T("Submit Feedback")); - // TODO: Handle. - rightColumnItems->Add(submit_); + rightColumnItems->Add(submit_)->OnClick.Handle(this, &ReportScreen::HandleSubmit); submit_->SetEnabled(overall_ >= 0 && graphics_ >= 0 && speed_ >= 0 && gameplay_ >= 0); rightColumnItems->Add(new Spacer(25.0)); @@ -161,6 +160,26 @@ void ReportScreen::CreateViews() { root_->Add(rightColumn); leftColumn->Add(leftColumnItems); - rightColumn->Add(rightColumnItems); +} + +EventReturn ReportScreen::HandleSubmit(EventParams &e) { + const char *compat; + switch (overall_) { + case 0: compat = "perfect"; break; + case 1: compat = "playable"; break; + case 2: compat = "ingame"; break; + case 3: compat = "menu"; break; + case 4: compat = "none"; break; + default: compat = "unknown"; break; + } + + Reporting::ReportCompatibility(compat, graphics_ + 1, speed_ + 1, gameplay_ + 1); + screenManager()->finishDialog(this, DR_OK); + return EVENT_DONE; +} + +EventReturn ReportScreen::HandleBrowser(EventParams &e) { + LaunchBrowser("http://report.ppsspp.org/"); + return EVENT_DONE; } \ No newline at end of file diff --git a/UI/ReportScreen.h b/UI/ReportScreen.h index 8484d7844b..affc643a40 100644 --- a/UI/ReportScreen.h +++ b/UI/ReportScreen.h @@ -28,6 +28,9 @@ public: protected: UI::EventReturn HandleChoice(UI::EventParams &e); + UI::EventReturn HandleSubmit(UI::EventParams &e); + UI::EventReturn HandleBrowser(UI::EventParams &e); + virtual void CreateViews(); UI::Choice *submit_;