2013-08-18 19:51:40 +02:00
// Copyright (c) 2013- PPSSPP Project.
2013-06-08 22:42:31 +02:00
// 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 "gfx_es2/draw_buffer.h"
# include "i18n/i18n.h"
# include "ui/view.h"
# include "ui/viewgroup.h"
2013-07-17 22:27:05 +02:00
# include "ui/ui_context.h"
2013-06-08 22:42:31 +02:00
# include "UI/EmuScreen.h"
# include "UI/PluginScreen.h"
# include "UI/GameSettingsScreen.h"
# include "UI/GameInfoCache.h"
2013-07-17 22:27:05 +02:00
# include "UI/MiscScreens.h"
2013-08-16 16:48:43 +02:00
# include "UI/ControlMappingScreen.h"
2013-06-08 22:42:31 +02:00
# include "Core/Config.h"
2013-07-18 11:39:54 +02:00
# include "android/jni/TestRunner.h"
2013-07-22 07:33:18 +08:00
# include "GPU/GPUInterface.h"
2013-07-30 22:28:34 +08:00
# include "base/colorutil.h"
# include "base/timeutil.h"
# include "math/curves.h"
2013-08-09 06:57:03 -04:00
# include "Core/HW/atrac3plus.h"
2013-08-14 08:44:36 -04:00
# include "Core/System.h"
2013-07-30 22:28:34 +08:00
2013-08-18 02:03:59 +02:00
# ifdef _WIN32
# include "Core/Host.h"
# endif
2013-08-04 03:39:49 -04:00
# ifdef _WIN32
namespace MainWindow {
2013-08-17 07:37:34 -04:00
enum {
WM_USER_LOG_STATUS_CHANGED = WM_USER + 200 ,
WM_USER_ATRAC_STATUS_CHANGED = WM_USER + 300 ,
} ;
2013-08-04 03:39:49 -04:00
extern HWND hwndMain ;
}
# endif
2013-08-17 23:49:06 +02:00
# ifdef IOS
extern bool isJailed ;
# endif
2013-08-04 03:39:49 -04:00
2013-07-17 22:27:05 +02:00
namespace UI {
// Reads and writes value to determine the current selection.
class PopupMultiChoice : public Choice {
public :
2013-07-18 01:04:11 +02:00
PopupMultiChoice ( int * value , const std : : string & text , const char * * choices , int minVal , int numChoices ,
2013-07-17 22:27:05 +02:00
I18NCategory * category , ScreenManager * screenManager , LayoutParams * layoutParams = 0 )
2013-07-18 01:04:11 +02:00
: Choice ( text , " " , false , layoutParams ) , value_ ( value ) , choices_ ( choices ) , minVal_ ( minVal ) , numChoices_ ( numChoices ) ,
2013-07-17 22:27:05 +02:00
category_ ( category ) , screenManager_ ( screenManager ) {
2013-07-18 10:26:29 +02:00
if ( * value < minVal ) * value = minVal ;
2013-07-17 22:27:05 +02:00
OnClick . Handle ( this , & PopupMultiChoice : : HandleClick ) ;
UpdateText ( ) ;
}
virtual void Draw ( UIContext & dc ) ;
private :
void UpdateText ( ) ;
EventReturn HandleClick ( EventParams & e ) ;
void ChoiceCallback ( int num ) ;
2013-07-20 14:05:07 +02:00
int * value_ ;
2013-07-17 22:27:05 +02:00
const char * * choices_ ;
2013-07-18 01:04:11 +02:00
int minVal_ ;
2013-07-20 14:05:07 +02:00
int numChoices_ ;
2013-07-17 22:27:05 +02:00
I18NCategory * category_ ;
2013-07-20 14:05:07 +02:00
ScreenManager * screenManager_ ;
2013-07-17 22:27:05 +02:00
std : : string valueText_ ;
} ;
EventReturn PopupMultiChoice : : HandleClick ( EventParams & e ) {
std : : vector < std : : string > choices ;
2013-07-20 14:05:07 +02:00
for ( int i = 0 ; i < numChoices_ ; i + + ) {
2013-07-17 22:27:05 +02:00
choices . push_back ( category_ ? category_ - > T ( choices_ [ i ] ) : choices_ [ i ] ) ;
}
2013-07-18 01:04:11 +02:00
Screen * popupScreen = new ListPopupScreen ( text_ , choices , * value_ - minVal_ ,
2013-07-17 22:27:05 +02:00
std : : bind ( & PopupMultiChoice : : ChoiceCallback , this , placeholder : : _1 ) ) ;
screenManager_ - > push ( popupScreen ) ;
return EVENT_DONE ;
}
void PopupMultiChoice : : UpdateText ( ) {
2013-07-18 01:04:11 +02:00
valueText_ = category_ ? category_ - > T ( choices_ [ * value_ - minVal_ ] ) : choices_ [ * value_ - minVal_ ] ;
2013-07-17 22:27:05 +02:00
}
void PopupMultiChoice : : ChoiceCallback ( int num ) {
2013-08-17 10:34:38 +02:00
if ( num ! = - 1 ) {
* value_ = num + minVal_ ;
UpdateText ( ) ;
}
2013-07-17 22:27:05 +02:00
}
void PopupMultiChoice : : Draw ( UIContext & dc ) {
Choice : : Draw ( dc ) ;
2013-08-16 16:48:43 +02:00
int paddingX = 12 ;
dc . Draw ( ) - > DrawText ( dc . theme - > uiFont , valueText_ . c_str ( ) , bounds_ . x2 ( ) - paddingX , bounds_ . centerY ( ) , 0xFFFFFFFF , ALIGN_RIGHT | ALIGN_VCENTER ) ;
2013-07-17 22:27:05 +02:00
}
2013-07-18 10:26:29 +02:00
class PopupSliderChoice : public Choice {
public :
PopupSliderChoice ( int * value , int minValue , int maxValue , const std : : string & text , ScreenManager * screenManager , LayoutParams * layoutParams = 0 )
: Choice ( text , " " , false , layoutParams ) , value_ ( value ) , minValue_ ( minValue ) , maxValue_ ( maxValue ) , screenManager_ ( screenManager ) {
OnClick . Handle ( this , & PopupSliderChoice : : HandleClick ) ;
}
void Draw ( UIContext & dc ) ;
private :
EventReturn HandleClick ( EventParams & e ) ;
int * value_ ;
int minValue_ ;
int maxValue_ ;
ScreenManager * screenManager_ ;
} ;
2013-07-20 14:05:07 +02:00
class PopupSliderChoiceFloat : public Choice {
public :
PopupSliderChoiceFloat ( float * value , float minValue , float maxValue , const std : : string & text , ScreenManager * screenManager , LayoutParams * layoutParams = 0 )
: Choice ( text , " " , false , layoutParams ) , value_ ( value ) , minValue_ ( minValue ) , maxValue_ ( maxValue ) , screenManager_ ( screenManager ) {
OnClick . Handle ( this , & PopupSliderChoiceFloat : : HandleClick ) ;
}
void Draw ( UIContext & dc ) ;
private :
EventReturn HandleClick ( EventParams & e ) ;
float * value_ ;
float minValue_ ;
float maxValue_ ;
ScreenManager * screenManager_ ;
} ;
2013-07-18 10:26:29 +02:00
EventReturn PopupSliderChoice : : HandleClick ( EventParams & e ) {
Screen * popupScreen = new SliderPopupScreen ( value_ , minValue_ , maxValue_ , text_ ) ;
screenManager_ - > push ( popupScreen ) ;
return EVENT_DONE ;
2013-07-17 22:27:05 +02:00
}
2013-07-20 14:05:07 +02:00
2013-07-18 10:26:29 +02:00
void PopupSliderChoice : : Draw ( UIContext & dc ) {
Choice : : Draw ( dc ) ;
char temp [ 4 ] ;
sprintf ( temp , " %i " , * value_ ) ;
2013-08-16 16:48:43 +02:00
dc . Draw ( ) - > DrawText ( dc . theme - > uiFont , temp , bounds_ . x2 ( ) - 12 , bounds_ . centerY ( ) , 0xFFFFFFFF , ALIGN_RIGHT | ALIGN_VCENTER ) ;
2013-07-18 10:26:29 +02:00
}
2013-07-20 14:05:07 +02:00
EventReturn PopupSliderChoiceFloat : : HandleClick ( EventParams & e ) {
Screen * popupScreen = new SliderFloatPopupScreen ( value_ , minValue_ , maxValue_ , text_ ) ;
screenManager_ - > push ( popupScreen ) ;
return EVENT_DONE ;
}
void PopupSliderChoiceFloat : : Draw ( UIContext & dc ) {
Choice : : Draw ( dc ) ;
2013-08-13 14:24:26 +08:00
char temp [ 5 ] ;
2013-07-20 14:05:07 +02:00
sprintf ( temp , " %2.2f " , * value_ ) ;
2013-08-16 16:48:43 +02:00
dc . Draw ( ) - > DrawText ( dc . theme - > uiFont , temp , bounds_ . x2 ( ) - 12 , bounds_ . centerY ( ) , 0xFFFFFFFF , ALIGN_RIGHT | ALIGN_VCENTER ) ;
2013-07-20 14:05:07 +02:00
}
2013-07-18 10:26:29 +02:00
}
2013-07-17 22:27:05 +02:00
2013-08-18 18:53:45 +02:00
static const int alternateSpeedTable [ 8 ] = {
15 , 30 , 45 , 60 , 75 , 90 , 120 , 180
} ;
2013-07-20 22:03:52 +08:00
2013-06-08 22:42:31 +02:00
void GameSettingsScreen : : CreateViews ( ) {
GameInfo * info = g_gameInfoCache . GetInfo ( gamePath_ , true ) ;
2013-07-18 01:04:11 +02:00
cap60FPS_ = g_Config . iForceMaxEmulatedFPS = = 60 ;
2013-08-18 18:53:45 +02:00
iAlternateSpeedPercent_ = 3 ;
for ( int i = 0 ; i < 8 ; i + + ) {
if ( g_Config . iFpsLimit < = alternateSpeedTable [ i ] ) {
iAlternateSpeedPercent_ = i ;
break ;
}
}
2013-07-18 01:04:11 +02:00
2013-06-08 22:42:31 +02:00
// Information in the top left.
// Back button to the bottom left.
// Scrolling action menu to the right.
using namespace UI ;
I18NCategory * g = GetI18NCategory ( " General " ) ;
I18NCategory * gs = GetI18NCategory ( " Graphics " ) ;
2013-06-10 22:06:51 +02:00
I18NCategory * c = GetI18NCategory ( " Controls " ) ;
I18NCategory * a = GetI18NCategory ( " Audio " ) ;
I18NCategory * s = GetI18NCategory ( " System " ) ;
2013-08-11 22:25:50 +07:00
I18NCategory * ms = GetI18NCategory ( " MainSettings " ) ;
2013-06-08 22:42:31 +02:00
2013-08-17 13:08:32 +02:00
root_ = new AnchorLayout ( new LayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
2013-06-08 22:42:31 +02:00
2013-07-20 22:03:52 +08:00
ViewGroup * leftColumn = new AnchorLayout ( new LinearLayoutParams ( 1.0f ) ) ;
2013-06-08 22:42:31 +02:00
root_ - > Add ( leftColumn ) ;
2013-08-17 13:08:32 +02:00
root_ - > Add ( new Choice ( g - > T ( " Back " ) , " " , false , new AnchorLayoutParams ( 150 , WRAP_CONTENT , 10 , NONE , NONE , 10 ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnBack ) ;
2013-06-08 22:42:31 +02:00
2013-08-17 13:08:32 +02:00
TabHolder * tabHolder = new TabHolder ( ORIENT_VERTICAL , 200 , new AnchorLayoutParams ( 10 , 0 , 10 , 0 , false ) ) ;
2013-07-22 00:03:54 +08:00
2013-06-08 22:42:31 +02:00
root_ - > Add ( tabHolder ) ;
// TODO: These currently point to global settings, not game specific ones.
2013-07-20 22:03:52 +08:00
// Graphics
2013-06-08 22:42:31 +02:00
ViewGroup * graphicsSettingsScroll = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
ViewGroup * graphicsSettings = new LinearLayout ( ORIENT_VERTICAL ) ;
graphicsSettingsScroll - > Add ( graphicsSettings ) ;
2013-08-11 22:25:50 +07:00
tabHolder - > AddTab ( ms - > T ( " Graphics " ) , graphicsSettingsScroll ) ;
2013-07-22 04:15:18 +08:00
graphicsSettings - > Add ( new ItemHeader ( gs - > T ( " Rendering Mode " ) ) ) ;
# ifndef USING_GLES2
2013-07-26 20:25:11 +08:00
static const char * renderingMode [ ] = { " Non-Buffered Rendering " , " Buffered Rendering " , " Read Framebuffers To Memory(CPU) " , " Read Framebuffers To Memory(GPU) " } ;
2013-07-22 05:06:04 +08:00
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iRenderingMode , gs - > T ( " Mode " ) , renderingMode , 0 , 4 , gs , screenManager ( ) ) ) ;
2013-07-26 20:25:11 +08:00
# else
static const char * renderingMode [ ] = { " Non-Buffered Rendering " , " Buffered Rendering " , " Read Framebuffers To Memory(GPU) " } ;
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iRenderingMode , gs - > T ( " Mode " ) , renderingMode , 0 , 3 , gs , screenManager ( ) ) ) ;
# endif
2013-07-30 21:18:49 +08:00
graphicsSettings - > Add ( new CheckBox ( & g_Config . bAntiAliasing , gs - > T ( " Anti-Aliasing " ) ) ) ;
2013-08-18 19:51:40 +02:00
graphicsSettings - > Add ( new ItemHeader ( gs - > T ( " Frame Rate Control " ) ) ) ;
static const char * frameSkip [ ] = { " Off " , " Auto " , " 1 " , " 2 " , " 3 " , " 4 " , " 5 " , " 6 " , " 7 " , " 8 " } ;
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iFrameSkip , gs - > T ( " Frame Skipping " ) , frameSkip , 0 , 9 , gs , screenManager ( ) ) ) ;
static const char * fpsChoices [ ] = { " None " , " Speed " , " FPS " , " Both " } ;
graphicsSettings - > Add ( new CheckBox ( & cap60FPS_ , gs - > T ( " Force 60 FPS or less (helps GoW) " ) ) ) ;
static const char * customSpeed [ ] = { " 25% " , " 50% " , " 75% " , " 100% " , " 125% " , " 150% " , " 200% " , " 300% " } ;
graphicsSettings - > Add ( new PopupMultiChoice ( & iAlternateSpeedPercent_ , gs - > T ( " Alternative Speed " ) , customSpeed , 0 , 8 , 0 , screenManager ( ) ) ) ;
2013-07-17 22:27:05 +02:00
graphicsSettings - > Add ( new ItemHeader ( gs - > T ( " Features " ) ) ) ;
2013-07-20 22:03:52 +08:00
graphicsSettings - > Add ( new CheckBox ( & g_Config . bHardwareTransform , gs - > T ( " Hardware Transform " ) ) ) ;
graphicsSettings - > Add ( new CheckBox ( & g_Config . bVertexCache , gs - > T ( " Vertex Cache " ) ) ) ;
2013-06-08 22:42:31 +02:00
graphicsSettings - > Add ( new CheckBox ( & g_Config . bStretchToDisplay , gs - > T ( " Stretch to Display " ) ) ) ;
graphicsSettings - > Add ( new CheckBox ( & g_Config . bMipMap , gs - > T ( " Mipmapping " ) ) ) ;
2013-08-18 19:51:40 +02:00
// This setting is not really useful for anyone atm.
// graphicsSettings->Add(new CheckBox(&g_Config.bTrueColor, gs->T("True Color")));
2013-07-20 22:03:52 +08:00
# ifdef _WIN32
graphicsSettings - > Add ( new CheckBox ( & g_Config . bVSync , gs - > T ( " VSync " ) ) ) ;
graphicsSettings - > Add ( new CheckBox ( & g_Config . bFullScreen , gs - > T ( " FullScreen " ) ) ) ;
2013-07-20 04:45:49 -04:00
# endif
2013-08-18 18:53:45 +02:00
2013-08-18 19:51:40 +02:00
graphicsSettings - > Add ( new ItemHeader ( gs - > T ( " Overlay Information " ) ) ) ;
2013-07-20 22:03:52 +08:00
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iShowFPSCounter , gs - > T ( " Show FPS Counter " ) , fpsChoices , 0 , 4 , gs , screenManager ( ) ) ) ;
graphicsSettings - > Add ( new CheckBox ( & g_Config . bShowDebugStats , gs - > T ( " Show Debug Statistics " ) ) ) ;
2013-07-27 21:31:47 +08:00
2013-07-20 22:03:52 +08:00
graphicsSettings - > Add ( new ItemHeader ( gs - > T ( " Texture Scaling " ) ) ) ;
2013-07-17 22:27:05 +02:00
# ifndef USING_GLES2
2013-07-26 20:25:11 +08:00
static const char * texScaleLevels [ ] = { " Off " , " 2x " , " 3x " , " 4x " , " 5x " } ;
2013-07-20 22:03:52 +08:00
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iTexScalingLevel , gs - > T ( " Upscale Level " ) , texScaleLevels , 1 , 5 , gs , screenManager ( ) ) ) ;
2013-07-26 20:25:11 +08:00
# else
static const char * texScaleLevels [ ] = { " Off " , " 2x " , " 3x " } ;
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iTexScalingLevel , gs - > T ( " Upscale Level " ) , texScaleLevels , 1 , 3 , gs , screenManager ( ) ) ) ;
# endif
2013-07-18 01:04:11 +02:00
static const char * texScaleAlgos [ ] = { " xBRZ " , " Hybrid " , " Bicubic " , " Hybrid + Bicubic " , } ;
2013-07-20 22:03:52 +08:00
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iTexScalingType , gs - > T ( " Upscale Type " ) , texScaleAlgos , 0 , 4 , gs , screenManager ( ) ) ) ;
2013-07-26 20:25:11 +08:00
graphicsSettings - > Add ( new CheckBox ( & g_Config . bTexDeposterize , gs - > T ( " Deposterize " ) ) ) ;
2013-07-20 22:03:52 +08:00
graphicsSettings - > Add ( new ItemHeader ( gs - > T ( " Texture Filtering " ) ) ) ;
2013-08-16 12:52:16 +02:00
static const char * anisoLevels [ ] = { " Off " , " 2x " , " 4x " , " 8x " , " 16x " } ;
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iAnisotropyLevel , gs - > T ( " Anisotropic Filtering " ) , anisoLevels , 0 , 5 , gs , screenManager ( ) ) ) ;
2013-07-26 20:25:11 +08:00
static const char * texFilters [ ] = { " Auto " , " Nearest " , " Linear " , " Linear on FMV " , } ;
2013-08-16 12:52:16 +02:00
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iTexFiltering , gs - > T ( " Texture Filter " ) , texFilters , 1 , 4 , gs , screenManager ( ) ) ) ;
2013-07-17 22:27:05 +02:00
2013-08-18 19:51:40 +02:00
// Developer tools are not accessible ingame, so it goes here
graphicsSettings - > Add ( new ItemHeader ( gs - > T ( " Debugging " ) ) ) ;
graphicsSettings - > Add ( new Choice ( gs - > T ( " Dump next frame to log " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnDumpNextFrameToLog ) ;
2013-07-20 22:03:52 +08:00
// Audio
2013-06-08 22:42:31 +02:00
ViewGroup * audioSettingsScroll = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
ViewGroup * audioSettings = new LinearLayout ( ORIENT_VERTICAL ) ;
audioSettingsScroll - > Add ( audioSettings ) ;
2013-08-11 22:25:50 +07:00
tabHolder - > AddTab ( ms - > T ( " Audio " ) , audioSettingsScroll ) ;
2013-08-09 06:57:03 -04:00
std : : string atracString ;
atracString . assign ( Atrac3plus_Decoder : : IsInstalled ( ) ? " Redownload Atrac3+ plugin " : " Download Atrac3+ plugin " ) ;
audioSettings - > Add ( new Choice ( a - > T ( atracString . c_str ( ) ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnDownloadPlugin ) ;
2013-08-09 08:04:13 -04:00
audioSettings - > Add ( new PopupSliderChoice ( & g_Config . iSFXVolume , 0 , 8 , a - > T ( " SFX volume " ) , screenManager ( ) ) ) ;
2013-07-21 12:11:10 +02:00
audioSettings - > Add ( new PopupSliderChoice ( & g_Config . iBGMVolume , 0 , 8 , a - > T ( " BGM volume " ) , screenManager ( ) ) ) ;
2013-07-20 22:03:52 +08:00
2013-08-16 19:34:44 +02:00
audioSettings - > Add ( new CheckBox ( & g_Config . bEnableSound , a - > T ( " Enable Sound " ) ) ) ;
audioSettings - > Add ( new CheckBox ( & g_Config . bEnableAtrac3plus , a - > T ( " Enable Atrac3+ " ) ) ) ;
2013-07-20 22:03:52 +08:00
// Control
2013-06-09 12:41:12 +02:00
ViewGroup * controlsSettingsScroll = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
2013-06-10 22:06:51 +02:00
ViewGroup * controlsSettings = new LinearLayout ( ORIENT_VERTICAL ) ;
2013-06-09 12:41:12 +02:00
controlsSettingsScroll - > Add ( controlsSettings ) ;
2013-08-11 22:25:50 +07:00
tabHolder - > AddTab ( ms - > T ( " Controls " ) , controlsSettingsScroll ) ;
2013-07-29 08:15:30 +08:00
controlsSettings - > Add ( new Choice ( gs - > T ( " Control Mapping " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnControlMapping ) ;
2013-08-16 19:34:44 +02:00
controlsSettings - > Add ( new CheckBox ( & g_Config . bShowTouchControls , c - > T ( " OnScreen " , " On-Screen Touch Controls " ) ) ) ;
2013-08-10 19:23:50 +02:00
controlsSettings - > Add ( new PopupSliderChoice ( & g_Config . iTouchButtonOpacity , 0 , 85 , c - > T ( " Button Opacity " ) , screenManager ( ) ) ) ;
2013-08-13 14:24:26 +08:00
controlsSettings - > Add ( new PopupSliderChoiceFloat ( & g_Config . fButtonScale , 1.15 , 2.05 , c - > T ( " Button Scaling " ) , screenManager ( ) ) ) ;
2013-08-16 19:34:44 +02:00
controlsSettings - > Add ( new CheckBox ( & g_Config . bShowAnalogStick , c - > T ( " Show Left Analog Stick " ) ) ) ;
controlsSettings - > Add ( new CheckBox ( & g_Config . bAccelerometerToAnalogHoriz , c - > T ( " Tilt " , " Tilt to Analog (horizontal) " ) ) ) ;
2013-07-29 08:15:30 +08:00
2013-07-20 22:03:52 +08:00
// System
2013-06-09 12:41:12 +02:00
ViewGroup * systemSettingsScroll = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
ViewGroup * systemSettings = new LinearLayout ( ORIENT_VERTICAL ) ;
systemSettingsScroll - > Add ( systemSettings ) ;
2013-08-11 22:25:50 +07:00
tabHolder - > AddTab ( ms - > T ( " System " ) , systemSettingsScroll ) ;
2013-08-17 23:49:06 +02:00
2013-08-18 19:51:40 +02:00
systemSettings - > Add ( new ItemHeader ( s - > T ( " Emulation " ) ) ) ;
systemSettings - > Add ( new CheckBox ( & g_Config . bFastMemory , s - > T ( " Fast Memory " , " Fast Memory (Unstable) " ) ) ) ;
2013-08-17 23:49:06 +02:00
# ifdef IOS
if ( isJailed ) {
systemSettings - > Add ( new TextView ( s - > T ( " DynarecisJailed " , " Dynarec (JIT) - (Not jailbroken - JIT not available) " ) ) ) ;
} else {
systemSettings - > Add ( new CheckBox ( & g_Config . bJit , s - > T ( " Dynarec " , " Dynarec (JIT) " ) ) ) ;
}
# else
2013-06-10 22:06:51 +02:00
systemSettings - > Add ( new CheckBox ( & g_Config . bJit , s - > T ( " Dynarec " , " Dynarec (JIT) " ) ) ) ;
2013-08-17 23:49:06 +02:00
# endif
2013-08-18 19:57:50 +02:00
2013-08-16 19:34:44 +02:00
systemSettings - > Add ( new CheckBox ( & g_Config . bSeparateCPUThread , s - > T ( " Multithreaded (experimental) " ) ) ) ;
systemSettings - > Add ( new PopupSliderChoice ( & g_Config . iLockedCPUSpeed , 0 , 1000 , gs - > T ( " Change CPU Clock " , " Change CPU Clock (0 = default) " ) , screenManager ( ) ) ) ;
2013-08-18 19:51:40 +02:00
2013-08-18 20:08:28 +02:00
# ifndef ANDROID
2013-08-18 19:57:50 +02:00
systemSettings - > Add ( new ItemHeader ( s - > T ( " Cheats " , " Cheats (experimental, see forums) " ) ) ) ;
systemSettings - > Add ( new Choice ( s - > T ( " Reload Cheats " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnReloadCheats ) ;
2013-08-18 20:08:28 +02:00
# endif
2013-08-18 19:57:50 +02:00
2013-08-18 19:51:40 +02:00
systemSettings - > Add ( new ItemHeader ( s - > T ( " PSP Settings " ) ) ) ;
2013-07-22 05:06:04 +08:00
systemSettings - > Add ( new CheckBox ( & g_Config . bDayLightSavings , s - > T ( " Day Light Saving " ) ) ) ;
2013-07-22 04:15:18 +08:00
static const char * dateFormat [ ] = { " YYYYMMDD " , " MMDDYYYY " , " DDMMYYYY " } ;
2013-07-22 05:06:04 +08:00
systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iDateFormat , gs - > T ( " Date Format " ) , dateFormat , 1 , 3 , s , screenManager ( ) ) ) ;
2013-07-22 04:15:18 +08:00
static const char * timeFormat [ ] = { " 12HR " , " 24HR " } ;
2013-07-22 05:06:04 +08:00
systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iTimeFormat , gs - > T ( " Time Format " ) , timeFormat , 1 , 2 , s , screenManager ( ) ) ) ;
static const char * buttonPref [ ] = { " Use X to confirm " , " Use O to confirm " } ;
2013-08-16 19:34:44 +02:00
systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iButtonPreference , gs - > T ( " Confirmation Button " ) , buttonPref , 1 , 2 , s , screenManager ( ) ) ) ;
2013-06-08 22:42:31 +02:00
}
2013-08-18 19:57:50 +02:00
UI : : EventReturn GameSettingsScreen : : OnReloadCheats ( UI : : EventParams & e ) {
// Hmm, strange mechanism.
g_Config . bReloadCheats = true ;
return UI : : EVENT_DONE ;
}
2013-07-30 22:28:34 +08:00
void DrawBackground ( float alpha ) ;
2013-08-18 19:51:40 +02:00
UI : : EventReturn GameSettingsScreen : : OnDumpNextFrameToLog ( UI : : EventParams & e ) {
gpu - > DumpNextFrame ( ) ;
return UI : : EVENT_DONE ;
}
2013-07-30 22:28:34 +08:00
void GameSettingsScreen : : DrawBackground ( UIContext & dc ) {
GameInfo * ginfo = g_gameInfoCache . GetInfo ( gamePath_ , true ) ;
dc . Flush ( ) ;
dc . RebindTexture ( ) ;
: : DrawBackground ( 1.0f ) ;
dc . Flush ( ) ;
if ( ginfo & & ginfo - > pic1Texture ) {
ginfo - > pic1Texture - > Bind ( 0 ) ;
uint32_t color = whiteAlpha ( ease ( ( time_now_d ( ) - ginfo - > timePic1WasLoaded ) * 3 ) ) & 0xFFc0c0c0 ;
dc . Draw ( ) - > DrawTexRect ( 0 , 0 , dp_xres , dp_yres , 0 , 0 , 1 , 1 , color ) ;
dc . Flush ( ) ;
dc . RebindTexture ( ) ;
}
/*
if ( ginfo & & ginfo - > pic0Texture ) {
ginfo - > pic0Texture - > Bind ( 0 ) ;
// Pic0 is drawn in the bottom right corner, overlaying pic1.
float sizeX = dp_xres / 480 * ginfo - > pic0Texture - > Width ( ) ;
float sizeY = dp_yres / 272 * ginfo - > pic0Texture - > Height ( ) ;
uint32_t color = whiteAlpha ( ease ( ( time_now_d ( ) - ginfo - > timePic1WasLoaded ) * 2 ) ) & 0xFFc0c0c0 ;
ui_draw2d . DrawTexRect ( dp_xres - sizeX , dp_yres - sizeY , dp_xres , dp_yres , 0 , 0 , 1 , 1 , color ) ;
ui_draw2d . Flush ( ) ;
dc . RebindTexture ( ) ;
} */
}
2013-08-10 11:34:27 +02:00
2013-07-21 13:31:46 +02:00
void GameSettingsScreen : : update ( InputState & input ) {
UIScreen : : update ( input ) ;
2013-07-18 01:04:11 +02:00
g_Config . iForceMaxEmulatedFPS = cap60FPS_ ? 60 : 0 ;
2013-08-18 18:53:45 +02:00
g_Config . iFpsLimit = alternateSpeedTable [ iAlternateSpeedPercent_ ] ;
2013-07-17 22:27:05 +02:00
}
2013-08-18 19:51:40 +02:00
UI : : EventReturn GameSettingsScreen : : OnDownloadPlugin ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new PluginScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2013-08-14 08:44:36 -04:00
UI : : EventReturn GameSettingsScreen : : OnBack ( UI : : EventParams & e ) {
screenManager ( ) - > finishDialog ( this , DR_OK ) ;
2013-08-14 08:55:31 -04:00
if ( g_Config . bEnableSound ) {
if ( PSP_IsInited ( ) & & ! IsAudioInitialised ( ) )
Audio_Init ( ) ;
2013-08-14 08:44:36 -04:00
}
2013-08-14 14:36:54 -04:00
// It doesn't matter if audio is inited or not, it'll still output no sound
// if the mixer isn't available, so go ahead and init/shutdown at our leisure.
if ( Atrac3plus_Decoder : : IsInstalled ( ) ) {
if ( g_Config . bEnableAtrac3plus )
Atrac3plus_Decoder : : Init ( ) ;
else Atrac3plus_Decoder : : Shutdown ( ) ;
}
2013-08-17 07:37:34 -04:00
# ifdef _WIN32
PostMessage ( MainWindow : : hwndMain , MainWindow : : WM_USER_ATRAC_STATUS_CHANGED , 0 , 0 ) ;
# endif
2013-08-14 08:44:36 -04:00
return UI : : EVENT_DONE ;
}
2013-07-17 22:27:05 +02:00
void GlobalSettingsScreen : : CreateViews ( ) {
using namespace UI ;
root_ = new ScrollView ( ORIENT_VERTICAL ) ;
2013-07-18 11:39:54 +02:00
enableReports_ = g_Config . sReportHost ! = " " ;
2013-07-17 22:27:05 +02:00
I18NCategory * g = GetI18NCategory ( " General " ) ;
I18NCategory * gs = GetI18NCategory ( " Graphics " ) ;
LinearLayout * list = root_ - > Add ( new LinearLayout ( ORIENT_VERTICAL , new LinearLayoutParams ( 1.0f ) ) ) ;
2013-08-13 18:18:01 +07:00
list - > Add ( new ItemHeader ( g - > T ( " General " ) ) ) ;
2013-08-09 08:04:13 -04:00
list - > Add ( new CheckBox ( & enableReports_ , gs - > T ( " Enable Compatibility Server Reports " ) ) ) ;
2013-08-17 23:49:06 +02:00
# ifndef ANDROID
// Need to move the cheat config dir somewhere where it can be read/written on android
2013-07-22 05:24:29 +08:00
list - > Add ( new CheckBox ( & g_Config . bEnableCheats , gs - > T ( " Enable Cheats " ) ) ) ;
2013-08-17 23:49:06 +02:00
# endif
# ifdef _WIN32
// Screenshot functionality is not yet available on non-Windows
2013-07-22 05:24:29 +08:00
list - > Add ( new CheckBox ( & g_Config . bScreenshotsAsPNG , gs - > T ( " Screenshots as PNG " ) ) ) ;
2013-08-17 23:49:06 +02:00
# endif
2013-08-18 02:03:59 +02:00
// TODO: Come up with a way to display a keyboard for mobile users,
// so until then, this is Windows/Desktop only.
# ifdef _WIN32
list - > Add ( new Choice ( g - > T ( " Change Nickname " ) ) ) - > OnClick . Handle ( this , & GlobalSettingsScreen : : OnChangeNickname ) ;
# endif
2013-07-20 22:03:52 +08:00
list - > Add ( new Choice ( gs - > T ( " System Language " ) ) ) - > OnClick . Handle ( this , & GlobalSettingsScreen : : OnLanguage ) ;
2013-07-18 11:39:54 +02:00
list - > Add ( new Choice ( gs - > T ( " Developer Tools " ) ) ) - > OnClick . Handle ( this , & GlobalSettingsScreen : : OnDeveloperTools ) ;
2013-07-17 22:27:05 +02:00
list - > Add ( new Choice ( g - > T ( " Back " ) ) ) - > OnClick . Handle ( this , & GlobalSettingsScreen : : OnBack ) ;
}
2013-08-18 02:03:59 +02:00
UI : : EventReturn GlobalSettingsScreen : : OnChangeNickname ( UI : : EventParams & e ) {
# ifdef _WIN32
const size_t name_len = 256 ;
char name [ name_len ] ;
memset ( name , 0 , sizeof ( name ) ) ;
if ( host - > InputBoxGetString ( " Enter a new PSP nickname " , " PPSSPP " , name , name_len ) ) {
g_Config . sNickName = name ;
}
# endif
return UI : : EVENT_DONE ;
}
2013-07-17 22:27:05 +02:00
UI : : EventReturn GlobalSettingsScreen : : OnFactoryReset ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new PluginScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
UI : : EventReturn GlobalSettingsScreen : : OnLanguage ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new NewLanguageScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2013-07-18 11:39:54 +02:00
UI : : EventReturn GlobalSettingsScreen : : OnDeveloperTools ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new DeveloperToolsScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2013-07-29 08:15:30 +08:00
UI : : EventReturn GameSettingsScreen : : OnControlMapping ( UI : : EventParams & e ) {
2013-08-17 10:34:38 +02:00
screenManager ( ) - > push ( new ControlMappingScreen ( ) ) ;
2013-07-23 00:06:07 +02:00
return UI : : EVENT_DONE ;
}
2013-07-17 22:27:05 +02:00
UI : : EventReturn GlobalSettingsScreen : : OnBack ( UI : : EventParams & e ) {
screenManager ( ) - > finishDialog ( this , DR_OK ) ;
2013-07-18 11:39:54 +02:00
g_Config . sReportHost = enableReports_ ? " report.ppsspp.org " : " " ;
2013-07-18 01:04:11 +02:00
g_Config . Save ( ) ;
2013-07-17 22:27:05 +02:00
return UI : : EVENT_DONE ;
}
2013-07-18 11:39:54 +02:00
void DeveloperToolsScreen : : CreateViews ( ) {
using namespace UI ;
root_ = new ScrollView ( ORIENT_VERTICAL ) ;
2013-08-04 04:45:09 -04:00
enableLogging_ = g_Config . bEnableLogging ;
2013-07-18 11:39:54 +02:00
I18NCategory * g = GetI18NCategory ( " General " ) ;
I18NCategory * d = GetI18NCategory ( " Developer " ) ;
2013-08-17 13:21:17 +02:00
I18NCategory * gs = GetI18NCategory ( " Graphics " ) ;
2013-07-20 12:06:06 +02:00
I18NCategory * a = GetI18NCategory ( " Audio " ) ;
2013-07-18 11:39:54 +02:00
LinearLayout * list = root_ - > Add ( new LinearLayout ( ORIENT_VERTICAL , new LinearLayoutParams ( 1.0f ) ) ) ;
list - > Add ( new ItemHeader ( g - > T ( " General " ) ) ) ;
2013-08-18 00:41:19 +02:00
list - > Add ( new Choice ( g - > T ( " System Information " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnSysInfo ) ;
2013-07-18 11:39:54 +02:00
list - > Add ( new Choice ( d - > T ( " Run CPU Tests " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnRunCPUTests ) ;
2013-08-18 18:07:15 +10:00
# ifndef __SYMBIAN32__
2013-08-17 13:21:17 +02:00
list - > Add ( new CheckBox ( & g_Config . bSoftwareRendering , gs - > T ( " Software Rendering " , " Software Rendering (experimental) " ) ) ) ;
2013-08-18 18:07:15 +10:00
# endif
2013-08-18 01:24:34 +02:00
list - > Add ( new CheckBox ( & enableLogging_ , d - > T ( " Enable Logging " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnLoggingChanged ) ;
2013-08-18 19:51:40 +02:00
list - > Add ( new Choice ( d - > T ( " Load language ini " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnLoadLanguageIni ) ;
list - > Add ( new Choice ( d - > T ( " Save language ini " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnSaveLanguageIni ) ;
2013-07-18 11:39:54 +02:00
list - > Add ( new Choice ( g - > T ( " Back " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnBack ) ;
}
UI : : EventReturn DeveloperToolsScreen : : OnBack ( UI : : EventParams & e ) {
screenManager ( ) - > finishDialog ( this , DR_OK ) ;
2013-08-04 04:45:09 -04:00
g_Config . bEnableLogging = enableLogging_ ;
# ifdef _WIN32
PostMessage ( MainWindow : : hwndMain , MainWindow : : WM_USER_LOG_STATUS_CHANGED , 0 , 0 ) ;
# endif
g_Config . Save ( ) ;
2013-07-18 11:39:54 +02:00
return UI : : EVENT_DONE ;
}
2013-08-18 01:24:34 +02:00
UI : : EventReturn DeveloperToolsScreen : : OnLoggingChanged ( UI : : EventParams & e ) {
2013-08-18 01:41:41 +02:00
# ifdef _WIN32
2013-08-18 01:24:34 +02:00
PostMessage ( MainWindow : : hwndMain , MainWindow : : WM_USER_LOG_STATUS_CHANGED , 0 , 0 ) ;
2013-08-18 01:41:41 +02:00
# endif
2013-08-18 01:24:34 +02:00
return UI : : EVENT_DONE ;
}
2013-08-18 00:41:19 +02:00
UI : : EventReturn DeveloperToolsScreen : : OnSysInfo ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new SystemInfoScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2013-07-18 11:39:54 +02:00
UI : : EventReturn DeveloperToolsScreen : : OnRunCPUTests ( UI : : EventParams & e ) {
RunTests ( ) ;
return UI : : EVENT_DONE ;
}
2013-07-20 12:06:06 +02:00
2013-08-18 19:51:40 +02:00
UI : : EventReturn DeveloperToolsScreen : : OnSaveLanguageIni ( UI : : EventParams & e ) {
i18nrepo . SaveIni ( g_Config . languageIni ) ;
return UI : : EVENT_DONE ;
}
UI : : EventReturn DeveloperToolsScreen : : OnLoadLanguageIni ( UI : : EventParams & e ) {
i18nrepo . LoadIni ( g_Config . languageIni ) ;
2013-07-20 12:06:06 +02:00
return UI : : EVENT_DONE ;
}