2017-04-26 14:48:55 +00:00
// Copyright (c) 2013- PPSSPP Project.
2013-06-08 20:42:31 +00: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/.
2017-02-24 19:50:27 +00:00
# include "ppsspp_config.h"
2020-09-14 22:34:45 +00:00
# include <algorithm>
2021-04-11 01:35:23 +00:00
# include <set>
2020-09-14 22:34:45 +00:00
2020-10-04 18:48:47 +00:00
# include "Common/Net/Resolve.h"
2020-10-04 21:24:14 +00:00
# include "Common/GPU/OpenGL/GLFeatures.h"
# include "Common/Render/DrawBuffer.h"
2020-10-04 18:48:47 +00:00
# include "Common/UI/Root.h"
# include "Common/UI/View.h"
# include "Common/UI/ViewGroup.h"
# include "Common/UI/Context.h"
2022-08-28 12:49:27 +00:00
# include "Common/VR/PPSSPPVR.h"
2020-10-04 08:30:18 +00:00
# include "Common/System/Display.h" // Only to check screen aspect ratio with pixel_yres/pixel_xres
2023-03-22 11:26:14 +00:00
# include "Common/System/Request.h"
2023-01-27 08:19:29 +00:00
# include "Common/Battery/Battery.h"
2020-10-04 08:30:18 +00:00
# include "Common/System/NativeApp.h"
# include "Common/Data/Color/RGBAUtil.h"
# include "Common/Math/curves.h"
# include "Common/Data/Text/I18n.h"
# include "Common/Data/Encoding/Utf8.h"
2013-06-08 20:42:31 +00:00
# include "UI/EmuScreen.h"
# include "UI/GameSettingsScreen.h"
# include "UI/GameInfoCache.h"
2013-11-29 15:46:47 +00:00
# include "UI/GamepadEmu.h"
2013-07-17 20:27:05 +00:00
# include "UI/MiscScreens.h"
2013-08-16 14:48:43 +00:00
# include "UI/ControlMappingScreen.h"
2013-09-07 11:38:37 +00:00
# include "UI/DevScreens.h"
2015-10-24 12:40:29 +00:00
# include "UI/DisplayLayoutScreen.h"
2016-07-03 17:24:33 +00:00
# include "UI/RemoteISOScreen.h"
2015-06-12 18:37:42 +00:00
# include "UI/SavedataScreen.h"
2013-10-09 20:15:56 +00:00
# include "UI/TouchControlLayoutScreen.h"
2013-10-20 02:40:52 +00:00
# include "UI/TouchControlVisibilityScreen.h"
2013-10-27 17:58:47 +00:00
# include "UI/TiltAnalogSettingsScreen.h"
2018-12-16 20:48:35 +00:00
# include "UI/GPUDriverTestScreen.h"
2021-04-24 20:47:57 +00:00
# include "UI/MemStickScreen.h"
2022-02-11 11:32:23 +00:00
# include "UI/Theme.h"
2023-06-16 14:29:44 +00:00
# include "UI/RetroAchievementScreens.h"
2013-09-07 11:38:37 +00:00
2020-10-04 18:48:47 +00:00
# include "Common/File/FileUtil.h"
2023-05-16 12:34:28 +00:00
# include "Common/File/AndroidContentURI.h"
2017-02-14 09:33:42 +00:00
# include "Common/OSVersion.h"
2020-09-29 10:19:22 +00:00
# include "Common/TimeUtil.h"
# include "Common/StringUtils.h"
2013-06-08 20:42:31 +00:00
# include "Core/Config.h"
2018-06-17 01:42:31 +00:00
# include "Core/ConfigValues.h"
2020-10-03 22:25:21 +00:00
# include "Core/KeyMap.h"
2023-02-01 14:04:32 +00:00
# include "Core/TiltEventProcessor.h"
2020-08-06 08:19:58 +00:00
# include "Core/Instance.h"
2013-08-14 12:44:36 +00:00
# include "Core/System.h"
2013-09-01 19:57:39 +00:00
# include "Core/Reporting.h"
2018-04-21 21:17:33 +00:00
# include "Core/WebServer.h"
2020-01-09 13:57:09 +00:00
# include "Core/HLE/sceUsbCam.h"
2020-07-31 02:24:17 +00:00
# include "Core/HLE/sceUsbMic.h"
2023-03-09 20:11:53 +00:00
# include "GPU/Common/TextureReplacer.h"
2018-03-25 12:26:44 +00:00
# include "GPU/Common/PostShader.h"
2013-10-17 14:15:04 +00:00
# include "android/jni/TestRunner.h"
# include "GPU/GPUInterface.h"
2020-08-03 21:17:22 +00:00
# include "GPU/Common/FramebufferManagerCommon.h"
2013-07-30 14:28:34 +00:00
2023-01-22 17:32:34 +00:00
# if PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS)
2023-01-31 10:36:14 +00:00
# include "UI/DarwinFileSystemServices.h"
2023-01-22 17:32:34 +00:00
# endif
2017-02-24 23:25:46 +00:00
# if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
2015-09-17 20:02:15 +00:00
# pragma warning(disable:4091) // workaround bug in VS2015 headers
2015-09-19 11:14:05 +00:00
# include "Windows/MainWindow.h"
2014-10-23 14:22:11 +00:00
# include <shlobj.h>
2014-10-27 18:57:40 +00:00
# include "Windows/W32Util/ShellUtil.h"
2017-02-24 19:50:27 +00:00
# endif
2014-10-23 14:22:11 +00:00
2021-06-14 22:23:45 +00:00
# if PPSSPP_PLATFORM(ANDROID)
# include "android/jni/AndroidAudio.h"
extern AndroidAudioState * g_audioState ;
# endif
2021-05-05 23:31:38 +00:00
GameSettingsScreen : : GameSettingsScreen ( const Path & gamePath , std : : string gameID , bool editThenRestore )
2023-06-16 11:44:35 +00:00
: TabbedUIDialogScreenWithGameBackground ( gamePath ) , gameID_ ( gameID ) , editThenRestore_ ( editThenRestore ) {
2020-03-03 03:21:15 +00:00
prevInflightFrames_ = g_Config . iInflightFrames ;
2023-03-29 09:59:31 +00:00
analogSpeedMapped_ = KeyMap : : InputMappingsFromPspButton ( VIRTKEY_SPEED_ANALOG , nullptr , true ) ;
2014-07-22 08:37:20 +00:00
}
2017-01-31 14:29:13 +00:00
// This needs before run CheckGPUFeatures()
// TODO: Remove this if fix the issue
2018-09-22 10:20:30 +00:00
bool CheckSupportShaderTessellationGLES ( ) {
2017-02-24 19:50:27 +00:00
# if PPSSPP_PLATFORM(UWP)
return true ;
# else
// TODO: Make work with non-GL backends
2018-01-19 23:05:59 +00:00
int maxVertexTextureImageUnits = gl_extensions . maxVertexTextureUnits ;
2017-01-31 14:29:13 +00:00
bool vertexTexture = maxVertexTextureImageUnits > = 3 ; // At least 3 for hardware tessellation
2017-03-26 10:00:20 +00:00
2017-03-12 15:41:28 +00:00
bool textureFloat = gl_extensions . ARB_texture_float | | gl_extensions . OES_texture_float ;
2017-12-22 02:44:47 +00:00
bool hasTexelFetch = gl_extensions . GLES3 | | ( ! gl_extensions . IsGLES & & gl_extensions . VersionGEThan ( 3 , 3 , 0 ) ) | | gl_extensions . EXT_gpu_shader4 ;
2017-01-31 14:29:13 +00:00
2018-09-22 10:20:30 +00:00
return vertexTexture & & textureFloat & & hasTexelFetch ;
2017-02-24 19:50:27 +00:00
# endif
2017-01-31 14:29:13 +00:00
}
2018-01-19 23:05:59 +00:00
bool DoesBackendSupportHWTess ( ) {
2017-12-26 23:55:24 +00:00
switch ( GetGPUBackend ( ) ) {
case GPUBackend : : OPENGL :
2018-09-22 10:20:30 +00:00
return CheckSupportShaderTessellationGLES ( ) ;
2017-12-26 23:55:24 +00:00
case GPUBackend : : VULKAN :
case GPUBackend : : DIRECT3D11 :
2017-03-04 13:46:55 +00:00
return true ;
2018-06-17 18:30:22 +00:00
default :
return false ;
2017-03-04 13:46:55 +00:00
}
}
2020-08-02 04:26:41 +00:00
static bool UsingHardwareTextureScaling ( ) {
// For now, Vulkan only.
return g_Config . bTexHardwareScaling & & GetGPUBackend ( ) = = GPUBackend : : VULKAN & & ! g_Config . bSoftwareRendering ;
}
static std : : string TextureTranslateName ( const char * value ) {
2023-04-05 22:34:50 +00:00
auto ts = GetI18NCategory ( I18NCat : : TEXTURESHADERS ) ;
2020-08-02 04:26:41 +00:00
const TextureShaderInfo * info = GetTextureShaderInfo ( value ) ;
if ( info ) {
2022-11-24 21:54:05 +00:00
return ts - > T ( value , info ? info - > name . c_str ( ) : value ) ;
2020-08-02 04:26:41 +00:00
} else {
return value ;
}
}
2018-09-30 07:53:21 +00:00
static std : : string * GPUDeviceNameSetting ( ) {
if ( g_Config . iGPUBackend = = ( int ) GPUBackend : : VULKAN ) {
return & g_Config . sVulkanDevice ;
}
# ifdef _WIN32
if ( g_Config . iGPUBackend = = ( int ) GPUBackend : : DIRECT3D11 ) {
return & g_Config . sD3D11Device ;
}
# endif
return nullptr ;
}
2021-09-19 17:19:15 +00:00
bool PathToVisualUsbPath ( Path path , std : : string & outPath ) {
switch ( path . Type ( ) ) {
case PathType : : NATIVE :
if ( path . StartsWith ( g_Config . memStickDirectory ) ) {
return g_Config . memStickDirectory . ComputePathTo ( path , outPath ) ;
}
break ;
case PathType : : CONTENT_URI :
# if PPSSPP_PLATFORM(ANDROID)
{
// Try to parse something sensible out of the content URI.
AndroidContentURI uri ( path . ToString ( ) ) ;
outPath = uri . RootPath ( ) ;
if ( startsWith ( outPath , " primary: " ) ) {
outPath = " / " + outPath . substr ( 8 ) ;
}
return true ;
}
# endif
default :
break ;
}
return false ;
}
2022-11-22 22:29:50 +00:00
static std : : string PostShaderTranslateName ( const char * value ) {
2023-04-05 22:34:50 +00:00
auto ps = GetI18NCategory ( I18NCat : : POSTSHADERS ) ;
2022-11-22 22:29:50 +00:00
const ShaderInfo * info = GetPostShaderInfo ( value ) ;
if ( info ) {
return ps - > T ( value , info ? info - > name . c_str ( ) : value ) ;
} else {
return value ;
}
}
2023-06-16 11:44:35 +00:00
void GameSettingsScreen : : PreCreateViews ( ) {
2021-09-28 21:35:57 +00:00
ReloadAllPostShaderInfo ( screenManager ( ) - > getDrawContext ( ) ) ;
2022-02-11 11:32:23 +00:00
ReloadAllThemeInfo ( ) ;
2018-08-31 04:17:30 +00:00
2016-08-05 17:46:11 +00:00
if ( editThenRestore_ ) {
2019-07-18 04:28:21 +00:00
std : : shared_ptr < GameInfo > info = g_gameInfoCache - > GetInfo ( nullptr , gamePath_ , 0 ) ;
g_Config . loadGameConfig ( gameID_ , info - > GetTitle ( ) ) ;
2014-12-14 19:33:20 +00:00
}
2018-06-17 03:07:11 +00:00
iAlternateSpeedPercent1_ = g_Config . iFpsLimit1 < 0 ? - 1 : ( g_Config . iFpsLimit1 * 100 ) / 60 ;
iAlternateSpeedPercent2_ = g_Config . iFpsLimit2 < 0 ? - 1 : ( g_Config . iFpsLimit2 * 100 ) / 60 ;
2022-07-04 20:10:42 +00:00
iAlternateSpeedPercentAnalog_ = ( g_Config . iAnalogFpsLimit * 100 ) / 60 ;
2023-06-16 11:44:35 +00:00
}
2014-06-10 21:32:37 +00:00
2023-06-16 11:44:35 +00:00
void GameSettingsScreen : : CreateTabs ( ) {
2013-06-08 20:42:31 +00:00
using namespace UI ;
2023-04-05 22:34:50 +00:00
auto ms = GetI18NCategory ( I18NCat : : MAINSETTINGS ) ;
2021-09-11 23:17:24 +00:00
2021-04-26 04:59:43 +00:00
LinearLayout * graphicsSettings = AddTab ( " GameSettingsGraphics " , ms - > T ( " Graphics " ) ) ;
2023-01-31 16:16:31 +00:00
CreateGraphicsSettings ( graphicsSettings ) ;
LinearLayout * controlsSettings = AddTab ( " GameSettingsControls " , ms - > T ( " Controls " ) ) ;
CreateControlsSettings ( controlsSettings ) ;
LinearLayout * audioSettings = AddTab ( " GameSettingsAudio " , ms - > T ( " Audio " ) ) ;
CreateAudioSettings ( audioSettings ) ;
LinearLayout * networkingSettings = AddTab ( " GameSettingsNetworking " , ms - > T ( " Networking " ) ) ;
CreateNetworkingSettings ( networkingSettings ) ;
LinearLayout * tools = AddTab ( " GameSettingsTools " , ms - > T ( " Tools " ) ) ;
CreateToolsSettings ( tools ) ;
LinearLayout * systemSettings = AddTab ( " GameSettingsSystem " , ms - > T ( " System " ) ) ;
systemSettings - > SetSpacing ( 0 ) ;
CreateSystemSettings ( systemSettings ) ;
int deviceType = System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) ;
if ( deviceType = = DEVICE_TYPE_VR ) {
LinearLayout * vrSettings = AddTab ( " GameSettingsVR " , ms - > T ( " VR " ) ) ;
CreateVRSettings ( vrSettings ) ;
}
}
// Graphics
void GameSettingsScreen : : CreateGraphicsSettings ( UI : : ViewGroup * graphicsSettings ) {
2023-04-05 22:34:50 +00:00
auto gr = GetI18NCategory ( I18NCat : : GRAPHICS ) ;
auto vr = GetI18NCategory ( I18NCat : : VR ) ;
2023-01-31 16:16:31 +00:00
using namespace UI ;
2013-07-21 20:15:18 +00:00
2015-07-01 21:50:16 +00:00
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Rendering Mode " ) ) ) ;
2018-04-07 15:37:31 +00:00
2022-12-11 19:55:09 +00:00
Draw : : DrawContext * draw = screenManager ( ) - > getDrawContext ( ) ;
2018-04-07 15:37:31 +00:00
# if !PPSSPP_PLATFORM(UWP)
2017-11-13 05:57:01 +00:00
static const char * renderingBackend [ ] = { " OpenGL " , " Direct3D 9 " , " Direct3D 11 " , " Vulkan " } ;
2023-04-05 22:34:50 +00:00
PopupMultiChoice * renderingBackendChoice = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iGPUBackend , gr - > T ( " Backend " ) , renderingBackend , ( int ) GPUBackend : : OPENGL , ARRAY_SIZE ( renderingBackend ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2022-12-11 19:55:09 +00:00
if ( g_Config . iGPUBackend ! = ( int ) GPUBackend : : DIRECT3D9 & & ! draw - > GetDeviceCaps ( ) . supportsD3D9 ) {
renderingBackendChoice - > HideChoice ( 1 ) ;
}
2014-09-14 10:59:27 +00:00
renderingBackendChoice - > OnChoice . Handle ( this , & GameSettingsScreen : : OnRenderingBackend ) ;
2019-06-22 18:48:36 +00:00
if ( ! g_Config . IsBackendEnabled ( GPUBackend : : OPENGL ) )
renderingBackendChoice - > HideChoice ( ( int ) GPUBackend : : OPENGL ) ;
if ( ! g_Config . IsBackendEnabled ( GPUBackend : : DIRECT3D9 ) )
renderingBackendChoice - > HideChoice ( ( int ) GPUBackend : : DIRECT3D9 ) ;
if ( ! g_Config . IsBackendEnabled ( GPUBackend : : DIRECT3D11 ) )
renderingBackendChoice - > HideChoice ( ( int ) GPUBackend : : DIRECT3D11 ) ;
if ( ! g_Config . IsBackendEnabled ( GPUBackend : : VULKAN ) )
renderingBackendChoice - > HideChoice ( ( int ) GPUBackend : : VULKAN ) ;
2020-08-06 08:19:58 +00:00
if ( ! IsFirstInstance ( ) ) {
// If we're not the first instance, can't save the setting, and it requires a restart, so...
renderingBackendChoice - > SetEnabled ( false ) ;
}
2018-04-07 15:37:31 +00:00
# endif
2019-06-22 18:48:36 +00:00
2018-06-06 08:24:16 +00:00
// Backends that don't allow a device choice will only expose one device.
2018-04-15 08:53:07 +00:00
if ( draw - > GetDeviceList ( ) . size ( ) > 1 ) {
2018-09-30 07:53:21 +00:00
std : : string * deviceNameSetting = GPUDeviceNameSetting ( ) ;
2018-04-15 07:56:37 +00:00
if ( deviceNameSetting ) {
2023-04-05 22:34:50 +00:00
PopupMultiChoiceDynamic * deviceChoice = graphicsSettings - > Add ( new PopupMultiChoiceDynamic ( deviceNameSetting , gr - > T ( " Device " ) , draw - > GetDeviceList ( ) , I18NCat : : NONE , screenManager ( ) ) ) ;
2018-09-30 07:53:21 +00:00
deviceChoice - > OnChoice . Handle ( this , & GameSettingsScreen : : OnRenderingDevice ) ;
2018-04-15 07:56:37 +00:00
}
}
2017-05-30 08:38:17 +00:00
2022-11-24 21:03:17 +00:00
static const char * internalResolutions [ ] = { " Auto (1:1) " , " 1x PSP " , " 2x PSP " , " 3x PSP " , " 4x PSP " , " 5x PSP " , " 6x PSP " , " 7x PSP " , " 8x PSP " , " 9x PSP " , " 10x PSP " } ;
2023-04-05 22:34:50 +00:00
resolutionChoice_ = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iInternalResolution , gr - > T ( " Rendering Resolution " ) , internalResolutions , 0 , ARRAY_SIZE ( internalResolutions ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2022-11-24 21:03:17 +00:00
resolutionChoice_ - > OnChoice . Handle ( this , & GameSettingsScreen : : OnResolutionChange ) ;
resolutionChoice_ - > SetEnabledFunc ( [ ] {
return ! g_Config . bSoftwareRendering & & ! g_Config . bSkipBufferEffects ;
} ) ;
2023-01-31 16:16:31 +00:00
int deviceType = System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) ;
2022-12-03 16:42:29 +00:00
if ( deviceType ! = DEVICE_TYPE_VR ) {
CheckBox * softwareGPU = graphicsSettings - > Add ( new CheckBox ( & g_Config . bSoftwareRendering , gr - > T ( " Software Rendering " , " Software Rendering (slow) " ) ) ) ;
softwareGPU - > SetEnabled ( ! PSP_IsInited ( ) ) ;
}
2022-11-28 10:50:28 +00:00
if ( draw - > GetDeviceCaps ( ) . multiSampleLevelsMask ! = 1 ) {
2022-11-28 19:45:06 +00:00
static const char * msaaModes [ ] = { " Off " , " 2x " , " 4x " , " 8x " , " 16x " } ;
2023-04-05 22:34:50 +00:00
auto msaaChoice = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iMultiSampleLevel , gr - > T ( " Antialiasing (MSAA) " ) , msaaModes , 0 , ARRAY_SIZE ( msaaModes ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2022-11-28 10:50:28 +00:00
msaaChoice - > OnChoice . Add ( [ & ] ( UI : : EventParams & ) - > UI : : EventReturn {
NativeMessageReceived ( " gpu_renderResized " , " " ) ;
return UI : : EVENT_DONE ;
} ) ;
2022-12-03 16:42:29 +00:00
msaaChoice - > SetDisabledPtr ( & g_Config . bSoftwareRendering ) ;
2022-11-28 10:50:28 +00:00
// Hide unsupported levels.
for ( int i = 1 ; i < 5 ; i + + ) {
if ( ( draw - > GetDeviceCaps ( ) . multiSampleLevelsMask & ( 1 < < i ) ) = = 0 ) {
msaaChoice - > HideChoice ( i ) ;
}
}
}
2023-05-17 07:37:15 +00:00
# if PPSSPP_PLATFORM(ANDROID)
if ( ( deviceType ! = DEVICE_TYPE_TV ) & & ( deviceType ! = DEVICE_TYPE_VR ) ) {
static const char * deviceResolutions [ ] = { " Native device resolution " , " Auto (same as Rendering) " , " 1x PSP " , " 2x PSP " , " 3x PSP " , " 4x PSP " , " 5x PSP " } ;
int max_res_temp = std : : max ( System_GetPropertyInt ( SYSPROP_DISPLAY_XRES ) , System_GetPropertyInt ( SYSPROP_DISPLAY_YRES ) ) / 480 + 2 ;
if ( max_res_temp = = 3 )
max_res_temp = 4 ; // At least allow 2x
int max_res = std : : min ( max_res_temp , ( int ) ARRAY_SIZE ( deviceResolutions ) ) ;
UI : : PopupMultiChoice * hwscale = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iAndroidHwScale , gr - > T ( " Display Resolution (HW scaler) " ) , deviceResolutions , 0 , max_res , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
hwscale - > OnChoice . Handle ( this , & GameSettingsScreen : : OnHwScaleChange ) ; // To refresh the display mode
}
# endif
2022-11-24 21:13:49 +00:00
if ( deviceType ! = DEVICE_TYPE_VR ) {
# if !defined(MOBILE_DEVICE)
graphicsSettings - > Add ( new CheckBox ( & g_Config . bFullScreen , gr - > T ( " FullScreen " , " Full Screen " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnFullscreenChange ) ;
if ( System_GetPropertyInt ( SYSPROP_DISPLAY_COUNT ) > 1 ) {
CheckBox * fullscreenMulti = new CheckBox ( & g_Config . bFullScreenMulti , gr - > T ( " Use all displays " ) ) ;
fullscreenMulti - > SetEnabledFunc ( [ ] {
return g_Config . UseFullScreen ( ) ;
} ) ;
graphicsSettings - > Add ( fullscreenMulti ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnFullscreenMultiChange ) ;
}
# endif
2022-11-24 21:48:32 +00:00
# if !(PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS))
CheckBox * vSync = graphicsSettings - > Add ( new CheckBox ( & g_Config . bVSync , gr - > T ( " VSync " ) ) ) ;
vSync - > OnClick . Add ( [ = ] ( EventParams & e ) {
NativeResized ( ) ;
return UI : : EVENT_CONTINUE ;
} ) ;
# endif
2022-11-24 21:13:49 +00:00
# if PPSSPP_PLATFORM(ANDROID)
// Hide Immersive Mode on pre-kitkat Android
if ( System_GetPropertyInt ( SYSPROP_SYSTEMVERSION ) > = 19 ) {
// Let's reuse the Fullscreen translation string from desktop.
graphicsSettings - > Add ( new CheckBox ( & g_Config . bImmersiveMode , gr - > T ( " FullScreen " , " Full Screen " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnImmersiveModeChange ) ;
}
# endif
2022-11-24 21:43:49 +00:00
// Display Layout Editor: To avoid overlapping touch controls on large tablets, meet geeky demands for integer zoom/unstretched image etc.
displayEditor_ = graphicsSettings - > Add ( new Choice ( gr - > T ( " Display Layout && Effects " ) ) ) ;
displayEditor_ - > OnClick . Add ( [ & ] ( UI : : EventParams & ) - > UI : : EventReturn {
screenManager ( ) - > push ( new DisplayLayoutScreen ( gamePath_ ) ) ;
return UI : : EVENT_DONE ;
} ) ;
2022-11-24 21:13:49 +00:00
}
2015-07-01 21:50:16 +00:00
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Frame Rate Control " ) ) ) ;
2014-01-25 16:41:39 +00:00
static const char * frameSkip [ ] = { " Off " , " 1 " , " 2 " , " 3 " , " 4 " , " 5 " , " 6 " , " 7 " , " 8 " } ;
2023-04-05 22:34:50 +00:00
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iFrameSkip , gr - > T ( " Frame Skipping " ) , frameSkip , 0 , ARRAY_SIZE ( frameSkip ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2018-11-03 01:33:41 +00:00
static const char * frameSkipType [ ] = { " Number of Frames " , " Percent of FPS " } ;
2023-04-05 22:34:50 +00:00
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iFrameSkipType , gr - > T ( " Frame Skipping Type " ) , frameSkipType , 0 , ARRAY_SIZE ( frameSkipType ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2015-07-01 21:50:16 +00:00
frameSkipAuto_ = graphicsSettings - > Add ( new CheckBox ( & g_Config . bAutoFrameSkip , gr - > T ( " Auto FrameSkip " ) ) ) ;
2014-07-22 07:55:12 +00:00
frameSkipAuto_ - > OnClick . Handle ( this , & GameSettingsScreen : : OnAutoFrameskip ) ;
2014-05-03 20:24:46 +00:00
2023-04-05 08:35:41 +00:00
PopupSliderChoice * altSpeed1 = graphicsSettings - > Add ( new PopupSliderChoice ( & iAlternateSpeedPercent1_ , 0 , 1000 , NO_DEFAULT_INT , gr - > T ( " Alternative Speed " , " Alternative speed " ) , 5 , screenManager ( ) , gr - > T ( " %, 0:unlimited " ) ) ) ;
2018-06-17 03:07:11 +00:00
altSpeed1 - > SetFormat ( " %i%% " ) ;
altSpeed1 - > SetZeroLabel ( gr - > T ( " Unlimited " ) ) ;
altSpeed1 - > SetNegativeDisable ( gr - > T ( " Disabled " ) ) ;
2023-04-05 08:35:41 +00:00
PopupSliderChoice * altSpeed2 = graphicsSettings - > Add ( new PopupSliderChoice ( & iAlternateSpeedPercent2_ , 0 , 1000 , NO_DEFAULT_INT , gr - > T ( " Alternative Speed 2 " , " Alternative speed 2 (in %, 0 = unlimited) " ) , 5 , screenManager ( ) , gr - > T ( " %, 0:unlimited " ) ) ) ;
2018-06-17 03:07:11 +00:00
altSpeed2 - > SetFormat ( " %i%% " ) ;
altSpeed2 - > SetZeroLabel ( gr - > T ( " Unlimited " ) ) ;
altSpeed2 - > SetNegativeDisable ( gr - > T ( " Disabled " ) ) ;
2013-09-30 09:57:30 +00:00
2022-07-05 03:20:31 +00:00
if ( analogSpeedMapped_ ) {
2023-04-05 08:35:41 +00:00
PopupSliderChoice * analogSpeed = graphicsSettings - > Add ( new PopupSliderChoice ( & iAlternateSpeedPercentAnalog_ , 1 , 1000 , NO_DEFAULT_INT , gr - > T ( " Analog Alternative Speed " , " Analog alternative speed (in %) " ) , 5 , screenManager ( ) , gr - > T ( " % " ) ) ) ;
2022-07-04 20:10:42 +00:00
altSpeed2 - > SetFormat ( " %i%% " ) ;
}
2022-11-06 18:30:17 +00:00
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Speed Hacks " , " Speed Hacks (can cause rendering errors!) " ) ) ) ;
CheckBox * skipBufferEffects = graphicsSettings - > Add ( new CheckBox ( & g_Config . bSkipBufferEffects , gr - > T ( " Skip Buffer Effects " ) ) ) ;
skipBufferEffects - > OnClick . Add ( [ = ] ( EventParams & e ) {
if ( g_Config . bSkipBufferEffects ) {
settingInfo_ - > Show ( gr - > T ( " RenderingMode NonBuffered Tip " , " Faster, but graphics may be missing in some games " ) , e . v ) ;
g_Config . bAutoFrameSkip = false ;
}
2022-11-29 08:42:11 +00:00
NativeMessageReceived ( " gpu_renderResized " , " " ) ;
2022-11-06 18:30:17 +00:00
return UI : : EVENT_DONE ;
} ) ;
skipBufferEffects - > SetDisabledPtr ( & g_Config . bSoftwareRendering ) ;
CheckBox * skipGPUReadbacks = graphicsSettings - > Add ( new CheckBox ( & g_Config . bSkipGPUReadbacks , gr - > T ( " Skip GPU Readbacks " ) ) ) ;
skipGPUReadbacks - > SetDisabledPtr ( & g_Config . bSoftwareRendering ) ;
CheckBox * vtxCache = graphicsSettings - > Add ( new CheckBox ( & g_Config . bVertexCache , gr - > T ( " Vertex Cache " ) ) ) ;
vtxCache - > OnClick . Add ( [ = ] ( EventParams & e ) {
settingInfo_ - > Show ( gr - > T ( " VertexCache Tip " , " Faster, but may cause temporary flicker " ) , e . v ) ;
return UI : : EVENT_CONTINUE ;
} ) ;
vtxCache - > SetEnabledFunc ( [ ] {
return ! g_Config . bSoftwareRendering & & g_Config . bHardwareTransform & & g_Config . iGPUBackend ! = ( int ) GPUBackend : : OPENGL ;
} ) ;
CheckBox * texBackoff = graphicsSettings - > Add ( new CheckBox ( & g_Config . bTextureBackoffCache , gr - > T ( " Lazy texture caching " , " Lazy texture caching (speedup) " ) ) ) ;
texBackoff - > SetDisabledPtr ( & g_Config . bSoftwareRendering ) ;
texBackoff - > OnClick . Add ( [ = ] ( EventParams & e ) {
settingInfo_ - > Show ( gr - > T ( " Lazy texture caching Tip " , " Faster, but can cause text problems in a few games " ) , e . v ) ;
return UI : : EVENT_CONTINUE ;
} ) ;
static const char * quality [ ] = { " Low " , " Medium " , " High " } ;
2023-04-05 22:34:50 +00:00
PopupMultiChoice * beziersChoice = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iSplineBezierQuality , gr - > T ( " LowCurves " , " Spline/Bezier curves quality " ) , quality , 0 , ARRAY_SIZE ( quality ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2022-11-06 18:30:17 +00:00
beziersChoice - > OnChoice . Add ( [ = ] ( EventParams & e ) {
if ( g_Config . iSplineBezierQuality ! = 0 ) {
settingInfo_ - > Show ( gr - > T ( " LowCurves Tip " , " Only used by some games, controls smoothness of curves " ) , e . v ) ;
}
return UI : : EVENT_CONTINUE ;
} ) ;
2015-07-01 21:50:16 +00:00
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Performance " ) ) ) ;
2020-01-29 09:16:03 +00:00
CheckBox * frameDuplication = graphicsSettings - > Add ( new CheckBox ( & g_Config . bRenderDuplicateFrames , gr - > T ( " Render duplicate frames to 60hz " ) ) ) ;
frameDuplication - > OnClick . Add ( [ = ] ( EventParams & e ) {
settingInfo_ - > Show ( gr - > T ( " RenderDuplicateFrames Tip " , " Can make framerate smoother in games that run at lower framerates " ) , e . v ) ;
return UI : : EVENT_CONTINUE ;
} ) ;
2020-08-07 08:16:43 +00:00
frameDuplication - > SetEnabledFunc ( [ ] {
2022-11-06 18:20:10 +00:00
return ! g_Config . bSkipBufferEffects & & g_Config . iFrameSkip = = 0 ;
2020-06-28 20:05:19 +00:00
} ) ;
2014-06-10 18:00:11 +00:00
2020-03-01 07:40:55 +00:00
if ( GetGPUBackend ( ) = = GPUBackend : : VULKAN | | GetGPUBackend ( ) = = GPUBackend : : OPENGL ) {
2020-03-01 16:53:46 +00:00
static const char * bufferOptions [ ] = { " No buffer " , " Up to 1 " , " Up to 2 " } ;
2023-04-05 22:34:50 +00:00
PopupMultiChoice * inflightChoice = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iInflightFrames , gr - > T ( " Buffer graphics commands (faster, input lag) " ) , bufferOptions , 1 , ARRAY_SIZE ( bufferOptions ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2020-03-03 03:21:15 +00:00
inflightChoice - > OnChoice . Handle ( this , & GameSettingsScreen : : OnInflightFramesChoice ) ;
2020-03-01 07:40:55 +00:00
}
2022-10-02 14:41:36 +00:00
if ( GetGPUBackend ( ) = = GPUBackend : : VULKAN ) {
2022-10-09 07:57:10 +00:00
const bool usable = ! draw - > GetBugs ( ) . Has ( Draw : : Bugs : : GEOMETRY_SHADERS_SLOW_OR_BROKEN ) ;
2022-10-02 14:41:36 +00:00
const bool vertexSupported = draw - > GetDeviceCaps ( ) . clipDistanceSupported & & draw - > GetDeviceCaps ( ) . cullDistanceSupported ;
if ( usable & & ! vertexSupported ) {
CheckBox * geometryCulling = graphicsSettings - > Add ( new CheckBox ( & g_Config . bUseGeometryShader , gr - > T ( " Geometry shader culling " ) ) ) ;
geometryCulling - > SetDisabledPtr ( & g_Config . bSoftwareRendering ) ;
}
}
2022-08-12 08:30:57 +00:00
if ( deviceType ! = DEVICE_TYPE_VR ) {
CheckBox * hwTransform = graphicsSettings - > Add ( new CheckBox ( & g_Config . bHardwareTransform , gr - > T ( " Hardware Transform " ) ) ) ;
hwTransform - > SetDisabledPtr ( & g_Config . bSoftwareRendering ) ;
}
2014-06-10 18:00:11 +00:00
2018-04-10 10:22:02 +00:00
CheckBox * swSkin = graphicsSettings - > Add ( new CheckBox ( & g_Config . bSoftwareSkinning , gr - > T ( " Software Skinning " ) ) ) ;
swSkin - > OnClick . Add ( [ = ] ( EventParams & e ) {
settingInfo_ - > Show ( gr - > T ( " SoftwareSkinning Tip " , " Combine skinned model draws on the CPU, faster in most games " ) , e . v ) ;
return UI : : EVENT_CONTINUE ;
} ) ;
swSkin - > SetDisabledPtr ( & g_Config . bSoftwareRendering ) ;
2018-03-24 16:37:17 +00:00
CheckBox * tessellationHW = graphicsSettings - > Add ( new CheckBox ( & g_Config . bHardwareTessellation , gr - > T ( " Hardware Tessellation " ) ) ) ;
2017-01-09 10:18:27 +00:00
tessellationHW - > OnClick . Add ( [ = ] ( EventParams & e ) {
2018-09-22 10:20:30 +00:00
settingInfo_ - > Show ( gr - > T ( " HardwareTessellation Tip " , " Uses hardware to make curves " ) , e . v ) ;
2017-01-09 10:18:27 +00:00
return UI : : EVENT_CONTINUE ;
} ) ;
2022-01-21 15:55:53 +00:00
tessellationHW - > SetEnabledFunc ( [ ] ( ) {
return DoesBackendSupportHWTess ( ) & & ! g_Config . bSoftwareRendering & & g_Config . bHardwareTransform ;
} ) ;
2017-01-06 15:14:58 +00:00
2013-09-28 06:21:59 +00:00
// In case we're going to add few other antialiasing option like MSAA in the future.
2015-07-01 21:50:16 +00:00
// graphicsSettings->Add(new CheckBox(&g_Config.bFXAA, gr->T("FXAA")));
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Texture Scaling " ) ) ) ;
2014-02-08 18:29:22 +00:00
# ifndef MOBILE_DEVICE
2021-10-05 18:41:40 +00:00
static const char * texScaleLevels [ ] = { " Off " , " 2x " , " 3x " , " 4x " , " 5x " } ;
2013-07-26 12:25:11 +00:00
# else
2021-10-05 18:41:40 +00:00
static const char * texScaleLevels [ ] = { " Off " , " 2x " , " 3x " } ;
2013-07-26 12:25:11 +00:00
# endif
2014-01-20 05:14:21 +00:00
2021-11-07 12:12:28 +00:00
static const char * texScaleAlgos [ ] = { " xBRZ " , " Hybrid " , " Bicubic " , " Hybrid + Bicubic " , } ;
2023-04-05 22:34:50 +00:00
PopupMultiChoice * texScalingType = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iTexScalingType , gr - > T ( " Upscale Type " ) , texScaleAlgos , 0 , ARRAY_SIZE ( texScaleAlgos ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2021-11-07 12:12:28 +00:00
texScalingType - > SetEnabledFunc ( [ ] ( ) {
return ! g_Config . bSoftwareRendering & & ! UsingHardwareTextureScaling ( ) ;
} ) ;
2023-04-05 22:34:50 +00:00
PopupMultiChoice * texScalingChoice = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iTexScalingLevel , gr - > T ( " Upscale Level " ) , texScaleLevels , 1 , ARRAY_SIZE ( texScaleLevels ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2016-03-26 21:34:24 +00:00
// TODO: Better check? When it won't work, it scales down anyway.
if ( ! gl_extensions . OES_texture_npot & & GetGPUBackend ( ) = = GPUBackend : : OPENGL ) {
texScalingChoice - > HideChoice ( 3 ) ; // 3x
texScalingChoice - > HideChoice ( 5 ) ; // 5x
}
2016-08-17 01:56:04 +00:00
texScalingChoice - > OnChoice . Add ( [ = ] ( EventParams & e ) {
2020-08-02 04:26:41 +00:00
if ( g_Config . iTexScalingLevel ! = 1 & & ! UsingHardwareTextureScaling ( ) ) {
2016-08-14 22:26:42 +00:00
settingInfo_ - > Show ( gr - > T ( " UpscaleLevel Tip " , " CPU heavy - some scaling may be delayed to avoid stutter " ) , e . v ) ;
}
return UI : : EVENT_CONTINUE ;
} ) ;
2021-11-07 12:12:28 +00:00
texScalingChoice - > SetEnabledFunc ( [ ] ( ) {
2020-08-02 04:26:41 +00:00
return ! g_Config . bSoftwareRendering & & ! UsingHardwareTextureScaling ( ) ;
} ) ;
2014-06-10 21:28:13 +00:00
2015-07-01 21:50:16 +00:00
CheckBox * deposterize = graphicsSettings - > Add ( new CheckBox ( & g_Config . bTexDeposterize , gr - > T ( " Deposterize " ) ) ) ;
2016-12-14 16:20:37 +00:00
deposterize - > OnClick . Add ( [ = ] ( EventParams & e ) {
2017-03-21 07:23:31 +00:00
if ( g_Config . bTexDeposterize = = true ) {
2017-03-21 14:18:54 +00:00
settingInfo_ - > Show ( gr - > T ( " Deposterize Tip " , " Fixes visual banding glitches in upscaled textures " ) , e . v ) ;
2017-03-21 07:23:31 +00:00
}
2016-12-14 16:20:37 +00:00
return UI : : EVENT_CONTINUE ;
} ) ;
2020-08-02 04:26:41 +00:00
deposterize - > SetEnabledFunc ( [ ] ( ) {
return ! g_Config . bSoftwareRendering & & ! UsingHardwareTextureScaling ( ) ;
} ) ;
ChoiceWithValueDisplay * textureShaderChoice = graphicsSettings - > Add ( new ChoiceWithValueDisplay ( & g_Config . sTextureShaderName , gr - > T ( " Texture Shader " ) , & TextureTranslateName ) ) ;
textureShaderChoice - > OnClick . Handle ( this , & GameSettingsScreen : : OnTextureShader ) ;
2020-08-02 05:32:55 +00:00
textureShaderChoice - > SetEnabledFunc ( [ ] ( ) {
return GetGPUBackend ( ) = = GPUBackend : : VULKAN & & ! g_Config . bSoftwareRendering ;
} ) ;
2014-06-10 21:28:13 +00:00
2015-07-01 21:50:16 +00:00
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Texture Filtering " ) ) ) ;
2013-08-16 10:52:16 +00:00
static const char * anisoLevels [ ] = { " Off " , " 2x " , " 4x " , " 8x " , " 16x " } ;
2023-04-05 22:34:50 +00:00
PopupMultiChoice * anisoFiltering = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iAnisotropyLevel , gr - > T ( " Anisotropic Filtering " ) , anisoLevels , 0 , ARRAY_SIZE ( anisoLevels ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2014-07-09 06:47:27 +00:00
anisoFiltering - > SetDisabledPtr ( & g_Config . bSoftwareRendering ) ;
2014-06-10 21:28:13 +00:00
2021-09-02 22:06:49 +00:00
static const char * texFilters [ ] = { " Auto " , " Nearest " , " Linear " , " Auto Max Quality " } ;
2023-04-05 22:34:50 +00:00
graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iTexFiltering , gr - > T ( " Texture Filter " ) , texFilters , 1 , ARRAY_SIZE ( texFilters ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2013-07-17 20:27:05 +00:00
2022-08-25 16:58:35 +00:00
# if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS)
2022-08-12 08:30:57 +00:00
bool showCardboardSettings = deviceType ! = DEVICE_TYPE_VR ;
2020-08-30 15:50:42 +00:00
# else
// If you enabled it through the ini, you can see this. Useful for testing.
bool showCardboardSettings = g_Config . bEnableCardboardVR ;
# endif
2020-08-30 20:43:13 +00:00
if ( showCardboardSettings ) {
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Cardboard VR Settings " , " Cardboard VR Settings " ) ) ) ;
graphicsSettings - > Add ( new CheckBox ( & g_Config . bEnableCardboardVR , gr - > T ( " Enable Cardboard VR " , " Enable Cardboard VR " ) ) ) ;
2023-04-05 08:35:41 +00:00
PopupSliderChoice * cardboardScreenSize = graphicsSettings - > Add ( new PopupSliderChoice ( & g_Config . iCardboardScreenSize , 30 , 150 , 50 , gr - > T ( " Cardboard Screen Size " , " Screen Size (in % of the viewport) " ) , 1 , screenManager ( ) , gr - > T ( " % of viewport " ) ) ) ;
2020-08-30 20:43:13 +00:00
cardboardScreenSize - > SetEnabledPtr ( & g_Config . bEnableCardboardVR ) ;
2023-04-05 08:35:41 +00:00
PopupSliderChoice * cardboardXShift = graphicsSettings - > Add ( new PopupSliderChoice ( & g_Config . iCardboardXShift , - 150 , 150 , 0 , gr - > T ( " Cardboard Screen X Shift " , " X Shift (in % of the void) " ) , 1 , screenManager ( ) , gr - > T ( " % of the void " ) ) ) ;
2020-08-30 20:43:13 +00:00
cardboardXShift - > SetEnabledPtr ( & g_Config . bEnableCardboardVR ) ;
2023-04-05 08:35:41 +00:00
PopupSliderChoice * cardboardYShift = graphicsSettings - > Add ( new PopupSliderChoice ( & g_Config . iCardboardYShift , - 100 , 100 , 0 , gr - > T ( " Cardboard Screen Y Shift " , " Y Shift (in % of the void) " ) , 1 , screenManager ( ) , gr - > T ( " % of the void " ) ) ) ;
2020-08-30 20:43:13 +00:00
cardboardYShift - > SetEnabledPtr ( & g_Config . bEnableCardboardVR ) ;
}
2019-10-25 08:34:08 +00:00
2020-03-09 02:56:02 +00:00
std : : vector < std : : string > cameraList = Camera : : getDeviceList ( ) ;
if ( cameraList . size ( ) > = 1 ) {
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Camera " ) ) ) ;
2023-04-05 22:34:50 +00:00
PopupMultiChoiceDynamic * cameraChoice = graphicsSettings - > Add ( new PopupMultiChoiceDynamic ( & g_Config . sCameraDevice , gr - > T ( " Camera Device " ) , cameraList , I18NCat : : NONE , screenManager ( ) ) ) ;
2020-03-09 02:56:02 +00:00
cameraChoice - > OnChoice . Handle ( this , & GameSettingsScreen : : OnCameraDeviceChange ) ;
}
2015-07-01 21:50:16 +00:00
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Hack Settings " , " Hack Settings (these WILL cause glitches) " ) ) ) ;
2016-12-14 16:20:37 +00:00
2015-01-23 01:08:20 +00:00
static const char * bloomHackOptions [ ] = { " Off " , " Safe " , " Balanced " , " Aggressive " } ;
2023-04-05 22:34:50 +00:00
PopupMultiChoice * bloomHack = graphicsSettings - > Add ( new PopupMultiChoice ( & g_Config . iBloomHack , gr - > T ( " Lower resolution for effects (reduces artifacts) " ) , bloomHackOptions , 0 , ARRAY_SIZE ( bloomHackOptions ) , I18NCat : : GRAPHICS , screenManager ( ) ) ) ;
2020-03-22 01:49:36 +00:00
bloomHack - > SetEnabledFunc ( [ ] {
return ! g_Config . bSoftwareRendering & & g_Config . iInternalResolution ! = 1 ;
} ) ;
2015-01-23 01:08:20 +00:00
2015-07-01 21:50:16 +00:00
graphicsSettings - > Add ( new ItemHeader ( gr - > T ( " Overlay Information " ) ) ) ;
2023-02-06 19:17:27 +00:00
BitCheckBox * showFPSCtr = graphicsSettings - > Add ( new BitCheckBox ( & g_Config . iShowStatusFlags , ( int ) ShowStatusFlags : : FPS_COUNTER , gr - > T ( " Show FPS Counter " ) ) ) ;
BitCheckBox * showSpeed = graphicsSettings - > Add ( new BitCheckBox ( & g_Config . iShowStatusFlags , ( int ) ShowStatusFlags : : SPEED_COUNTER , gr - > T ( " Show Speed " ) ) ) ;
2023-01-27 08:19:29 +00:00
# ifdef CAN_DISPLAY_CURRENT_BATTERY_CAPACITY
2023-02-06 19:17:27 +00:00
BitCheckBox * showBattery = graphicsSettings - > Add ( new BitCheckBox ( & g_Config . iShowStatusFlags , ( int ) ShowStatusFlags : : BATTERY_PERCENT , gr - > T ( " Show Battery % " ) ) ) ;
2023-01-27 08:19:29 +00:00
# endif
2023-01-28 23:25:00 +00:00
2015-07-01 21:50:16 +00:00
graphicsSettings - > Add ( new CheckBox ( & g_Config . bShowDebugStats , gr - > T ( " Show Debug Statistics " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnJitAffectingSetting ) ;
2023-01-31 16:16:31 +00:00
}
2013-10-20 15:33:18 +00:00
2023-01-31 16:16:31 +00:00
void GameSettingsScreen : : CreateAudioSettings ( UI : : ViewGroup * audioSettings ) {
using namespace UI ;
2023-04-05 22:34:50 +00:00
auto a = GetI18NCategory ( I18NCat : : AUDIO ) ;
auto ms = GetI18NCategory ( I18NCat : : MAINSETTINGS ) ;
2013-08-09 10:57:03 +00:00
2013-08-20 10:28:17 +00:00
audioSettings - > Add ( new ItemHeader ( ms - > T ( " Audio " ) ) ) ;
2023-02-06 19:17:27 +00:00
CheckBox * enableSound = audioSettings - > Add ( new CheckBox ( & g_Config . bEnableSound , a - > T ( " Enable Sound " ) ) ) ;
2023-04-05 08:35:41 +00:00
PopupSliderChoice * volume = audioSettings - > Add ( new PopupSliderChoice ( & g_Config . iGlobalVolume , VOLUME_OFF , VOLUME_FULL , VOLUME_FULL , a - > T ( " Global volume " ) , screenManager ( ) ) ) ;
2016-01-18 06:47:29 +00:00
volume - > SetEnabledPtr ( & g_Config . bEnableSound ) ;
2019-06-23 20:34:08 +00:00
volume - > SetZeroLabel ( a - > T ( " Mute " ) ) ;
2023-04-05 08:35:41 +00:00
PopupSliderChoice * altVolume = audioSettings - > Add ( new PopupSliderChoice ( & g_Config . iAltSpeedVolume , VOLUME_OFF , VOLUME_FULL , NO_DEFAULT_INT , a - > T ( " Alternate speed volume " ) , screenManager ( ) ) ) ;
2019-06-23 20:34:08 +00:00
altVolume - > SetEnabledPtr ( & g_Config . bEnableSound ) ;
altVolume - > SetZeroLabel ( a - > T ( " Mute " ) ) ;
altVolume - > SetNegativeDisable ( a - > T ( " Use global volume " ) ) ;
2016-01-18 06:47:29 +00:00
2023-04-05 08:35:41 +00:00
PopupSliderChoice * reverbVolume = audioSettings - > Add ( new PopupSliderChoice ( & g_Config . iReverbVolume , VOLUME_OFF , 2 * VOLUME_FULL , VOLUME_FULL , a - > T ( " Reverb volume " ) , screenManager ( ) ) ) ;
2021-08-10 03:47:24 +00:00
reverbVolume - > SetEnabledPtr ( & g_Config . bEnableSound ) ;
reverbVolume - > SetZeroLabel ( a - > T ( " Disabled " ) ) ;
2020-12-19 11:57:05 +00:00
// Hide the backend selector in UWP builds (we only support XAudio2 there).
# if PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP)
2015-02-01 10:56:44 +00:00
if ( IsVistaOrHigher ( ) ) {
2015-02-01 17:04:06 +00:00
static const char * backend [ ] = { " Auto " , " DSound (compatible) " , " WASAPI (fast) " } ;
2023-04-05 22:34:50 +00:00
PopupMultiChoice * audioBackend = audioSettings - > Add ( new PopupMultiChoice ( & g_Config . iAudioBackend , a - > T ( " Audio backend " , " Audio backend (restart req.) " ) , backend , 0 , ARRAY_SIZE ( backend ) , I18NCat : : AUDIO , screenManager ( ) ) ) ;
2015-02-01 10:56:44 +00:00
audioBackend - > SetEnabledPtr ( & g_Config . bEnableSound ) ;
}
2015-01-24 12:50:27 +00:00
# endif
2021-07-17 22:07:05 +00:00
bool sdlAudio = false ;
2019-09-15 20:23:48 +00:00
# if defined(SDL)
std : : vector < std : : string > audioDeviceList ;
SplitString ( System_GetProperty ( SYSPROP_AUDIO_DEVICE_LIST ) , ' \0 ' , audioDeviceList ) ;
2019-09-15 20:42:56 +00:00
audioDeviceList . insert ( audioDeviceList . begin ( ) , a - > T ( " Auto " ) ) ;
2023-04-06 10:33:40 +00:00
PopupMultiChoiceDynamic * audioDevice = audioSettings - > Add ( new PopupMultiChoiceDynamic ( & g_Config . sAudioDevice , a - > T ( " Device " ) , audioDeviceList , I18NCat : : NONE , screenManager ( ) ) ) ;
2019-09-15 20:23:48 +00:00
audioDevice - > OnChoice . Handle ( this , & GameSettingsScreen : : OnAudioDevice ) ;
2021-07-17 22:07:05 +00:00
sdlAudio = true ;
2019-09-15 20:23:48 +00:00
# endif
2021-07-17 22:07:05 +00:00
if ( sdlAudio | | g_Config . iAudioBackend = = AUDIO_BACKEND_WASAPI ) {
audioSettings - > Add ( new CheckBox ( & g_Config . bAutoAudioDevice , a - > T ( " Use new audio devices automatically " ) ) ) ;
}
2021-08-19 22:03:42 +00:00
# if PPSSPP_PLATFORM(ANDROID)
2016-12-01 20:40:44 +00:00
CheckBox * extraAudio = audioSettings - > Add ( new CheckBox ( & g_Config . bExtraAudioBuffering , a - > T ( " AudioBufferingForBluetooth " , " Bluetooth-friendly buffer (slower) " ) ) ) ;
2016-12-01 20:35:32 +00:00
extraAudio - > SetEnabledPtr ( & g_Config . bEnableSound ) ;
2021-06-14 22:23:45 +00:00
// Show OpenSL debug info
const std : : string audioErrorStr = AndroidAudio_GetErrorString ( g_audioState ) ;
if ( ! audioErrorStr . empty ( ) ) {
audioSettings - > Add ( new InfoItem ( a - > T ( " Audio Error " ) , audioErrorStr ) ) ;
}
2016-12-01 20:40:44 +00:00
# endif
2013-08-16 17:34:44 +00:00
2021-07-17 22:09:01 +00:00
std : : vector < std : : string > micList = Microphone : : getDeviceList ( ) ;
if ( ! micList . empty ( ) ) {
audioSettings - > Add ( new ItemHeader ( a - > T ( " Microphone " ) ) ) ;
2023-04-05 22:34:50 +00:00
PopupMultiChoiceDynamic * MicChoice = audioSettings - > Add ( new PopupMultiChoiceDynamic ( & g_Config . sMicDevice , a - > T ( " Microphone Device " ) , micList , I18NCat : : NONE , screenManager ( ) ) ) ;
2021-07-17 22:09:01 +00:00
MicChoice - > OnChoice . Handle ( this , & GameSettingsScreen : : OnMicDeviceChange ) ;
}
2023-01-31 16:16:31 +00:00
}
2021-07-17 22:09:01 +00:00
2023-01-31 16:16:31 +00:00
void GameSettingsScreen : : CreateControlsSettings ( UI : : ViewGroup * controlsSettings ) {
using namespace UI ;
2023-04-05 22:34:50 +00:00
auto co = GetI18NCategory ( I18NCat : : CONTROLS ) ;
2023-04-11 21:07:33 +00:00
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
2023-04-05 22:34:50 +00:00
auto ms = GetI18NCategory ( I18NCat : : MAINSETTINGS ) ;
2023-01-31 16:16:31 +00:00
int deviceType = System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) ;
2021-04-26 04:59:43 +00:00
2013-08-20 10:28:17 +00:00
controlsSettings - > Add ( new ItemHeader ( ms - > T ( " Controls " ) ) ) ;
2015-07-01 20:31:04 +00:00
controlsSettings - > Add ( new Choice ( co - > T ( " Control Mapping " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnControlMapping ) ;
2021-07-09 11:16:38 +00:00
controlsSettings - > Add ( new Choice ( co - > T ( " Calibrate Analog Stick " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnCalibrateAnalogs ) ;
2013-10-09 20:15:56 +00:00
2015-02-28 22:02:03 +00:00
# if defined(USING_WIN_UI)
2021-02-27 22:40:02 +00:00
controlsSettings - > Add ( new CheckBox ( & g_Config . bSystemControls , co - > T ( " Enable standard shortcut keys " ) ) ) ;
2015-07-01 20:31:04 +00:00
controlsSettings - > Add ( new CheckBox ( & g_Config . bGamepadOnlyFocused , co - > T ( " Ignore gamepads when not focused " ) ) ) ;
2015-02-28 22:02:03 +00:00
# endif
2021-08-09 20:33:53 +00:00
if ( System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) = = DEVICE_TYPE_MOBILE ) {
2023-02-02 09:53:42 +00:00
Choice * customizeTilt = controlsSettings - > Add ( new Choice ( co - > T ( " Tilt control setup " ) ) ) ;
2021-08-09 20:33:53 +00:00
customizeTilt - > OnClick . Handle ( this , & GameSettingsScreen : : OnTiltCustomize ) ;
2022-08-16 14:47:31 +00:00
} else if ( System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) = = DEVICE_TYPE_VR ) {
controlsSettings - > Add ( new CheckBox ( & g_Config . bHapticFeedback , co - > T ( " HapticFeedback " , " Haptic Feedback (vibration) " ) ) ) ;
2021-08-09 20:33:53 +00:00
}
2015-04-03 09:50:03 +00:00
// TVs don't have touch control, at least not yet.
2022-08-12 08:30:57 +00:00
if ( ( deviceType ! = DEVICE_TYPE_TV ) & & ( deviceType ! = DEVICE_TYPE_VR ) ) {
2015-07-01 20:31:04 +00:00
controlsSettings - > Add ( new ItemHeader ( co - > T ( " OnScreen " , " On-Screen Touch Controls " ) ) ) ;
controlsSettings - > Add ( new CheckBox ( & g_Config . bShowTouchControls , co - > T ( " OnScreen " , " On-Screen Touch Controls " ) ) ) ;
2021-03-04 09:37:35 +00:00
layoutEditorChoice_ = controlsSettings - > Add ( new Choice ( co - > T ( " Customize Touch Controls " ) ) ) ;
2015-04-03 09:50:03 +00:00
layoutEditorChoice_ - > OnClick . Handle ( this , & GameSettingsScreen : : OnTouchControlLayout ) ;
layoutEditorChoice_ - > SetEnabledPtr ( & g_Config . bShowTouchControls ) ;
2023-02-08 21:05:01 +00:00
Choice * gesture = controlsSettings - > Add ( new Choice ( co - > T ( " Gesture mapping " ) ) ) ;
gesture - > OnClick . Add ( [ = ] ( EventParams & e ) {
screenManager ( ) - > push ( new GestureMappingScreen ( gamePath_ ) ) ;
return UI : : EVENT_DONE ;
} ) ;
gesture - > SetEnabledPtr ( & g_Config . bShowTouchControls ) ;
static const char * touchControlStyles [ ] = { " Classic " , " Thin borders " , " Glowing borders " } ;
2023-04-05 22:34:50 +00:00
View * style = controlsSettings - > Add ( new PopupMultiChoice ( & g_Config . iTouchButtonStyle , co - > T ( " Button style " ) , touchControlStyles , 0 , ARRAY_SIZE ( touchControlStyles ) , I18NCat : : CONTROLS , screenManager ( ) ) ) ;
2023-02-08 21:05:01 +00:00
style - > SetEnabledPtr ( & g_Config . bShowTouchControls ) ;
2023-04-05 08:35:41 +00:00
PopupSliderChoice * opacity = controlsSettings - > Add ( new PopupSliderChoice ( & g_Config . iTouchButtonOpacity , 0 , 100 , 65 , co - > T ( " Button Opacity " ) , screenManager ( ) , " % " ) ) ;
2023-02-08 21:05:01 +00:00
opacity - > SetEnabledPtr ( & g_Config . bShowTouchControls ) ;
opacity - > SetFormat ( " %i%% " ) ;
2023-04-14 12:34:48 +00:00
PopupSliderChoice * autoHide = controlsSettings - > Add ( new PopupSliderChoice ( & g_Config . iTouchButtonHideSeconds , 0 , 300 , 20 , co - > T ( " Auto-hide buttons after delay " ) , screenManager ( ) , di - > T ( " seconds, 0:off " ) ) ) ;
2023-02-08 21:05:01 +00:00
autoHide - > SetEnabledPtr ( & g_Config . bShowTouchControls ) ;
2023-04-11 21:07:33 +00:00
autoHide - > SetFormat ( di - > T ( " %d seconds " ) ) ;
2023-02-08 21:05:01 +00:00
autoHide - > SetZeroLabel ( co - > T ( " Off " ) ) ;
2015-04-03 09:50:03 +00:00
2023-02-02 10:59:56 +00:00
// Hide stick background, useful when increasing the size
2021-07-11 15:51:10 +00:00
CheckBox * hideStickBackground = controlsSettings - > Add ( new CheckBox ( & g_Config . bHideStickBackground , co - > T ( " Hide touch analog stick background circle " ) ) ) ;
hideStickBackground - > SetEnabledPtr ( & g_Config . bShowTouchControls ) ;
2023-02-08 21:05:01 +00:00
// Re-centers itself to the touch location on touch-down.
CheckBox * floatingAnalog = controlsSettings - > Add ( new CheckBox ( & g_Config . bAutoCenterTouchAnalog , co - > T ( " Auto-centering analog stick " ) ) ) ;
floatingAnalog - > SetEnabledPtr ( & g_Config . bShowTouchControls ) ;
2023-02-02 10:59:56 +00:00
if ( System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) = = DEVICE_TYPE_MOBILE ) {
controlsSettings - > Add ( new CheckBox ( & g_Config . bHapticFeedback , co - > T ( " HapticFeedback " , " Haptic Feedback (vibration) " ) ) ) ;
}
2016-10-12 10:32:20 +00:00
// On non iOS systems, offer to let the user see this button.
2015-04-03 09:50:03 +00:00
// Some Windows touch devices don't have a back button or other button to call up the menu.
2017-04-30 00:35:12 +00:00
if ( System_GetPropertyBool ( SYSPROP_HAS_BACK_BUTTON ) ) {
2017-04-13 05:02:50 +00:00
CheckBox * enablePauseBtn = controlsSettings - > Add ( new CheckBox ( & g_Config . bShowTouchPause , co - > T ( " Show Touch Pause Menu Button " ) ) ) ;
// Don't allow the user to disable it once in-game, so they can't lock themselves out of the menu.
if ( ! PSP_IsInited ( ) ) {
enablePauseBtn - > SetEnabledPtr ( & g_Config . bShowTouchControls ) ;
} else {
enablePauseBtn - > SetEnabled ( false ) ;
}
2015-04-03 09:50:03 +00:00
}
2014-02-25 06:39:10 +00:00
2015-07-01 20:31:04 +00:00
CheckBox * disableDiags = controlsSettings - > Add ( new CheckBox ( & g_Config . bDisableDpadDiagonals , co - > T ( " Disable D-Pad diagonals (4-way touch) " ) ) ) ;
2015-04-03 09:50:03 +00:00
disableDiags - > SetEnabledPtr ( & g_Config . bShowTouchControls ) ;
}
2013-10-10 14:44:12 +00:00
2022-08-12 08:30:57 +00:00
if ( deviceType ! = DEVICE_TYPE_VR ) {
controlsSettings - > Add ( new ItemHeader ( co - > T ( " Keyboard " , " Keyboard Control Settings " ) ) ) ;
2014-08-16 19:05:37 +00:00
# if defined(USING_WIN_UI)
2022-08-12 08:30:57 +00:00
controlsSettings - > Add ( new CheckBox ( & g_Config . bIgnoreWindowsKey , co - > T ( " Ignore Windows Key " ) ) ) ;
2014-08-16 19:05:37 +00:00
# endif // #if defined(USING_WIN_UI)
2023-04-05 08:16:21 +00:00
auto analogLimiter = new PopupSliderChoiceFloat ( & g_Config . fAnalogLimiterDeadzone , 0.0f , 1.0f , 0.6f , co - > T ( " Analog Limiter " ) , 0.10f , screenManager ( ) , " / 1.0 " ) ;
2022-08-12 08:30:57 +00:00
controlsSettings - > Add ( analogLimiter ) ;
analogLimiter - > OnChange . Add ( [ = ] ( EventParams & e ) {
settingInfo_ - > Show ( co - > T ( " AnalogLimiter Tip " , " When the analog limiter button is pressed " ) , e . v ) ;
return UI : : EVENT_CONTINUE ;
} ) ;
2020-02-04 04:11:07 +00:00
# if defined(USING_WIN_UI) || defined(SDL)
2022-08-12 08:30:57 +00:00
controlsSettings - > Add ( new ItemHeader ( co - > T ( " Mouse " , " Mouse settings " ) ) ) ;
CheckBox * mouseControl = controlsSettings - > Add ( new CheckBox ( & g_Config . bMouseControl , co - > T ( " Use Mouse Control " ) ) ) ;
mouseControl - > OnClick . Add ( [ = ] ( EventParams & e ) {
2023-01-31 16:16:31 +00:00
if ( g_Config . bMouseControl )
2022-08-12 08:30:57 +00:00
settingInfo_ - > Show ( co - > T ( " MouseControl Tip " , " You can now map mouse in control mapping screen by pressing the 'M' icon. " ) , e . v ) ;
return UI : : EVENT_CONTINUE ;
} ) ;
controlsSettings - > Add ( new CheckBox ( & g_Config . bMouseConfine , co - > T ( " Confine Mouse " , " Trap mouse within window/display area " ) ) ) - > SetEnabledPtr ( & g_Config . bMouseControl ) ;
2023-04-05 08:16:21 +00:00
controlsSettings - > Add ( new PopupSliderChoiceFloat ( & g_Config . fMouseSensitivity , 0.01f , 1.0f , 0.1f , co - > T ( " Mouse sensitivity " ) , 0.01f , screenManager ( ) , " x " ) ) - > SetEnabledPtr ( & g_Config . bMouseControl ) ;
controlsSettings - > Add ( new PopupSliderChoiceFloat ( & g_Config . fMouseSmoothing , 0.0f , 0.95f , 0.9f , co - > T ( " Mouse smoothing " ) , 0.05f , screenManager ( ) , " x " ) ) - > SetEnabledPtr ( & g_Config . bMouseControl ) ;
2017-04-26 14:48:55 +00:00
# endif
2022-08-12 08:30:57 +00:00
}
2023-01-31 16:16:31 +00:00
}
2014-01-07 20:32:58 +00:00
2023-01-31 16:16:31 +00:00
void GameSettingsScreen : : CreateNetworkingSettings ( UI : : ViewGroup * networkingSettings ) {
using namespace UI ;
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
auto ms = GetI18NCategory ( I18NCat : : MAINSETTINGS ) ;
2015-01-05 00:32:53 +00:00
2021-01-09 14:01:35 +00:00
networkingSettings - > Add ( new ItemHeader ( ms - > T ( " Networking " ) ) ) ;
2015-01-04 10:59:43 +00:00
2022-07-02 18:53:38 +00:00
networkingSettings - > Add ( new Choice ( n - > T ( " Open PPSSPP Multiplayer Wiki Page " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnAdhocGuides ) ;
2015-01-29 21:15:42 +00:00
2015-01-04 10:59:43 +00:00
networkingSettings - > Add ( new CheckBox ( & g_Config . bEnableWlan , n - > T ( " Enable networking " , " Enable networking/wlan (beta) " ) ) ) ;
2023-04-05 22:34:50 +00:00
networkingSettings - > Add ( new ChoiceWithValueDisplay ( & g_Config . sMACAddress , n - > T ( " Change Mac Address " ) , I18NCat : : NONE ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeMacAddress ) ;
2020-03-01 20:59:13 +00:00
static const char * wlanChannels [ ] = { " Auto " , " 1 " , " 2 " , " 3 " , " 4 " , " 5 " , " 6 " , " 7 " , " 8 " , " 9 " , " 10 " , " 11 " } ;
2023-04-05 22:34:50 +00:00
auto wlanChannelChoice = networkingSettings - > Add ( new PopupMultiChoice ( & g_Config . iWlanAdhocChannel , n - > T ( " WLAN Channel " ) , wlanChannels , 0 , ARRAY_SIZE ( wlanChannels ) , I18NCat : : NETWORKING , screenManager ( ) ) ) ;
2020-03-01 20:59:13 +00:00
for ( int i = 0 ; i < 4 ; i + + ) {
2020-08-01 16:36:17 +00:00
wlanChannelChoice - > HideChoice ( i + 2 ) ;
wlanChannelChoice - > HideChoice ( i + 7 ) ;
2020-03-01 20:59:13 +00:00
}
2020-08-01 16:36:17 +00:00
networkingSettings - > Add ( new CheckBox ( & g_Config . bDiscordPresence , n - > T ( " Send Discord Presence information " ) ) ) ;
2020-03-19 08:21:00 +00:00
2020-08-01 16:36:17 +00:00
networkingSettings - > Add ( new ItemHeader ( n - > T ( " AdHoc Server " ) ) ) ;
networkingSettings - > Add ( new CheckBox ( & g_Config . bEnableAdhocServer , n - > T ( " Enable built-in PRO Adhoc Server " , " Enable built-in PRO Adhoc Server " ) ) ) ;
2023-04-05 22:34:50 +00:00
networkingSettings - > Add ( new ChoiceWithValueDisplay ( & g_Config . proAdhocServer , n - > T ( " Change proAdhocServer Address " , " Change proAdhocServer Address (localhost = multiple instance) " ) , I18NCat : : NONE ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeproAdhocServerAddress ) ;
2020-08-01 16:36:17 +00:00
networkingSettings - > Add ( new ItemHeader ( n - > T ( " UPnP (port-forwarding) " ) ) ) ;
2020-03-19 08:21:00 +00:00
networkingSettings - > Add ( new CheckBox ( & g_Config . bEnableUPnP , n - > T ( " Enable UPnP " , " Enable UPnP (need a few seconds to detect) " ) ) ) ;
2022-06-30 17:32:36 +00:00
auto useOriPort = networkingSettings - > Add ( new CheckBox ( & g_Config . bUPnPUseOriginalPort , n - > T ( " UPnP use original port " , " UPnP use original port (Enabled = PSP compatibility) " ) ) ) ;
useOriPort - > OnClick . Add ( [ = ] ( EventParams & e ) {
if ( g_Config . bUPnPUseOriginalPort )
2022-07-02 18:37:51 +00:00
settingInfo_ - > Show ( n - > T ( " UseOriginalPort Tip " , " May not work for all devices or games, see wiki. " ) , e . v ) ;
2022-06-30 17:32:36 +00:00
return UI : : EVENT_CONTINUE ;
} ) ;
useOriPort - > SetEnabledPtr ( & g_Config . bEnableUPnP ) ;
2015-01-04 10:59:43 +00:00
2020-03-23 21:39:09 +00:00
networkingSettings - > Add ( new ItemHeader ( n - > T ( " Chat " ) ) ) ;
2016-10-21 12:40:11 +00:00
networkingSettings - > Add ( new CheckBox ( & g_Config . bEnableNetworkChat , n - > T ( " Enable network chat " , " Enable network chat " ) ) ) ;
2021-08-19 22:03:42 +00:00
static const char * chatButtonPositions [ ] = { " Bottom Left " , " Bottom Center " , " Bottom Right " , " Top Left " , " Top Center " , " Top Right " , " Center Left " , " Center Right " , " None " } ;
2023-04-05 22:34:50 +00:00
networkingSettings - > Add ( new PopupMultiChoice ( & g_Config . iChatButtonPosition , n - > T ( " Chat Button Position " ) , chatButtonPositions , 0 , ARRAY_SIZE ( chatButtonPositions ) , I18NCat : : NETWORKING , screenManager ( ) ) ) - > SetEnabledPtr ( & g_Config . bEnableNetworkChat ) ;
2020-03-23 21:39:09 +00:00
static const char * chatScreenPositions [ ] = { " Bottom Left " , " Bottom Center " , " Bottom Right " , " Top Left " , " Top Center " , " Top Right " } ;
2023-04-05 22:34:50 +00:00
networkingSettings - > Add ( new PopupMultiChoice ( & g_Config . iChatScreenPosition , n - > T ( " Chat Screen Position " ) , chatScreenPositions , 0 , ARRAY_SIZE ( chatScreenPositions ) , I18NCat : : NETWORKING , screenManager ( ) ) ) - > SetEnabledPtr ( & g_Config . bEnableNetworkChat ) ;
2021-08-19 22:03:42 +00:00
# if (!defined(MOBILE_DEVICE) && !defined(USING_QT_UI)) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) // Missing only iOS?
2020-03-23 21:39:09 +00:00
networkingSettings - > Add ( new ItemHeader ( n - > T ( " QuickChat " , " Quick Chat " ) ) ) ;
2021-08-19 22:03:42 +00:00
CheckBox * qc = networkingSettings - > Add ( new CheckBox ( & g_Config . bEnableQuickChat , n - > T ( " EnableQuickChat " , " Enable Quick Chat " ) ) ) ;
qc - > SetEnabledPtr ( & g_Config . bEnableNetworkChat ) ;
# endif
2017-07-06 13:43:39 +00:00
# if !defined(MOBILE_DEVICE) && !defined(USING_QT_UI) // TODO: Add all platforms where KEY_CHAR support is added
2020-03-23 21:39:09 +00:00
PopupTextInputChoice * qc1 = networkingSettings - > Add ( new PopupTextInputChoice ( & g_Config . sQuickChat0 , n - > T ( " Quick Chat 1 " ) , " " , 32 , screenManager ( ) ) ) ;
PopupTextInputChoice * qc2 = networkingSettings - > Add ( new PopupTextInputChoice ( & g_Config . sQuickChat1 , n - > T ( " Quick Chat 2 " ) , " " , 32 , screenManager ( ) ) ) ;
PopupTextInputChoice * qc3 = networkingSettings - > Add ( new PopupTextInputChoice ( & g_Config . sQuickChat2 , n - > T ( " Quick Chat 3 " ) , " " , 32 , screenManager ( ) ) ) ;
PopupTextInputChoice * qc4 = networkingSettings - > Add ( new PopupTextInputChoice ( & g_Config . sQuickChat3 , n - > T ( " Quick Chat 4 " ) , " " , 32 , screenManager ( ) ) ) ;
PopupTextInputChoice * qc5 = networkingSettings - > Add ( new PopupTextInputChoice ( & g_Config . sQuickChat4 , n - > T ( " Quick Chat 5 " ) , " " , 32 , screenManager ( ) ) ) ;
2017-07-06 13:43:39 +00:00
# elif defined(USING_QT_UI)
2020-03-23 21:39:09 +00:00
Choice * qc1 = networkingSettings - > Add ( new Choice ( n - > T ( " Quick Chat 1 " ) ) ) ;
Choice * qc2 = networkingSettings - > Add ( new Choice ( n - > T ( " Quick Chat 2 " ) ) ) ;
Choice * qc3 = networkingSettings - > Add ( new Choice ( n - > T ( " Quick Chat 3 " ) ) ) ;
Choice * qc4 = networkingSettings - > Add ( new Choice ( n - > T ( " Quick Chat 4 " ) ) ) ;
Choice * qc5 = networkingSettings - > Add ( new Choice ( n - > T ( " Quick Chat 5 " ) ) ) ;
2021-08-19 22:03:42 +00:00
# elif PPSSPP_PLATFORM(ANDROID)
2023-04-06 14:26:12 +00:00
ChoiceWithValueDisplay * qc1 = networkingSettings - > Add ( new ChoiceWithValueDisplay ( & g_Config . sQuickChat0 , n - > T ( " Quick Chat 1 " ) , I18NCat : : NONE ) ) ;
ChoiceWithValueDisplay * qc2 = networkingSettings - > Add ( new ChoiceWithValueDisplay ( & g_Config . sQuickChat1 , n - > T ( " Quick Chat 2 " ) , I18NCat : : NONE ) ) ;
ChoiceWithValueDisplay * qc3 = networkingSettings - > Add ( new ChoiceWithValueDisplay ( & g_Config . sQuickChat2 , n - > T ( " Quick Chat 3 " ) , I18NCat : : NONE ) ) ;
ChoiceWithValueDisplay * qc4 = networkingSettings - > Add ( new ChoiceWithValueDisplay ( & g_Config . sQuickChat3 , n - > T ( " Quick Chat 4 " ) , I18NCat : : NONE ) ) ;
ChoiceWithValueDisplay * qc5 = networkingSettings - > Add ( new ChoiceWithValueDisplay ( & g_Config . sQuickChat4 , n - > T ( " Quick Chat 5 " ) , I18NCat : : NONE ) ) ;
2021-08-19 22:03:42 +00:00
# endif
# if (!defined(MOBILE_DEVICE) && !defined(USING_QT_UI)) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID)
qc1 - > SetEnabledFunc ( [ ] { return g_Config . bEnableQuickChat & & g_Config . bEnableNetworkChat ; } ) ;
qc2 - > SetEnabledFunc ( [ ] { return g_Config . bEnableQuickChat & & g_Config . bEnableNetworkChat ; } ) ;
qc3 - > SetEnabledFunc ( [ ] { return g_Config . bEnableQuickChat & & g_Config . bEnableNetworkChat ; } ) ;
qc4 - > SetEnabledFunc ( [ ] { return g_Config . bEnableQuickChat & & g_Config . bEnableNetworkChat ; } ) ;
qc5 - > SetEnabledFunc ( [ ] { return g_Config . bEnableQuickChat & & g_Config . bEnableNetworkChat ; } ) ;
# endif
# if defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID)
2021-10-02 04:54:38 +00:00
if ( System_GetPropertyBool ( SYSPROP_HAS_KEYBOARD ) ) {
qc1 - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeQuickChat0 ) ;
qc2 - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeQuickChat1 ) ;
qc3 - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeQuickChat2 ) ;
qc4 - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeQuickChat3 ) ;
qc5 - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeQuickChat4 ) ;
}
2017-07-06 13:43:39 +00:00
# endif
2017-08-08 20:19:28 +00:00
2020-11-22 17:02:23 +00:00
networkingSettings - > Add ( new ItemHeader ( n - > T ( " Misc " , " Misc (default = compatibility) " ) ) ) ;
2023-04-05 08:35:41 +00:00
networkingSettings - > Add ( new PopupSliderChoice ( & g_Config . iPortOffset , 0 , 60000 , 10000 , n - > T ( " Port offset " , " Port offset (0 = PSP compatibility) " ) , 100 , screenManager ( ) ) ) ;
networkingSettings - > Add ( new PopupSliderChoice ( & g_Config . iMinTimeout , 0 , 15000 , 0 , n - > T ( " Minimum Timeout " , " Minimum Timeout (override in ms, 0 = default) " ) , 50 , screenManager ( ) ) ) ;
2020-10-07 18:38:43 +00:00
networkingSettings - > Add ( new CheckBox ( & g_Config . bForcedFirstConnect , n - > T ( " Forced First Connect " , " Forced First Connect (faster Connect) " ) ) ) ;
2023-01-31 16:16:31 +00:00
}
2020-08-01 16:36:17 +00:00
2023-01-31 16:16:31 +00:00
void GameSettingsScreen : : CreateToolsSettings ( UI : : ViewGroup * tools ) {
using namespace UI ;
2023-04-05 22:34:50 +00:00
auto sa = GetI18NCategory ( I18NCat : : SAVEDATA ) ;
auto sy = GetI18NCategory ( I18NCat : : SYSTEM ) ;
auto ms = GetI18NCategory ( I18NCat : : MAINSETTINGS ) ;
auto dev = GetI18NCategory ( I18NCat : : DEVELOPER ) ;
auto ri = GetI18NCategory ( I18NCat : : REMOTEISO ) ;
2015-06-12 18:37:42 +00:00
tools - > Add ( new ItemHeader ( ms - > T ( " Tools " ) ) ) ;
2015-07-04 20:05:17 +00:00
// These were moved here so use the wrong translation objects, to avoid having to change all inis... This isn't a sustainable situation :P
2015-06-21 14:49:21 +00:00
tools - > Add ( new Choice ( sa - > T ( " Savedata Manager " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnSavedataManager ) ;
2015-06-30 03:28:31 +00:00
tools - > Add ( new Choice ( dev - > T ( " System Information " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnSysInfo ) ;
2015-07-04 20:05:17 +00:00
tools - > Add ( new Choice ( sy - > T ( " Developer Tools " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnDeveloperTools ) ;
2017-08-16 22:21:00 +00:00
tools - > Add ( new Choice ( ri - > T ( " Remote disc streaming " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnRemoteISO ) ;
2023-01-31 16:16:31 +00:00
}
2015-06-12 18:37:42 +00:00
2023-01-31 16:16:31 +00:00
void GameSettingsScreen : : CreateSystemSettings ( UI : : ViewGroup * systemSettings ) {
using namespace UI ;
2023-04-05 22:34:50 +00:00
auto sy = GetI18NCategory ( I18NCat : : SYSTEM ) ;
2023-04-11 21:07:33 +00:00
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
2023-04-05 22:34:50 +00:00
auto vr = GetI18NCategory ( I18NCat : : VR ) ;
auto th = GetI18NCategory ( I18NCat : : THEMES ) ;
2013-08-17 21:49:06 +00:00
2023-06-21 13:45:07 +00:00
systemSettings - > Add ( new ItemHeader ( sy - > T ( " UI " ) ) ) ;
systemSettings - > Add ( new Choice ( sy - > T ( " RetroAchievements " ) ) ) - > OnClick . Add ( [ & ] ( UI : : EventParams & ) - > UI : : EventReturn {
2023-06-16 14:29:44 +00:00
screenManager ( ) - > push ( new RetroAchievementsSettingsScreen ( gamePath_ ) ) ;
return UI : : EVENT_DONE ;
} ) ;
2022-12-05 11:07:07 +00:00
auto langCodeToName = [ ] ( const char * value ) - > std : : string {
auto & mapping = g_Config . GetLangValuesMapping ( ) ;
auto iter = mapping . find ( value ) ;
if ( iter ! = mapping . end ( ) ) {
return iter - > second . first ;
}
return value ;
} ;
systemSettings - > Add ( new ChoiceWithValueDisplay ( & g_Config . sLanguageIni , sy - > T ( " Language " ) , langCodeToName ) ) - > OnClick . Add ( [ & ] ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto sy = GetI18NCategory ( I18NCat : : SYSTEM ) ;
2022-11-30 21:59:43 +00:00
auto langScreen = new NewLanguageScreen ( sy - > T ( " Language " ) ) ;
langScreen - > OnChoice . Add ( [ & ] ( UI : : EventParams & e ) {
screenManager ( ) - > RecreateAllViews ( ) ;
2023-03-21 10:21:19 +00:00
System_Notify ( SystemNotification : : UI ) ;
2023-02-01 02:41:12 +00:00
return UI : : EVENT_DONE ;
} ) ;
2022-11-30 21:59:43 +00:00
if ( e . v )
langScreen - > SetPopupOrigin ( e . v ) ;
screenManager ( ) - > push ( langScreen ) ;
return UI : : EVENT_DONE ;
} ) ;
2020-10-22 18:17:02 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bUISound , sy - > T ( " UI Sound " ) ) ) ;
2021-05-05 23:31:38 +00:00
const Path bgPng = GetSysDirectory ( DIRECTORY_SYSTEM ) / " background.png " ;
const Path bgJpg = GetSysDirectory ( DIRECTORY_SYSTEM ) / " background.jpg " ;
2021-03-23 22:41:16 +00:00
if ( File : : Exists ( bgPng ) | | File : : Exists ( bgJpg ) ) {
backgroundChoice_ = systemSettings - > Add ( new Choice ( sy - > T ( " Clear UI background " ) ) ) ;
} else if ( System_GetPropertyBool ( SYSPROP_HAS_IMAGE_BROWSER ) ) {
backgroundChoice_ = systemSettings - > Add ( new Choice ( sy - > T ( " Set UI background... " ) ) ) ;
} else {
backgroundChoice_ = nullptr ;
}
if ( backgroundChoice_ ! = nullptr ) {
backgroundChoice_ - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeBackground ) ;
}
2022-02-11 11:32:23 +00:00
2022-12-16 08:09:21 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bTransparentBackground , sy - > T ( " Transparent UI background " ) ) ) ;
2023-05-01 12:36:41 +00:00
static const char * backgroundAnimations [ ] = { " No animation " , " Floating symbols " , " Recent games " , " Waves " , " Moving background " } ;
systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iBackgroundAnimation , sy - > T ( " UI background animation " ) , backgroundAnimations , 0 , ARRAY_SIZE ( backgroundAnimations ) , I18NCat : : SYSTEM , screenManager ( ) ) ) ;
2023-04-05 22:34:50 +00:00
PopupMultiChoiceDynamic * theme = systemSettings - > Add ( new PopupMultiChoiceDynamic ( & g_Config . sThemeName , sy - > T ( " Theme " ) , GetThemeInfoNames ( ) , I18NCat : : THEMES , screenManager ( ) ) ) ;
2022-02-11 11:32:23 +00:00
theme - > OnChoice . Add ( [ = ] ( EventParams & e ) {
2022-03-31 15:03:34 +00:00
UpdateTheme ( screenManager ( ) - > getUIContext ( ) ) ;
2022-02-11 11:32:23 +00:00
return UI : : EVENT_CONTINUE ;
} ) ;
2023-01-31 16:16:31 +00:00
Draw : : DrawContext * draw = screenManager ( ) - > getDrawContext ( ) ;
2022-06-19 09:53:16 +00:00
if ( ! draw - > GetBugs ( ) . Has ( Draw : : Bugs : : RASPBERRY_SHADER_COMP_HANG ) ) {
// We use shaders without tint capability on hardware with this driver bug.
2023-04-05 08:16:21 +00:00
PopupSliderChoiceFloat * tint = new PopupSliderChoiceFloat ( & g_Config . fUITint , 0.0f , 1.0f , 0.0f , sy - > T ( " Color Tint " ) , 0.01f , screenManager ( ) ) ;
2022-06-19 09:53:16 +00:00
tint - > SetHasDropShadow ( false ) ;
tint - > SetLiveUpdate ( true ) ;
systemSettings - > Add ( tint ) ;
2023-04-05 08:16:21 +00:00
PopupSliderChoiceFloat * saturation = new PopupSliderChoiceFloat ( & g_Config . fUISaturation , 0.0f , 2.0f , 1.0f , sy - > T ( " Color Saturation " ) , 0.01f , screenManager ( ) ) ;
2022-06-19 09:53:16 +00:00
saturation - > SetHasDropShadow ( false ) ;
saturation - > SetLiveUpdate ( true ) ;
systemSettings - > Add ( saturation ) ;
}
2022-02-11 14:12:52 +00:00
2021-06-05 21:49:39 +00:00
systemSettings - > Add ( new ItemHeader ( sy - > T ( " PSP Memory Stick " ) ) ) ;
2017-04-02 17:50:09 +00:00
2023-02-02 13:54:50 +00:00
if ( System_GetPropertyBool ( SYSPROP_HAS_OPEN_DIRECTORY ) ) {
systemSettings - > Add ( new Choice ( sy - > T ( " Show Memory Stick folder " ) ) ) - > OnClick . Add ( [ ] ( UI : : EventParams & p ) {
2023-03-21 09:42:23 +00:00
System_ShowFileInFolder ( File : : ResolvePath ( g_Config . memStickDirectory . ToString ( ) ) . c_str ( ) ) ;
2023-02-02 13:54:50 +00:00
return UI : : EVENT_DONE ;
} ) ;
}
2021-10-09 22:59:32 +00:00
2023-01-22 17:32:34 +00:00
# if PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS)
systemSettings - > Add ( new Choice ( sy - > T ( " Set Memory Stick folder " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeMemStickDir ) ;
# endif
2021-09-19 16:49:48 +00:00
# if PPSSPP_PLATFORM(ANDROID)
2023-05-03 17:41:23 +00:00
if ( System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) ! = DEVICE_TYPE_VR ) {
memstickDisplay_ = g_Config . memStickDirectory . ToVisualString ( ) ;
auto memstickPath = systemSettings - > Add ( new ChoiceWithValueDisplay ( & memstickDisplay_ , sy - > T ( " Memory Stick folder " , " Memory Stick folder " ) , I18NCat : : NONE ) ) ;
memstickPath - > SetEnabled ( ! PSP_IsInited ( ) ) ;
memstickPath - > OnClick . Handle ( this , & GameSettingsScreen : : OnChangeMemStickDir ) ;
// Display USB path for convenience.
std : : string usbPath ;
if ( PathToVisualUsbPath ( g_Config . memStickDirectory , usbPath ) ) {
if ( usbPath . empty ( ) ) {
// Probably it's just the root. So let's add PSP to make it clear.
usbPath = " /PSP " ;
}
systemSettings - > Add ( new InfoItem ( sy - > T ( " USB " ) , usbPath ) ) - > SetChoiceStyle ( true ) ;
2021-09-19 17:19:15 +00:00
}
}
2019-02-18 17:15:15 +00:00
# elif defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
2015-07-01 23:00:04 +00:00
SavePathInMyDocumentChoice = systemSettings - > Add ( new CheckBox ( & installed_ , sy - > T ( " Save path in My Documents " , " Save path in My Documents " ) ) ) ;
2020-04-11 17:46:06 +00:00
SavePathInMyDocumentChoice - > SetEnabled ( ! PSP_IsInited ( ) ) ;
2014-10-26 00:35:11 +00:00
SavePathInMyDocumentChoice - > OnClick . Handle ( this , & GameSettingsScreen : : OnSavePathMydoc ) ;
2015-07-01 23:00:04 +00:00
SavePathInOtherChoice = systemSettings - > Add ( new CheckBox ( & otherinstalled_ , sy - > T ( " Save path in installed.txt " , " Save path in installed.txt " ) ) ) ;
2014-10-23 14:22:11 +00:00
SavePathInOtherChoice - > SetEnabled ( false ) ;
SavePathInOtherChoice - > OnClick . Handle ( this , & GameSettingsScreen : : OnSavePathOther ) ;
2020-01-04 18:57:23 +00:00
const bool myDocsExists = W32Util : : UserDocumentsPath ( ) . size ( ) ! = 0 ;
2021-05-05 23:31:38 +00:00
2021-05-15 16:59:25 +00:00
const Path & PPSSPPpath = File : : GetExeDirectory ( ) ;
2021-05-05 23:31:38 +00:00
const Path installedFile = PPSSPPpath / " installed.txt " ;
2014-11-03 00:53:15 +00:00
installed_ = File : : Exists ( installedFile ) ;
otherinstalled_ = false ;
2020-01-04 18:57:23 +00:00
if ( ! installed_ & & myDocsExists ) {
2021-05-05 23:31:38 +00:00
if ( File : : CreateEmptyFile ( PPSSPPpath / " installedTEMP.txt " ) ) {
2014-10-26 00:35:11 +00:00
// Disable the setting whether cannot create & delete file
2021-05-05 23:31:38 +00:00
if ( ! ( File : : Delete ( PPSSPPpath / " installedTEMP.txt " ) ) )
2014-10-26 00:35:11 +00:00
SavePathInMyDocumentChoice - > SetEnabled ( false ) ;
2014-10-27 10:48:48 +00:00
else
2020-04-11 17:46:06 +00:00
SavePathInOtherChoice - > SetEnabled ( ! PSP_IsInited ( ) ) ;
2015-01-10 23:09:17 +00:00
} else
2014-10-23 14:22:11 +00:00
SavePathInMyDocumentChoice - > SetEnabled ( false ) ;
2015-01-10 23:09:17 +00:00
} else {
2020-01-04 18:57:23 +00:00
if ( installed_ & & myDocsExists ) {
2021-05-09 23:15:57 +00:00
FILE * testInstalled = File : : OpenCFile ( installedFile , " rt " ) ;
if ( testInstalled ) {
char temp [ 2048 ] ;
char * tempStr = fgets ( temp , sizeof ( temp ) , testInstalled ) ;
2014-10-24 14:21:49 +00:00
// Skip UTF-8 encoding bytes if there are any. There are 3 of them.
2021-05-09 23:15:57 +00:00
if ( tempStr & & strncmp ( tempStr , " \xEF \xBB \xBF " , 3 ) = = 0 ) {
tempStr + = 3 ;
}
2020-04-11 17:46:06 +00:00
SavePathInOtherChoice - > SetEnabled ( ! PSP_IsInited ( ) ) ;
2021-05-09 23:15:57 +00:00
if ( tempStr & & strlen ( tempStr ) ! = 0 & & strcmp ( tempStr , " \n " ) ! = 0 ) {
2014-11-03 00:53:15 +00:00
installed_ = false ;
otherinstalled_ = true ;
2014-10-24 14:21:49 +00:00
}
2021-05-09 23:15:57 +00:00
fclose ( testInstalled ) ;
2014-10-23 14:22:11 +00:00
}
2020-01-04 18:57:23 +00:00
} else if ( ! myDocsExists ) {
2014-10-24 14:21:49 +00:00
SavePathInMyDocumentChoice - > SetEnabled ( false ) ;
2020-01-04 18:57:23 +00:00
}
2015-01-10 23:09:17 +00:00
}
2014-10-23 14:22:11 +00:00
# endif
2021-08-04 21:21:28 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bMemStickInserted , sy - > T ( " Memory Stick inserted " ) ) ) ;
2023-04-05 08:35:41 +00:00
UI : : PopupSliderChoice * sizeChoice = systemSettings - > Add ( new PopupSliderChoice ( & g_Config . iMemStickSizeGB , 1 , 32 , 16 , sy - > T ( " Memory Stick size " , " Memory Stick size " ) , screenManager ( ) , " GB " ) ) ;
2021-09-19 17:19:15 +00:00
sizeChoice - > SetFormat ( " %d GB " ) ;
2021-08-04 21:21:28 +00:00
2021-09-18 17:08:41 +00:00
systemSettings - > Add ( new ItemHeader ( sy - > T ( " Help the PPSSPP team " ) ) ) ;
if ( ! enableReportsSet_ )
enableReports_ = Reporting : : IsEnabled ( ) ;
enableReportsSet_ = true ;
enableReportsCheckbox_ = new CheckBox ( & enableReports_ , sy - > T ( " Enable Compatibility Server Reports " ) ) ;
enableReportsCheckbox_ - > SetEnabled ( Reporting : : IsSupported ( ) ) ;
systemSettings - > Add ( enableReportsCheckbox_ ) ;
systemSettings - > Add ( new ItemHeader ( sy - > T ( " Emulation " ) ) ) ;
systemSettings - > Add ( new CheckBox ( & g_Config . bFastMemory , sy - > T ( " Fast Memory " , " Fast Memory " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnJitAffectingSetting ) ;
systemSettings - > Add ( new CheckBox ( & g_Config . bIgnoreBadMemAccess , sy - > T ( " Ignore bad memory accesses " ) ) ) ;
static const char * ioTimingMethods [ ] = { " Fast (lag on slow storage) " , " Host (bugs, less lag) " , " Simulate UMD delays " } ;
2023-04-05 22:34:50 +00:00
View * ioTimingMethod = systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iIOTimingMethod , sy - > T ( " IO timing method " ) , ioTimingMethods , 0 , ARRAY_SIZE ( ioTimingMethods ) , I18NCat : : SYSTEM , screenManager ( ) ) ) ;
2022-05-11 00:06:09 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bForceLagSync , sy - > T ( " Force real clock sync (slower, less lag) " ) ) ) - > SetDisabledPtr ( & g_Config . bAutoFrameSkip ) ;
2023-04-05 08:35:41 +00:00
PopupSliderChoice * lockedMhz = systemSettings - > Add ( new PopupSliderChoice ( & g_Config . iLockedCPUSpeed , 0 , 1000 , 0 , sy - > T ( " Change CPU Clock " , " Change CPU Clock (unstable) " ) , screenManager ( ) , sy - > T ( " MHz, 0:default " ) ) ) ;
2021-09-18 17:08:41 +00:00
lockedMhz - > OnChange . Add ( [ & ] ( UI : : EventParams & ) {
enableReportsCheckbox_ - > SetEnabled ( Reporting : : IsSupported ( ) ) ;
return UI : : EVENT_CONTINUE ;
} ) ;
lockedMhz - > SetZeroLabel ( sy - > T ( " Auto " ) ) ;
2023-04-14 12:34:48 +00:00
PopupSliderChoice * rewindInterval = systemSettings - > Add ( new PopupSliderChoice ( & g_Config . iRewindSnapshotInterval , 0 , 60 , 0 , sy - > T ( " Rewind Snapshot Interval " ) , screenManager ( ) , di - > T ( " seconds, 0:off " ) ) ) ;
2023-04-11 21:07:33 +00:00
rewindInterval - > SetFormat ( di - > T ( " %d seconds " ) ) ;
2023-02-13 10:17:03 +00:00
rewindInterval - > SetZeroLabel ( sy - > T ( " Off " ) ) ;
2021-09-18 17:08:41 +00:00
2021-06-05 21:49:39 +00:00
systemSettings - > Add ( new ItemHeader ( sy - > T ( " General " ) ) ) ;
# if PPSSPP_PLATFORM(ANDROID)
if ( System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) = = DEVICE_TYPE_MOBILE ) {
2023-04-05 22:34:50 +00:00
auto co = GetI18NCategory ( I18NCat : : CONTROLS ) ;
2023-01-31 20:26:12 +00:00
2021-06-05 21:49:39 +00:00
static const char * screenRotation [ ] = { " Auto " , " Landscape " , " Portrait " , " Landscape Reversed " , " Portrait Reversed " , " Landscape Auto " } ;
2023-04-06 14:45:24 +00:00
PopupMultiChoice * rot = systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iScreenRotation , co - > T ( " Screen Rotation " ) , screenRotation , 0 , ARRAY_SIZE ( screenRotation ) , I18NCat : : CONTROLS , screenManager ( ) ) ) ;
2021-06-05 21:49:39 +00:00
rot - > OnChoice . Handle ( this , & GameSettingsScreen : : OnScreenRotation ) ;
if ( System_GetPropertyBool ( SYSPROP_SUPPORTS_SUSTAINED_PERF_MODE ) ) {
systemSettings - > Add ( new CheckBox ( & g_Config . bSustainedPerformanceMode , sy - > T ( " Sustained performance mode " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnSustainedPerformanceModeChange ) ;
}
}
# endif
systemSettings - > Add ( new Choice ( sy - > T ( " Restore Default Settings " ) ) ) - > OnClick . Handle ( this , & GameSettingsScreen : : OnRestoreDefaultSettings ) ;
systemSettings - > Add ( new CheckBox ( & g_Config . bEnableStateUndo , sy - > T ( " Savestate slot backups " ) ) ) ;
static const char * autoLoadSaveStateChoices [ ] = { " Off " , " Oldest Save " , " Newest Save " , " Slot 1 " , " Slot 2 " , " Slot 3 " , " Slot 4 " , " Slot 5 " } ;
2023-04-05 22:34:50 +00:00
systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iAutoLoadSaveState , sy - > T ( " Auto Load Savestate " ) , autoLoadSaveStateChoices , 0 , ARRAY_SIZE ( autoLoadSaveStateChoices ) , I18NCat : : SYSTEM , screenManager ( ) ) ) ;
2021-04-26 05:54:28 +00:00
if ( System_GetPropertyBool ( SYSPROP_HAS_KEYBOARD ) )
systemSettings - > Add ( new CheckBox ( & g_Config . bBypassOSKWithKeyboard , sy - > T ( " Use system native keyboard " ) ) ) ;
2013-10-15 06:06:37 +00:00
2020-04-11 17:46:06 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bCacheFullIsoInRam , sy - > T ( " Cache ISO in RAM " , " Cache full ISO in RAM " ) ) ) - > SetEnabled ( ! PSP_IsInited ( ) ) ;
2023-01-31 19:38:09 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bCheckForNewVersion , sy - > T ( " VersionCheck " , " Check for new versions of PPSSPP " ) ) ) ;
2014-10-30 23:14:00 +00:00
2021-08-14 14:57:33 +00:00
systemSettings - > Add ( new ItemHeader ( sy - > T ( " Cheats " , " Cheats " ) ) ) ;
2020-03-22 01:49:36 +00:00
CheckBox * enableCheats = systemSettings - > Add ( new CheckBox ( & g_Config . bEnableCheats , sy - > T ( " Enable Cheats " ) ) ) ;
enableCheats - > OnClick . Add ( [ & ] ( UI : : EventParams & ) {
enableReportsCheckbox_ - > SetEnabled ( Reporting : : IsSupported ( ) ) ;
return UI : : EVENT_CONTINUE ;
} ) ;
2013-08-20 16:03:52 +00:00
2015-07-01 23:00:04 +00:00
systemSettings - > Add ( new ItemHeader ( sy - > T ( " PSP Settings " ) ) ) ;
2023-01-31 16:16:31 +00:00
static const char * models [ ] = { " PSP-1000 " , " PSP-2000/3000 " } ;
2023-04-05 22:34:50 +00:00
systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iPSPModel , sy - > T ( " PSP Model " ) , models , 0 , ARRAY_SIZE ( models ) , I18NCat : : SYSTEM , screenManager ( ) ) ) - > SetEnabled ( ! PSP_IsInited ( ) ) ;
2015-07-01 23:00:04 +00:00
systemSettings - > Add ( new PopupTextInputChoice ( & g_Config . sNickName , sy - > T ( " Change Nickname " ) , " " , 32 , screenManager ( ) ) ) ;
systemSettings - > Add ( new CheckBox ( & g_Config . bScreenshotsAsPNG , sy - > T ( " Screenshots as PNG " ) ) ) ;
2019-05-02 20:56:25 +00:00
# if defined(_WIN32) || (defined(USING_QT_UI) && !defined(MOBILE_DEVICE))
2016-09-03 22:26:01 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bDumpFrames , sy - > T ( " Record Display " ) ) ) ;
systemSettings - > Add ( new CheckBox ( & g_Config . bUseFFV1 , sy - > T ( " Use Lossless Video Codec (FFV1) " ) ) ) ;
2019-06-04 08:30:47 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bDumpVideoOutput , sy - > T ( " Use output buffer (with overlay) for recording " ) ) ) ;
2016-09-04 16:52:14 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bDumpAudio , sy - > T ( " Record Audio " ) ) ) ;
2017-11-14 04:12:27 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bSaveLoadResetsAVdumping , sy - > T ( " Reset Recording on Save/Load State " ) ) ) ;
2013-11-29 15:46:47 +00:00
# endif
2015-07-01 23:00:04 +00:00
systemSettings - > Add ( new CheckBox ( & g_Config . bDayLightSavings , sy - > T ( " Day Light Saving " ) ) ) ;
2023-01-31 16:16:31 +00:00
static const char * dateFormat [ ] = { " YYYYMMDD " , " MMDDYYYY " , " DDMMYYYY " } ;
2023-04-05 22:34:50 +00:00
systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iDateFormat , sy - > T ( " Date Format " ) , dateFormat , 0 , 3 , I18NCat : : SYSTEM , screenManager ( ) ) ) ;
2020-07-15 01:59:23 +00:00
static const char * timeFormat [ ] = { " 24HR " , " 12HR " } ;
2023-04-05 22:34:50 +00:00
systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iTimeFormat , sy - > T ( " Time Format " ) , timeFormat , 0 , 2 , I18NCat : : SYSTEM , screenManager ( ) ) ) ;
2013-08-21 09:17:55 +00:00
static const char * buttonPref [ ] = { " Use O to confirm " , " Use X to confirm " } ;
2023-04-05 22:34:50 +00:00
systemSettings - > Add ( new PopupMultiChoice ( & g_Config . iButtonPreference , sy - > T ( " Confirmation Button " ) , buttonPref , 0 , 2 , I18NCat : : SYSTEM , screenManager ( ) ) ) ;
2023-01-31 16:16:31 +00:00
}
2021-04-26 05:40:37 +00:00
2023-01-31 16:16:31 +00:00
void GameSettingsScreen : : CreateVRSettings ( UI : : ViewGroup * vrSettings ) {
using namespace UI ;
2021-04-26 05:40:37 +00:00
2023-04-05 22:34:50 +00:00
auto vr = GetI18NCategory ( I18NCat : : VR ) ;
2022-07-27 17:47:11 +00:00
2023-01-31 16:16:31 +00:00
vrSettings - > Add ( new ItemHeader ( vr - > T ( " Virtual reality " ) ) ) ;
vrSettings - > Add ( new CheckBox ( & g_Config . bEnableVR , vr - > T ( " Virtual reality " ) ) ) ;
CheckBox * vr6DoF = vrSettings - > Add ( new CheckBox ( & g_Config . bEnable6DoF , vr - > T ( " 6DoF movement " ) ) ) ;
vr6DoF - > SetEnabledPtr ( & g_Config . bEnableVR ) ;
vrSettings - > Add ( new CheckBox ( & g_Config . bEnableStereo , vr - > T ( " Stereoscopic vision (Experimental) " ) ) ) ;
vrSettings - > Add ( new CheckBox ( & g_Config . bForce72Hz , vr - > T ( " Force 72Hz update " ) ) ) ;
2023-06-17 19:55:47 +00:00
if ( IsPassthroughSupported ( ) ) {
vrSettings - > Add ( new CheckBox ( & g_Config . bPassthrough , vr - > T ( " Enable passthrough " ) ) ) ;
}
2023-01-31 16:16:31 +00:00
vrSettings - > Add ( new ItemHeader ( vr - > T ( " VR camera " ) ) ) ;
2023-04-05 08:16:21 +00:00
vrSettings - > Add ( new PopupSliderChoiceFloat ( & g_Config . fCanvasDistance , 1.0f , 15.0f , 12.0f , vr - > T ( " Distance to 2D menus and scenes " ) , 1.0f , screenManager ( ) , " " ) ) ;
vrSettings - > Add ( new PopupSliderChoiceFloat ( & g_Config . fFieldOfViewPercentage , 100.0f , 200.0f , 100.0f , vr - > T ( " Field of view scale " ) , 10.0f , screenManager ( ) , vr - > T ( " % of native FoV " ) ) ) ;
2023-04-05 20:49:46 +00:00
vrSettings - > Add ( new CheckBox ( & g_Config . bRescaleHUD , vr - > T ( " Heads-up display detection " ) ) ) ;
PopupSliderChoiceFloat * vrHudScale = vrSettings - > Add ( new PopupSliderChoiceFloat ( & g_Config . fHeadUpDisplayScale , 0.0f , 1.5f , 0.3f , vr - > T ( " Heads-up display scale " ) , 0.1f , screenManager ( ) , " " ) ) ;
vrHudScale - > SetEnabledPtr ( & g_Config . bRescaleHUD ) ;
vrSettings - > Add ( new CheckBox ( & g_Config . bManualForceVR , vr - > T ( " Manual switching between flat screen and VR using SCREEN key " ) ) ) ;
2023-01-31 16:16:31 +00:00
vrSettings - > Add ( new ItemHeader ( vr - > T ( " Experts only " ) ) ) ;
2023-03-09 10:22:54 +00:00
vrSettings - > Add ( new CheckBox ( & g_Config . bHeadRotationEnabled , vr - > T ( " Map HMD rotations on keys instead of VR camera " ) ) ) ;
2023-04-05 08:16:21 +00:00
PopupSliderChoiceFloat * vrHeadRotationScale = vrSettings - > Add ( new PopupSliderChoiceFloat ( & g_Config . fHeadRotationScale , 0.1f , 10.0f , 5.0f , vr - > T ( " Game camera rotation step per frame " ) , 0.1f , screenManager ( ) , " ° " ) ) ;
2023-03-09 10:22:54 +00:00
vrHeadRotationScale - > SetEnabledPtr ( & g_Config . bHeadRotationEnabled ) ;
2023-01-31 16:16:31 +00:00
CheckBox * vrHeadRotationSmoothing = vrSettings - > Add ( new CheckBox ( & g_Config . bHeadRotationSmoothing , vr - > T ( " Game camera uses rotation smoothing " ) ) ) ;
2023-03-09 10:22:54 +00:00
vrHeadRotationSmoothing - > SetEnabledPtr ( & g_Config . bHeadRotationEnabled ) ;
2023-01-31 16:16:31 +00:00
vrSettings - > Add ( new CheckBox ( & g_Config . bEnableMotions , vr - > T ( " Map controller movements to keys " ) ) ) ;
2023-04-05 08:16:21 +00:00
PopupSliderChoiceFloat * vrMotions = vrSettings - > Add ( new PopupSliderChoiceFloat ( & g_Config . fMotionLength , 0.3f , 1.0f , 0.5f , vr - > T ( " Motion needed to generate action " ) , 0.1f , screenManager ( ) , vr - > T ( " m " ) ) ) ;
2023-01-31 16:16:31 +00:00
vrMotions - > SetEnabledPtr ( & g_Config . bEnableMotions ) ;
2023-03-12 13:41:17 +00:00
static const char * cameraPitchModes [ ] = { " Disabled " , " Top view -> First person " , " First person -> Top view " } ;
2023-04-12 20:55:35 +00:00
vrSettings - > Add ( new PopupMultiChoice ( & g_Config . iCameraPitch , vr - > T ( " Camera type " ) , cameraPitchModes , 0 , 3 , I18NCat : : NONE , screenManager ( ) ) ) ;
2013-06-08 20:42:31 +00:00
}
2014-07-22 07:55:12 +00:00
UI : : EventReturn GameSettingsScreen : : OnAutoFrameskip ( UI : : EventParams & e ) {
2023-02-14 16:11:32 +00:00
g_Config . UpdateAfterSettingAutoFrameSkip ( ) ;
2014-07-22 07:55:12 +00:00
return UI : : EVENT_DONE ;
}
2014-02-04 11:58:37 +00:00
UI : : EventReturn GameSettingsScreen : : OnScreenRotation ( UI : : EventParams & e ) {
2020-08-15 14:13:24 +00:00
INFO_LOG ( SYSTEM , " New display rotation: %d " , g_Config . iScreenRotation ) ;
INFO_LOG ( SYSTEM , " Sending rotate " ) ;
2023-03-22 21:55:53 +00:00
System_Notify ( SystemNotification : : ROTATE_UPDATED ) ;
2020-08-15 14:13:24 +00:00
INFO_LOG ( SYSTEM , " Got back from rotate " ) ;
2014-02-04 11:58:37 +00:00
return UI : : EVENT_DONE ;
}
2015-01-29 21:15:42 +00:00
UI : : EventReturn GameSettingsScreen : : OnAdhocGuides ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2023-03-21 09:42:23 +00:00
System_LaunchUrl ( LaunchUrlType : : BROWSER_URL , n - > T ( " MultiplayerHowToURL " , " https://github.com/hrydgard/ppsspp/wiki/How-to-play-multiplayer-games-with-PPSSPP " ) ) ;
2015-01-29 21:15:42 +00:00
return UI : : EVENT_DONE ;
}
2014-02-09 22:16:08 +00:00
UI : : EventReturn GameSettingsScreen : : OnImmersiveModeChange ( UI : : EventParams & e ) {
2023-03-22 22:15:08 +00:00
System_Notify ( SystemNotification : : IMMERSIVE_MODE_CHANGE ) ;
2023-05-17 07:37:15 +00:00
if ( g_Config . iAndroidHwScale ! = 0 ) {
System_RecreateActivity ( ) ;
}
2014-02-09 22:16:08 +00:00
return UI : : EVENT_DONE ;
}
2017-06-09 13:29:57 +00:00
UI : : EventReturn GameSettingsScreen : : OnSustainedPerformanceModeChange ( UI : : EventParams & e ) {
2023-03-22 22:25:00 +00:00
System_Notify ( SystemNotification : : SUSTAINED_PERF_CHANGE ) ;
2017-06-09 13:29:57 +00:00
return UI : : EVENT_DONE ;
}
2014-05-27 06:39:53 +00:00
UI : : EventReturn GameSettingsScreen : : OnJitAffectingSetting ( UI : : EventParams & e ) {
NativeMessageReceived ( " clear jit " , " " ) ;
return UI : : EVENT_DONE ;
}
2019-02-18 17:15:15 +00:00
UI : : EventReturn GameSettingsScreen : : OnChangeMemStickDir ( UI : : EventParams & e ) {
2023-01-22 21:23:07 +00:00
# if PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS)
2023-03-22 16:57:28 +00:00
System_BrowseForFolder ( " " , [ ] ( const std : : string & value , int ) {
DarwinFileSystemServices : : setUserPreferredMemoryStickDirectory ( Path ( value ) ) ;
} ) ;
2023-01-22 21:23:07 +00:00
# else
2021-07-25 13:33:11 +00:00
screenManager ( ) - > push ( new MemStickScreen ( false ) ) ;
2023-01-22 21:23:07 +00:00
# endif
2019-02-18 17:15:15 +00:00
return UI : : EVENT_DONE ;
}
2021-04-24 20:47:57 +00:00
# if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
2014-10-23 14:22:11 +00:00
UI : : EventReturn GameSettingsScreen : : OnSavePathMydoc ( UI : : EventParams & e ) {
2021-05-15 16:59:25 +00:00
const Path & PPSSPPpath = File : : GetExeDirectory ( ) ;
2021-08-14 00:07:38 +00:00
const Path installedFile = PPSSPPpath / " installed.txt " ;
2014-11-03 00:53:15 +00:00
installed_ = File : : Exists ( installedFile ) ;
if ( otherinstalled_ ) {
2021-05-05 23:31:38 +00:00
File : : Delete ( PPSSPPpath / " installed.txt " ) ;
File : : CreateEmptyFile ( PPSSPPpath / " installed.txt " ) ;
2014-11-03 00:53:15 +00:00
otherinstalled_ = false ;
2020-01-04 18:57:23 +00:00
const std : : string myDocsPath = W32Util : : UserDocumentsPath ( ) + " /PPSSPP/ " ;
2021-05-05 23:31:38 +00:00
g_Config . memStickDirectory = Path ( myDocsPath ) ;
2020-01-04 18:57:23 +00:00
} else if ( installed_ ) {
2021-05-05 23:31:38 +00:00
File : : Delete ( PPSSPPpath / " installed.txt " ) ;
2014-11-03 00:53:15 +00:00
installed_ = false ;
2021-05-05 23:31:38 +00:00
g_Config . memStickDirectory = PPSSPPpath / " memstick " ;
2020-01-04 18:57:23 +00:00
} else {
2021-05-05 23:31:38 +00:00
FILE * f = File : : OpenCFile ( PPSSPPpath / " installed.txt " , " wb " ) ;
2021-05-09 22:48:36 +00:00
if ( f ) {
fclose ( f ) ;
2014-10-23 14:22:11 +00:00
}
2020-01-04 18:57:23 +00:00
const std : : string myDocsPath = W32Util : : UserDocumentsPath ( ) + " /PPSSPP/ " ;
2021-05-05 23:31:38 +00:00
g_Config . memStickDirectory = Path ( myDocsPath ) ;
2014-11-03 00:53:15 +00:00
installed_ = true ;
2014-10-23 14:22:11 +00:00
}
2014-10-26 06:50:21 +00:00
return UI : : EVENT_DONE ;
2014-10-23 14:22:11 +00:00
}
UI : : EventReturn GameSettingsScreen : : OnSavePathOther ( UI : : EventParams & e ) {
2021-05-15 16:59:25 +00:00
const Path & PPSSPPpath = File : : GetExeDirectory ( ) ;
2014-11-03 00:53:15 +00:00
if ( otherinstalled_ ) {
2023-04-05 22:34:50 +00:00
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
2014-10-27 19:10:21 +00:00
std : : string folder = W32Util : : BrowseForFolder ( MainWindow : : GetHWND ( ) , di - > T ( " Choose PPSSPP save folder " ) ) ;
2014-10-27 18:57:40 +00:00
if ( folder . size ( ) ) {
2021-05-05 23:31:38 +00:00
g_Config . memStickDirectory = Path ( folder ) ;
FILE * f = File : : OpenCFile ( PPSSPPpath / " installed.txt " , " wb " ) ;
2015-01-27 22:56:41 +00:00
if ( f ) {
std : : string utfstring ( " \xEF \xBB \xBF " ) ;
utfstring . append ( folder ) ;
2015-02-04 12:34:53 +00:00
fwrite ( utfstring . c_str ( ) , 1 , utfstring . length ( ) , f ) ;
2015-01-27 22:56:41 +00:00
fclose ( f ) ;
}
2014-11-03 00:53:15 +00:00
installed_ = false ;
2014-10-27 10:48:48 +00:00
}
2014-10-27 11:14:39 +00:00
else
2014-11-03 00:53:15 +00:00
otherinstalled_ = false ;
2014-10-27 10:48:48 +00:00
}
else {
2021-05-05 23:31:38 +00:00
File : : Delete ( PPSSPPpath / " installed.txt " ) ;
2014-10-27 10:48:48 +00:00
SavePathInMyDocumentChoice - > SetEnabled ( true ) ;
2014-11-03 00:53:15 +00:00
otherinstalled_ = false ;
installed_ = false ;
2021-05-05 23:31:38 +00:00
g_Config . memStickDirectory = PPSSPPpath / " memstick " ;
2014-10-27 10:48:48 +00:00
}
2014-10-23 14:22:11 +00:00
return UI : : EVENT_DONE ;
}
# endif
2017-04-02 17:50:09 +00:00
UI : : EventReturn GameSettingsScreen : : OnChangeBackground ( UI : : EventParams & e ) {
2021-05-05 23:31:38 +00:00
const Path bgPng = GetSysDirectory ( DIRECTORY_SYSTEM ) / " background.png " ;
const Path bgJpg = GetSysDirectory ( DIRECTORY_SYSTEM ) / " background.jpg " ;
2017-04-02 17:50:09 +00:00
if ( File : : Exists ( bgPng ) | | File : : Exists ( bgJpg ) ) {
2021-04-26 21:34:20 +00:00
File : : Delete ( bgPng ) ;
File : : Delete ( bgJpg ) ;
2023-03-22 12:43:44 +00:00
UIBackgroundShutdown ( ) ;
2017-04-02 17:50:09 +00:00
} else {
2023-04-05 22:34:50 +00:00
auto sy = GetI18NCategory ( I18NCat : : SYSTEM ) ;
2023-03-22 12:43:44 +00:00
System_BrowseForImage ( sy - > T ( " Set UI background... " ) , [ ] ( const std : : string & value , int ) {
if ( ! value . empty ( ) ) {
Path dest = GetSysDirectory ( DIRECTORY_SYSTEM ) / ( endsWithNoCase ( value , " .jpg " ) ? " background.jpg " : " background.png " ) ;
File : : Copy ( Path ( value ) , dest ) ;
}
// It will init again automatically. We can't init outside a frame on Vulkan.
UIBackgroundShutdown ( ) ;
} ) ;
2017-04-02 17:50:09 +00:00
}
// Change to a browse or clear button.
RecreateViews ( ) ;
return UI : : EVENT_DONE ;
}
2013-10-13 17:24:49 +00:00
UI : : EventReturn GameSettingsScreen : : OnFullscreenChange ( UI : : EventParams & e ) {
2022-05-28 22:47:12 +00:00
g_Config . iForceFullScreen = - 1 ;
2023-03-22 21:17:53 +00:00
System_ToggleFullscreenState ( g_Config . UseFullScreen ( ) ? " 1 " : " 0 " ) ;
2022-05-28 22:47:12 +00:00
return UI : : EVENT_DONE ;
}
UI : : EventReturn GameSettingsScreen : : OnFullscreenMultiChange ( UI : : EventParams & e ) {
2023-03-22 21:17:53 +00:00
System_ToggleFullscreenState ( g_Config . UseFullScreen ( ) ? " 1 " : " 0 " ) ;
2013-10-13 17:24:49 +00:00
return UI : : EVENT_DONE ;
}
2013-09-10 22:19:34 +00:00
UI : : EventReturn GameSettingsScreen : : OnResolutionChange ( UI : : EventParams & e ) {
2023-05-17 07:37:15 +00:00
if ( g_Config . iAndroidHwScale = = 1 ) {
System_RecreateActivity ( ) ;
}
2014-02-09 22:04:16 +00:00
Reporting : : UpdateConfig ( ) ;
2022-11-27 20:34:51 +00:00
NativeMessageReceived ( " gpu_renderResized " , " " ) ;
2013-09-10 22:19:34 +00:00
return UI : : EVENT_DONE ;
}
2023-05-17 07:37:15 +00:00
UI : : EventReturn GameSettingsScreen : : OnHwScaleChange ( UI : : EventParams & e ) {
System_RecreateActivity ( ) ;
return UI : : EVENT_DONE ;
}
2013-10-25 11:19:08 +00:00
void GameSettingsScreen : : onFinish ( DialogResult result ) {
2013-09-01 19:57:39 +00:00
Reporting : : Enable ( enableReports_ , " report.ppsspp.org " ) ;
2014-02-16 04:34:03 +00:00
Reporting : : UpdateConfig ( ) ;
2021-08-07 08:47:11 +00:00
if ( ! g_Config . Save ( " GameSettingsScreen::onFinish " ) ) {
2023-03-22 21:55:53 +00:00
System_Toast ( " Failed to save settings! \n Check permissions, or try to restart the device. " ) ;
2021-08-07 08:47:11 +00:00
}
2016-08-05 17:46:11 +00:00
if ( editThenRestore_ ) {
2019-07-18 04:28:21 +00:00
// In case we didn't have the title yet before, try again.
std : : shared_ptr < GameInfo > info = g_gameInfoCache - > GetInfo ( nullptr , gamePath_ , 0 ) ;
g_Config . changeGameSpecific ( gameID_ , info - > GetTitle ( ) ) ;
2014-12-14 19:33:20 +00:00
g_Config . unloadGameConfig ( ) ;
}
2013-08-20 16:03:52 +00:00
2023-03-21 10:21:19 +00:00
System_Notify ( SystemNotification : : UI ) ;
2013-09-08 04:42:15 +00:00
2015-08-28 18:55:32 +00:00
KeyMap : : UpdateNativeMenuKeys ( ) ;
2017-03-17 09:27:49 +00:00
// Wipe some caches after potentially changing settings.
2022-11-21 14:14:20 +00:00
// Let's not send resize messages here, handled elsewhere.
NativeMessageReceived ( " gpu_configChanged " , " " ) ;
2013-10-25 11:19:08 +00:00
}
2021-07-24 22:54:41 +00:00
void GameSettingsScreen : : dialogFinished ( const Screen * dialog , DialogResult result ) {
if ( result = = DialogResult : : DR_OK ) {
2021-08-11 04:42:44 +00:00
g_Config . iFpsLimit1 = iAlternateSpeedPercent1_ < 0 ? - 1 : ( iAlternateSpeedPercent1_ * 60 ) / 100 ;
g_Config . iFpsLimit2 = iAlternateSpeedPercent2_ < 0 ? - 1 : ( iAlternateSpeedPercent2_ * 60 ) / 100 ;
2022-07-04 20:10:42 +00:00
g_Config . iAnalogFpsLimit = ( iAlternateSpeedPercentAnalog_ * 60 ) / 100 ;
2021-08-11 04:42:44 +00:00
2021-07-24 22:54:41 +00:00
RecreateViews ( ) ;
}
2022-07-05 03:20:31 +00:00
2023-03-29 09:59:31 +00:00
bool mapped = KeyMap : : InputMappingsFromPspButton ( VIRTKEY_SPEED_ANALOG , nullptr , true ) ;
2022-07-05 03:20:31 +00:00
if ( mapped ! = analogSpeedMapped_ ) {
analogSpeedMapped_ = mapped ;
RecreateViews ( ) ;
}
2021-07-24 22:54:41 +00:00
}
2019-02-18 17:15:15 +00:00
void GameSettingsScreen : : CallbackMemstickFolder ( bool yes ) {
2023-04-05 22:34:50 +00:00
auto sy = GetI18NCategory ( I18NCat : : SYSTEM ) ;
2019-02-18 17:15:15 +00:00
if ( yes ) {
2021-05-15 16:32:41 +00:00
Path memstickDirFile = g_Config . internalDataDirectory / " memstick_dir.txt " ;
2019-02-18 17:15:15 +00:00
std : : string testWriteFile = pendingMemstickFolder_ + " /.write_verify_file " ;
// Already, create away.
2021-05-09 13:02:46 +00:00
if ( ! File : : Exists ( Path ( pendingMemstickFolder_ ) ) ) {
2021-05-05 23:31:38 +00:00
File : : CreateFullPath ( Path ( pendingMemstickFolder_ ) ) ;
2019-02-18 17:15:15 +00:00
}
2021-05-09 13:02:46 +00:00
if ( ! File : : WriteDataToFile ( true , " 1 " , 1 , Path ( testWriteFile ) ) ) {
2019-02-18 17:15:15 +00:00
settingInfo_ - > Show ( sy - > T ( " ChangingMemstickPathInvalid " , " That path couldn't be used to save Memory Stick files. " ) , nullptr ) ;
return ;
}
2021-05-05 23:31:38 +00:00
File : : Delete ( Path ( testWriteFile ) ) ;
2019-02-18 17:15:15 +00:00
2021-05-29 20:55:43 +00:00
if ( ! File : : WriteDataToFile ( true , pendingMemstickFolder_ . c_str ( ) , ( unsigned int ) pendingMemstickFolder_ . size ( ) , memstickDirFile ) ) {
WARN_LOG ( SYSTEM , " Failed to write memstick folder to '%s' " , memstickDirFile . c_str ( ) ) ;
} else {
// Save so the settings, at least, are transferred.
g_Config . memStickDirectory = Path ( pendingMemstickFolder_ ) ;
g_Config . Save ( " MemstickPathChanged " ) ;
}
2019-02-18 17:15:15 +00:00
screenManager ( ) - > RecreateAllViews ( ) ;
}
}
2020-05-09 20:52:04 +00:00
void GameSettingsScreen : : TriggerRestart ( const char * why ) {
// Extra save here to make sure the choice really gets saved even if there are shutdown bugs in
// the GPU backend code.
g_Config . Save ( why ) ;
std : : string param = " --gamesettings " ;
if ( editThenRestore_ ) {
// We won't pass the gameID, so don't resume back into settings.
2022-09-30 09:26:30 +00:00
param . clear ( ) ;
2020-05-09 20:52:04 +00:00
} else if ( ! gamePath_ . empty ( ) ) {
2021-05-05 23:31:38 +00:00
param + = " \" " + ReplaceAll ( ReplaceAll ( gamePath_ . ToString ( ) , " \\ " , " \\ \\ " ) , " \" " , " \\ \" " ) + " \" " ;
2020-05-09 20:52:04 +00:00
}
2020-08-06 08:19:58 +00:00
// Make sure the new instance is considered the first.
ShutdownInstanceCounter ( ) ;
2023-03-22 21:17:53 +00:00
System_RestartApp ( param ) ;
2020-05-09 20:52:04 +00:00
}
2014-09-14 10:59:27 +00:00
void GameSettingsScreen : : CallbackRenderingBackend ( bool yes ) {
2016-01-06 06:37:28 +00:00
// If the user ends up deciding not to restart, set the config back to the current backend
2014-09-14 10:59:27 +00:00
// so it doesn't get switched by accident.
if ( yes ) {
2020-05-09 20:52:04 +00:00
TriggerRestart ( " GameSettingsScreen::RenderingBackendYes " ) ;
2014-09-14 10:59:27 +00:00
} else {
2016-01-06 06:37:28 +00:00
g_Config . iGPUBackend = ( int ) GetGPUBackend ( ) ;
2014-09-14 10:59:27 +00:00
}
}
2018-09-30 07:53:21 +00:00
void GameSettingsScreen : : CallbackRenderingDevice ( bool yes ) {
// If the user ends up deciding not to restart, set the config back to the current backend
// so it doesn't get switched by accident.
if ( yes ) {
2020-05-09 20:52:04 +00:00
TriggerRestart ( " GameSettingsScreen::RenderingDeviceYes " ) ;
2018-09-30 07:53:21 +00:00
} else {
std : : string * deviceNameSetting = GPUDeviceNameSetting ( ) ;
if ( deviceNameSetting )
* deviceNameSetting = GetGPUBackendDevice ( ) ;
// Needed to redraw the setting.
RecreateViews ( ) ;
}
}
2020-03-03 03:21:15 +00:00
void GameSettingsScreen : : CallbackInflightFrames ( bool yes ) {
if ( yes ) {
2020-05-09 20:52:04 +00:00
TriggerRestart ( " GameSettingsScreen::InflightFramesYes " ) ;
2020-03-03 03:21:15 +00:00
} else {
g_Config . iInflightFrames = prevInflightFrames_ ;
}
}
2014-09-14 10:59:27 +00:00
UI : : EventReturn GameSettingsScreen : : OnRenderingBackend ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
2014-09-14 10:59:27 +00:00
// It only makes sense to show the restart prompt if the backend was actually changed.
2016-01-06 06:37:28 +00:00
if ( g_Config . iGPUBackend ! = ( int ) GetGPUBackend ( ) ) {
2022-11-29 15:29:43 +00:00
screenManager ( ) - > push ( new PromptScreen ( gamePath_ , di - > T ( " ChangingGPUBackends " , " Changing GPU backends requires PPSSPP to restart. Restart now? " ) , di - > T ( " Yes " ) , di - > T ( " No " ) ,
2016-10-12 09:32:24 +00:00
std : : bind ( & GameSettingsScreen : : CallbackRenderingBackend , this , std : : placeholders : : _1 ) ) ) ;
2014-09-14 10:59:27 +00:00
}
return UI : : EVENT_DONE ;
}
2018-09-30 07:53:21 +00:00
UI : : EventReturn GameSettingsScreen : : OnRenderingDevice ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
2018-09-30 07:53:21 +00:00
// It only makes sense to show the restart prompt if the device was actually changed.
std : : string * deviceNameSetting = GPUDeviceNameSetting ( ) ;
if ( deviceNameSetting & & * deviceNameSetting ! = GetGPUBackendDevice ( ) ) {
2022-11-29 15:29:43 +00:00
screenManager ( ) - > push ( new PromptScreen ( gamePath_ , di - > T ( " ChangingGPUBackends " , " Changing GPU backends requires PPSSPP to restart. Restart now? " ) , di - > T ( " Yes " ) , di - > T ( " No " ) ,
2018-09-30 07:53:21 +00:00
std : : bind ( & GameSettingsScreen : : CallbackRenderingDevice , this , std : : placeholders : : _1 ) ) ) ;
}
return UI : : EVENT_DONE ;
}
2020-03-03 03:21:15 +00:00
UI : : EventReturn GameSettingsScreen : : OnInflightFramesChoice ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
2020-03-03 03:21:15 +00:00
if ( g_Config . iInflightFrames ! = prevInflightFrames_ ) {
2022-11-29 15:29:43 +00:00
screenManager ( ) - > push ( new PromptScreen ( gamePath_ , di - > T ( " ChangingInflightFrames " , " Changing graphics command buffering requires PPSSPP to restart. Restart now? " ) , di - > T ( " Yes " ) , di - > T ( " No " ) ,
2020-03-03 03:21:15 +00:00
std : : bind ( & GameSettingsScreen : : CallbackInflightFrames , this , std : : placeholders : : _1 ) ) ) ;
}
return UI : : EVENT_DONE ;
}
2020-01-09 13:57:09 +00:00
UI : : EventReturn GameSettingsScreen : : OnCameraDeviceChange ( UI : : EventParams & e ) {
Camera : : onCameraDeviceChange ( ) ;
return UI : : EVENT_DONE ;
}
2020-07-31 02:24:17 +00:00
UI : : EventReturn GameSettingsScreen : : OnMicDeviceChange ( UI : : EventParams & e ) {
Microphone : : onMicDeviceChange ( ) ;
return UI : : EVENT_DONE ;
}
2019-09-15 20:23:48 +00:00
UI : : EventReturn GameSettingsScreen : : OnAudioDevice ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto a = GetI18NCategory ( I18NCat : : AUDIO ) ;
2019-09-15 20:42:56 +00:00
if ( g_Config . sAudioDevice = = a - > T ( " Auto " ) ) {
g_Config . sAudioDevice . clear ( ) ;
}
2023-03-22 22:15:08 +00:00
System_Notify ( SystemNotification : : AUDIO_RESET_DEVICE ) ;
2019-09-15 20:23:48 +00:00
return UI : : EVENT_DONE ;
2020-03-02 15:25:18 +00:00
}
2017-07-06 13:43:39 +00:00
UI : : EventReturn GameSettingsScreen : : OnChangeQuickChat0 ( UI : : EventParams & e ) {
2023-06-21 22:47:00 +00:00
# if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2023-03-22 11:26:14 +00:00
System_InputBoxGetString ( n - > T ( " Enter Quick Chat 1 " ) , g_Config . sQuickChat0 , [ ] ( const std : : string & value , int ) {
g_Config . sQuickChat0 = value ;
2020-03-09 01:59:17 +00:00
} ) ;
2017-07-06 13:43:39 +00:00
# endif
return UI : : EVENT_DONE ;
}
UI : : EventReturn GameSettingsScreen : : OnChangeQuickChat1 ( UI : : EventParams & e ) {
2023-06-21 22:47:00 +00:00
# if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2023-03-22 11:26:14 +00:00
System_InputBoxGetString ( n - > T ( " Enter Quick Chat 2 " ) , g_Config . sQuickChat1 , [ ] ( const std : : string & value , int ) {
g_Config . sQuickChat1 = value ;
2020-03-09 01:59:17 +00:00
} ) ;
2017-07-06 13:43:39 +00:00
# endif
return UI : : EVENT_DONE ;
}
UI : : EventReturn GameSettingsScreen : : OnChangeQuickChat2 ( UI : : EventParams & e ) {
2023-06-21 22:47:00 +00:00
# if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2023-03-22 11:26:14 +00:00
System_InputBoxGetString ( n - > T ( " Enter Quick Chat 3 " ) , g_Config . sQuickChat2 , [ ] ( const std : : string & value , int ) {
g_Config . sQuickChat2 = value ;
2020-03-09 01:59:17 +00:00
} ) ;
2017-07-06 13:43:39 +00:00
# endif
return UI : : EVENT_DONE ;
}
UI : : EventReturn GameSettingsScreen : : OnChangeQuickChat3 ( UI : : EventParams & e ) {
2023-06-21 22:47:00 +00:00
# if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2023-03-22 11:26:14 +00:00
System_InputBoxGetString ( n - > T ( " Enter Quick Chat 4 " ) , g_Config . sQuickChat3 , [ ] ( const std : : string & value , int ) {
g_Config . sQuickChat3 = value ;
2020-03-09 01:59:17 +00:00
} ) ;
2017-07-06 13:43:39 +00:00
# endif
return UI : : EVENT_DONE ;
}
UI : : EventReturn GameSettingsScreen : : OnChangeQuickChat4 ( UI : : EventParams & e ) {
2023-06-21 22:47:00 +00:00
# if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2023-03-22 11:26:14 +00:00
System_InputBoxGetString ( n - > T ( " Enter Quick Chat 5 " ) , g_Config . sQuickChat4 , [ ] ( const std : : string & value , int ) {
g_Config . sQuickChat4 = value ;
2020-03-09 01:59:17 +00:00
} ) ;
2017-07-06 13:43:39 +00:00
# endif
return UI : : EVENT_DONE ;
2019-09-15 20:23:48 +00:00
}
2013-08-20 16:03:52 +00:00
UI : : EventReturn GameSettingsScreen : : OnChangeNickname ( UI : : EventParams & e ) {
2023-06-21 22:47:00 +00:00
# if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2023-03-22 11:26:14 +00:00
System_InputBoxGetString ( n - > T ( " Enter a new PSP nickname " ) , g_Config . sNickName , [ ] ( const std : : string & value , int ) {
g_Config . sNickName = StripSpaces ( value ) ;
2020-03-09 01:59:17 +00:00
} ) ;
2013-12-07 18:57:06 +00:00
# endif
2014-05-25 05:19:56 +00:00
return UI : : EVENT_DONE ;
}
2016-08-27 18:38:05 +00:00
UI : : EventReturn GameSettingsScreen : : OnChangeproAdhocServerAddress ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2019-08-18 00:14:31 +00:00
2020-07-17 01:54:37 +00:00
screenManager ( ) - > push ( new HostnameSelectScreen ( & g_Config . proAdhocServer , n - > T ( " proAdhocServer Address: " ) ) ) ;
2016-08-27 18:38:05 +00:00
2014-05-25 05:19:56 +00:00
return UI : : EVENT_DONE ;
}
2013-08-21 08:52:40 +00:00
2014-05-25 05:19:56 +00:00
UI : : EventReturn GameSettingsScreen : : OnChangeMacAddress ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
2022-07-27 21:17:18 +00:00
2022-08-07 15:48:27 +00:00
const char * confirmMessage = n - > T ( " ChangeMacSaveConfirm " , " Generate a new MAC address? " ) ;
const char * warningMessage = n - > T ( " ChangeMacSaveWarning " , " Some games verify the MAC address when loading savedata, so this may break old saves. " ) ;
std : : string combined = std : : string ( confirmMessage ) + " \n \n " + warningMessage ;
2022-07-27 21:17:18 +00:00
auto confirmScreen = new PromptScreen (
2022-11-29 15:29:43 +00:00
gamePath_ ,
2022-08-07 15:48:27 +00:00
combined , di - > T ( " Yes " ) , di - > T ( " No " ) ,
2022-07-27 21:17:18 +00:00
[ & ] ( bool success ) {
if ( success ) {
g_Config . sMACAddress = CreateRandMAC ( ) ;
} }
) ;
screenManager ( ) - > push ( confirmScreen ) ;
2014-06-02 06:15:07 +00:00
2013-08-18 00:03:59 +00:00
return UI : : EVENT_DONE ;
}
2020-08-02 04:26:41 +00:00
UI : : EventReturn GameSettingsScreen : : OnTextureShader ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto gr = GetI18NCategory ( I18NCat : : GRAPHICS ) ;
2020-08-02 04:26:41 +00:00
auto shaderScreen = new TextureShaderScreen ( gr - > T ( " Texture Shader " ) ) ;
shaderScreen - > OnChoice . Handle ( this , & GameSettingsScreen : : OnTextureShaderChange ) ;
if ( e . v )
shaderScreen - > SetPopupOrigin ( e . v ) ;
screenManager ( ) - > push ( shaderScreen ) ;
return UI : : EVENT_DONE ;
}
UI : : EventReturn GameSettingsScreen : : OnTextureShaderChange ( UI : : EventParams & e ) {
2022-11-21 14:14:20 +00:00
NativeMessageReceived ( " gpu_configChanged " , " " ) ;
2020-08-02 04:26:41 +00:00
RecreateViews ( ) ; // Update setting name
2020-08-02 05:32:55 +00:00
g_Config . bTexHardwareScaling = g_Config . sTextureShaderName ! = " Off " ;
2020-08-02 04:26:41 +00:00
return UI : : EVENT_DONE ;
}
2013-08-20 16:03:52 +00:00
UI : : EventReturn GameSettingsScreen : : OnDeveloperTools ( UI : : EventParams & e ) {
2022-11-22 21:53:54 +00:00
screenManager ( ) - > push ( new DeveloperToolsScreen ( gamePath_ ) ) ;
2020-05-15 09:15:38 +00:00
return UI : : EVENT_DONE ;
2013-07-18 09:39:54 +00:00
}
2016-07-03 17:24:33 +00:00
UI : : EventReturn GameSettingsScreen : : OnRemoteISO ( UI : : EventParams & e ) {
2023-01-01 20:33:11 +00:00
screenManager ( ) - > push ( new RemoteISOScreen ( gamePath_ ) ) ;
2016-07-03 17:24:33 +00:00
return UI : : EVENT_DONE ;
}
2013-07-29 00:15:30 +00:00
UI : : EventReturn GameSettingsScreen : : OnControlMapping ( UI : : EventParams & e ) {
2022-11-22 21:53:54 +00:00
screenManager ( ) - > push ( new ControlMappingScreen ( gamePath_ ) ) ;
2013-07-22 22:06:07 +00:00
return UI : : EVENT_DONE ;
}
2021-07-09 11:10:16 +00:00
UI : : EventReturn GameSettingsScreen : : OnCalibrateAnalogs ( UI : : EventParams & e ) {
2022-11-22 21:53:54 +00:00
screenManager ( ) - > push ( new AnalogSetupScreen ( gamePath_ ) ) ;
2021-07-09 11:10:16 +00:00
return UI : : EVENT_DONE ;
}
2013-10-20 02:45:58 +00:00
UI : : EventReturn GameSettingsScreen : : OnTouchControlLayout ( UI : : EventParams & e ) {
2022-11-22 21:53:54 +00:00
screenManager ( ) - > push ( new TouchControlLayoutScreen ( gamePath_ ) ) ;
2013-10-09 20:15:56 +00:00
return UI : : EVENT_DONE ;
2016-07-03 17:24:33 +00:00
}
2013-10-09 20:15:56 +00:00
2018-12-16 20:48:35 +00:00
UI : : EventReturn GameSettingsScreen : : OnTiltCustomize ( UI : : EventParams & e ) {
2023-02-01 14:35:57 +00:00
screenManager ( ) - > push ( new TiltAnalogSettingsScreen ( gamePath_ ) ) ;
2013-10-27 17:58:47 +00:00
return UI : : EVENT_DONE ;
} ;
2015-06-12 18:37:42 +00:00
UI : : EventReturn GameSettingsScreen : : OnSavedataManager ( UI : : EventParams & e ) {
2023-01-01 20:33:11 +00:00
auto saveData = new SavedataScreen ( gamePath_ ) ;
2015-06-12 18:37:42 +00:00
screenManager ( ) - > push ( saveData ) ;
return UI : : EVENT_DONE ;
}
2015-06-29 00:56:04 +00:00
UI : : EventReturn GameSettingsScreen : : OnSysInfo ( UI : : EventParams & e ) {
2023-01-01 20:33:11 +00:00
screenManager ( ) - > push ( new SystemInfoScreen ( gamePath_ ) ) ;
2015-06-29 00:56:04 +00:00
return UI : : EVENT_DONE ;
}
2013-07-18 09:39:54 +00:00
void DeveloperToolsScreen : : CreateViews ( ) {
using namespace UI ;
2017-03-22 06:59:59 +00:00
root_ = new LinearLayout ( ORIENT_VERTICAL , new LayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
ScrollView * settingsScroll = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( 1.0f ) ) ;
settingsScroll - > SetTag ( " DevToolsSettings " ) ;
root_ - > Add ( settingsScroll ) ;
2013-07-18 09:39:54 +00:00
2023-04-05 22:34:50 +00:00
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
auto dev = GetI18NCategory ( I18NCat : : DEVELOPER ) ;
auto gr = GetI18NCategory ( I18NCat : : GRAPHICS ) ;
auto a = GetI18NCategory ( I18NCat : : AUDIO ) ;
auto sy = GetI18NCategory ( I18NCat : : SYSTEM ) ;
auto ps = GetI18NCategory ( I18NCat : : POSTSHADERS ) ;
2013-07-18 09:39:54 +00:00
2017-03-22 06:59:59 +00:00
AddStandardBack ( root_ ) ;
2021-02-22 02:41:08 +00:00
LinearLayout * list = settingsScroll - > Add ( new LinearLayoutList ( ORIENT_VERTICAL , new LinearLayoutParams ( 1.0f ) ) ) ;
2013-08-19 22:49:25 +00:00
list - > SetSpacing ( 0 ) ;
2015-07-01 23:00:04 +00:00
list - > Add ( new ItemHeader ( sy - > T ( " General " ) ) ) ;
2013-10-20 15:33:18 +00:00
2014-05-27 06:55:48 +00:00
bool canUseJit = true ;
2016-08-28 17:00:13 +00:00
// iOS can now use JIT on all modes, apparently.
// The bool may come in handy for future non-jit platforms though (UWP XB1?)
2016-05-07 23:43:27 +00:00
2018-12-16 20:48:35 +00:00
static const char * cpuCores [ ] = { " Interpreter " , " Dynarec (JIT) " , " IR Interpreter " } ;
2023-04-05 22:34:50 +00:00
PopupMultiChoice * core = list - > Add ( new PopupMultiChoice ( & g_Config . iCpuCore , gr - > T ( " CPU Core " ) , cpuCores , 0 , ARRAY_SIZE ( cpuCores ) , I18NCat : : SYSTEM , screenManager ( ) ) ) ;
2016-08-20 19:31:02 +00:00
core - > OnChoice . Handle ( this , & DeveloperToolsScreen : : OnJitAffectingSetting ) ;
2023-02-28 14:58:30 +00:00
core - > OnChoice . Add ( [ ] ( UI : : EventParams & ) {
g_Config . NotifyUpdatedCpuCore ( ) ;
return UI : : EVENT_DONE ;
} ) ;
2016-05-07 23:43:27 +00:00
if ( ! canUseJit ) {
core - > HideChoice ( 1 ) ;
2014-05-27 07:39:07 +00:00
}
2013-10-20 15:33:18 +00:00
2019-02-04 12:00:08 +00:00
list - > Add ( new Choice ( dev - > T ( " JIT debug tools " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnJitDebugTools ) ;
2015-06-30 03:28:31 +00:00
list - > Add ( new CheckBox ( & g_Config . bShowDeveloperMenu , dev - > T ( " Show Developer Menu " ) ) ) ;
list - > Add ( new CheckBox ( & g_Config . bDumpDecryptedEboot , dev - > T ( " Dump Decrypted Eboot " , " Dump Decrypted EBOOT.BIN (If Encrypted) When Booting Game " ) ) ) ;
2013-10-12 19:34:13 +00:00
2017-02-24 23:25:46 +00:00
# if !PPSSPP_PLATFORM(UWP)
2015-06-30 03:28:31 +00:00
Choice * cpuTests = new Choice ( dev - > T ( " Run CPU Tests " ) ) ;
2013-10-12 19:34:13 +00:00
list - > Add ( cpuTests ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnRunCPUTests ) ;
2017-02-24 23:25:46 +00:00
2018-01-04 17:10:41 +00:00
cpuTests - > SetEnabled ( TestsAvailable ( ) ) ;
2017-02-24 23:25:46 +00:00
# endif
2018-12-18 22:56:36 +00:00
// For now, we only implement GPU driver tests for Vulkan and OpenGL. This is simply
// because the D3D drivers are generally solid enough to not need this type of investigation.
if ( g_Config . iGPUBackend = = ( int ) GPUBackend : : VULKAN | | g_Config . iGPUBackend = = ( int ) GPUBackend : : OPENGL ) {
list - > Add ( new Choice ( dev - > T ( " GPU Driver Test " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnGPUDriverTest ) ;
}
2021-01-31 14:19:06 +00:00
list - > Add ( new CheckBox ( & g_Config . bVendorBugChecksEnabled , dev - > T ( " Enable driver bug workarounds " ) ) ) ;
2021-01-31 14:49:52 +00:00
list - > Add ( new Choice ( dev - > T ( " Framedump tests " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnFramedumpTest ) ;
2019-10-02 20:03:02 +00:00
list - > Add ( new Choice ( dev - > T ( " Touchscreen Test " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnTouchscreenTest ) ;
2013-10-12 19:34:13 +00:00
2018-09-01 18:00:05 +00:00
allowDebugger_ = ! WebServerStopped ( WebServerFlags : : DEBUGGER ) ;
canAllowDebugger_ = ! WebServerStopping ( WebServerFlags : : DEBUGGER ) ;
CheckBox * allowDebugger = new CheckBox ( & allowDebugger_ , dev - > T ( " Allow remote debugger " ) ) ;
list - > Add ( allowDebugger ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnRemoteDebugger ) ;
allowDebugger - > SetEnabledPtr ( & canAllowDebugger_ ) ;
2020-11-22 18:08:14 +00:00
list - > Add ( new CheckBox ( & g_Config . bShowOnScreenMessages , dev - > T ( " Show on-screen messages " ) ) ) ;
2015-06-30 03:28:31 +00:00
list - > Add ( new CheckBox ( & g_Config . bEnableLogging , dev - > T ( " Enable Logging " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnLoggingChanged ) ;
2022-11-23 10:13:21 +00:00
list - > Add ( new Choice ( dev - > T ( " Logging Channels " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnLogConfig ) ;
list - > Add ( new CheckBox ( & g_Config . bLogFrameDrops , dev - > T ( " Log Dropped Frame Statistics " ) ) ) ;
2021-12-19 21:49:42 +00:00
if ( GetGPUBackend ( ) = = GPUBackend : : VULKAN ) {
2022-11-29 09:04:09 +00:00
list - > Add ( new CheckBox ( & g_Config . bGpuLogProfiler , dev - > T ( " GPU log profiler " ) ) ) ;
2021-12-19 21:49:42 +00:00
}
2016-06-21 22:33:06 +00:00
list - > Add ( new ItemHeader ( dev - > T ( " Texture Replacement " ) ) ) ;
2022-05-03 02:23:37 +00:00
list - > Add ( new CheckBox ( & g_Config . bSaveNewTextures , dev - > T ( " Save new textures " ) ) ) ;
2016-06-21 22:33:06 +00:00
list - > Add ( new CheckBox ( & g_Config . bReplaceTextures , dev - > T ( " Replace textures " ) ) ) ;
2018-12-16 20:48:35 +00:00
2022-11-29 09:10:34 +00:00
Choice * createTextureIni = list - > Add ( new Choice ( dev - > T ( " Create/Open textures.ini file for current game " ) ) ) ;
createTextureIni - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnOpenTexturesIniFile ) ;
createTextureIni - > SetEnabledFunc ( [ & ] {
if ( ! PSP_IsInited ( ) )
return false ;
// Disable the choice to Open/Create if the textures.ini file already exists, and we can't open it due to platform support limitations.
if ( ! System_GetPropertyBool ( SYSPROP_SUPPORTS_OPEN_FILE_IN_EDITOR ) ) {
if ( hasTexturesIni_ = = HasIni : : MAYBE )
hasTexturesIni_ = TextureReplacer : : IniExists ( g_paramSFO . GetDiscID ( ) ) ? HasIni : : YES : HasIni : : NO ;
return hasTexturesIni_ ! = HasIni : : YES ;
}
return true ;
} ) ;
2022-11-24 21:54:05 +00:00
Draw : : DrawContext * draw = screenManager ( ) - > getDrawContext ( ) ;
// Experimental, will move to main graphics settings later.
bool multiViewSupported = draw - > GetDeviceCaps ( ) . multiViewSupported ;
auto enableStereo = [ = ] ( ) - > bool {
return g_Config . bStereoRendering & & multiViewSupported ;
} ;
if ( draw - > GetDeviceCaps ( ) . multiViewSupported ) {
2023-02-12 10:40:50 +00:00
list - > Add ( new ItemHeader ( gr - > T ( " Stereo rendering " ) ) ) ;
2022-11-24 21:54:05 +00:00
list - > Add ( new CheckBox ( & g_Config . bStereoRendering , gr - > T ( " Stereo rendering " ) ) ) ;
std : : vector < std : : string > stereoShaderNames ;
2022-11-30 22:02:11 +00:00
ChoiceWithValueDisplay * stereoShaderChoice = list - > Add ( new ChoiceWithValueDisplay ( & g_Config . sStereoToMonoShader , gr - > T ( " Stereo display shader " ) , & PostShaderTranslateName ) ) ;
2022-11-24 21:54:05 +00:00
stereoShaderChoice - > SetEnabledFunc ( enableStereo ) ;
stereoShaderChoice - > OnClick . Add ( [ = ] ( EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto gr = GetI18NCategory ( I18NCat : : GRAPHICS ) ;
2022-11-24 21:54:05 +00:00
auto procScreen = new PostProcScreen ( gr - > T ( " Stereo display shader " ) , 0 , true ) ;
if ( e . v )
procScreen - > SetPopupOrigin ( e . v ) ;
screenManager ( ) - > push ( procScreen ) ;
return UI : : EVENT_DONE ;
} ) ;
const ShaderInfo * shaderInfo = GetPostShaderInfo ( g_Config . sStereoToMonoShader ) ;
if ( shaderInfo ) {
for ( size_t i = 0 ; i < ARRAY_SIZE ( shaderInfo - > settings ) ; + + i ) {
auto & setting = shaderInfo - > settings [ i ] ;
if ( ! setting . name . empty ( ) ) {
2022-12-13 03:11:20 +00:00
std : : string key = StringFromFormat ( " %sSettingCurrentValue%d " , shaderInfo - > section . c_str ( ) , i + 1 ) ;
2022-12-13 03:09:14 +00:00
bool keyExisted = g_Config . mPostShaderSetting . find ( key ) ! = g_Config . mPostShaderSetting . end ( ) ;
auto & value = g_Config . mPostShaderSetting [ key ] ;
if ( ! keyExisted )
value = setting . value ;
2023-04-05 08:16:21 +00:00
PopupSliderChoiceFloat * settingValue = list - > Add ( new PopupSliderChoiceFloat ( & value , setting . minValue , setting . maxValue , setting . value , ps - > T ( setting . name ) , setting . step , screenManager ( ) ) ) ;
2022-11-24 21:54:05 +00:00
settingValue - > SetEnabledFunc ( [ = ] {
return ! g_Config . bSkipBufferEffects & & enableStereo ( ) ;
} ) ;
}
}
}
}
2020-12-15 23:06:39 +00:00
// Makes it easy to get savestates out of an iOS device. The file listing shown in MacOS doesn't allow
// you to descend into directories.
# if PPSSPP_PLATFORM(IOS)
list - > Add ( new Choice ( dev - > T ( " Copy savestates to memstick root " ) ) ) - > OnClick . Handle ( this , & DeveloperToolsScreen : : OnCopyStatesToRoot ) ;
# endif
2022-07-11 23:24:37 +00:00
// Reconsider whenever recreating views.
hasTexturesIni_ = HasIni : : MAYBE ;
2013-07-18 09:39:54 +00:00
}
2013-10-25 11:19:08 +00:00
void DeveloperToolsScreen : : onFinish ( DialogResult result ) {
2019-02-23 09:49:49 +00:00
g_Config . Save ( " DeveloperToolsScreen::onFinish " ) ;
2022-11-21 14:14:20 +00:00
NativeMessageReceived ( " gpu_configChanged " , " " ) ;
2013-07-18 09:39:54 +00:00
}
2013-09-28 06:21:59 +00:00
void GameSettingsScreen : : CallbackRestoreDefaults ( bool yes ) {
2023-01-31 17:56:18 +00:00
if ( yes ) {
g_Config . RestoreDefaults ( RestoreSettingsBits : : SETTINGS ) ;
}
2023-03-21 10:21:19 +00:00
System_Notify ( SystemNotification : : UI ) ;
2013-08-28 20:23:16 +00:00
}
2013-09-28 06:21:59 +00:00
UI : : EventReturn GameSettingsScreen : : OnRestoreDefaultSettings ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto dev = GetI18NCategory ( I18NCat : : DEVELOPER ) ;
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
auto sy = GetI18NCategory ( I18NCat : : SYSTEM ) ;
2023-01-31 17:56:18 +00:00
if ( g_Config . bGameSpecific ) {
2014-12-19 16:03:42 +00:00
screenManager ( ) - > push (
2022-11-29 15:29:43 +00:00
new PromptScreen ( gamePath_ , dev - > T ( " RestoreGameDefaultSettings " , " Are you sure you want to restore the game-specific settings back to the ppsspp defaults? \n " ) , di - > T ( " OK " ) , di - > T ( " Cancel " ) ,
2016-10-12 09:32:24 +00:00
std : : bind ( & GameSettingsScreen : : CallbackRestoreDefaults , this , std : : placeholders : : _1 ) ) ) ;
2023-01-31 17:56:18 +00:00
} else {
const char * title = sy - > T ( " Restore Default Settings " ) ;
screenManager ( ) - > push ( new RestoreSettingsScreen ( title ) ) ;
2014-12-19 16:03:42 +00:00
}
2013-08-28 20:23:16 +00:00
return UI : : EVENT_DONE ;
}
2013-08-17 23:24:34 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnLoggingChanged ( UI : : EventParams & e ) {
2023-03-24 20:43:45 +00:00
System_Notify ( SystemNotification : : TOGGLE_DEBUG_CONSOLE ) ;
2013-08-17 23:24:34 +00:00
return UI : : EVENT_DONE ;
}
2013-07-18 09:39:54 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnRunCPUTests ( UI : : EventParams & e ) {
2017-02-24 23:25:46 +00:00
# if !PPSSPP_PLATFORM(UWP)
2013-07-18 09:39:54 +00:00
RunTests ( ) ;
2017-02-24 23:25:46 +00:00
# endif
2013-07-18 09:39:54 +00:00
return UI : : EVENT_DONE ;
}
2013-07-20 10:06:06 +00:00
2016-06-21 22:33:06 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnOpenTexturesIniFile ( UI : : EventParams & e ) {
2017-06-03 03:54:28 +00:00
std : : string gameID = g_paramSFO . GetDiscID ( ) ;
2021-05-05 23:31:38 +00:00
Path generatedFilename ;
2022-07-10 20:34:44 +00:00
2021-05-11 07:50:28 +00:00
if ( TextureReplacer : : GenerateIni ( gameID , generatedFilename ) ) {
2022-07-10 20:34:44 +00:00
if ( System_GetPropertyBool ( SYSPROP_SUPPORTS_OPEN_FILE_IN_EDITOR ) ) {
File : : OpenFileInEditor ( generatedFilename ) ;
} else {
// Can't do much here, let's send a "toast" so the user sees that something happened.
2023-04-05 22:34:50 +00:00
auto dev = GetI18NCategory ( I18NCat : : DEVELOPER ) ;
2022-07-10 20:34:44 +00:00
System_Toast ( ( generatedFilename . ToVisualString ( ) + " : " + dev - > T ( " Texture ini file created " ) ) . c_str ( ) ) ;
}
2022-07-11 23:24:37 +00:00
hasTexturesIni_ = HasIni : : YES ;
2016-06-21 22:33:06 +00:00
}
return UI : : EVENT_DONE ;
}
2013-09-07 11:38:37 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnLogConfig ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new LogConfigScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2014-05-27 06:55:48 +00:00
2019-02-04 12:00:08 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnJitDebugTools ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new JitDebugScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2018-12-16 20:48:35 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnGPUDriverTest ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new GPUDriverTestScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2021-01-31 12:13:42 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnFramedumpTest ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new FrameDumpTestScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2019-10-02 20:03:02 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnTouchscreenTest ( UI : : EventParams & e ) {
2022-11-22 21:53:54 +00:00
screenManager ( ) - > push ( new TouchTestScreen ( gamePath_ ) ) ;
2019-10-02 20:03:02 +00:00
return UI : : EVENT_DONE ;
}
2014-05-27 06:55:48 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnJitAffectingSetting ( UI : : EventParams & e ) {
NativeMessageReceived ( " clear jit " , " " ) ;
return UI : : EVENT_DONE ;
}
2014-06-02 06:15:07 +00:00
2020-12-15 23:06:39 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnCopyStatesToRoot ( UI : : EventParams & e ) {
2021-05-05 23:31:38 +00:00
Path savestate_dir = GetSysDirectory ( DIRECTORY_SAVESTATE ) ;
Path root_dir = GetSysDirectory ( DIRECTORY_MEMSTICK_ROOT ) ;
2020-12-15 23:06:39 +00:00
2021-04-25 18:38:22 +00:00
std : : vector < File : : FileInfo > files ;
2021-05-05 23:31:38 +00:00
GetFilesInDir ( savestate_dir , & files , nullptr , 0 ) ;
2020-12-15 23:06:39 +00:00
2021-04-25 18:38:22 +00:00
for ( const File : : FileInfo & file : files ) {
2021-05-15 05:48:04 +00:00
Path src = file . fullName ;
2021-05-09 13:02:46 +00:00
Path dst = root_dir / file . name ;
2020-12-15 23:06:39 +00:00
INFO_LOG ( SYSTEM , " Copying file '%s' to '%s' " , src . c_str ( ) , dst . c_str ( ) ) ;
File : : Copy ( src , dst ) ;
}
return UI : : EVENT_DONE ;
}
2018-04-21 21:17:33 +00:00
UI : : EventReturn DeveloperToolsScreen : : OnRemoteDebugger ( UI : : EventParams & e ) {
if ( allowDebugger_ ) {
StartWebServer ( WebServerFlags : : DEBUGGER ) ;
} else {
StopWebServer ( WebServerFlags : : DEBUGGER ) ;
}
// Persist the setting. Maybe should separate?
g_Config . bRemoteDebuggerOnStartup = allowDebugger_ ;
return UI : : EVENT_CONTINUE ;
}
void DeveloperToolsScreen : : update ( ) {
UIDialogScreenWithBackground : : update ( ) ;
allowDebugger_ = ! WebServerStopped ( WebServerFlags : : DEBUGGER ) ;
canAllowDebugger_ = ! WebServerStopping ( WebServerFlags : : DEBUGGER ) ;
}
2019-08-18 00:14:31 +00:00
void HostnameSelectScreen : : CreatePopupContents ( UI : : ViewGroup * parent ) {
2016-08-27 18:38:05 +00:00
using namespace UI ;
2023-04-05 22:34:50 +00:00
auto sy = GetI18NCategory ( I18NCat : : SYSTEM ) ;
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2016-08-27 18:38:05 +00:00
2019-08-18 00:14:31 +00:00
LinearLayout * valueRow = new LinearLayout ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , FILL_PARENT , Margins ( 0 , 0 , 0 , 10 ) ) ) ;
2014-06-02 06:15:07 +00:00
2021-02-22 00:38:02 +00:00
addrView_ = new TextEdit ( * value_ , n - > T ( " Hostname " ) , " " ) ;
2019-08-18 00:38:29 +00:00
addrView_ - > SetTextAlign ( FLAG_DYNAMIC_ASCII ) ;
2019-08-18 00:14:31 +00:00
valueRow - > Add ( addrView_ ) ;
parent - > Add ( valueRow ) ;
2014-06-02 06:15:07 +00:00
2019-08-18 00:14:31 +00:00
LinearLayout * buttonsRow1 = new LinearLayout ( ORIENT_HORIZONTAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
LinearLayout * buttonsRow2 = new LinearLayout ( ORIENT_HORIZONTAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
parent - > Add ( buttonsRow1 ) ;
parent - > Add ( buttonsRow2 ) ;
2014-06-02 06:15:07 +00:00
2019-08-18 00:38:29 +00:00
buttonsRow1 - > Add ( new Spacer ( new LinearLayoutParams ( 1.0 , G_LEFT ) ) ) ;
2019-08-18 00:14:31 +00:00
for ( char c = ' 0 ' ; c < = ' 9 ' ; + + c ) {
char label [ ] = { c , ' \0 ' } ;
auto button = buttonsRow1 - > Add ( new Button ( label ) ) ;
button - > OnClick . Handle ( this , & HostnameSelectScreen : : OnNumberClick ) ;
button - > SetTag ( label ) ;
}
buttonsRow1 - > Add ( new Button ( " . " ) ) - > OnClick . Handle ( this , & HostnameSelectScreen : : OnPointClick ) ;
2019-08-18 00:38:29 +00:00
buttonsRow1 - > Add ( new Spacer ( new LinearLayoutParams ( 1.0 , G_RIGHT ) ) ) ;
2014-06-02 06:15:07 +00:00
2019-08-18 00:38:29 +00:00
buttonsRow2 - > Add ( new Spacer ( new LinearLayoutParams ( 1.0 , G_LEFT ) ) ) ;
2023-06-22 07:06:19 +00:00
if ( System_GetPropertyBool ( SYSPROP_HAS_TEXT_INPUT_DIALOG ) ) {
2021-04-26 05:54:28 +00:00
buttonsRow2 - > Add ( new Button ( di - > T ( " Edit " ) ) ) - > OnClick . Handle ( this , & HostnameSelectScreen : : OnEditClick ) ;
2023-06-22 07:06:19 +00:00
}
2019-08-18 00:14:31 +00:00
buttonsRow2 - > Add ( new Button ( di - > T ( " Delete " ) ) ) - > OnClick . Handle ( this , & HostnameSelectScreen : : OnDeleteClick ) ;
buttonsRow2 - > Add ( new Button ( di - > T ( " Delete all " ) ) ) - > OnClick . Handle ( this , & HostnameSelectScreen : : OnDeleteAllClick ) ;
2020-07-17 01:54:37 +00:00
buttonsRow2 - > Add ( new Button ( di - > T ( " Toggle List " ) ) ) - > OnClick . Handle ( this , & HostnameSelectScreen : : OnShowIPListClick ) ;
2019-08-18 00:38:29 +00:00
buttonsRow2 - > Add ( new Spacer ( new LinearLayoutParams ( 1.0 , G_RIGHT ) ) ) ;
2019-08-18 01:24:57 +00:00
2022-06-26 12:47:33 +00:00
std : : vector < std : : string > listIP = { " socom.cc " , " psp.gameplayer.club " , " myneighborsushicat.com " , " localhost " } ; // TODO: Add some saved recent history too?
2020-07-17 01:54:37 +00:00
net : : GetIPList ( listIP ) ;
ipRows_ = new LinearLayout ( ORIENT_VERTICAL , new LinearLayoutParams ( 1.0 ) ) ;
ScrollView * scrollView = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
LinearLayout * innerView = new LinearLayout ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
if ( listIP . size ( ) > 0 ) {
for ( const auto & label : listIP ) {
// Filter out IP prefixed with "127." and "169.254." also "0." since they can be rendundant or unusable
if ( label . find ( " 127. " ) ! = 0 & & label . find ( " 169.254. " ) ! = 0 & & label . find ( " 0. " ) ! = 0 ) {
auto button = innerView - > Add ( new Button ( label , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ) ;
button - > OnClick . Handle ( this , & HostnameSelectScreen : : OnIPClick ) ;
button - > SetTag ( label ) ;
}
}
}
scrollView - > Add ( innerView ) ;
ipRows_ - > Add ( scrollView ) ;
ipRows_ - > SetVisibility ( V_GONE ) ;
parent - > Add ( ipRows_ ) ;
listIP . clear ( ) ; listIP . shrink_to_fit ( ) ;
2022-06-26 13:23:35 +00:00
progressView_ = parent - > Add ( new TextView ( n - > T ( " Validating address... " ) , ALIGN_HCENTER , false , new LinearLayoutParams ( Margins ( 0 , 5 , 0 , 0 ) ) ) ) ;
2022-06-26 13:26:09 +00:00
progressView_ - > SetVisibility ( UI : : V_GONE ) ;
2019-08-18 00:38:29 +00:00
}
2023-05-26 16:40:13 +00:00
void HostnameSelectScreen : : SendEditKey ( InputKeyCode keyCode , int flags ) {
2019-08-18 00:38:29 +00:00
auto oldView = UI : : GetFocusedView ( ) ;
UI : : SetFocusedView ( addrView_ ) ;
KeyInput fakeKey { DEVICE_ID_KEYBOARD , keyCode , KEY_DOWN | flags } ;
addrView_ - > Key ( fakeKey ) ;
UI : : SetFocusedView ( oldView ) ;
2014-06-02 06:15:07 +00:00
}
2019-08-18 00:14:31 +00:00
UI : : EventReturn HostnameSelectScreen : : OnNumberClick ( UI : : EventParams & e ) {
std : : string text = e . v ? e . v - > Tag ( ) : " " ;
2019-08-18 00:38:29 +00:00
if ( text . length ( ) = = 1 & & text [ 0 ] > = ' 0 ' & & text [ 0 ] < = ' 9 ' ) {
2023-05-26 16:40:13 +00:00
SendEditKey ( ( InputKeyCode ) text [ 0 ] , KEY_CHAR ) ; // ASCII for digits match keycodes.
2019-08-18 00:38:29 +00:00
}
2014-06-02 06:15:07 +00:00
return UI : : EVENT_DONE ;
}
2019-08-17 23:42:19 +00:00
UI : : EventReturn HostnameSelectScreen : : OnPointClick ( UI : : EventParams & e ) {
2023-07-06 14:49:36 +00:00
SendEditKey ( ( InputKeyCode ) ' . ' , KEY_CHAR ) ;
2014-06-02 06:15:07 +00:00
return UI : : EVENT_DONE ;
}
2019-08-17 23:42:19 +00:00
UI : : EventReturn HostnameSelectScreen : : OnDeleteClick ( UI : : EventParams & e ) {
2019-08-18 00:38:29 +00:00
SendEditKey ( NKCODE_DEL ) ;
2014-06-02 06:15:07 +00:00
return UI : : EVENT_DONE ;
}
2019-08-17 23:42:19 +00:00
UI : : EventReturn HostnameSelectScreen : : OnDeleteAllClick ( UI : : EventParams & e ) {
2019-08-18 00:38:29 +00:00
addrView_ - > SetText ( " " ) ;
2014-06-02 06:15:07 +00:00
return UI : : EVENT_DONE ;
}
2020-07-17 01:54:37 +00:00
UI : : EventReturn HostnameSelectScreen : : OnEditClick ( UI : : EventParams & e ) {
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2023-03-22 11:26:14 +00:00
System_InputBoxGetString ( n - > T ( " proAdhocServer Address: " ) , addrView_ - > GetText ( ) , [ this ] ( const std : : string & value , int ) {
addrView_ - > SetText ( value ) ;
2020-07-17 01:54:37 +00:00
} ) ;
return UI : : EVENT_DONE ;
}
UI : : EventReturn HostnameSelectScreen : : OnShowIPListClick ( UI : : EventParams & e ) {
if ( ipRows_ - > GetVisibility ( ) = = UI : : V_GONE ) {
ipRows_ - > SetVisibility ( UI : : V_VISIBLE ) ;
}
else {
ipRows_ - > SetVisibility ( UI : : V_GONE ) ;
}
return UI : : EVENT_DONE ;
}
UI : : EventReturn HostnameSelectScreen : : OnIPClick ( UI : : EventParams & e ) {
std : : string text = e . v ? e . v - > Tag ( ) : " " ;
if ( text . length ( ) > 0 ) {
addrView_ - > SetText ( text ) ;
2023-03-22 21:07:29 +00:00
// Copy the IP to clipboard for the host to easily share their IP through chatting apps.
System_CopyStringToClipboard ( text ) ;
2020-07-17 01:54:37 +00:00
}
return UI : : EVENT_DONE ;
}
2019-08-18 01:24:57 +00:00
void HostnameSelectScreen : : ResolverThread ( ) {
std : : unique_lock < std : : mutex > guard ( resolverLock_ ) ;
while ( resolverState_ ! = ResolverState : : QUIT ) {
resolverCond_ . wait ( guard ) ;
if ( resolverState_ = = ResolverState : : QUEUED ) {
resolverState_ = ResolverState : : PROGRESS ;
addrinfo * resolved = nullptr ;
std : : string err ;
toResolveResult_ = net : : DNSResolve ( toResolve_ , " 80 " , & resolved , err ) ;
if ( resolved )
net : : DNSResolveFree ( resolved ) ;
resolverState_ = ResolverState : : READY ;
}
}
}
bool HostnameSelectScreen : : CanComplete ( DialogResult result ) {
2023-04-05 22:34:50 +00:00
auto n = GetI18NCategory ( I18NCat : : NETWORKING ) ;
2021-09-15 07:56:36 +00:00
2019-08-18 01:24:57 +00:00
if ( result ! = DR_OK )
return true ;
std : : string value = addrView_ - > GetText ( ) ;
if ( lastResolved_ = = value ) {
return true ;
}
// Currently running.
if ( resolverState_ = = ResolverState : : PROGRESS )
return false ;
std : : lock_guard < std : : mutex > guard ( resolverLock_ ) ;
switch ( resolverState_ ) {
case ResolverState : : PROGRESS :
case ResolverState : : QUIT :
return false ;
case ResolverState : : QUEUED :
case ResolverState : : WAITING :
break ;
case ResolverState : : READY :
if ( toResolve_ = = value ) {
// Reset the state, nothing there now.
resolverState_ = ResolverState : : WAITING ;
toResolve_ . clear ( ) ;
lastResolved_ = value ;
lastResolvedResult_ = toResolveResult_ ;
if ( lastResolvedResult_ ) {
2022-06-26 13:26:09 +00:00
progressView_ - > SetVisibility ( UI : : V_GONE ) ;
2019-08-18 01:24:57 +00:00
} else {
2021-09-15 07:56:36 +00:00
progressView_ - > SetText ( n - > T ( " Invalid IP or hostname " ) ) ;
progressView_ - > SetTextColor ( 0xFF3030FF ) ;
progressView_ - > SetVisibility ( UI : : V_VISIBLE ) ;
2019-08-18 01:24:57 +00:00
}
return true ;
}
// Throw away that last result, it was for a different value.
break ;
}
resolverState_ = ResolverState : : QUEUED ;
toResolve_ = value ;
resolverCond_ . notify_one ( ) ;
2021-09-15 07:56:36 +00:00
progressView_ - > SetText ( n - > T ( " Validating address... " ) ) ;
progressView_ - > SetTextColor ( 0xFFFFFFFF ) ;
2019-08-18 01:24:57 +00:00
progressView_ - > SetVisibility ( UI : : V_VISIBLE ) ;
return false ;
}
2019-08-18 00:14:31 +00:00
void HostnameSelectScreen : : OnCompleted ( DialogResult result ) {
if ( result = = DR_OK )
2020-08-19 05:33:20 +00:00
* value_ = StripSpaces ( addrView_ - > GetText ( ) ) ;
2014-06-02 06:15:07 +00:00
}
2021-08-17 07:17:37 +00:00
void GestureMappingScreen : : CreateViews ( ) {
using namespace UI ;
2023-04-05 22:34:50 +00:00
auto di = GetI18NCategory ( I18NCat : : DIALOG ) ;
auto co = GetI18NCategory ( I18NCat : : CONTROLS ) ;
auto mc = GetI18NCategory ( I18NCat : : MAPPABLECONTROLS ) ;
2021-08-17 07:17:37 +00:00
root_ = new AnchorLayout ( new LayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
2021-09-24 09:13:01 +00:00
AddStandardBack ( root_ ) ;
TabHolder * tabHolder = new TabHolder ( ORIENT_VERTICAL , 200 , new AnchorLayoutParams ( 10 , 0 , 10 , 0 , false ) ) ;
2021-08-17 07:17:37 +00:00
root_ - > Add ( tabHolder ) ;
ScrollView * rightPanel = new ScrollView ( ORIENT_VERTICAL ) ;
tabHolder - > AddTab ( co - > T ( " Gesture " ) , rightPanel ) ;
LinearLayout * vert = rightPanel - > Add ( new LinearLayout ( ORIENT_VERTICAL , new LayoutParams ( FILL_PARENT , FILL_PARENT ) ) ) ;
vert - > SetSpacing ( 0 ) ;
2021-08-30 10:26:13 +00:00
static const char * gestureButton [ ARRAY_SIZE ( GestureKey : : keyList ) + 1 ] ;
gestureButton [ 0 ] = " None " ;
for ( int i = 1 ; i < ARRAY_SIZE ( gestureButton ) ; + + i ) {
2021-08-30 11:13:09 +00:00
gestureButton [ i ] = KeyMap : : GetPspButtonNameCharPointer ( GestureKey : : keyList [ i - 1 ] ) ;
2021-08-30 10:26:13 +00:00
}
2021-08-17 07:17:37 +00:00
vert - > Add ( new CheckBox ( & g_Config . bGestureControlEnabled , co - > T ( " Enable gesture control " ) ) ) ;
2021-08-30 10:26:13 +00:00
vert - > Add ( new ItemHeader ( co - > T ( " Swipe " ) ) ) ;
2023-04-05 22:34:50 +00:00
vert - > Add ( new PopupMultiChoice ( & g_Config . iSwipeUp , mc - > T ( " Swipe Up " ) , gestureButton , 0 , ARRAY_SIZE ( gestureButton ) , I18NCat : : MAPPABLECONTROLS , screenManager ( ) ) ) - > SetEnabledPtr ( & g_Config . bGestureControlEnabled ) ;
vert - > Add ( new PopupMultiChoice ( & g_Config . iSwipeDown , mc - > T ( " Swipe Down " ) , gestureButton , 0 , ARRAY_SIZE ( gestureButton ) , I18NCat : : MAPPABLECONTROLS , screenManager ( ) ) ) - > SetEnabledPtr ( & g_Config . bGestureControlEnabled ) ;
vert - > Add ( new PopupMultiChoice ( & g_Config . iSwipeLeft , mc - > T ( " Swipe Left " ) , gestureButton , 0 , ARRAY_SIZE ( gestureButton ) , I18NCat : : MAPPABLECONTROLS , screenManager ( ) ) ) - > SetEnabledPtr ( & g_Config . bGestureControlEnabled ) ;
vert - > Add ( new PopupMultiChoice ( & g_Config . iSwipeRight , mc - > T ( " Swipe Right " ) , gestureButton , 0 , ARRAY_SIZE ( gestureButton ) , I18NCat : : MAPPABLECONTROLS , screenManager ( ) ) ) - > SetEnabledPtr ( & g_Config . bGestureControlEnabled ) ;
2023-04-05 08:16:21 +00:00
vert - > Add ( new PopupSliderChoiceFloat ( & g_Config . fSwipeSensitivity , 0.01f , 1.0f , 1.0f , co - > T ( " Swipe sensitivity " ) , 0.01f , screenManager ( ) , " x " ) ) - > SetEnabledPtr ( & g_Config . bGestureControlEnabled ) ;
vert - > Add ( new PopupSliderChoiceFloat ( & g_Config . fSwipeSmoothing , 0.0f , 0.95f , 0.3f , co - > T ( " Swipe smoothing " ) , 0.05f , screenManager ( ) , " x " ) ) - > SetEnabledPtr ( & g_Config . bGestureControlEnabled ) ;
2022-07-10 20:34:44 +00:00
2021-08-30 10:26:13 +00:00
vert - > Add ( new ItemHeader ( co - > T ( " Double tap " ) ) ) ;
2023-04-05 22:34:50 +00:00
vert - > Add ( new PopupMultiChoice ( & g_Config . iDoubleTapGesture , mc - > T ( " Double tap button " ) , gestureButton , 0 , ARRAY_SIZE ( gestureButton ) , I18NCat : : MAPPABLECONTROLS , screenManager ( ) ) ) - > SetEnabledPtr ( & g_Config . bGestureControlEnabled ) ;
2021-08-17 07:17:37 +00:00
}
2023-01-31 17:56:18 +00:00
RestoreSettingsScreen : : RestoreSettingsScreen ( const char * title )
: PopupScreen ( title , " OK " , " Cancel " ) { }
void RestoreSettingsScreen : : CreatePopupContents ( UI : : ViewGroup * parent ) {
using namespace UI ;
// Carefully re-use various translations.
2023-04-05 22:34:50 +00:00
auto ga = GetI18NCategory ( I18NCat : : GAME ) ;
auto ms = GetI18NCategory ( I18NCat : : MAINSETTINGS ) ;
auto mm = GetI18NCategory ( I18NCat : : MAINMENU ) ;
auto dev = GetI18NCategory ( I18NCat : : DEVELOPER ) ;
2023-01-31 17:56:18 +00:00
const char * text = dev - > T (
" RestoreDefaultSettings " ,
" Restore these settings back to their defaults? \n You can't undo this. \n Please restart PPSSPP after restoring settings. " ) ;
2023-01-31 20:26:12 +00:00
TextView * textView = parent - > Add ( new TextView ( text , FLAG_WRAP_TEXT , false ) ) ;
textView - > SetPadding ( 10.0f ) ;
2023-01-31 17:56:18 +00:00
parent - > Add ( new BitCheckBox ( & restoreFlags_ , ( int ) RestoreSettingsBits : : SETTINGS , ga - > T ( " Game Settings " ) ) ) ;
2023-04-11 21:08:38 +00:00
parent - > Add ( new BitCheckBox ( & restoreFlags_ , ( int ) RestoreSettingsBits : : CONTROLS , ms - > T ( " Controls " ) ) ) ;
2023-01-31 17:56:18 +00:00
parent - > Add ( new BitCheckBox ( & restoreFlags_ , ( int ) RestoreSettingsBits : : RECENT , mm - > T ( " Recent " ) ) ) ;
}
void RestoreSettingsScreen : : OnCompleted ( DialogResult result ) {
if ( result = = DialogResult : : DR_OK ) {
g_Config . RestoreDefaults ( ( RestoreSettingsBits ) restoreFlags_ ) ;
}
}