2014-02-10 09:24:40 +00:00
// Copyright (c) 2014- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
# include <string>
2020-08-10 13:53:52 +00:00
2020-03-10 02:51:25 +00:00
// TODO: For text align flags, probably shouldn't be in gfx_es2/...
2020-10-04 21:24:14 +00:00
# include "Common/Render/DrawBuffer.h"
# include "Common/GPU/thin3d.h"
2022-11-21 19:15:22 +00:00
# include "Common/UI/AsyncImageFileView.h"
2020-10-04 18:48:47 +00:00
# include "Common/UI/Context.h"
2016-06-12 14:21:56 +00:00
# include "UI/PauseScreen.h"
2014-02-10 09:24:40 +00:00
# include "UI/ReportScreen.h"
2020-10-01 11:05:04 +00:00
# include "Common/Data/Text/I18n.h"
2020-10-04 18:48:47 +00:00
# include "Common/File/FileUtil.h"
2020-10-01 11:05:04 +00:00
# include "Common/Log.h"
# include "Common/StringUtils.h"
2020-10-04 08:30:18 +00:00
# include "Common/System/Display.h"
# include "Common/System/System.h"
2022-01-30 23:49:02 +00:00
# include "Core/Config.h"
2016-07-25 00:31:41 +00:00
# include "Core/Core.h"
2014-02-10 09:24:40 +00:00
# include "Core/Reporting.h"
2016-06-12 14:21:56 +00:00
# include "Core/Screenshot.h"
# include "Core/System.h"
2014-02-10 09:24:40 +00:00
using namespace UI ;
class RatingChoice : public LinearLayout {
public :
2024-01-19 12:44:49 +00:00
RatingChoice ( std : : string_view captionKey , int * value , LayoutParams * layoutParams = 0 ) ;
2014-02-10 09:24:40 +00:00
2022-12-11 04:32:12 +00:00
RatingChoice * SetEnabledPtrs ( bool * enabled ) ;
2016-06-10 04:07:30 +00:00
2014-02-10 09:24:40 +00:00
Event OnChoice ;
2014-09-27 21:59:37 +00:00
protected :
2017-03-15 05:01:18 +00:00
void Update ( ) override ;
2016-06-10 04:07:30 +00:00
2014-09-27 21:59:37 +00:00
virtual void SetupChoices ( ) ;
virtual int TotalChoices ( ) {
return 3 ;
}
2024-01-19 12:44:49 +00:00
void AddChoice ( int i , std : : string_view title ) ;
2016-06-10 04:07:30 +00:00
StickyChoice * GetChoice ( int i ) {
return static_cast < StickyChoice * > ( group_ - > GetViewByIndex ( i ) ) ;
}
2014-02-10 09:24:40 +00:00
LinearLayout * group_ ;
2014-09-27 21:59:37 +00:00
private :
EventReturn OnChoiceClick ( EventParams & e ) ;
2014-02-10 09:24:40 +00:00
int * value_ ;
} ;
2024-01-19 12:44:49 +00:00
RatingChoice : : RatingChoice ( std : : string_view captionKey , int * value , LayoutParams * layoutParams )
2014-02-10 09:24:40 +00:00
: LinearLayout ( ORIENT_VERTICAL , layoutParams ) , value_ ( value ) {
2018-01-02 06:06:20 +00:00
SetSpacing ( 0.0f ) ;
2014-02-10 09:24:40 +00:00
2023-04-05 22:34:50 +00:00
auto rp = GetI18NCategory ( I18NCat : : REPORTING ) ;
2014-02-10 09:24:40 +00:00
group_ = new LinearLayout ( ORIENT_HORIZONTAL ) ;
2018-06-03 21:47:49 +00:00
Add ( new TextView ( rp - > T ( captionKey ) , FLAG_WRAP_TEXT , false ) ) - > SetShadow ( true ) ;
2014-02-10 09:24:40 +00:00
Add ( group_ ) ;
group_ - > SetSpacing ( 0.0f ) ;
2014-09-27 21:59:37 +00:00
SetupChoices ( ) ;
}
2017-03-15 05:01:18 +00:00
void RatingChoice : : Update ( ) {
LinearLayout : : Update ( ) ;
2016-06-10 04:07:30 +00:00
for ( int i = 0 ; i < TotalChoices ( ) ; i + + ) {
StickyChoice * chosen = GetChoice ( i ) ;
bool down = chosen - > IsDown ( ) ;
if ( down & & * value_ ! = i ) {
chosen - > Release ( ) ;
} else if ( ! down & & * value_ = = i ) {
chosen - > Press ( ) ;
}
}
}
2022-12-11 04:32:12 +00:00
RatingChoice * RatingChoice : : SetEnabledPtrs ( bool * ptr ) {
2016-06-10 04:07:30 +00:00
for ( int i = 0 ; i < TotalChoices ( ) ; i + + ) {
GetChoice ( i ) - > SetEnabledPtr ( ptr ) ;
}
return this ;
}
2014-09-27 21:59:37 +00:00
void RatingChoice : : SetupChoices ( ) {
2023-04-05 22:34:50 +00:00
auto rp = GetI18NCategory ( I18NCat : : REPORTING ) ;
2014-02-10 09:24:40 +00:00
AddChoice ( 0 , rp - > T ( " Bad " ) ) ;
AddChoice ( 1 , rp - > T ( " OK " ) ) ;
AddChoice ( 2 , rp - > T ( " Great " ) ) ;
}
2024-01-19 12:44:49 +00:00
void RatingChoice : : AddChoice ( int i , std : : string_view title ) {
2014-02-10 09:24:40 +00:00
auto c = group_ - > Add ( new StickyChoice ( title , " " ) ) ;
c - > OnClick . Handle ( this , & RatingChoice : : OnChoiceClick ) ;
}
EventReturn RatingChoice : : OnChoiceClick ( EventParams & e ) {
// Unstick the other choices that weren't clicked.
2014-09-27 21:59:37 +00:00
int total = TotalChoices ( ) ;
for ( int i = 0 ; i < total ; i + + ) {
2016-06-10 04:07:30 +00:00
StickyChoice * v = GetChoice ( i ) ;
2014-02-10 09:24:40 +00:00
if ( v ! = e . v ) {
2016-06-10 04:07:30 +00:00
v - > Release ( ) ;
2014-02-10 09:24:40 +00:00
} else {
* value_ = i ;
}
}
2017-03-22 01:34:52 +00:00
EventParams e2 { } ;
2014-02-10 09:24:40 +00:00
e2 . v = e . v ;
e2 . a = * value_ ;
// Dispatch immediately (we're already on the UI thread as we're in an event handler).
2014-09-27 22:37:53 +00:00
OnChoice . Dispatch ( e2 ) ;
return EVENT_DONE ;
2014-02-10 09:24:40 +00:00
}
2014-09-27 21:59:37 +00:00
class CompatRatingChoice : public RatingChoice {
public :
CompatRatingChoice ( const char * captionKey , int * value , LayoutParams * layoutParams = 0 ) ;
protected :
2022-12-11 04:32:12 +00:00
void SetupChoices ( ) override ;
int TotalChoices ( ) override {
2014-09-27 21:59:37 +00:00
return 5 ;
}
} ;
CompatRatingChoice : : CompatRatingChoice ( const char * captionKey , int * value , LayoutParams * layoutParams )
: RatingChoice ( captionKey , value , layoutParams ) {
SetupChoices ( ) ;
}
void CompatRatingChoice : : SetupChoices ( ) {
2023-04-05 22:34:50 +00:00
auto rp = GetI18NCategory ( I18NCat : : REPORTING ) ;
2014-09-27 21:59:37 +00:00
group_ - > Clear ( ) ;
2014-09-27 22:37:53 +00:00
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 " ) ) ;
2014-09-27 21:59:37 +00:00
}
2024-09-17 09:24:22 +00:00
ReportScreen : : ReportScreen ( const Path & gamePath ) // unused gamePath, after removing the background
: UIDialogScreen ( ) , gamePath_ ( gamePath ) {
2016-06-12 17:33:33 +00:00
enableReporting_ = Reporting : : IsEnabled ( ) ;
ratingEnabled_ = enableReporting_ ;
2016-06-12 14:21:56 +00:00
}
2023-12-11 11:41:44 +00:00
ScreenRenderFlags ReportScreen : : render ( ScreenRenderMode mode ) {
2024-09-17 09:24:22 +00:00
_dbg_assert_ ( mode & ScreenRenderMode : : FIRST ) ;
_dbg_assert_ ( mode & ScreenRenderMode : : TOP ) ;
2023-12-10 13:09:55 +00:00
if ( mode & ScreenRenderMode : : TOP ) {
// We do this after render because we need it to be within the frame (so the screenshot works).
// We could do it mid frame, but then we have to reapply viewport/scissor.
2024-09-17 09:24:22 +00:00
if ( ! tookScreenshot_ & & ! g_Config . bSkipBufferEffects ) {
2023-12-10 13:09:55 +00:00
Path path = GetSysDirectory ( DIRECTORY_SCREENSHOT ) ;
if ( ! File : : Exists ( path ) ) {
File : : CreateDir ( path ) ;
}
screenshotFilename_ = path / " .reporting.jpg " ;
2024-05-10 19:01:03 +00:00
if ( TakeGameScreenshot ( screenManager ( ) - > getDrawContext ( ) , screenshotFilename_ , ScreenshotFormat : : JPG , SCREENSHOT_DISPLAY , nullptr , nullptr , 4 ) ) {
2023-12-10 13:09:55 +00:00
// Redo the views already, now with a screenshot included.
RecreateViews ( ) ;
} else {
// Good news (?), the views are good as-is without a screenshot.
screenshotFilename_ . clear ( ) ;
}
tookScreenshot_ = true ;
2020-05-18 03:37:26 +00:00
}
}
2024-09-17 09:24:22 +00:00
// We take the screenshot first, then we start rendering.
// We are the only screen visible so this avoid starting and then trying to resume a backbuffer render pass.
ScreenRenderFlags flags = UIScreen : : render ( mode ) ;
2023-12-11 11:41:44 +00:00
return flags ;
2020-05-18 03:37:26 +00:00
}
2017-03-15 05:01:18 +00:00
void ReportScreen : : update ( ) {
2016-06-12 14:21:56 +00:00
if ( screenshot_ ) {
if ( includeScreenshot_ ) {
screenshot_ - > SetVisibility ( V_VISIBLE ) ;
} else {
screenshot_ - > SetVisibility ( V_GONE ) ;
}
}
2024-09-17 09:24:22 +00:00
UIDialogScreen : : update ( ) ;
2021-01-31 20:12:54 +00:00
UpdateCRCInfo ( ) ;
2014-02-10 09:24:40 +00:00
}
2018-06-03 19:08:51 +00:00
void ReportScreen : : resized ( ) {
2024-09-17 09:24:22 +00:00
UIDialogScreen : : resized ( ) ;
2018-06-03 19:08:51 +00:00
RecreateViews ( ) ;
}
2014-02-10 09:24:40 +00:00
EventReturn ReportScreen : : HandleChoice ( EventParams & e ) {
2016-09-18 23:33:25 +00:00
if ( overall_ = = ReportingOverallScore : : NONE ) {
2016-06-10 04:07:30 +00:00
graphics_ = 0 ;
speed_ = 0 ;
gameplay_ = 0 ;
ratingEnabled_ = false ;
} else if ( ! ratingEnabled_ ) {
graphics_ = - 1 ;
speed_ = - 1 ;
gameplay_ = - 1 ;
ratingEnabled_ = true ;
}
2017-05-29 16:52:38 +00:00
// Whether enabled before or not, move to Great when Perfect is selected.
if ( overall_ = = ReportingOverallScore : : PERFECT ) {
if ( graphics_ = = - 1 )
graphics_ = 2 ;
if ( speed_ = = - 1 )
speed_ = 2 ;
if ( gameplay_ = = - 1 )
gameplay_ = 2 ;
}
2016-06-12 17:33:33 +00:00
UpdateSubmit ( ) ;
2016-09-18 23:33:25 +00:00
UpdateOverallDescription ( ) ;
2016-06-12 17:33:33 +00:00
return EVENT_DONE ;
}
EventReturn ReportScreen : : HandleReportingChange ( EventParams & e ) {
2016-09-18 23:33:25 +00:00
if ( overall_ = = ReportingOverallScore : : NONE ) {
2016-06-12 17:33:33 +00:00
ratingEnabled_ = false ;
} else {
ratingEnabled_ = enableReporting_ ;
}
if ( reportingNotice_ ) {
reportingNotice_ - > SetTextColor ( enableReporting_ ? 0xFFFFFFFF : 0xFF3030FF ) ;
}
UpdateSubmit ( ) ;
2014-02-10 09:24:40 +00:00
return EVENT_DONE ;
}
void ReportScreen : : CreateViews ( ) {
2023-04-05 22:34:50 +00:00
auto rp = GetI18NCategory ( I18NCat : : REPORTING ) ;
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
2016-06-12 17:33:33 +00:00
Margins actionMenuMargins ( 0 , 20 , 15 , 0 ) ;
Margins contentMargins ( 0 , 20 , 5 , 5 ) ;
2023-02-25 12:09:44 +00:00
float leftColumnWidth = g_display . dp_xres - actionMenuMargins . horiz ( ) - contentMargins . horiz ( ) - 300.0f ;
2016-06-12 17:33:33 +00:00
ViewGroup * leftColumn = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( WRAP_CONTENT , FILL_PARENT , 0.4f , contentMargins ) ) ;
2014-09-27 21:59:37 +00:00
LinearLayout * leftColumnItems = new LinearLayout ( ORIENT_VERTICAL , new LayoutParams ( WRAP_CONTENT , FILL_PARENT ) ) ;
2014-02-10 09:24:40 +00:00
ViewGroup * rightColumn = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( 300 , FILL_PARENT , actionMenuMargins ) ) ;
LinearLayout * rightColumnItems = new LinearLayout ( ORIENT_VERTICAL ) ;
2018-06-03 21:47:49 +00:00
leftColumnItems - > Add ( new TextView ( rp - > T ( " FeedbackDesc " , " How's the emulation? Let us and the community know! " ) , FLAG_WRAP_TEXT , false , new LinearLayoutParams ( Margins ( 12 , 5 , 0 , 5 ) ) ) ) - > SetShadow ( true ) ;
2016-06-12 17:33:33 +00:00
if ( ! Reporting : : IsEnabled ( ) ) {
2023-12-20 09:35:02 +00:00
auto sy = GetI18NCategory ( I18NCat : : SYSTEM ) ;
2018-06-03 21:47:49 +00:00
reportingNotice_ = leftColumnItems - > Add ( new TextView ( rp - > T ( " FeedbackDisabled " , " Compatibility server reports must be enabled. " ) , FLAG_WRAP_TEXT , false , new LinearLayoutParams ( Margins ( 12 , 5 , 0 , 5 ) ) ) ) ;
2016-06-12 17:33:33 +00:00
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 ;
}
2014-02-10 09:24:40 +00:00
2016-07-04 19:19:25 +00:00
# ifdef MOBILE_DEVICE
2021-05-09 16:38:48 +00:00
if ( ! Core_GetPowerSaving ( ) & & ! Reporting : : HasCRC ( gamePath_ ) ) {
2018-06-03 21:47:49 +00:00
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_ ) ;
leftColumnItems - > Add ( crcWarning ) ;
2016-07-25 00:31:41 +00:00
}
2016-07-04 19:19:25 +00:00
# endif
2021-01-31 20:12:54 +00:00
crcInfo_ = new TextView ( " " , FLAG_WRAP_TEXT , false , new LinearLayoutParams ( Margins ( 12 , 5 , 0 , 5 ) ) ) ;
crcInfo_ - > SetShadow ( true ) ;
crcInfo_ - > SetVisibility ( V_GONE ) ;
leftColumnItems - > Add ( crcInfo_ ) ;
2020-05-18 03:37:26 +00:00
if ( tookScreenshot_ & & ! screenshotFilename_ . empty ( ) ) {
2016-06-12 17:33:33 +00:00
leftColumnItems - > Add ( new CheckBox ( & includeScreenshot_ , rp - > T ( " FeedbackIncludeScreen " , " Include a screenshot " ) ) ) - > SetEnabledPtr ( & enableReporting_ ) ;
2020-11-30 12:55:38 +00:00
screenshot_ = leftColumnItems - > Add ( new AsyncImageFileView ( screenshotFilename_ , IS_KEEP_ASPECT , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT , Margins ( 12 , 0 ) ) ) ) ;
2016-06-12 14:21:56 +00:00
} else {
2020-05-18 03:37:26 +00:00
if ( tookScreenshot_ ) {
includeScreenshot_ = false ;
}
2016-06-16 21:46:11 +00:00
screenshot_ = nullptr ;
2016-06-12 14:21:56 +00:00
}
2022-12-11 04:32:12 +00:00
leftColumnItems - > Add ( new CompatRatingChoice ( " Overall " , ( int * ) & overall_ ) ) - > SetEnabledPtrs ( & enableReporting_ ) - > OnChoice . Handle ( this , & ReportScreen : : HandleChoice ) ;
2018-06-03 21:47:49 +00:00
overallDescription_ = leftColumnItems - > Add ( new TextView ( " " , FLAG_WRAP_TEXT , false , new LinearLayoutParams ( Margins ( 10 , 0 ) ) ) ) ;
2018-01-02 06:06:20 +00:00
overallDescription_ - > SetShadow ( true ) ;
2018-06-03 19:08:51 +00:00
UI : : Orientation ratingsOrient = leftColumnWidth > = 750.0f ? ORIENT_HORIZONTAL : ORIENT_VERTICAL ;
2021-02-22 02:41:08 +00:00
UI : : LinearLayout * ratingsHolder = new LinearLayoutList ( ratingsOrient , new LinearLayoutParams ( WRAP_CONTENT , WRAP_CONTENT ) ) ;
2018-06-03 19:08:51 +00:00
leftColumnItems - > Add ( ratingsHolder ) ;
2022-12-11 04:32:12 +00:00
ratingsHolder - > Add ( new RatingChoice ( " Graphics " , & graphics_ ) ) - > SetEnabledPtrs ( & ratingEnabled_ ) - > OnChoice . Handle ( this , & ReportScreen : : HandleChoice ) ;
ratingsHolder - > Add ( new RatingChoice ( " Speed " , & speed_ ) ) - > SetEnabledPtrs ( & ratingEnabled_ ) - > OnChoice . Handle ( this , & ReportScreen : : HandleChoice ) ;
ratingsHolder - > Add ( new RatingChoice ( " Gameplay " , & gameplay_ ) ) - > SetEnabledPtrs ( & ratingEnabled_ ) - > OnChoice . Handle ( this , & ReportScreen : : HandleChoice ) ;
2014-02-10 09:24:40 +00:00
rightColumnItems - > SetSpacing ( 0.0f ) ;
2014-09-27 22:37:53 +00:00
rightColumnItems - > Add ( new Choice ( rp - > T ( " Open Browser " ) ) ) - > OnClick . Handle ( this , & ReportScreen : : HandleBrowser ) ;
2021-01-31 20:12:54 +00:00
showCrcButton_ = new Choice ( rp - > T ( " Show disc CRC " ) ) ;
rightColumnItems - > Add ( showCrcButton_ ) - > OnClick . Handle ( this , & ReportScreen : : HandleShowCRC ) ;
2014-02-10 09:24:40 +00:00
submit_ = new Choice ( rp - > T ( " Submit Feedback " ) ) ;
2014-09-27 22:37:53 +00:00
rightColumnItems - > Add ( submit_ ) - > OnClick . Handle ( this , & ReportScreen : : HandleSubmit ) ;
2016-06-12 17:33:33 +00:00
UpdateSubmit ( ) ;
2016-09-18 23:33:25 +00:00
UpdateOverallDescription ( ) ;
2014-09-27 21:59:37 +00:00
rightColumnItems - > Add ( new Spacer ( 25.0 ) ) ;
2015-07-01 21:26:55 +00:00
rightColumnItems - > Add ( new Choice ( di - > T ( " Back " ) , " " , false , new AnchorLayoutParams ( 150 , WRAP_CONTENT , 10 , NONE , NONE , 10 ) ) ) - > OnClick . Handle < UIScreen > ( this , & UIScreen : : OnBack ) ;
2014-02-10 09:24:40 +00:00
2014-09-27 21:59:37 +00:00
root_ = new LinearLayout ( ORIENT_HORIZONTAL , new LinearLayoutParams ( FILL_PARENT , FILL_PARENT , 1.0f ) ) ;
2014-02-10 09:24:40 +00:00
root_ - > Add ( leftColumn ) ;
root_ - > Add ( rightColumn ) ;
leftColumn - > Add ( leftColumnItems ) ;
rightColumn - > Add ( rightColumnItems ) ;
2021-01-31 20:12:54 +00:00
UpdateCRCInfo ( ) ;
2014-09-27 22:37:53 +00:00
}
2016-06-12 17:33:33 +00:00
void ReportScreen : : UpdateSubmit ( ) {
2016-09-18 23:33:25 +00:00
submit_ - > SetEnabled ( enableReporting_ & & overall_ ! = ReportingOverallScore : : INVALID & & graphics_ > = 0 & & speed_ > = 0 & & gameplay_ > = 0 ) ;
}
2021-01-31 20:12:54 +00:00
void ReportScreen : : UpdateCRCInfo ( ) {
2023-04-05 22:34:50 +00:00
auto rp = GetI18NCategory ( I18NCat : : REPORTING ) ;
2021-01-31 20:12:54 +00:00
std : : string updated ;
2021-05-09 16:38:48 +00:00
if ( Reporting : : HasCRC ( gamePath_ ) ) {
std : : string crc = StringFromFormat ( " %08X " , Reporting : : RetrieveCRC ( gamePath_ ) ) ;
2023-07-16 14:16:47 +00:00
updated = ApplySafeSubstitutions ( rp - > T ( " FeedbackCRCValue " , " Disc CRC: %1 " ) , crc ) ;
2021-01-31 20:12:54 +00:00
} else if ( showCRC_ ) {
updated = rp - > T ( " FeedbackCRCCalculating " , " Disc CRC: Calculating... " ) ;
}
if ( ! updated . empty ( ) ) {
crcInfo_ - > SetText ( updated ) ;
crcInfo_ - > SetVisibility ( V_VISIBLE ) ;
showCrcButton_ - > SetEnabled ( false ) ;
}
}
2016-09-18 23:33:25 +00:00
void ReportScreen : : UpdateOverallDescription ( ) {
2023-04-05 22:34:50 +00:00
auto rp = GetI18NCategory ( I18NCat : : REPORTING ) ;
2024-01-19 12:44:49 +00:00
std : : string_view desc ;
2018-06-03 19:08:51 +00:00
uint32_t c = 0xFFFFFFFF ;
2016-09-18 23:33:25 +00:00
switch ( overall_ ) {
case ReportingOverallScore : : PERFECT : desc = rp - > T ( " Perfect Description " , " Flawless emulation for the entire game - great! " ) ; break ;
case ReportingOverallScore : : PLAYABLE : desc = rp - > T ( " Plays Description " , " Fully playable but might be with glitches " ) ; break ;
2018-06-03 21:50:20 +00:00
case ReportingOverallScore : : INGAME : desc = rp - > T ( " In-game Description " , " Gets into gameplay, but too buggy to complete " ) ; break ;
2016-09-18 23:33:25 +00:00
case ReportingOverallScore : : MENU : desc = rp - > T ( " Menu/Intro Description " , " Can't get into the game itself " ) ; break ;
2018-06-03 19:08:51 +00:00
case ReportingOverallScore : : NONE : desc = rp - > T ( " Nothing Description " , " Completely broken " ) ; c = 0xFF0000FF ; break ;
2016-09-18 23:33:25 +00:00
default : desc = rp - > T ( " Unselected Overall Description " , " How well does this game emulate? " ) ; break ;
}
overallDescription_ - > SetText ( desc ) ;
2018-06-03 19:08:51 +00:00
overallDescription_ - > SetTextColor ( c ) ;
2016-06-12 17:33:33 +00:00
}
2014-09-27 22:37:53 +00:00
EventReturn ReportScreen : : HandleSubmit ( EventParams & e ) {
const char * compat ;
switch ( overall_ ) {
2016-09-18 23:33:25 +00:00
case ReportingOverallScore : : PERFECT : compat = " perfect " ; break ;
case ReportingOverallScore : : PLAYABLE : compat = " playable " ; break ;
case ReportingOverallScore : : INGAME : compat = " ingame " ; break ;
case ReportingOverallScore : : MENU : compat = " menu " ; break ;
case ReportingOverallScore : : NONE : compat = " none " ; break ;
2014-09-27 22:37:53 +00:00
default : compat = " unknown " ; break ;
}
2016-06-12 17:33:33 +00:00
if ( Reporting : : Enable ( enableReporting_ , " report.ppsspp.org " ) ) {
Reporting : : UpdateConfig ( ) ;
2019-02-23 09:49:49 +00:00
g_Config . Save ( " ReportScreen::HandleSubmit " ) ;
2016-06-12 17:33:33 +00:00
}
2021-05-05 23:31:38 +00:00
std : : string filename = tookScreenshot_ & & includeScreenshot_ ? screenshotFilename_ . ToString ( ) : " " ;
2016-06-12 17:00:32 +00:00
Reporting : : ReportCompatibility ( compat , graphics_ + 1 , speed_ + 1 , gameplay_ + 1 , filename ) ;
2017-03-20 00:43:03 +00:00
TriggerFinish ( DR_OK ) ;
2018-06-03 21:47:49 +00:00
screenManager ( ) - > push ( new ReportFinishScreen ( gamePath_ , overall_ ) ) ;
2014-09-27 22:37:53 +00:00
return EVENT_DONE ;
}
EventReturn ReportScreen : : HandleBrowser ( EventParams & e ) {
2019-03-04 05:39:21 +00:00
const std : : string url = " https:// " + Reporting : : ServerHost ( ) + " / " ;
2023-03-21 09:42:23 +00:00
System_LaunchUrl ( LaunchUrlType : : BROWSER_URL , url . c_str ( ) ) ;
2014-09-27 22:37:53 +00:00
return EVENT_DONE ;
2016-06-26 06:11:07 +00:00
}
2021-01-31 20:12:54 +00:00
EventReturn ReportScreen : : HandleShowCRC ( EventParams & e ) {
2021-05-09 16:38:48 +00:00
Reporting : : QueueCRC ( gamePath_ ) ;
2021-01-31 20:12:54 +00:00
showCRC_ = true ;
return EVENT_DONE ;
}
2021-05-05 23:31:38 +00:00
ReportFinishScreen : : ReportFinishScreen ( const Path & gamePath , ReportingOverallScore score )
2024-09-17 09:24:22 +00:00
: UIDialogScreen ( ) , gamePath_ ( gamePath ) , score_ ( score ) {
2016-06-26 06:11:07 +00:00
}
void ReportFinishScreen : : CreateViews ( ) {
2023-04-05 22:34:50 +00:00
auto rp = GetI18NCategory ( I18NCat : : REPORTING ) ;
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
2016-06-26 06:11:07 +00:00
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 ) ;
2018-06-03 21:47:49 +00:00
leftColumnItems - > Add ( new TextView ( rp - > T ( " FeedbackThanks " , " Thanks for your feedback. " ) , FLAG_WRAP_TEXT , false , new LinearLayoutParams ( Margins ( 12 , 5 , 0 , 5 ) ) ) ) - > SetShadow ( true ) ;
if ( score_ = = ReportingOverallScore : : PERFECT | | score_ = = ReportingOverallScore : : PLAYABLE ) {
resultNotice_ = leftColumnItems - > Add ( new TextView ( rp - > T ( " FeedbackDelayInfo " , " Your data is being submitted in the background. " ) , FLAG_WRAP_TEXT , false , new LinearLayoutParams ( Margins ( 12 , 5 , 0 , 5 ) ) ) ) ;
} else {
resultNotice_ = leftColumnItems - > Add ( new TextView ( rp - > T ( " SuggestionsWaiting " , " Submitting and checking other user feedback.. " ) , FLAG_WRAP_TEXT , false , new LinearLayoutParams ( Margins ( 12 , 5 , 0 , 5 ) ) ) ) ;
}
resultNotice_ - > SetShadow ( true ) ;
resultItems_ = new LinearLayout ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT , Margins ( 12 , 5 , 0 , 5 ) ) ) ;
leftColumnItems - > Add ( resultItems_ ) ;
2016-06-26 06:11:07 +00:00
rightColumnItems - > SetSpacing ( 0.0f ) ;
rightColumnItems - > Add ( new Choice ( rp - > T ( " View Feedback " ) ) ) - > OnClick . Handle ( this , & ReportFinishScreen : : HandleViewFeedback ) ;
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 < UIScreen > ( this , & UIScreen : : OnBack ) ;
root_ = new LinearLayout ( ORIENT_HORIZONTAL , new LinearLayoutParams ( FILL_PARENT , FILL_PARENT , 1.0f ) ) ;
root_ - > Add ( leftColumn ) ;
root_ - > Add ( rightColumn ) ;
leftColumn - > Add ( leftColumnItems ) ;
rightColumn - > Add ( rightColumnItems ) ;
}
2017-03-15 05:01:18 +00:00
void ReportFinishScreen : : update ( ) {
2023-04-05 22:34:50 +00:00
auto rp = GetI18NCategory ( I18NCat : : REPORTING ) ;
2016-06-28 05:59:09 +00:00
if ( ! setStatus_ ) {
2017-12-13 22:11:40 +00:00
Reporting : : ReportStatus status = Reporting : : GetStatus ( ) ;
2016-06-28 05:59:09 +00:00
switch ( status ) {
2017-12-13 22:11:40 +00:00
case Reporting : : ReportStatus : : WORKING :
2018-06-03 21:47:49 +00:00
ShowSuggestions ( ) ;
setStatus_ = true ;
2016-06-28 05:59:09 +00:00
break ;
2017-12-13 22:11:40 +00:00
case Reporting : : ReportStatus : : FAILING :
2016-06-28 05:59:09 +00:00
resultNotice_ - > SetText ( rp - > T ( " FeedbackSubmitFail " , " Could not submit data to server. Try updating PPSSPP. " ) ) ;
2018-06-03 21:47:49 +00:00
setStatus_ = true ;
2016-06-28 05:59:09 +00:00
break ;
2017-12-13 22:11:40 +00:00
case Reporting : : ReportStatus : : BUSY :
2016-06-28 05:59:09 +00:00
default :
// Can't update yet.
break ;
}
}
2024-09-17 09:24:22 +00:00
UIDialogScreen : : update ( ) ;
2016-06-28 05:59:09 +00:00
}
2018-06-03 21:47:49 +00:00
void ReportFinishScreen : : ShowSuggestions ( ) {
2023-04-05 22:34:50 +00:00
auto rp = GetI18NCategory ( I18NCat : : REPORTING ) ;
2018-06-03 21:47:49 +00:00
auto suggestions = Reporting : : CompatibilitySuggestions ( ) ;
if ( score_ = = ReportingOverallScore : : PERFECT | | score_ = = ReportingOverallScore : : PLAYABLE ) {
resultNotice_ - > SetText ( rp - > T ( " FeedbackSubmitDone " , " Your data has been submitted. " ) ) ;
} else if ( suggestions . empty ( ) ) {
resultNotice_ - > SetText ( rp - > T ( " SuggestionsNone " , " This game isn't working for other users too. " ) ) ;
} else {
resultNotice_ - > SetText ( rp - > T ( " SuggestionsFound " , " Other users have reported better results. Tap View Feedback for more detail. " ) ) ;
resultItems_ - > Clear ( ) ;
bool shownConfig = false ;
bool valid = false ;
2023-12-12 14:38:50 +00:00
for ( const auto & item : suggestions ) {
2024-01-19 12:44:49 +00:00
std : : string_view suggestion = " " ;
2018-06-03 21:47:49 +00:00
if ( item = = " Upgrade " ) {
suggestion = rp - > T ( " SuggestionUpgrade " , " Upgrade to a newer PPSSPP build " ) ;
2022-12-03 14:29:14 +00:00
} else if ( item = = " Downgrade " ) {
2018-06-03 21:47:49 +00:00
suggestion = rp - > T ( " SuggestionDowngrade " , " Downgrade to an older PPSSPP version (please report this bug) " ) ;
} else if ( item = = " VerifyDisc " ) {
suggestion = rp - > T ( " SuggestionVerifyDisc " , " Check your ISO is a good copy of your disc " ) ;
} else if ( item = = " Config:CPUSpeed:0 " ) {
suggestion = rp - > T ( " SuggestionCPUSpeed0 " , " Disable locked CPU speed setting " ) ;
} else {
bool isConfig = startsWith ( item , " Config: " ) ;
if ( isConfig & & ! shownConfig ) {
suggestion = rp - > T ( " SuggestionConfig " , " See reports on website for good settings " ) ;
shownConfig = true ;
}
// Ignore unknown configs, hopefully we recognized "Upgrade" at least.
}
2024-01-19 12:44:49 +00:00
if ( ! suggestion . empty ( ) ) {
2018-06-03 21:47:49 +00:00
valid = true ;
2024-01-19 12:44:49 +00:00
resultItems_ - > Add ( new TextView ( std : : string ( " - " ) + std : : string ( suggestion ) , FLAG_WRAP_TEXT , false ) ) - > SetShadow ( true ) ;
2018-06-03 21:47:49 +00:00
}
}
if ( ! valid ) {
// No actual valid versions. Let's just say upgrade and hope the server's not broken.
2024-01-19 12:44:49 +00:00
resultItems_ - > Add ( new TextView ( std : : string ( " - " ) + rp - > T_cstr ( " SuggestionUpgrade " , " Upgrade to a newer PPSSPP build " ) , FLAG_WRAP_TEXT , false ) ) - > SetShadow ( true ) ;
2018-06-03 21:47:49 +00:00
}
}
}
2016-06-26 06:11:07 +00:00
UI : : EventReturn ReportFinishScreen : : HandleViewFeedback ( UI : : EventParams & e ) {
2019-03-04 05:39:21 +00:00
const std : : string url = " https:// " + Reporting : : ServerHost ( ) + " /game/ " + Reporting : : CurrentGameID ( ) ;
2023-03-21 09:42:23 +00:00
System_LaunchUrl ( LaunchUrlType : : BROWSER_URL , url . c_str ( ) ) ;
2016-06-26 06:11:07 +00:00
return EVENT_DONE ;
}