From a02237d6f6af6dd638201a5dab20dc1851dc84cd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 12 Jun 2016 07:21:56 -0700 Subject: [PATCH] Show a screenshot when reporting compatibility. --- UI/ReportScreen.cpp | 31 ++++++++++++++++++++++++++++--- UI/ReportScreen.h | 6 ++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index 1d1675fb0c..6af443ab64 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -16,12 +16,16 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include "base/display.h" #include "i18n/i18n.h" -#include "gfx_es2/draw_buffer.h" +#include "thin3d/thin3d.h" #include "ui/ui_context.h" +#include "UI/PauseScreen.h" #include "UI/ReportScreen.h" #include "Core/Reporting.h" +#include "Core/Screenshot.h" +#include "Core/System.h" #include "Common/Log.h" using namespace UI; @@ -148,7 +152,19 @@ void CompatRatingChoice::SetupChoices() { } ReportScreen::ReportScreen(const std::string &gamePath) - : UIScreenWithGameBackground(gamePath), overall_(-1), graphics_(-1), speed_(-1), gameplay_(-1), ratingEnabled_(true) { + : UIScreenWithGameBackground(gamePath), overall_(-1), graphics_(-1), speed_(-1), gameplay_(-1), + ratingEnabled_(true), includeScreenshot_(true) { +} + +void ReportScreen::update(InputState &input) { + if (screenshot_) { + if (includeScreenshot_) { + screenshot_->SetVisibility(V_VISIBLE); + } else { + screenshot_->SetVisibility(V_GONE); + } + } + UIScreenWithGameBackground::update(input); } EventReturn ReportScreen::HandleChoice(EventParams &e) { @@ -178,7 +194,16 @@ void ReportScreen::CreateViews() { leftColumnItems->Add(new InfoItem(rp->T("FeedbackDesc", "How's the emulation? Let us and the community know!"), "")); - // TODO: screenshot + 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"))); + 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 RatingChoice("Graphics", &graphics_))->SetEnabledPtr(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); leftColumnItems->Add(new RatingChoice("Speed", &speed_))->SetEnabledPtr(&ratingEnabled_)->OnChoice.Handle(this, &ReportScreen::HandleChoice); diff --git a/UI/ReportScreen.h b/UI/ReportScreen.h index edfbfeb8b2..7893b35ac0 100644 --- a/UI/ReportScreen.h +++ b/UI/ReportScreen.h @@ -27,6 +27,8 @@ public: ReportScreen(const std::string &gamePath); protected: + void update(InputState &input) override; + UI::EventReturn HandleChoice(UI::EventParams &e); UI::EventReturn HandleSubmit(UI::EventParams &e); UI::EventReturn HandleBrowser(UI::EventParams &e); @@ -34,9 +36,13 @@ protected: virtual void CreateViews(); UI::Choice *submit_; + UI::View *screenshot_; + std::string screenshotFilename_; + int overall_; int graphics_; int speed_; int gameplay_; bool ratingEnabled_; + bool includeScreenshot_; };