2007-05-30 21:56:52 +00:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
2002-12-12 23:22:48 +00:00
*
2021-12-26 17:47:58 +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 , either version 3 of the License , or
* ( at your option ) any later version .
2002-12-12 23:22:48 +00:00
*
* 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 for more details .
*
* You should have received a copy of the GNU General Public License
2021-12-26 17:47:58 +00:00
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
2014-02-18 01:34:20 +00:00
*
2002-12-12 23:22:48 +00:00
*/
2003-10-02 22:52:57 +00:00
# include "gui/browser.h"
2006-10-08 18:22:28 +00:00
# include "gui/themebrowser.h"
2007-06-14 18:40:27 +00:00
# include "gui/message.h"
2010-11-16 10:19:01 +00:00
# include "gui/gui-manager.h"
2003-10-02 22:52:57 +00:00
# include "gui/options.h"
2010-11-16 10:11:57 +00:00
# include "gui/widgets/popup.h"
# include "gui/widgets/tab.h"
2011-10-24 17:46:11 +00:00
# include "gui/ThemeEval.h"
2021-07-12 14:18:19 +00:00
# include "gui/launcher.h"
2002-12-12 23:22:48 +00:00
2020-01-23 09:50:52 +00:00
# include "backends/keymapper/keymapper.h"
# include "backends/keymapper/remap-widget.h"
2020-03-16 00:48:57 +00:00
# include "common/achievements.h"
2006-06-24 08:07:48 +00:00
# include "common/fs.h"
2003-10-08 21:59:23 +00:00
# include "common/config-manager.h"
2012-02-22 14:33:29 +00:00
# include "common/gui_options.h"
# include "common/rendermode.h"
2021-08-21 21:05:40 +00:00
# include "common/savefile.h"
2005-01-10 22:06:49 +00:00
# include "common/system.h"
2011-04-24 08:34:27 +00:00
# include "common/textconsole.h"
2010-06-15 10:44:51 +00:00
# include "common/translation.h"
2016-03-29 08:44:46 +00:00
# include "common/updates.h"
2019-07-15 11:35:24 +00:00
# include "common/util.h"
2019-07-12 20:16:44 +00:00
# include "common/text-to-speech.h"
2006-06-24 08:07:48 +00:00
2011-02-09 01:09:01 +00:00
# include "audio/mididrv.h"
# include "audio/musicplugin.h"
# include "audio/mixer.h"
# include "audio/fmopl.h"
2016-07-11 07:57:46 +00:00
# include "widgets/scrollcontainer.h"
2016-07-20 09:55:30 +00:00
# include "widgets/edittext.h"
2002-12-12 23:22:48 +00:00
2016-10-17 16:45:12 +00:00
# ifdef USE_CLOUD
2016-07-05 09:05:30 +00:00
# ifdef USE_LIBCURL
2016-06-08 12:56:17 +00:00
# include "backends/cloud/cloudmanager.h"
2016-07-15 12:27:56 +00:00
# include "gui/downloaddialog.h"
2021-11-16 22:36:21 +00:00
# include "gui/downloadiconsdialog.h"
2016-06-08 12:56:17 +00:00
# endif
2016-07-05 10:31:52 +00:00
# ifdef USE_SDL_NET
# include "backends/networking/sdl_net/localwebserver.h"
# endif
2016-10-17 16:45:12 +00:00
# endif
2016-07-05 10:31:52 +00:00
2022-10-01 23:15:50 +00:00
# include "base/version.h"
# include "graphics/fonts/amigafont.h"
2022-10-01 15:22:24 +00:00
# include "graphics/palette.h"
2020-10-09 17:04:07 +00:00
# include "graphics/renderer.h"
2021-01-06 23:24:00 +00:00
# include "graphics/scalerplugin.h"
2015-12-28 15:42:05 +00:00
2003-11-10 23:40:48 +00:00
namespace GUI {
2002-12-12 23:22:48 +00:00
enum {
2006-06-11 20:51:14 +00:00
kMidiGainChanged = ' mgch ' ,
2003-03-25 15:32:36 +00:00
kMusicVolumeChanged = ' muvc ' ,
kSfxVolumeChanged = ' sfvc ' ,
2009-08-08 18:01:44 +00:00
kMuteAllChanged = ' mute ' ,
2006-05-13 17:30:04 +00:00
kSubtitleToggle = ' sttg ' ,
kSubtitleSpeedChanged = ' stsc ' ,
2004-12-25 23:43:05 +00:00
kSpeechVolumeChanged = ' vcvc ' ,
2005-04-10 14:33:44 +00:00
kChooseSoundFontCmd = ' chsf ' ,
2007-02-13 19:55:20 +00:00
kClearSoundFontCmd = ' clsf ' ,
2004-11-15 04:41:51 +00:00
kChooseSaveDirCmd = ' chos ' ,
2011-10-24 18:34:10 +00:00
kSavePathClearCmd = ' clsp ' ,
2006-06-11 20:40:22 +00:00
kChooseThemeDirCmd = ' chth ' ,
2021-07-09 16:53:26 +00:00
kChooseIconDirCmd = ' chic ' ,
2011-10-24 18:34:10 +00:00
kThemePathClearCmd = ' clth ' ,
2021-08-02 15:04:23 +00:00
kBrowserPathClearCmd = ' clbr ' ,
2021-07-09 16:53:26 +00:00
kIconPathClearCmd = ' clic ' ,
2006-10-08 18:22:28 +00:00
kChooseExtraDirCmd = ' chex ' ,
2011-10-24 18:34:10 +00:00
kExtraPathClearCmd = ' clex ' ,
2008-05-09 01:58:12 +00:00
kChoosePluginsDirCmd = ' chpl ' ,
2020-01-04 14:33:57 +00:00
kPluginsPathClearCmd = ' clpl ' ,
2016-03-31 11:59:01 +00:00
kChooseThemeCmd = ' chtf ' ,
2021-11-16 22:36:21 +00:00
kUpdateIconsCmd = ' upic ' ,
2022-06-30 23:11:46 +00:00
kChooseShaderCmd = ' chsh ' ,
kClearShaderCmd = ' clsh ' ,
2017-02-20 02:14:51 +00:00
kUpdatesCheckCmd = ' updc ' ,
kKbdMouseSpeedChanged = ' kmsc ' ,
2018-07-21 23:01:01 +00:00
kJoystickDeadzoneChanged = ' jodc ' ,
2018-07-31 16:24:44 +00:00
kGraphicsTabContainerReflowCmd = ' gtcr ' ,
2021-01-06 23:24:00 +00:00
kScalerPopUpCmd = ' scPU ' ,
2022-10-02 20:54:24 +00:00
kFullscreenToggled = ' oful ' ,
kScalerToggle = ' sctg ' ,
2002-12-12 23:22:48 +00:00
} ;
2010-06-15 10:48:39 +00:00
enum {
kSubtitlesSpeech ,
kSubtitlesSubs ,
2022-10-02 20:54:24 +00:00
kSubtitlesBoth ,
} ;
enum {
kScalerScaler ,
kScalerShader ,
2010-06-15 10:48:39 +00:00
} ;
2012-12-27 14:08:54 +00:00
# ifdef USE_FLUIDSYNTH
enum {
2020-11-14 14:29:26 +00:00
kFluidSynthSettingsCmd = ' flst '
2012-12-27 14:08:54 +00:00
} ;
# endif
2016-07-05 09:05:30 +00:00
# ifdef USE_CLOUD
2016-06-08 12:56:17 +00:00
enum {
2021-01-06 22:13:14 +00:00
kStoragePopUpCmd = ' sPup ' ,
2019-07-18 16:10:49 +00:00
kSyncSavesStorageCmd = ' ssst ' ,
2016-07-05 07:11:29 +00:00
kDownloadStorageCmd = ' dlst ' ,
2016-07-11 08:17:27 +00:00
kRunServerCmd = ' rnsv ' ,
2016-07-20 10:48:50 +00:00
kCloudTabContainerReflowCmd = ' ctcr ' ,
2016-08-01 09:49:42 +00:00
kServerPortClearCmd = ' spcl ' ,
kChooseRootDirCmd = ' chrp ' ,
2019-07-18 16:10:49 +00:00
kRootPathClearCmd = ' clrp ' ,
kConnectStorageCmd = ' Cnnt ' ,
kOpenUrlStorageCmd = ' OpUr ' ,
kPasteCodeStorageCmd = ' PsCd ' ,
2019-07-27 15:44:15 +00:00
kDisconnectStorageCmd = ' DcSt ' ,
kEnableStorageCmd = ' EnSt '
2016-06-08 12:56:17 +00:00
} ;
# endif
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
enum {
kApplyCmd = ' appl '
} ;
2016-06-08 12:56:17 +00:00
2020-06-29 22:10:13 +00:00
static const char * savePeriodLabels [ ] = { _s ( " Never " ) , _s ( " Every 5 mins " ) , _s ( " Every 10 mins " ) , _s ( " Every 15 mins " ) , _s ( " Every 30 mins " ) , nullptr } ;
2007-02-13 21:06:45 +00:00
static const int savePeriodValues [ ] = { 0 , 5 * 60 , 10 * 60 , 15 * 60 , 30 * 60 , - 1 } ;
2021-04-17 17:35:08 +00:00
2021-04-17 19:24:49 +00:00
static const char * guiBaseLabels [ ] = {
2021-08-10 22:37:32 +00:00
// I18N: Very large GUI scale
_s ( " Very large " ) ,
2021-04-17 20:19:47 +00:00
// I18N: Large GUI scale
_s ( " Large " ) ,
// I18N: Medium GUI scale
_s ( " Medium " ) ,
// I18N: Small GUI scale
_s ( " Small " ) ,
2021-04-17 19:24:49 +00:00
nullptr
} ;
2021-08-10 22:37:32 +00:00
static const int guiBaseValues [ ] = { 150 , 125 , 100 , 75 , - 1 } ;
2021-04-17 17:35:08 +00:00
2017-02-26 17:17:41 +00:00
// The keyboard mouse speed values range from 0 to 7 and correspond to speeds shown in the label
// "10" (value 3) is the default speed corresponding to the speed before introduction of this control
2020-06-29 22:10:13 +00:00
static const char * kbdMouseSpeedLabels [ ] = { " 3 " , " 5 " , " 8 " , " 10 " , " 13 " , " 15 " , " 18 " , " 20 " , nullptr } ;
2007-02-13 21:06:45 +00:00
2010-04-06 09:26:59 +00:00
OptionsDialog : : OptionsDialog ( const Common : : String & domain , int x , int y , int w , int h )
2022-10-02 20:54:24 +00:00
: Dialog ( x , y , w , h ) , _domain ( domain ) , _graphicsTabId ( - 1 ) , _midiTabId ( - 1 ) , _pathsTabId ( - 1 ) , _tabWidget ( nullptr ) {
2006-03-07 19:02:42 +00:00
init ( ) ;
}
2010-04-06 09:26:59 +00:00
OptionsDialog : : OptionsDialog ( const Common : : String & domain , const Common : : String & name )
2022-10-02 20:54:24 +00:00
: Dialog ( name ) , _domain ( domain ) , _graphicsTabId ( - 1 ) , _midiTabId ( - 1 ) , _pathsTabId ( - 1 ) , _tabWidget ( nullptr ) {
2006-03-07 19:02:42 +00:00
init ( ) ;
}
2010-11-16 09:26:35 +00:00
OptionsDialog : : ~ OptionsDialog ( ) {
delete _subToggleGroup ;
}
2006-03-07 19:02:42 +00:00
void OptionsDialog : : init ( ) {
2017-02-14 13:13:58 +00:00
_enableControlSettings = false ;
2020-01-05 16:48:04 +00:00
_touchpadCheckbox = nullptr ;
_kbdMouseSpeedDesc = nullptr ;
_kbdMouseSpeedSlider = nullptr ;
_kbdMouseSpeedLabel = nullptr ;
_joystickDeadzoneDesc = nullptr ;
_joystickDeadzoneSlider = nullptr ;
_joystickDeadzoneLabel = nullptr ;
2020-01-23 09:50:52 +00:00
_keymapperWidget = nullptr ;
2020-05-11 11:05:56 +00:00
_backendOptions = nullptr ;
2006-03-07 19:02:42 +00:00
_enableGraphicSettings = false ;
2020-01-05 16:48:04 +00:00
_gfxPopUp = nullptr ;
_gfxPopUpDesc = nullptr ;
_renderModePopUp = nullptr ;
_renderModePopUpDesc = nullptr ;
_stretchPopUp = nullptr ;
_stretchPopUpDesc = nullptr ;
2021-01-06 23:24:00 +00:00
_scalerPopUp = nullptr ;
_scalerPopUpDesc = nullptr ;
_scaleFactorPopUp = nullptr ;
2020-01-05 16:48:04 +00:00
_fullscreenCheckbox = nullptr ;
_filteringCheckbox = nullptr ;
_aspectCheckbox = nullptr ;
2017-03-01 20:00:17 +00:00
_enableShaderSettings = false ;
2022-06-30 23:11:46 +00:00
_shader = nullptr ;
_shaderButton = nullptr ;
_shaderClearButton = nullptr ;
2020-10-09 17:04:07 +00:00
_vsyncCheckbox = nullptr ;
_rendererTypePopUpDesc = nullptr ;
_rendererTypePopUp = nullptr ;
_antiAliasPopUpDesc = nullptr ;
_antiAliasPopUp = nullptr ;
2006-03-07 19:02:42 +00:00
_enableAudioSettings = false ;
2020-01-05 16:48:04 +00:00
_midiPopUp = nullptr ;
_midiPopUpDesc = nullptr ;
_oplPopUp = nullptr ;
_oplPopUpDesc = nullptr ;
2006-03-07 19:02:42 +00:00
_enableMIDISettings = false ;
2020-01-05 16:48:04 +00:00
_gmDevicePopUp = nullptr ;
_gmDevicePopUpDesc = nullptr ;
_soundFont = nullptr ;
_soundFontButton = nullptr ;
_soundFontClearButton = nullptr ;
_multiMidiCheckbox = nullptr ;
_midiGainDesc = nullptr ;
_midiGainSlider = nullptr ;
_midiGainLabel = nullptr ;
2010-07-24 22:29:17 +00:00
_enableMT32Settings = false ;
2020-01-05 16:48:04 +00:00
_mt32Checkbox = nullptr ;
_mt32DevicePopUp = nullptr ;
_mt32DevicePopUpDesc = nullptr ;
_enableGSCheckbox = nullptr ;
2006-03-07 19:02:42 +00:00
_enableVolumeSettings = false ;
2020-01-05 16:48:04 +00:00
_musicVolumeDesc = nullptr ;
_musicVolumeSlider = nullptr ;
_musicVolumeLabel = nullptr ;
_sfxVolumeDesc = nullptr ;
_sfxVolumeSlider = nullptr ;
_sfxVolumeLabel = nullptr ;
_speechVolumeDesc = nullptr ;
_speechVolumeSlider = nullptr ;
_speechVolumeLabel = nullptr ;
_muteCheckbox = nullptr ;
2016-06-01 09:18:17 +00:00
_enableSubtitleSettings = false ;
2021-10-14 18:04:53 +00:00
_enableSubtitleToggle = false ;
2020-01-05 16:48:04 +00:00
_subToggleDesc = nullptr ;
_subToggleGroup = nullptr ;
_subToggleSubOnly = nullptr ;
_subToggleSpeechOnly = nullptr ;
_subToggleSubBoth = nullptr ;
_subSpeedDesc = nullptr ;
_subSpeedSlider = nullptr ;
_subSpeedLabel = nullptr ;
2016-06-01 09:18:17 +00:00
2009-06-06 17:58:08 +00:00
// Retrieve game GUI options
2011-10-23 18:02:35 +00:00
_guioptions . clear ( ) ;
2010-06-15 10:57:28 +00:00
if ( ConfMan . hasKey ( " guioptions " , _domain ) ) {
_guioptionsString = ConfMan . get ( " guioptions " , _domain ) ;
_guioptions = parseGameGUIOptions ( _guioptionsString ) ;
}
2003-11-05 12:25:42 +00:00
}
2017-03-04 10:22:41 +00:00
2016-10-30 18:36:22 +00:00
void OptionsDialog : : build ( ) {
2009-06-06 17:58:08 +00:00
// Retrieve game GUI options
2011-10-23 18:02:35 +00:00
_guioptions . clear ( ) ;
2010-06-15 10:57:28 +00:00
if ( ConfMan . hasKey ( " guioptions " , _domain ) ) {
_guioptionsString = ConfMan . get ( " guioptions " , _domain ) ;
_guioptions = parseGameGUIOptions ( _guioptionsString ) ;
}
2017-03-04 10:22:41 +00:00
2017-02-14 13:13:58 +00:00
// Control options
if ( g_system - > hasFeature ( OSystem : : kFeatureTouchpadMode ) ) {
if ( ConfMan . hasKey ( " touchpad_mouse_mode " , _domain ) ) {
bool touchpadState = g_system - > getFeatureState ( OSystem : : kFeatureTouchpadMode ) ;
2020-01-05 16:48:04 +00:00
if ( _touchpadCheckbox ! = nullptr )
2017-02-14 13:13:58 +00:00
_touchpadCheckbox - > setState ( touchpadState ) ;
}
2017-01-30 20:35:40 +00:00
}
2017-02-20 02:14:51 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureKbdMouseSpeed ) ) {
2017-12-19 05:26:47 +00:00
int value = ConfMan . getInt ( " kbdmouse_speed " , _domain ) ;
if ( _kbdMouseSpeedSlider & & value < ARRAYSIZE ( kbdMouseSpeedLabels ) - 1 & & value > = 0 ) {
_kbdMouseSpeedSlider - > setValue ( value ) ;
2020-07-01 18:01:48 +00:00
_kbdMouseSpeedLabel - > setLabel ( _ ( kbdMouseSpeedLabels [ value ] ) ) ;
2017-02-20 02:14:51 +00:00
}
}
if ( g_system - > hasFeature ( OSystem : : kFeatureJoystickDeadzone ) ) {
2017-12-19 05:26:47 +00:00
int value = ConfMan . getInt ( " joystick_deadzone " , _domain ) ;
2020-01-05 16:48:04 +00:00
if ( _joystickDeadzoneSlider ! = nullptr ) {
2017-12-19 05:26:47 +00:00
_joystickDeadzoneSlider - > setValue ( value ) ;
_joystickDeadzoneLabel - > setValue ( value ) ;
2017-02-20 02:14:51 +00:00
}
}
2009-06-06 17:58:08 +00:00
2020-01-23 09:50:52 +00:00
// Keymapper options
if ( _keymapperWidget ) {
2020-03-22 14:19:56 +00:00
_keymapperWidget - > load ( ) ;
2020-01-23 09:50:52 +00:00
}
2020-05-11 11:05:56 +00:00
// Backend options
if ( _backendOptions ) {
_backendOptions - > load ( ) ;
}
2006-05-13 17:30:04 +00:00
// Graphic options
2003-11-07 16:01:51 +00:00
if ( _fullscreenCheckbox ) {
_gfxPopUp - > setSelected ( 0 ) ;
2003-11-08 23:22:16 +00:00
2004-03-15 02:28:47 +00:00
if ( ConfMan . hasKey ( " gfx_mode " , _domain ) ) {
2004-02-24 22:39:42 +00:00
const OSystem : : GraphicsMode * gm = g_system - > getSupportedGraphicsModes ( ) ;
2010-04-06 09:26:59 +00:00
Common : : String gfxMode ( ConfMan . get ( " gfx_mode " , _domain ) ) ;
2004-03-15 02:28:47 +00:00
int gfxCount = 1 ;
2004-01-16 16:28:56 +00:00
while ( gm - > name ) {
2004-02-24 22:39:42 +00:00
gfxCount + + ;
2004-01-16 16:28:56 +00:00
if ( scumm_stricmp ( gm - > name , gfxMode . c_str ( ) ) = = 0 )
_gfxPopUp - > setSelected ( gfxCount ) ;
gm + + ;
}
}
2005-02-20 00:17:22 +00:00
_renderModePopUp - > setSelected ( 0 ) ;
if ( ConfMan . hasKey ( " render_mode " , _domain ) ) {
const Common : : RenderModeDescription * p = Common : : g_renderModes ;
const Common : : RenderMode renderMode = Common : : parseRenderMode ( ConfMan . get ( " render_mode " , _domain ) ) ;
int sel = 0 ;
for ( int i = 0 ; p - > code ; + + p , + + i ) {
if ( renderMode = = p - > id )
2012-02-19 15:26:09 +00:00
sel = p - > id ;
2005-02-20 00:17:22 +00:00
}
2012-02-19 15:26:09 +00:00
_renderModePopUp - > setSelectedTag ( sel ) ;
2005-02-20 00:17:22 +00:00
}
2018-07-01 22:57:00 +00:00
_stretchPopUp - > setSelected ( 0 ) ;
if ( g_system - > hasFeature ( OSystem : : kFeatureStretchMode ) ) {
if ( ConfMan . hasKey ( " stretch_mode " , _domain ) ) {
const OSystem : : GraphicsMode * sm = g_system - > getSupportedStretchModes ( ) ;
Common : : String stretchMode ( ConfMan . get ( " stretch_mode " , _domain ) ) ;
int stretchCount = 1 ;
while ( sm - > name ) {
stretchCount + + ;
if ( scumm_stricmp ( sm - > name , stretchMode . c_str ( ) ) = = 0 )
_stretchPopUp - > setSelected ( stretchCount ) ;
sm + + ;
}
}
} else {
_stretchPopUpDesc - > setVisible ( false ) ;
_stretchPopUp - > setVisible ( false ) ;
2021-10-09 20:23:28 +00:00
_stretchPopUp - > setEnabled ( false ) ;
2018-07-01 22:57:00 +00:00
}
2021-01-06 23:24:00 +00:00
_scalerPopUp - > setSelected ( 0 ) ;
_scaleFactorPopUp - > setSelected ( 0 ) ;
2022-10-03 19:08:42 +00:00
// Set the scaler checkbox value
int scalerVal = kScalerScaler ;
if ( ConfMan . hasKey ( " usehaders " , _domain ) & & ConfMan . get ( " usehaders " , _domain ) = = " shaders " )
scalerVal = kScalerShader ;
_scalerToggleGroup - > setValue ( scalerVal ) ;
setScalerControls ( ) ;
2021-01-06 23:24:00 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureScalers ) ) {
if ( ConfMan . hasKey ( " scaler " , _domain ) ) {
const PluginList & scalerPlugins = ScalerMan . getPlugins ( ) ;
Common : : String scaler ( ConfMan . get ( " scaler " , _domain ) ) ;
for ( uint scalerIndex = 0 ; scalerIndex < scalerPlugins . size ( ) ; scalerIndex + + ) {
if ( scumm_stricmp ( scalerPlugins [ scalerIndex ] - > get < ScalerPluginObject > ( ) . getName ( ) , scaler . c_str ( ) ) ! = 0 )
continue ;
_scalerPopUp - > setSelectedTag ( scalerIndex ) ;
updateScaleFactors ( scalerIndex ) ;
if ( ConfMan . hasKey ( " scale_factor " , _domain ) ) {
int scaleFactor = ConfMan . getInt ( " scale_factor " , _domain ) ;
if ( scalerPlugins [ scalerIndex ] - > get < ScalerPluginObject > ( ) . hasFactor ( scaleFactor ) )
_scaleFactorPopUp - > setSelectedTag ( scaleFactor ) ;
}
break ;
}
}
} else {
_scalerPopUpDesc - > setVisible ( false ) ;
_scalerPopUp - > setVisible ( false ) ;
2021-10-09 20:23:28 +00:00
_scalerPopUp - > setEnabled ( false ) ;
2021-01-06 23:24:00 +00:00
_scaleFactorPopUp - > setVisible ( false ) ;
2021-10-09 20:23:28 +00:00
_scaleFactorPopUp - > setEnabled ( false ) ;
2021-01-06 23:24:00 +00:00
}
2003-11-07 16:01:51 +00:00
// Fullscreen setting
2019-08-17 11:48:29 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureFullscreenMode ) ) {
_fullscreenCheckbox - > setState ( ConfMan . getBool ( " fullscreen " , _domain ) ) ;
2022-09-30 13:39:25 +00:00
if ( ConfMan . isKeyTemporary ( " fullscreen " ) )
_fullscreenCheckbox - > setOverride ( true ) ;
2019-08-17 11:48:29 +00:00
} else {
_fullscreenCheckbox - > setState ( true ) ;
_fullscreenCheckbox - > setEnabled ( false ) ;
}
2005-07-30 21:11:48 +00:00
2016-10-12 21:32:36 +00:00
// Filtering setting
2021-10-09 20:23:28 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureFilteringMode ) ) {
2016-10-12 21:32:36 +00:00
_filteringCheckbox - > setState ( ConfMan . getBool ( " filtering " , _domain ) ) ;
2022-05-15 22:17:57 +00:00
if ( ConfMan . isKeyTemporary ( " filtering " ) )
2022-09-30 13:39:25 +00:00
_filteringCheckbox - > setOverride ( true ) ;
2021-10-09 20:23:28 +00:00
} else {
_filteringCheckbox - > setState ( false ) ;
_filteringCheckbox - > setEnabled ( false ) ;
}
2016-10-12 21:32:36 +00:00
2003-11-07 16:01:51 +00:00
// Aspect ratio setting
2011-10-23 19:44:39 +00:00
if ( _guioptions . contains ( GUIO_NOASPECT ) ) {
_aspectCheckbox - > setState ( false ) ;
_aspectCheckbox - > setEnabled ( false ) ;
2011-10-24 11:36:52 +00:00
} else {
_aspectCheckbox - > setEnabled ( true ) ;
2011-10-23 19:44:39 +00:00
_aspectCheckbox - > setState ( ConfMan . getBool ( " aspect_ratio " , _domain ) ) ;
2011-10-24 11:36:52 +00:00
}
2011-10-24 14:51:18 +00:00
2019-05-16 20:23:32 +00:00
_vsyncCheckbox - > setState ( ConfMan . getBool ( " vsync " , _domain ) ) ;
2016-11-20 12:13:15 +00:00
2019-05-16 20:23:32 +00:00
_rendererTypePopUp - > setEnabled ( true ) ;
2022-04-02 16:15:25 +00:00
_rendererTypePopUp - > setSelectedTag ( Graphics : : Renderer : : parseTypeCode ( ConfMan . get ( " renderer " , _domain ) ) ) ;
2019-05-16 20:23:32 +00:00
_antiAliasPopUp - > setEnabled ( true ) ;
if ( ConfMan . hasKey ( " antialiasing " , _domain ) ) {
_antiAliasPopUp - > setSelectedTag ( ConfMan . getInt ( " antialiasing " , _domain ) ) ;
} else {
_antiAliasPopUp - > setSelectedTag ( - 1 ) ;
}
2003-11-05 12:25:42 +00:00
}
2017-03-01 20:00:17 +00:00
// Shader options
2022-06-30 23:11:46 +00:00
if ( _shader ) {
if ( g_system - > hasFeature ( OSystem : : kFeatureShaders ) ) {
Common : : String shader ( ConfMan . get ( " shader " , _domain ) ) ;
if ( ConfMan . isKeyTemporary ( " shader " ) ) {
_shader - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
}
if ( shader . empty ( ) | | ! ConfMan . hasKey ( " shader " , _domain ) ) {
_shader - > setLabel ( _c ( " None " , " shader " ) ) ;
_shaderClearButton - > setEnabled ( false ) ;
} else {
_shader - > setLabel ( shader ) ;
_shaderClearButton - > setEnabled ( true ) ;
2020-01-31 23:11:09 +00:00
}
2020-01-29 23:13:32 +00:00
} else {
2022-06-30 23:11:46 +00:00
_shader - > setVisible ( false ) ;
_shaderButton - > setVisible ( false ) ;
_shaderClearButton - > setVisible ( false ) ;
2017-03-01 20:00:17 +00:00
}
}
2006-05-13 17:30:04 +00:00
// Audio options
2010-07-04 18:24:13 +00:00
if ( ! loadMusicDeviceSetting ( _midiPopUp , " music_driver " ) )
2010-06-21 21:36:36 +00:00
_midiPopUp - > setSelected ( 0 ) ;
2009-05-12 19:36:09 +00:00
if ( _oplPopUp ) {
OPL : : Config : : DriverId id = MAX < OPL : : Config : : DriverId > ( OPL : : Config : : parse ( ConfMan . get ( " opl_driver " , _domain ) ) , 0 ) ;
_oplPopUp - > setSelectedTag ( id ) ;
}
2009-05-12 18:42:44 +00:00
2005-04-13 00:11:49 +00:00
if ( _multiMidiCheckbox ) {
2010-10-25 14:31:06 +00:00
if ( ! loadMusicDeviceSetting ( _gmDevicePopUp , " gm_device " ) )
_gmDevicePopUp - > setSelected ( 0 ) ;
2005-07-30 21:11:48 +00:00
2003-11-07 16:01:51 +00:00
// Multi midi setting
_multiMidiCheckbox - > setState ( ConfMan . getBool ( " multi_midi " , _domain ) ) ;
2022-05-15 22:17:57 +00:00
if ( ConfMan . isKeyTemporary ( " multi_midi " ) )
2022-09-30 13:39:25 +00:00
_multiMidiCheckbox - > setOverride ( true ) ;
2003-11-08 23:22:16 +00:00
2010-04-06 09:26:59 +00:00
Common : : String soundFont ( ConfMan . get ( " soundfont " , _domain ) ) ;
2022-05-15 22:56:16 +00:00
if ( ConfMan . isKeyTemporary ( " soundfont " ) ) {
_soundFont - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
}
2007-02-13 21:41:49 +00:00
if ( soundFont . empty ( ) | | ! ConfMan . hasKey ( " soundfont " , _domain ) ) {
2020-07-01 18:01:48 +00:00
_soundFont - > setLabel ( _c ( " None " , " soundfont " ) ) ;
2007-02-13 21:41:49 +00:00
_soundFontClearButton - > setEnabled ( false ) ;
} else {
2006-04-16 18:17:53 +00:00
_soundFont - > setLabel ( soundFont ) ;
2007-02-13 21:41:49 +00:00
_soundFontClearButton - > setEnabled ( true ) ;
}
2006-06-11 20:51:14 +00:00
// MIDI gain setting
_midiGainSlider - > setValue ( ConfMan . getInt ( " midi_gain " , _domain ) ) ;
2011-06-01 22:07:18 +00:00
_midiGainLabel - > setLabel ( Common : : String : : format ( " %.2f " , ( double ) _midiGainSlider - > getValue ( ) / 100.0 ) ) ;
2022-05-15 22:56:16 +00:00
if ( ConfMan . isKeyTemporary ( " midi_gain " ) )
2022-09-30 13:39:25 +00:00
_midiGainDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2006-04-16 18:17:53 +00:00
}
2003-11-08 23:22:16 +00:00
2010-07-24 22:29:17 +00:00
// MT-32 options
if ( _mt32DevicePopUp ) {
2010-10-25 14:31:06 +00:00
if ( ! loadMusicDeviceSetting ( _mt32DevicePopUp , " mt32_device " ) )
_mt32DevicePopUp - > setSelected ( 0 ) ;
2010-07-24 22:29:17 +00:00
// Native mt32 setting
_mt32Checkbox - > setState ( ConfMan . getBool ( " native_mt32 " , _domain ) ) ;
2022-05-16 19:40:43 +00:00
if ( ConfMan . isKeyTemporary ( " native_mt32 " ) )
2022-09-30 13:39:25 +00:00
_mt32Checkbox - > setOverride ( true ) ;
2010-07-24 22:29:17 +00:00
// GS extensions setting
_enableGSCheckbox - > setState ( ConfMan . getBool ( " enable_gs " , _domain ) ) ;
2022-05-15 21:53:58 +00:00
if ( ConfMan . isKeyTemporary ( " enable_gs " ) )
2022-09-30 13:39:25 +00:00
_enableGSCheckbox - > setOverride ( true ) ;
2010-07-24 22:29:17 +00:00
}
2006-04-16 18:17:53 +00:00
// Volume options
2004-12-25 23:43:05 +00:00
if ( _musicVolumeSlider ) {
2003-11-07 16:01:51 +00:00
int vol ;
2003-11-08 23:22:16 +00:00
2003-11-07 16:01:51 +00:00
vol = ConfMan . getInt ( " music_volume " , _domain ) ;
_musicVolumeSlider - > setValue ( vol ) ;
_musicVolumeLabel - > setValue ( vol ) ;
2003-11-08 23:22:16 +00:00
2003-11-07 16:01:51 +00:00
vol = ConfMan . getInt ( " sfx_volume " , _domain ) ;
_sfxVolumeSlider - > setValue ( vol ) ;
_sfxVolumeLabel - > setValue ( vol ) ;
2004-04-05 18:24:36 +00:00
2004-04-06 11:50:35 +00:00
vol = ConfMan . getInt ( " speech_volume " , _domain ) ;
_speechVolumeSlider - > setValue ( vol ) ;
_speechVolumeLabel - > setValue ( vol ) ;
2009-06-06 17:36:06 +00:00
bool val = false ;
if ( ConfMan . hasKey ( " mute " , _domain ) ) {
val = ConfMan . getBool ( " mute " , _domain ) ;
} else {
ConfMan . setBool ( " mute " , false ) ;
}
_muteCheckbox - > setState ( val ) ;
2003-11-07 16:01:51 +00:00
}
2006-05-13 17:30:04 +00:00
// Subtitle options
2010-06-15 10:48:39 +00:00
if ( _subToggleGroup ) {
2010-07-04 18:00:46 +00:00
int speed ;
2010-06-15 10:48:39 +00:00
int sliderMaxValue = _subSpeedSlider - > getMaxValue ( ) ;
2006-05-13 17:30:04 +00:00
2010-06-20 14:46:00 +00:00
int subMode = getSubtitleMode ( ConfMan . getBool ( " subtitles " , _domain ) , ConfMan . getBool ( " speech_mute " , _domain ) ) ;
_subToggleGroup - > setValue ( subMode ) ;
2006-05-13 17:30:04 +00:00
// Engines that reuse the subtitle speed widget set their own max value.
// Scale the config value accordingly (see addSubtitleControls)
speed = ( ConfMan . getInt ( " talkspeed " , _domain ) * sliderMaxValue + 255 / 2 ) / 255 ;
_subSpeedSlider - > setValue ( speed ) ;
_subSpeedLabel - > setValue ( speed ) ;
}
2003-11-05 12:25:42 +00:00
}
2017-03-04 10:22:41 +00:00
2016-10-30 18:36:22 +00:00
void OptionsDialog : : clean ( ) {
delete _subToggleGroup ;
while ( _firstWidget ) {
Widget * w = _firstWidget ;
removeWidget ( w ) ;
2017-03-10 02:05:27 +00:00
// This is called from rebuild() which may result from handleCommand being called by
// a child widget sendCommand call. In such a case sendCommand is still being executed
// so we should not delete yet the child widget. Thus delay the deletion.
g_gui . addToTrash ( w , this ) ;
2016-10-30 18:36:22 +00:00
}
init ( ) ;
}
2017-03-04 10:22:41 +00:00
2016-10-30 18:36:22 +00:00
void OptionsDialog : : rebuild ( ) {
int currentTab = _tabWidget - > getActiveTab ( ) ;
clean ( ) ;
build ( ) ;
reflowLayout ( ) ;
_tabWidget - > setActiveTab ( currentTab ) ;
2017-06-13 05:18:33 +00:00
setDefaultFocusedWidget ( ) ;
2016-10-30 18:36:22 +00:00
}
void OptionsDialog : : open ( ) {
build ( ) ;
Dialog : : open ( ) ;
// Reset result value
setResult ( 0 ) ;
}
2003-11-05 12:25:42 +00:00
2016-10-30 15:43:14 +00:00
void OptionsDialog : : apply ( ) {
2017-02-26 17:17:41 +00:00
bool graphicsModeChanged = false ;
2017-02-14 13:13:58 +00:00
2016-10-30 15:43:14 +00:00
// Graphic options
if ( _fullscreenCheckbox ) {
if ( _enableGraphicSettings ) {
2022-05-15 22:17:57 +00:00
if ( ConfMan . getBool ( " filtering " , _domain ) ! = _filteringCheckbox - > getState ( ) ) {
2016-10-30 15:43:14 +00:00
graphicsModeChanged = true ;
2022-05-15 22:17:57 +00:00
ConfMan . setBool ( " filtering " , _filteringCheckbox - > getState ( ) , _domain ) ;
2022-09-30 13:39:25 +00:00
_filteringCheckbox - > setOverride ( false ) ;
2022-05-15 22:17:57 +00:00
}
2022-05-12 19:43:31 +00:00
if ( ConfMan . getBool ( " fullscreen " , _domain ) ! = _fullscreenCheckbox - > getState ( ) ) {
2016-10-30 15:43:14 +00:00
graphicsModeChanged = true ;
2022-05-15 21:53:58 +00:00
ConfMan . setBool ( " fullscreen " , _fullscreenCheckbox - > getState ( ) , _domain ) ;
2022-09-30 13:39:25 +00:00
_fullscreenCheckbox - > setOverride ( false ) ;
2022-05-12 19:43:31 +00:00
}
2016-10-30 15:43:14 +00:00
if ( ConfMan . getBool ( " aspect_ratio " , _domain ) ! = _aspectCheckbox - > getState ( ) )
graphicsModeChanged = true ;
2020-10-09 17:04:07 +00:00
if ( ConfMan . getBool ( " vsync " , _domain ) ! = _vsyncCheckbox - > getState ( ) )
graphicsModeChanged = true ;
2021-04-01 16:18:41 +00:00
2016-10-30 15:43:14 +00:00
ConfMan . setBool ( " aspect_ratio " , _aspectCheckbox - > getState ( ) , _domain ) ;
2020-10-09 17:04:07 +00:00
ConfMan . setBool ( " vsync " , _vsyncCheckbox - > getState ( ) , _domain ) ;
2021-04-01 16:18:41 +00:00
2022-10-03 19:08:42 +00:00
Common : : String useshader = " scalers " ;
if ( _scalerToggleGroup - > getValue ( ) = = kScalerShader )
useshader = " shaders " ;
ConfMan . set ( " usehaders " , useshader , _domain ) ;
2016-10-30 15:43:14 +00:00
bool isSet = false ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
if ( ( int32 ) _gfxPopUp - > getSelectedTag ( ) > = 0 ) {
const OSystem : : GraphicsMode * gm = g_system - > getSupportedGraphicsModes ( ) ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
while ( gm - > name ) {
if ( gm - > id = = ( int ) _gfxPopUp - > getSelectedTag ( ) ) {
2022-05-15 21:53:58 +00:00
if ( ConfMan . get ( " gfx_mode " , _domain ) ! = gm - > name ) {
2022-09-30 13:39:25 +00:00
_gfxPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2016-10-30 15:43:14 +00:00
graphicsModeChanged = true ;
2022-05-15 21:53:58 +00:00
ConfMan . set ( " gfx_mode " , gm - > name , _domain ) ;
}
2016-10-30 15:43:14 +00:00
isSet = true ;
break ;
2006-05-18 15:40:44 +00:00
}
2016-10-30 15:43:14 +00:00
gm + + ;
2006-05-18 15:40:44 +00:00
}
2004-03-15 02:28:47 +00:00
}
2020-12-17 19:46:47 +00:00
if ( ! isSet ) {
2022-09-30 13:39:25 +00:00
_gfxPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2016-10-30 15:43:14 +00:00
ConfMan . removeKey ( " gfx_mode " , _domain ) ;
2020-12-17 19:46:47 +00:00
if ( g_system - > getGraphicsMode ( ) ! = g_system - > getDefaultGraphicsMode ( ) )
graphicsModeChanged = true ;
}
2017-03-04 10:22:41 +00:00
2022-05-06 22:15:57 +00:00
if ( ( int32 ) _renderModePopUp - > getSelectedTag ( ) > = 0 ) {
2022-09-30 13:39:25 +00:00
Common : : String renderModeCode = Common : : getRenderModeCode ( ( Common : : RenderMode ) _renderModePopUp - > getSelectedTag ( ) ) ;
2022-05-15 21:53:58 +00:00
if ( _renderModePopUp - > getSelectedTag ( ) = = 0 | | ConfMan . get ( " render_mode " , _domain ) ! = renderModeCode ) {
ConfMan . set ( " render_mode " , renderModeCode , _domain ) ;
2022-09-30 13:39:25 +00:00
_renderModePopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-05-15 21:53:58 +00:00
}
2022-05-06 22:15:57 +00:00
}
2018-07-01 22:57:00 +00:00
isSet = false ;
if ( ( int32 ) _stretchPopUp - > getSelectedTag ( ) > = 0 ) {
const OSystem : : GraphicsMode * sm = g_system - > getSupportedStretchModes ( ) ;
2022-05-06 22:15:57 +00:00
2018-07-01 22:57:00 +00:00
while ( sm - > name ) {
if ( sm - > id = = ( int ) _stretchPopUp - > getSelectedTag ( ) ) {
2022-05-15 21:53:58 +00:00
if ( ConfMan . get ( " stretch_mode " , _domain ) ! = sm - > name ) {
2018-07-01 22:57:00 +00:00
graphicsModeChanged = true ;
2022-05-15 21:53:58 +00:00
ConfMan . set ( " stretch_mode " , sm - > name , _domain ) ;
2022-09-30 13:39:25 +00:00
_stretchPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-05-15 21:53:58 +00:00
}
2018-07-01 22:57:00 +00:00
isSet = true ;
break ;
}
sm + + ;
}
}
2020-12-17 19:46:47 +00:00
if ( ! isSet ) {
2022-09-30 13:39:25 +00:00
_stretchPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2018-07-01 22:57:00 +00:00
ConfMan . removeKey ( " stretch_mode " , _domain ) ;
2020-12-17 19:46:47 +00:00
if ( g_system - > getStretchMode ( ) ! = g_system - > getDefaultStretchMode ( ) )
graphicsModeChanged = true ;
2021-04-01 16:18:41 +00:00
}
2017-01-24 19:01:41 +00:00
2021-01-06 23:24:00 +00:00
isSet = false ;
const PluginList & scalerPlugins = ScalerMan . getPlugins ( ) ;
if ( ( int32 ) _scalerPopUp - > getSelectedTag ( ) > = 0 ) {
const char * name = scalerPlugins [ _scalerPopUp - > getSelectedTag ( ) ] - > get < ScalerPluginObject > ( ) . getName ( ) ;
2022-05-17 19:33:12 +00:00
if ( ConfMan . get ( " scaler " , _domain ) ! = name ) {
2021-01-06 23:24:00 +00:00
graphicsModeChanged = true ;
2022-05-17 19:33:12 +00:00
ConfMan . set ( " scaler " , name , _domain ) ;
2022-09-30 13:39:25 +00:00
_scalerPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-05-17 19:33:12 +00:00
}
2021-01-06 23:24:00 +00:00
int factor = _scaleFactorPopUp - > getSelectedTag ( ) ;
2022-05-17 19:33:12 +00:00
if ( ConfMan . getInt ( " scale_factor " , _domain ) ! = factor ) {
ConfMan . setInt ( " scale_factor " , factor , _domain ) ;
2021-01-06 23:24:00 +00:00
graphicsModeChanged = true ;
2022-09-30 13:39:25 +00:00
_scalerPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-05-17 19:33:12 +00:00
}
2021-01-06 23:24:00 +00:00
isSet = true ;
}
if ( ! isSet ) {
ConfMan . removeKey ( " scaler " , _domain ) ;
ConfMan . removeKey ( " scale_factor " , _domain ) ;
2022-09-30 13:39:25 +00:00
_scalerPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2021-01-06 23:24:00 +00:00
uint defaultScaler = g_system - > getDefaultScaler ( ) ;
2021-11-22 00:01:20 +00:00
uint defaultScaleFactor = g_system - > getDefaultScaleFactor ( ) ;
2021-01-06 23:24:00 +00:00
if ( g_system - > getScaler ( ) ! = defaultScaler )
graphicsModeChanged = true ;
2021-11-22 00:01:20 +00:00
else if ( g_system - > getScaleFactor ( ) ! = defaultScaleFactor )
2021-01-06 23:24:00 +00:00
graphicsModeChanged = true ;
}
2017-01-24 19:01:41 +00:00
if ( _rendererTypePopUp - > getSelectedTag ( ) > 0 ) {
Graphics : : RendererType selected = ( Graphics : : RendererType ) _rendererTypePopUp - > getSelectedTag ( ) ;
2022-04-02 16:15:25 +00:00
ConfMan . set ( " renderer " , Graphics : : Renderer : : getTypeCode ( selected ) , _domain ) ;
2017-01-24 19:01:41 +00:00
} else {
ConfMan . removeKey ( " renderer " , _domain ) ;
}
2019-05-16 20:23:32 +00:00
if ( _antiAliasPopUp - > getSelectedTag ( ) ! = ( uint32 ) - 1 ) {
uint level = _antiAliasPopUp - > getSelectedTag ( ) ;
ConfMan . setInt ( " antialiasing " , level , _domain ) ;
} else {
ConfMan . removeKey ( " antialiasing " , _domain ) ;
}
2017-01-24 19:01:41 +00:00
2016-10-30 15:43:14 +00:00
} else {
ConfMan . removeKey ( " fullscreen " , _domain ) ;
ConfMan . removeKey ( " filtering " , _domain ) ;
ConfMan . removeKey ( " aspect_ratio " , _domain ) ;
ConfMan . removeKey ( " gfx_mode " , _domain ) ;
2018-10-22 21:06:44 +00:00
ConfMan . removeKey ( " stretch_mode " , _domain ) ;
2021-01-06 23:24:00 +00:00
ConfMan . removeKey ( " scaler " , _domain ) ;
ConfMan . removeKey ( " scale_factor " , _domain ) ;
2016-10-30 15:43:14 +00:00
ConfMan . removeKey ( " render_mode " , _domain ) ;
2020-10-09 17:04:07 +00:00
ConfMan . removeKey ( " renderer " , _domain ) ;
ConfMan . removeKey ( " antialiasing " , _domain ) ;
ConfMan . removeKey ( " vsync " , _domain ) ;
2003-11-05 12:25:42 +00:00
}
2016-10-30 15:43:14 +00:00
}
2017-03-04 10:22:41 +00:00
2022-09-30 13:40:14 +00:00
Common : : U32String previousShader ;
2020-01-29 23:13:32 +00:00
// Shader options
2022-06-30 23:11:46 +00:00
if ( _shader ) {
2020-01-29 23:13:32 +00:00
if ( _enableShaderSettings ) {
2022-06-30 23:11:46 +00:00
bool isSet ;
2020-01-29 23:13:32 +00:00
2022-09-30 13:40:14 +00:00
if ( ConfMan . hasKey ( " shader " , _domain ) & & ! ConfMan . get ( " shader " , _domain ) . empty ( ) )
previousShader = ConfMan . get ( " shader " , _domain ) ;
2022-06-30 23:11:46 +00:00
Common : : U32String shader ( _shader - > getLabel ( ) ) ;
if ( shader . empty ( ) | | ( shader = = _c ( " None " , " shader " ) ) )
isSet = false ;
else
isSet = true ;
if ( isSet ) {
if ( ! ConfMan . hasKey ( " shader " , _domain ) | | shader ! = ConfMan . get ( " shader " , _domain ) )
2020-12-29 23:22:42 +00:00
graphicsModeChanged = true ;
2022-06-30 23:11:46 +00:00
ConfMan . set ( " shader " , shader . encode ( ) , _domain ) ;
} else {
if ( ConfMan . hasKey ( " shader " , _domain ) & & ! ConfMan . get ( " shader " , _domain ) . empty ( ) )
graphicsModeChanged = true ;
ConfMan . removeKey ( " shader " , _domain ) ;
2020-12-29 23:22:42 +00:00
}
2022-06-30 23:11:46 +00:00
_shader - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2020-01-29 23:13:32 +00:00
} else {
ConfMan . removeKey ( " shader " , _domain ) ;
}
}
2016-10-30 15:43:14 +00:00
// Setup graphics again if needed
if ( _domain = = Common : : ConfigManager : : kApplicationDomain & & graphicsModeChanged ) {
g_system - > beginGFXTransaction ( ) ;
g_system - > setGraphicsMode ( ConfMan . get ( " gfx_mode " , _domain ) . c_str ( ) ) ;
2020-12-17 19:46:47 +00:00
g_system - > setStretchMode ( ConfMan . get ( " stretch_mode " , _domain ) . c_str ( ) ) ;
2021-01-06 23:24:00 +00:00
g_system - > setScaler ( ConfMan . get ( " scaler " , _domain ) . c_str ( ) , ConfMan . getInt ( " scale_factor " , _domain ) ) ;
2022-08-07 20:50:52 +00:00
g_system - > setShader ( ConfMan . get ( " shader " , _domain ) ) ;
2021-04-01 16:18:41 +00:00
2016-10-30 15:43:14 +00:00
if ( ConfMan . hasKey ( " aspect_ratio " ) )
g_system - > setFeatureState ( OSystem : : kFeatureAspectRatioCorrection , ConfMan . getBool ( " aspect_ratio " , _domain ) ) ;
if ( ConfMan . hasKey ( " fullscreen " ) )
g_system - > setFeatureState ( OSystem : : kFeatureFullscreenMode , ConfMan . getBool ( " fullscreen " , _domain ) ) ;
if ( ConfMan . hasKey ( " filtering " ) )
g_system - > setFeatureState ( OSystem : : kFeatureFilteringMode , ConfMan . getBool ( " filtering " , _domain ) ) ;
2020-12-29 23:22:42 +00:00
2016-10-30 15:43:14 +00:00
OSystem : : TransactionError gfxError = g_system - > endGFXTransaction ( ) ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
// Since this might change the screen resolution we need to give
// the GUI a chance to update it's internal state. Otherwise we might
// get a crash when the GUI tries to grab the overlay.
//
2021-02-28 09:28:23 +00:00
// This fixes bug #5703 "Switching from HQ2x->HQ3x crashes ScummVM"
2016-10-30 15:43:14 +00:00
//
// It is important that this is called *before* any of the current
// dialog's widgets are destroyed (for example before
// Dialog::close) is called, to prevent crashes caused by invalid
// widgets being referenced or similar errors.
g_gui . checkScreenChange ( ) ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
if ( gfxError ! = OSystem : : kTransactionSuccess ) {
// Revert ConfMan to what OSystem is using.
2020-06-13 16:42:25 +00:00
Common : : U32String message = _ ( " Failed to apply some of the graphic options changes: " ) ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
if ( gfxError & OSystem : : kTransactionModeSwitchFailed ) {
const OSystem : : GraphicsMode * gm = g_system - > getSupportedGraphicsModes ( ) ;
while ( gm - > name ) {
if ( gm - > id = = g_system - > getGraphicsMode ( ) ) {
ConfMan . set ( " gfx_mode " , gm - > name , _domain ) ;
break ;
2011-05-15 15:31:58 +00:00
}
2016-10-30 15:43:14 +00:00
gm + + ;
2011-05-15 15:31:58 +00:00
}
2020-06-13 16:42:25 +00:00
message + = Common : : U32String ( " \n " ) ;
2018-07-01 22:57:00 +00:00
message + = _ ( " the video mode could not be changed " ) ;
}
if ( gfxError & OSystem : : kTransactionStretchModeSwitchFailed ) {
const OSystem : : GraphicsMode * sm = g_system - > getSupportedStretchModes ( ) ;
while ( sm - > name ) {
if ( sm - > id = = g_system - > getStretchMode ( ) ) {
ConfMan . set ( " stretch_mode " , sm - > name , _domain ) ;
break ;
}
sm + + ;
}
2020-06-13 16:42:25 +00:00
message + = Common : : U32String ( " \n " ) ;
2018-07-01 22:57:00 +00:00
message + = _ ( " the stretch mode could not be changed " ) ;
2011-05-15 15:31:58 +00:00
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
if ( gfxError & OSystem : : kTransactionAspectRatioFailed ) {
ConfMan . setBool ( " aspect_ratio " , g_system - > getFeatureState ( OSystem : : kFeatureAspectRatioCorrection ) , _domain ) ;
2020-06-13 16:42:25 +00:00
message + = Common : : U32String ( " \n " ) ;
2016-10-30 15:43:14 +00:00
message + = _ ( " the aspect ratio setting could not be changed " ) ;
2004-03-15 02:28:47 +00:00
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
if ( gfxError & OSystem : : kTransactionFullscreenFailed ) {
ConfMan . setBool ( " fullscreen " , g_system - > getFeatureState ( OSystem : : kFeatureFullscreenMode ) , _domain ) ;
2020-06-13 16:42:25 +00:00
message + = Common : : U32String ( " \n " ) ;
2016-10-30 15:43:14 +00:00
message + = _ ( " the fullscreen setting could not be changed " ) ;
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
if ( gfxError & OSystem : : kTransactionFilteringFailed ) {
ConfMan . setBool ( " filtering " , g_system - > getFeatureState ( OSystem : : kFeatureFilteringMode ) , _domain ) ;
2020-06-13 16:42:25 +00:00
message + = Common : : U32String ( " \n " ) ;
2016-10-30 15:43:14 +00:00
message + = _ ( " the filtering setting could not be changed " ) ;
2010-06-28 23:41:43 +00:00
}
2017-03-04 10:22:41 +00:00
2022-09-30 13:40:14 +00:00
if ( gfxError & OSystem : : kTransactionShaderChangeFailed ) {
if ( previousShader . empty ( ) ) {
ConfMan . removeKey ( " shader " , _domain ) ;
_shader - > setLabel ( _c ( " None " , " shader " ) ) ;
2022-10-02 19:39:26 +00:00
_shaderClearButton - > setEnabled ( false ) ;
2022-09-30 13:40:14 +00:00
} else {
ConfMan . set ( " shader " , previousShader . encode ( ) , _domain ) ;
_shader - > setLabel ( previousShader ) ;
2022-10-02 19:39:26 +00:00
_shaderClearButton - > setEnabled ( true ) ;
2022-09-30 13:40:14 +00:00
}
message + = Common : : U32String ( " \n " ) ;
2022-10-01 09:52:48 +00:00
message + = _ ( " the shader could not be changed " ) ;
2022-09-30 13:40:14 +00:00
}
2016-10-30 15:43:14 +00:00
// And display the error
GUI : : MessageDialog dialog ( message ) ;
dialog . runModal ( ) ;
2022-10-01 09:52:48 +00:00
} else {
// Successful transaction. Check if we need to show test screen
Common : : String shader ;
if ( ConfMan . hasKey ( " shader " , _domain ) )
shader = ConfMan . get ( " shader " , _domain ) ;
2022-10-02 19:39:26 +00:00
// If shader was changed, show the test dialog
2022-10-02 12:48:13 +00:00
if ( previousShader ! = shader & & ! shader . empty ( ) ) {
2022-10-01 09:52:48 +00:00
if ( ! testGraphicsSettings ( ) ) {
if ( previousShader . empty ( ) ) {
ConfMan . removeKey ( " shader " , _domain ) ;
_shader - > setLabel ( _c ( " None " , " shader " ) ) ;
2022-10-02 19:39:26 +00:00
_shaderClearButton - > setEnabled ( false ) ;
2022-10-01 09:52:48 +00:00
} else {
ConfMan . set ( " shader " , previousShader . encode ( ) , _domain ) ;
_shader - > setLabel ( previousShader ) ;
2022-10-02 19:39:26 +00:00
_shaderClearButton - > setEnabled ( true ) ;
2022-10-01 09:52:48 +00:00
}
g_system - > beginGFXTransaction ( ) ;
g_system - > setShader ( ConfMan . get ( " shader " , _domain ) ) ;
g_system - > endGFXTransaction ( ) ;
}
}
2010-06-27 16:58:06 +00:00
}
2016-10-30 15:43:14 +00:00
}
2017-02-26 17:17:41 +00:00
2020-01-23 09:50:52 +00:00
if ( _keymapperWidget ) {
bool changes = _keymapperWidget - > save ( ) ;
if ( changes ) {
Common : : Keymapper * keymapper = g_system - > getEventManager ( ) - > getKeymapper ( ) ;
keymapper - > reloadAllMappings ( ) ;
}
}
2020-05-11 11:05:56 +00:00
if ( _backendOptions ) {
bool changes = _backendOptions - > save ( ) ;
if ( changes & & _domain = = Common : : ConfigManager : : kApplicationDomain )
g_system - > applyBackendSettings ( ) ;
}
2017-02-26 17:17:41 +00:00
// Control options
if ( _enableControlSettings ) {
if ( g_system - > hasFeature ( OSystem : : kFeatureTouchpadMode ) ) {
if ( ConfMan . getBool ( " touchpad_mouse_mode " , _domain ) ! = _touchpadCheckbox - > getState ( ) ) {
g_system - > setFeatureState ( OSystem : : kFeatureTouchpadMode , _touchpadCheckbox - > getState ( ) ) ;
}
}
if ( g_system - > hasFeature ( OSystem : : kFeatureKbdMouseSpeed ) ) {
if ( ConfMan . getInt ( " kbdmouse_speed " , _domain ) ! = _kbdMouseSpeedSlider - > getValue ( ) ) {
ConfMan . setInt ( " kbdmouse_speed " , _kbdMouseSpeedSlider - > getValue ( ) , _domain ) ;
}
}
if ( g_system - > hasFeature ( OSystem : : kFeatureJoystickDeadzone ) ) {
if ( ConfMan . getInt ( " joystick_deadzone " , _domain ) ! = _joystickDeadzoneSlider - > getValue ( ) ) {
ConfMan . setInt ( " joystick_deadzone " , _joystickDeadzoneSlider - > getValue ( ) , _domain ) ;
}
}
}
2016-10-30 15:43:14 +00:00
// Volume options
if ( _musicVolumeSlider ) {
if ( _enableVolumeSettings ) {
ConfMan . setInt ( " music_volume " , _musicVolumeSlider - > getValue ( ) , _domain ) ;
ConfMan . setInt ( " sfx_volume " , _sfxVolumeSlider - > getValue ( ) , _domain ) ;
ConfMan . setInt ( " speech_volume " , _speechVolumeSlider - > getValue ( ) , _domain ) ;
ConfMan . setBool ( " mute " , _muteCheckbox - > getState ( ) , _domain ) ;
} else {
ConfMan . removeKey ( " music_volume " , _domain ) ;
ConfMan . removeKey ( " sfx_volume " , _domain ) ;
ConfMan . removeKey ( " speech_volume " , _domain ) ;
ConfMan . removeKey ( " mute " , _domain ) ;
}
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
// Audio options
if ( _midiPopUp ) {
if ( _enableAudioSettings ) {
saveMusicDeviceSetting ( _midiPopUp , " music_driver " ) ;
} else {
ConfMan . removeKey ( " music_driver " , _domain ) ;
}
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
if ( _oplPopUp ) {
if ( _enableAudioSettings ) {
const OPL : : Config : : EmulatorDescription * ed = OPL : : Config : : findDriver ( _oplPopUp - > getSelectedTag ( ) ) ;
2017-03-04 10:22:41 +00:00
2022-05-22 22:23:44 +00:00
if ( ( ed & & ConfMan . get ( " opl_driver " , _domain ) ! = ed - > name ) | | ! ed ) {
2022-09-30 13:39:25 +00:00
_oplPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
if ( ed )
2022-05-22 22:23:44 +00:00
ConfMan . set ( " opl_driver " , ed - > name , _domain ) ;
else
ConfMan . removeKey ( " opl_driver " , _domain ) ;
}
2016-10-30 15:43:14 +00:00
} else {
2022-09-30 13:39:25 +00:00
_oplPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-05-22 22:33:00 +00:00
ConfMan . removeKey ( " opl_driver " , _domain ) ;
2009-05-12 18:42:44 +00:00
}
2016-10-30 15:43:14 +00:00
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
// MIDI options
if ( _multiMidiCheckbox ) {
if ( _enableMIDISettings ) {
saveMusicDeviceSetting ( _gmDevicePopUp , " gm_device " ) ;
2017-03-04 10:22:41 +00:00
2022-05-15 22:17:57 +00:00
if ( _multiMidiCheckbox - > getState ( ) ! = ConfMan . getBool ( " multi_midi " , _domain ) ) {
ConfMan . setBool ( " multi_midi " , _multiMidiCheckbox - > getState ( ) , _domain ) ;
2022-09-30 13:39:25 +00:00
_multiMidiCheckbox - > setOverride ( false ) ;
2022-05-15 22:17:57 +00:00
}
2022-05-15 22:56:16 +00:00
if ( _midiGainSlider - > getValue ( ) ! = ConfMan . getInt ( " midi_gain " , _domain ) ) {
ConfMan . setInt ( " midi_gain " , _midiGainSlider - > getValue ( ) , _domain ) ;
2022-09-30 13:39:25 +00:00
_midiGainDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-05-15 22:56:16 +00:00
}
2017-03-04 10:22:41 +00:00
2020-06-13 21:40:03 +00:00
Common : : U32String soundFont ( _soundFont - > getLabel ( ) ) ;
2022-05-15 22:56:16 +00:00
if ( soundFont ! = ConfMan . get ( " soundfont " , _domain ) ) {
2022-09-30 13:39:25 +00:00
_soundFont - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-06-02 19:07:49 +00:00
if ( soundFont . empty ( ) | | ( soundFont = = _c ( " None " , " soundfont " ) ) )
ConfMan . removeKey ( " soundfont " , _domain ) ;
2022-09-30 13:39:25 +00:00
else
ConfMan . set ( " soundfont " , soundFont . encode ( ) , _domain ) ;
}
2016-10-30 15:43:14 +00:00
} else {
ConfMan . removeKey ( " gm_device " , _domain ) ;
ConfMan . removeKey ( " multi_midi " , _domain ) ;
2022-09-30 13:39:25 +00:00
_multiMidiCheckbox - > setOverride ( false ) ;
2016-10-30 15:43:14 +00:00
ConfMan . removeKey ( " midi_gain " , _domain ) ;
2022-05-15 22:56:16 +00:00
_midiGainDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2016-10-30 15:43:14 +00:00
ConfMan . removeKey ( " soundfont " , _domain ) ;
2022-09-30 13:39:25 +00:00
_soundFont - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2005-04-13 00:11:49 +00:00
}
2016-10-30 15:43:14 +00:00
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
// MT-32 options
if ( _mt32DevicePopUp ) {
if ( _enableMT32Settings ) {
saveMusicDeviceSetting ( _mt32DevicePopUp , " mt32_device " ) ;
ConfMan . setBool ( " native_mt32 " , _mt32Checkbox - > getState ( ) , _domain ) ;
2022-05-16 19:40:43 +00:00
if ( ConfMan . getBool ( " native_mt32 " , _domain ) ! = _mt32Checkbox - > getState ( ) ) {
ConfMan . setBool ( " native_mt32 " , _mt32Checkbox - > getState ( ) , _domain ) ;
2022-09-30 13:39:25 +00:00
_mt32Checkbox - > setOverride ( false ) ;
2022-05-16 19:40:43 +00:00
}
if ( ConfMan . getBool ( " enable_gs " , _domain ) ! = _enableGSCheckbox - > getState ( ) ) {
ConfMan . setBool ( " enable_gs " , _enableGSCheckbox - > getState ( ) , _domain ) ;
2022-09-30 13:39:25 +00:00
_enableGSCheckbox - > setOverride ( false ) ;
2022-05-16 19:40:43 +00:00
}
2016-10-30 15:43:14 +00:00
} else {
ConfMan . removeKey ( " mt32_device " , _domain ) ;
ConfMan . removeKey ( " native_mt32 " , _domain ) ;
2022-09-30 13:39:25 +00:00
_mt32Checkbox - > setOverride ( false ) ;
2016-10-30 15:43:14 +00:00
ConfMan . removeKey ( " enable_gs " , _domain ) ;
2022-09-30 13:39:25 +00:00
_enableGSCheckbox - > setOverride ( false ) ;
2010-07-24 22:29:17 +00:00
}
2016-10-30 15:43:14 +00:00
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
// Subtitle options
if ( _subToggleGroup ) {
if ( _enableSubtitleSettings ) {
2021-10-14 18:04:53 +00:00
if ( _enableSubtitleToggle ) {
bool subtitles , speech_mute ;
switch ( _subToggleGroup - > getValue ( ) ) {
2010-06-15 10:48:39 +00:00
case kSubtitlesSpeech :
2006-05-13 17:30:04 +00:00
subtitles = speech_mute = false ;
break ;
2010-06-15 10:48:39 +00:00
case kSubtitlesBoth :
2006-05-13 17:30:04 +00:00
subtitles = true ;
speech_mute = false ;
break ;
2010-06-15 10:48:39 +00:00
case kSubtitlesSubs :
2006-05-13 17:30:04 +00:00
default :
subtitles = speech_mute = true ;
break ;
2021-10-14 18:04:53 +00:00
}
2017-03-04 10:22:41 +00:00
2022-06-30 14:14:35 +00:00
if ( subtitles ! = ConfMan . getBool ( " subtitles " , _domain ) ) {
2022-05-22 22:33:00 +00:00
ConfMan . setBool ( " subtitles " , subtitles , _domain ) ;
2022-09-30 13:39:25 +00:00
_subToggleDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-05-22 22:33:00 +00:00
}
2021-10-14 18:04:53 +00:00
ConfMan . setBool ( " speech_mute " , speech_mute , _domain ) ;
2021-11-11 21:04:34 +00:00
} else if ( ! _domain . empty ( ) ) {
2021-10-14 18:04:53 +00:00
ConfMan . removeKey ( " subtitles " , _domain ) ;
2022-09-30 13:39:25 +00:00
_subToggleDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2021-10-14 18:04:53 +00:00
ConfMan . removeKey ( " speech_mute " , _domain ) ;
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
// Engines that reuse the subtitle speed widget set their own max value.
// Scale the config value accordingly (see addSubtitleControls)
2021-10-14 18:04:53 +00:00
int sliderMaxValue = _subSpeedSlider - > getMaxValue ( ) ;
int talkspeed = ( _subSpeedSlider - > getValue ( ) * 255 + sliderMaxValue / 2 ) / sliderMaxValue ;
2022-05-22 22:23:44 +00:00
if ( talkspeed ! = ConfMan . getInt ( " talkspeed " , _domain ) ) {
ConfMan . setInt ( " talkspeed " , talkspeed , _domain ) ;
2022-09-30 13:39:25 +00:00
_subSpeedDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-05-22 22:23:44 +00:00
}
2016-10-30 15:43:14 +00:00
} else {
ConfMan . removeKey ( " subtitles " , _domain ) ;
ConfMan . removeKey ( " talkspeed " , _domain ) ;
2022-09-30 13:39:25 +00:00
_subSpeedDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2016-10-30 15:43:14 +00:00
ConfMan . removeKey ( " speech_mute " , _domain ) ;
2006-05-13 17:30:04 +00:00
}
2007-06-11 07:35:52 +00:00
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
// Save config file
ConfMan . flushToDisk ( ) ;
}
void OptionsDialog : : close ( ) {
2019-10-22 19:06:43 +00:00
if ( getResult ( ) > 0 )
2016-10-30 15:43:14 +00:00
apply ( ) ;
2007-06-11 07:35:52 +00:00
Dialog : : close ( ) ;
2003-11-05 12:25:42 +00:00
}
void OptionsDialog : : handleCommand ( CommandSender * sender , uint32 cmd , uint32 data ) {
switch ( cmd ) {
2022-06-30 23:11:46 +00:00
case kClearShaderCmd :
_shader - > setLabel ( _c ( " None " , " shader " ) ) ;
_shaderClearButton - > setEnabled ( false ) ;
g_gui . scheduleTopDialogRedraw ( ) ;
break ;
2022-10-02 20:54:24 +00:00
case kScalerToggle :
setScalerControls ( ) ;
break ;
2006-06-11 20:51:14 +00:00
case kMidiGainChanged :
2011-06-01 22:07:18 +00:00
_midiGainLabel - > setLabel ( Common : : String : : format ( " %.2f " , ( double ) _midiGainSlider - > getValue ( ) / 100.0 ) ) ;
2018-01-06 13:40:02 +00:00
_midiGainLabel - > markAsDirty ( ) ;
2006-06-11 20:51:14 +00:00
break ;
2017-01-26 02:36:42 +00:00
case kMusicVolumeChanged : {
const int newValue = _musicVolumeSlider - > getValue ( ) ;
_musicVolumeLabel - > setValue ( newValue ) ;
2018-01-06 13:40:02 +00:00
_musicVolumeLabel - > markAsDirty ( ) ;
2017-01-26 02:36:42 +00:00
if ( _guioptions . contains ( GUIO_LINKMUSICTOSFX ) ) {
updateSfxVolume ( newValue ) ;
if ( _guioptions . contains ( GUIO_LINKSPEECHTOSFX ) ) {
updateSpeechVolume ( newValue ) ;
}
}
2022-09-30 13:39:25 +00:00
_musicVolumeDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2003-11-05 12:25:42 +00:00
break ;
2017-01-26 02:36:42 +00:00
}
case kSfxVolumeChanged : {
const int newValue = _sfxVolumeSlider - > getValue ( ) ;
2003-11-05 12:25:42 +00:00
_sfxVolumeLabel - > setValue ( _sfxVolumeSlider - > getValue ( ) ) ;
2018-01-06 13:40:02 +00:00
_sfxVolumeLabel - > markAsDirty ( ) ;
2017-01-26 02:36:42 +00:00
if ( _guioptions . contains ( GUIO_LINKMUSICTOSFX ) ) {
updateMusicVolume ( newValue ) ;
}
if ( _guioptions . contains ( GUIO_LINKSPEECHTOSFX ) ) {
updateSpeechVolume ( newValue ) ;
}
2022-09-30 13:39:25 +00:00
_sfxVolumeDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2003-11-05 12:25:42 +00:00
break ;
2017-01-26 02:36:42 +00:00
}
case kSpeechVolumeChanged : {
const int newValue = _speechVolumeSlider - > getValue ( ) ;
_speechVolumeLabel - > setValue ( newValue ) ;
2018-01-06 13:40:02 +00:00
_speechVolumeLabel - > markAsDirty ( ) ;
2017-01-26 02:36:42 +00:00
if ( _guioptions . contains ( GUIO_LINKSPEECHTOSFX ) ) {
updateSfxVolume ( newValue ) ;
if ( _guioptions . contains ( GUIO_LINKMUSICTOSFX ) ) {
updateMusicVolume ( newValue ) ;
}
}
2022-09-30 13:39:25 +00:00
_speechVolumeDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2004-04-05 18:24:36 +00:00
break ;
2017-01-26 02:36:42 +00:00
}
2009-08-08 18:01:44 +00:00
case kMuteAllChanged :
// 'true' because if control is disabled then event do not pass
setVolumeSettingsState ( true ) ;
break ;
2011-11-13 22:39:26 +00:00
case kSubtitleToggle :
// We update the slider settings here, when there are sliders, to
// disable the speech volume in case we are in subtitle only mode.
if ( _musicVolumeSlider )
setVolumeSettingsState ( true ) ;
break ;
2006-05-13 17:30:04 +00:00
case kSubtitleSpeedChanged :
_subSpeedLabel - > setValue ( _subSpeedSlider - > getValue ( ) ) ;
2018-01-06 13:40:02 +00:00
_subSpeedLabel - > markAsDirty ( ) ;
2006-05-13 17:30:04 +00:00
break ;
2009-01-14 18:17:19 +00:00
case kClearSoundFontCmd :
2020-07-01 18:01:48 +00:00
_soundFont - > setLabel ( _c ( " None " , " soundfont " ) ) ;
2009-01-14 18:17:19 +00:00
_soundFontClearButton - > setEnabled ( false ) ;
2018-01-06 15:13:29 +00:00
g_gui . scheduleTopDialogRedraw ( ) ;
2009-01-14 18:17:19 +00:00
break ;
2017-02-20 02:14:51 +00:00
case kKbdMouseSpeedChanged :
2020-07-01 18:01:48 +00:00
_kbdMouseSpeedLabel - > setLabel ( _ ( kbdMouseSpeedLabels [ _kbdMouseSpeedSlider - > getValue ( ) ] ) ) ;
2018-01-06 13:40:02 +00:00
_kbdMouseSpeedLabel - > markAsDirty ( ) ;
2017-02-20 02:14:51 +00:00
break ;
case kJoystickDeadzoneChanged :
_joystickDeadzoneLabel - > setValue ( _joystickDeadzoneSlider - > getValue ( ) ) ;
2018-01-06 13:40:02 +00:00
_joystickDeadzoneLabel - > markAsDirty ( ) ;
2017-02-20 02:14:51 +00:00
break ;
2018-07-21 23:01:01 +00:00
case kGraphicsTabContainerReflowCmd :
setupGraphicsTab ( ) ;
break ;
2021-01-06 23:24:00 +00:00
case kScalerPopUpCmd :
updateScaleFactors ( data ) ;
g_gui . scheduleTopDialogRedraw ( ) ;
break ;
2016-10-30 15:43:14 +00:00
case kApplyCmd :
apply ( ) ;
break ;
2004-03-15 02:28:47 +00:00
case kOKCmd :
setResult ( 1 ) ;
2003-11-05 12:25:42 +00:00
close ( ) ;
break ;
2011-04-15 14:00:47 +00:00
case kCloseCmd :
close ( ) ;
break ;
2003-11-05 12:25:42 +00:00
default :
Dialog : : handleCommand ( sender , cmd , data ) ;
}
}
2017-03-04 10:22:41 +00:00
2020-01-23 09:50:52 +00:00
void OptionsDialog : : handleTickle ( ) {
Dialog : : handleTickle ( ) ;
if ( _keymapperWidget ) {
_keymapperWidget - > handleTickle ( ) ;
}
}
2020-03-11 19:42:59 +00:00
void OptionsDialog : : handleOtherEvent ( const Common : : Event & event ) {
Dialog : : handleOtherEvent ( event ) ;
if ( event . type = = Common : : EVENT_INPUT_CHANGED & & _keymapperWidget ) {
_keymapperWidget - > handleInputChanged ( ) ;
}
}
2003-11-07 16:01:51 +00:00
void OptionsDialog : : setGraphicSettingsState ( bool enabled ) {
_enableGraphicSettings = enabled ;
2009-06-06 17:52:44 +00:00
_gfxPopUpDesc - > setEnabled ( enabled ) ;
2004-01-16 16:28:56 +00:00
_gfxPopUp - > setEnabled ( enabled ) ;
2009-06-06 17:52:44 +00:00
_renderModePopUpDesc - > setEnabled ( enabled ) ;
2005-02-20 00:17:22 +00:00
_renderModePopUp - > setEnabled ( enabled ) ;
2020-10-12 16:44:15 +00:00
_vsyncCheckbox - > setEnabled ( enabled ) ;
_rendererTypePopUpDesc - > setEnabled ( enabled ) ;
_rendererTypePopUp - > setEnabled ( enabled ) ;
_antiAliasPopUpDesc - > setEnabled ( enabled ) ;
_antiAliasPopUp - > setEnabled ( enabled ) ;
2019-08-17 11:48:29 +00:00
2021-10-09 20:23:28 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureStretchMode ) ) {
_stretchPopUpDesc - > setEnabled ( enabled ) ;
_stretchPopUp - > setEnabled ( enabled ) ;
} else {
_stretchPopUpDesc - > setEnabled ( false ) ;
_stretchPopUp - > setEnabled ( false ) ;
}
if ( g_system - > hasFeature ( OSystem : : kFeatureScalers ) ) {
_scalerPopUpDesc - > setEnabled ( enabled ) ;
_scalerPopUp - > setEnabled ( enabled ) ;
_scaleFactorPopUp - > setEnabled ( enabled ) ;
} else {
_scalerPopUpDesc - > setEnabled ( false ) ;
_scalerPopUp - > setEnabled ( false ) ;
_scaleFactorPopUp - > setEnabled ( false ) ;
}
if ( g_system - > hasFeature ( OSystem : : kFeatureFilteringMode ) )
_filteringCheckbox - > setEnabled ( enabled ) ;
else
_filteringCheckbox - > setEnabled ( false ) ;
2019-08-17 11:48:29 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureFullscreenMode ) )
_fullscreenCheckbox - > setEnabled ( enabled ) ;
else
_fullscreenCheckbox - > setEnabled ( false ) ;
2011-10-23 19:44:39 +00:00
if ( _guioptions . contains ( GUIO_NOASPECT ) )
_aspectCheckbox - > setEnabled ( false ) ;
else
_aspectCheckbox - > setEnabled ( enabled ) ;
2003-11-07 16:01:51 +00:00
}
2020-01-29 23:13:32 +00:00
void OptionsDialog : : setShaderSettingsState ( bool enabled ) {
_enableShaderSettings = enabled ;
2022-06-30 23:11:46 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureShaders ) ) {
_shader - > setEnabled ( enabled ) ;
_shaderButton - > setEnabled ( enabled ) ;
_shaderClearButton - > setEnabled ( enabled ) ;
if ( enabled & & ! _shader - > getLabel ( ) . empty ( ) & & ( _shader - > getLabel ( ) ! = _c ( " None " , " shader " ) ) )
_shaderClearButton - > setEnabled ( enabled ) ;
else
_shaderClearButton - > setEnabled ( false ) ;
}
2020-01-29 23:13:32 +00:00
}
2003-11-07 16:01:51 +00:00
void OptionsDialog : : setAudioSettingsState ( bool enabled ) {
_enableAudioSettings = enabled ;
2009-06-06 17:52:44 +00:00
_midiPopUpDesc - > setEnabled ( enabled ) ;
2003-11-07 16:01:51 +00:00
_midiPopUp - > setEnabled ( enabled ) ;
2010-06-15 10:56:46 +00:00
2011-10-24 18:29:28 +00:00
const Common : : String allFlags = MidiDriver : : musicType2GUIO ( ( uint32 ) - 1 ) ;
2020-01-05 16:48:04 +00:00
bool hasMidiDefined = ( strpbrk ( _guioptions . c_str ( ) , allFlags . c_str ( ) ) ! = nullptr ) ;
2010-06-15 10:56:46 +00:00
if ( _domain ! = Common : : ConfigManager : : kApplicationDomain & & // global dialog
2011-10-23 14:14:41 +00:00
hasMidiDefined & & // No flags are specified
! ( _guioptions . contains ( GUIO_MIDIADLIB ) ) ) {
2010-06-15 10:56:46 +00:00
_oplPopUpDesc - > setEnabled ( false ) ;
_oplPopUp - > setEnabled ( false ) ;
} else {
_oplPopUpDesc - > setEnabled ( enabled ) ;
_oplPopUp - > setEnabled ( enabled ) ;
}
2005-04-13 00:11:49 +00:00
}
void OptionsDialog : : setMIDISettingsState ( bool enabled ) {
2011-10-23 14:14:41 +00:00
if ( _guioptions . contains ( GUIO_NOMIDI ) )
2009-06-06 18:21:07 +00:00
enabled = false ;
2010-07-24 22:29:17 +00:00
_gmDevicePopUpDesc - > setEnabled ( _domain . equals ( Common : : ConfigManager : : kApplicationDomain ) ? enabled : false ) ;
_gmDevicePopUp - > setEnabled ( _domain . equals ( Common : : ConfigManager : : kApplicationDomain ) ? enabled : false ) ;
2005-04-13 00:11:49 +00:00
_enableMIDISettings = enabled ;
2005-05-16 06:33:33 +00:00
_soundFontButton - > setEnabled ( enabled ) ;
_soundFont - > setEnabled ( enabled ) ;
2007-02-13 21:41:49 +00:00
2010-08-23 19:45:14 +00:00
if ( enabled & & ! _soundFont - > getLabel ( ) . empty ( ) & & ( _soundFont - > getLabel ( ) ! = _c ( " None " , " soundfont " ) ) )
2007-02-13 21:41:49 +00:00
_soundFontClearButton - > setEnabled ( enabled ) ;
else
_soundFontClearButton - > setEnabled ( false ) ;
2003-11-07 16:01:51 +00:00
_multiMidiCheckbox - > setEnabled ( enabled ) ;
2006-06-11 20:51:14 +00:00
_midiGainDesc - > setEnabled ( enabled ) ;
_midiGainSlider - > setEnabled ( enabled ) ;
_midiGainLabel - > setEnabled ( enabled ) ;
2003-11-07 16:01:51 +00:00
}
2010-07-24 22:29:17 +00:00
void OptionsDialog : : setMT32SettingsState ( bool enabled ) {
_enableMT32Settings = enabled ;
_mt32DevicePopUpDesc - > setEnabled ( _domain . equals ( Common : : ConfigManager : : kApplicationDomain ) ? enabled : false ) ;
_mt32DevicePopUp - > setEnabled ( _domain . equals ( Common : : ConfigManager : : kApplicationDomain ) ? enabled : false ) ;
_mt32Checkbox - > setEnabled ( enabled ) ;
_enableGSCheckbox - > setEnabled ( enabled ) ;
}
2003-11-07 16:01:51 +00:00
void OptionsDialog : : setVolumeSettingsState ( bool enabled ) {
2009-06-06 17:58:08 +00:00
bool ena ;
2003-11-07 16:01:51 +00:00
_enableVolumeSettings = enabled ;
2009-08-08 18:01:44 +00:00
ena = enabled & & ! _muteCheckbox - > getState ( ) ;
2011-10-23 14:14:41 +00:00
if ( _guioptions . contains ( GUIO_NOMUSIC ) )
2009-06-06 17:58:08 +00:00
ena = false ;
_musicVolumeDesc - > setEnabled ( ena ) ;
_musicVolumeSlider - > setEnabled ( ena ) ;
_musicVolumeLabel - > setEnabled ( ena ) ;
2009-08-08 18:01:44 +00:00
ena = enabled & & ! _muteCheckbox - > getState ( ) ;
2011-10-23 14:14:41 +00:00
if ( _guioptions . contains ( GUIO_NOSFX ) )
2009-06-06 17:58:08 +00:00
ena = false ;
_sfxVolumeDesc - > setEnabled ( ena ) ;
_sfxVolumeSlider - > setEnabled ( ena ) ;
_sfxVolumeLabel - > setEnabled ( ena ) ;
2009-08-08 18:01:44 +00:00
ena = enabled & & ! _muteCheckbox - > getState ( ) ;
2011-11-13 22:39:26 +00:00
// Disable speech volume slider, when we are in subtitle only mode.
if ( _subToggleGroup )
ena = ena & & _subToggleGroup - > getValue ( ) ! = kSubtitlesSubs ;
2017-01-26 02:36:42 +00:00
if ( _guioptions . contains ( GUIO_NOSPEECH ) | | _guioptions . contains ( GUIO_NOSPEECHVOLUME ) )
2009-06-06 17:58:08 +00:00
ena = false ;
_speechVolumeDesc - > setEnabled ( ena ) ;
_speechVolumeSlider - > setEnabled ( ena ) ;
_speechVolumeLabel - > setEnabled ( ena ) ;
2009-06-06 17:36:06 +00:00
_muteCheckbox - > setEnabled ( enabled ) ;
2003-11-07 16:01:51 +00:00
}
2006-05-13 17:30:04 +00:00
void OptionsDialog : : setSubtitleSettingsState ( bool enabled ) {
2009-06-06 17:58:08 +00:00
bool ena ;
2006-05-13 17:30:04 +00:00
_enableSubtitleSettings = enabled ;
2009-06-06 17:58:08 +00:00
ena = enabled ;
2011-10-23 14:14:41 +00:00
if ( ( _guioptions . contains ( GUIO_NOSUBTITLES ) ) | | ( _guioptions . contains ( GUIO_NOSPEECH ) ) )
2009-06-06 17:58:08 +00:00
ena = false ;
2021-10-14 18:04:53 +00:00
_enableSubtitleToggle = ena ;
2010-06-15 10:48:39 +00:00
_subToggleGroup - > setEnabled ( ena ) ;
2009-06-06 17:58:08 +00:00
_subToggleDesc - > setEnabled ( ena ) ;
ena = enabled ;
2011-10-23 14:14:41 +00:00
if ( _guioptions . contains ( GUIO_NOSUBTITLES ) )
2009-06-06 17:58:08 +00:00
ena = false ;
_subSpeedDesc - > setEnabled ( ena ) ;
_subSpeedSlider - > setEnabled ( ena ) ;
_subSpeedLabel - > setEnabled ( ena ) ;
2006-05-13 17:30:04 +00:00
}
2017-03-04 10:22:41 +00:00
2017-02-20 02:14:51 +00:00
void OptionsDialog : : addControlControls ( GuiObject * boss , const Common : : String & prefix ) {
// Touchpad Mouse mode
if ( g_system - > hasFeature ( OSystem : : kFeatureTouchpadMode ) )
2020-06-13 16:42:25 +00:00
_touchpadCheckbox = new CheckboxWidget ( boss , prefix + " grTouchpadCheckbox " , _ ( " Touchpad mouse mode " ) ) ;
2017-02-20 02:14:51 +00:00
// Keyboard and joystick mouse speed
if ( g_system - > hasFeature ( OSystem : : kFeatureKbdMouseSpeed ) ) {
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
_kbdMouseSpeedDesc = new StaticTextWidget ( boss , prefix + " grKbdMouseSpeedDesc " , _ ( " Pointer Speed: " ) , _ ( " Speed for keyboard/joystick mouse pointer control " ) ) ;
2017-02-20 02:14:51 +00:00
else
2020-07-01 18:01:48 +00:00
_kbdMouseSpeedDesc = new StaticTextWidget ( boss , prefix + " grKbdMouseSpeedDesc " , _c ( " Pointer Speed: " , " lowres " ) , _ ( " Speed for keyboard/joystick mouse pointer control " ) ) ;
2017-02-26 17:17:41 +00:00
_kbdMouseSpeedSlider = new SliderWidget ( boss , prefix + " grKbdMouseSpeedSlider " , _ ( " Speed for keyboard/joystick mouse pointer control " ) , kKbdMouseSpeedChanged ) ;
2021-09-30 16:17:49 +00:00
_kbdMouseSpeedLabel = new StaticTextWidget ( boss , prefix + " grKbdMouseSpeedLabel " , Common : : U32String ( " " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleBold , Common : : UNK_LANG , false ) ;
2017-02-20 02:14:51 +00:00
_kbdMouseSpeedSlider - > setMinValue ( 0 ) ;
_kbdMouseSpeedSlider - > setMaxValue ( 7 ) ;
_kbdMouseSpeedLabel - > setFlags ( WIDGET_CLEARBG ) ;
}
// Joystick deadzone
if ( g_system - > hasFeature ( OSystem : : kFeatureJoystickDeadzone ) ) {
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
_joystickDeadzoneDesc = new StaticTextWidget ( boss , prefix + " grJoystickDeadzoneDesc " , _ ( " Joy Deadzone: " ) , _ ( " Analog joystick Deadzone " ) ) ;
2017-02-20 02:14:51 +00:00
else
2020-07-01 18:01:48 +00:00
_joystickDeadzoneDesc = new StaticTextWidget ( boss , prefix + " grJoystickDeadzoneDesc " , _c ( " Joy Deadzone: " , " lowres " ) , _ ( " Analog joystick Deadzone " ) ) ;
2017-02-26 17:17:41 +00:00
_joystickDeadzoneSlider = new SliderWidget ( boss , prefix + " grJoystickDeadzoneSlider " , _ ( " Analog joystick Deadzone " ) , kJoystickDeadzoneChanged ) ;
2021-09-30 16:17:49 +00:00
_joystickDeadzoneLabel = new StaticTextWidget ( boss , prefix + " grJoystickDeadzoneLabel " , Common : : U32String ( " " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleBold , Common : : UNK_LANG , false ) ;
2017-02-20 02:14:51 +00:00
_joystickDeadzoneSlider - > setMinValue ( 1 ) ;
_joystickDeadzoneSlider - > setMaxValue ( 10 ) ;
_joystickDeadzoneLabel - > setFlags ( WIDGET_CLEARBG ) ;
}
_enableControlSettings = true ;
}
2006-05-13 17:30:04 +00:00
2020-01-28 17:44:08 +00:00
void OptionsDialog : : addKeyMapperControls ( GuiObject * boss , const Common : : String & prefix , const Common : : KeymapArray & keymaps , const Common : : String & domain ) {
Common : : Keymapper * mapper = g_system - > getEventManager ( ) - > getKeymapper ( ) ;
for ( uint i = 0 ; i < keymaps . size ( ) ; i + + ) {
mapper - > initKeymap ( keymaps [ i ] , ConfMan . getDomain ( domain ) ) ;
}
2020-01-23 09:50:52 +00:00
_keymapperWidget = new Common : : RemapWidget ( boss , prefix + " Container " , keymaps ) ;
}
2021-06-04 01:37:45 +00:00
void OptionsDialog : : addAchievementsControls ( GuiObject * boss , const Common : : String & prefix ) {
2020-03-16 00:48:57 +00:00
GUI : : ScrollContainerWidget * scrollContainer ;
scrollContainer = new GUI : : ScrollContainerWidget ( boss , prefix + " Container " , " " ) ;
scrollContainer - > setBackgroundType ( GUI : : ThemeEngine : : kWidgetBackgroundNo ) ;
uint16 nAchieved = 0 ;
uint16 nHidden = 0 ;
2021-06-04 01:37:45 +00:00
uint16 nMax = AchMan . getAchievementCount ( ) ;
2020-03-16 00:48:57 +00:00
uint16 lineHeight = g_gui . xmlEval ( ) - > getVar ( " Globals.Line.Height " ) ;
uint16 yStep = lineHeight ;
2021-05-31 20:45:36 +00:00
uint16 ySmallStep = yStep / 3 ;
uint16 yPos = lineHeight + yStep * 3 ;
2020-03-16 00:48:57 +00:00
uint16 progressBarWidth = 240 ;
uint16 width = g_system - > getOverlayWidth ( ) < = 320 ? 240 : 410 ;
2021-06-04 01:37:45 +00:00
uint16 commentDelta = g_system - > getOverlayWidth ( ) < = 320 ? 25 : 30 ;
2020-03-16 00:48:57 +00:00
for ( int16 viewAchieved = 1 ; viewAchieved > = 0 ; viewAchieved - - ) {
// run this twice, first view all achieved, then view all non-hidden & non-achieved
2020-05-09 19:04:53 +00:00
2020-03-16 00:48:57 +00:00
for ( uint16 idx = 0 ; idx < nMax ; idx + + ) {
2021-06-04 01:37:45 +00:00
const Common : : AchievementDescription * descr = AchMan . getAchievementDescription ( idx ) ;
int16 isAchieved = AchMan . isAchieved ( descr - > id ) ? 1 : 0 ;
2020-03-16 00:48:57 +00:00
if ( isAchieved ! = viewAchieved ) {
continue ;
}
if ( isAchieved ) {
nAchieved + + ;
}
2020-05-09 19:04:53 +00:00
2021-06-04 01:37:45 +00:00
if ( ! isAchieved & & descr - > isHidden ) {
2020-03-16 00:48:57 +00:00
nHidden + + ;
continue ;
}
CheckboxWidget * checkBox ;
2021-06-04 01:37:45 +00:00
checkBox = new CheckboxWidget ( scrollContainer , lineHeight , yPos , width , yStep , Common : : U32String ( descr - > title ) ) ;
2020-03-16 00:48:57 +00:00
checkBox - > setEnabled ( false ) ;
checkBox - > setState ( isAchieved ) ;
yPos + = yStep ;
2021-06-04 01:37:45 +00:00
if ( ! descr - > comment . empty ( ) ) {
new StaticTextWidget ( scrollContainer , lineHeight + commentDelta , yPos , width - commentDelta , yStep , Common : : U32String ( descr - > comment ) , Graphics : : kTextAlignStart , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
2020-03-16 00:48:57 +00:00
yPos + = yStep ;
}
yPos + = ySmallStep ;
}
}
if ( nHidden ) {
2020-06-20 18:04:23 +00:00
Common : : U32String hiddenStr = Common : : U32String : : format ( _ ( " %d hidden achievements remaining " ) , nHidden ) ;
2020-06-13 21:40:03 +00:00
new StaticTextWidget ( scrollContainer , lineHeight , yPos , width , yStep , hiddenStr , Graphics : : kTextAlignStart ) ;
2020-03-16 00:48:57 +00:00
}
if ( nMax ) {
2020-06-20 18:04:23 +00:00
Common : : U32String totalStr = Common : : U32String : : format ( _ ( " Achievements unlocked: %d/%d " ) , nAchieved , nMax ) ;
2020-06-13 16:42:25 +00:00
new StaticTextWidget ( scrollContainer , lineHeight , lineHeight , width , yStep , totalStr , Graphics : : kTextAlignStart ) ;
2020-03-16 00:48:57 +00:00
SliderWidget * progressBar ;
progressBar = new SliderWidget ( scrollContainer , lineHeight , lineHeight * 2 , progressBarWidth , lineHeight ) ;
progressBar - > setMinValue ( 0 ) ;
progressBar - > setValue ( nAchieved ) ;
progressBar - > setMaxValue ( nMax ) ;
progressBar - > setEnabled ( false ) ;
}
}
2021-06-04 01:37:45 +00:00
void OptionsDialog : : addStatisticsControls ( GuiObject * boss , const Common : : String & prefix ) {
2021-05-31 01:28:35 +00:00
GUI : : ScrollContainerWidget * scrollContainer ;
scrollContainer = new GUI : : ScrollContainerWidget ( boss , prefix + " Container " , " " ) ;
scrollContainer - > setBackgroundType ( GUI : : ThemeEngine : : kWidgetBackgroundNo ) ;
2021-06-04 01:37:45 +00:00
uint16 nMax = AchMan . getStatCount ( ) ;
2021-05-31 01:28:35 +00:00
uint16 lineHeight = g_gui . xmlEval ( ) - > getVar ( " Globals.Line.Height " ) ;
uint16 yStep = lineHeight ;
2021-05-31 20:45:36 +00:00
uint16 ySmallStep = yStep / 3 ;
2021-05-31 01:28:35 +00:00
uint16 yPos = lineHeight ;
uint16 width = g_system - > getOverlayWidth ( ) < = 320 ? 240 : 410 ;
for ( uint16 idx = 0 ; idx < nMax ; idx + + ) {
2021-06-04 01:37:45 +00:00
const Common : : StatDescription * descr = AchMan . getStatDescription ( idx ) ;
2021-05-31 01:28:35 +00:00
2021-06-04 22:10:30 +00:00
const Common : : String & key = descr - > comment . empty ( ) ? descr - > id : descr - > comment ;
2021-06-04 01:37:45 +00:00
Common : : String value = AchMan . getStatRaw ( descr - > id ) ;
2021-05-31 01:28:35 +00:00
2021-06-01 20:59:00 +00:00
Common : : U32String str = Common : : U32String : : format ( " %s: %s " , key . c_str ( ) , value . c_str ( ) ) ;
2021-05-31 01:28:35 +00:00
new StaticTextWidget ( scrollContainer , lineHeight , yPos , width , yStep , str , Graphics : : kTextAlignStart ) ;
yPos + = yStep ;
yPos + = ySmallStep ;
}
}
2010-04-06 09:26:59 +00:00
void OptionsDialog : : addGraphicControls ( GuiObject * boss , const Common : : String & prefix ) {
2004-02-24 22:39:42 +00:00
const OSystem : : GraphicsMode * gm = g_system - > getSupportedGraphicsModes ( ) ;
2010-08-30 22:24:40 +00:00
Common : : String context ;
if ( g_system - > getOverlayWidth ( ) < = 320 )
context = " lowres " ;
2010-10-12 02:18:11 +00:00
2003-11-05 12:25:42 +00:00
// The GFX mode popup
2020-07-01 18:01:48 +00:00
_gfxPopUpDesc = new StaticTextWidget ( boss , prefix + " grModePopupDesc " , _ ( " Graphics mode: " ) ) ;
2022-05-06 22:15:57 +00:00
if ( ConfMan . isKeyTemporary ( " gfx_mode " ) )
2022-09-30 13:39:25 +00:00
_gfxPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2009-06-06 17:52:44 +00:00
_gfxPopUp = new PopUpWidget ( boss , prefix + " grModePopup " ) ;
2003-11-03 05:27:53 +00:00
2020-07-01 18:01:48 +00:00
_gfxPopUp - > appendEntry ( _ ( " <default> " ) ) ;
2020-11-15 18:15:58 +00:00
_gfxPopUp - > appendEntry ( Common : : U32String ( ) ) ;
2004-02-24 22:39:42 +00:00
while ( gm - > name ) {
2010-08-30 22:24:40 +00:00
_gfxPopUp - > appendEntry ( _c ( gm - > description , context ) , gm - > id ) ;
2004-02-24 22:39:42 +00:00
gm + + ;
}
2003-11-05 12:25:42 +00:00
2005-02-20 00:17:22 +00:00
// RenderMode popup
2012-02-29 10:43:21 +00:00
const Common : : String allFlags = Common : : allRenderModesGUIOs ( ) ;
2020-01-05 16:48:04 +00:00
bool renderingTypeDefined = ( strpbrk ( _guioptions . c_str ( ) , allFlags . c_str ( ) ) ! = nullptr ) ;
2012-02-19 15:26:09 +00:00
2020-07-01 18:01:48 +00:00
_renderModePopUpDesc = new StaticTextWidget ( boss , prefix + " grRenderPopupDesc " , _ ( " Render mode: " ) , _ ( " Special dithering modes supported by some games " ) ) ;
2022-05-06 22:15:57 +00:00
if ( ConfMan . isKeyTemporary ( " render_mode " ) )
2022-09-30 13:39:25 +00:00
_renderModePopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2010-06-15 10:53:30 +00:00
_renderModePopUp = new PopUpWidget ( boss , prefix + " grRenderPopup " , _ ( " Special dithering modes supported by some games " ) ) ;
2020-07-01 18:01:48 +00:00
_renderModePopUp - > appendEntry ( _ ( " <default> " ) , Common : : kRenderDefault ) ;
2020-11-15 18:15:58 +00:00
_renderModePopUp - > appendEntry ( Common : : U32String ( ) ) ;
2005-02-20 00:17:22 +00:00
const Common : : RenderModeDescription * rm = Common : : g_renderModes ;
for ( ; rm - > code ; + + rm ) {
2012-02-29 10:43:21 +00:00
Common : : String renderGuiOption = Common : : renderMode2GUIO ( rm - > id ) ;
2012-02-19 15:26:09 +00:00
if ( ( _domain = = Common : : ConfigManager : : kApplicationDomain ) | | ( _domain ! = Common : : ConfigManager : : kApplicationDomain & & ! renderingTypeDefined ) | | ( _guioptions . contains ( renderGuiOption ) ) )
_renderModePopUp - > appendEntry ( _c ( rm - > description , context ) , rm - > id ) ;
2005-02-20 00:17:22 +00:00
}
2018-07-01 22:57:00 +00:00
// The Stretch mode popup
const OSystem : : GraphicsMode * sm = g_system - > getSupportedStretchModes ( ) ;
2020-07-01 18:01:48 +00:00
_stretchPopUpDesc = new StaticTextWidget ( boss , prefix + " grStretchModePopupDesc " , _ ( " Stretch mode: " ) ) ;
2022-05-06 22:15:57 +00:00
if ( ConfMan . isKeyTemporary ( " stretch_mode " ) )
2022-09-30 13:39:25 +00:00
_stretchPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2018-07-01 22:57:00 +00:00
_stretchPopUp = new PopUpWidget ( boss , prefix + " grStretchModePopup " ) ;
2020-07-01 18:01:48 +00:00
_stretchPopUp - > appendEntry ( _ ( " <default> " ) ) ;
2020-11-15 18:15:58 +00:00
_stretchPopUp - > appendEntry ( Common : : U32String ( ) ) ;
2018-07-01 22:57:00 +00:00
while ( sm - > name ) {
_stretchPopUp - > appendEntry ( _c ( sm - > description , context ) , sm - > id ) ;
sm + + ;
}
2022-10-02 20:54:24 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureShaders ) ) {
_scalerToggleGroup = new RadiobuttonGroup ( boss , kScalerToggle ) ;
_scalerToggleScalers = new RadiobuttonWidget ( boss , prefix + " grScalerRadioButton " , _scalerToggleGroup , kScalerScaler , Common : : U32String ( " " ) ) ;
}
2021-01-06 23:24:00 +00:00
// The Scaler popup
const PluginList & scalerPlugins = ScalerMan . getPlugins ( ) ;
2022-10-02 20:54:24 +00:00
_scalerPopUpDesc = new StaticTextWidget ( boss , prefix + " grScalerPopupDesc " , _ ( " Use scaler: " ) ) ;
2021-01-06 23:24:00 +00:00
_scalerPopUp = new PopUpWidget ( boss , prefix + " grScalerPopup " , Common : : U32String ( ) , kScalerPopUpCmd ) ;
_scalerPopUp - > appendEntry ( _ ( " <default> " ) ) ;
_scalerPopUp - > appendEntry ( Common : : U32String ( ) ) ;
for ( uint scalerIndex = 0 ; scalerIndex < scalerPlugins . size ( ) ; scalerIndex + + ) {
_scalerPopUp - > appendEntry ( _c ( scalerPlugins [ scalerIndex ] - > get < ScalerPluginObject > ( ) . getPrettyName ( ) , context ) , scalerIndex ) ;
}
_scaleFactorPopUp = new PopUpWidget ( boss , prefix + " grScaleFactorPopup " ) ;
updateScaleFactors ( _scalerPopUp - > getSelectedTag ( ) ) ;
2022-10-02 20:54:24 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureShaders ) ) {
_scalerToggleShaders = new RadiobuttonWidget ( boss , prefix + " grShaderRadioButton " , _scalerToggleGroup , kScalerShader , Common : : U32String ( " " ) ) ;
if ( g_system - > getOverlayWidth ( ) > 320 )
_shaderButton = new ButtonWidget ( boss , prefix + " grShaderButton " , _ ( " Use Shader: " ) , _ ( " Specifies path to the shader used for scaling the game screen " ) , kChooseShaderCmd ) ;
else
_shaderButton = new ButtonWidget ( boss , prefix + " grShaderButton " , _c ( " Shader Path: " , " lowres " ) , _ ( " Specifies path to the shader used for scaling the game screen " ) , kChooseShaderCmd ) ;
_shader = new StaticTextWidget ( boss , prefix + " grShader " , _c ( " None " , " shader " ) , _ ( " Specifies path to the shader used for scaling the game screen " ) ) ;
_shaderClearButton = addClearButton ( boss , prefix + " grShaderClearButton " , kClearShaderCmd ) ;
_enableShaderSettings = true ;
}
2003-11-05 12:25:42 +00:00
// Fullscreen checkbox
2020-11-15 18:15:58 +00:00
_fullscreenCheckbox = new CheckboxWidget ( boss , prefix + " grFullscreenCheckbox " , _ ( " Fullscreen mode " ) , Common : : U32String ( ) , kFullscreenToggled ) ;
2016-11-12 11:59:06 +00:00
2021-10-21 06:02:00 +00:00
_vsyncCheckbox = new CheckboxWidget ( boss , prefix + " grVSyncCheckbox " , _ ( " V-Sync " ) , _ ( " Wait for the vertical sync to refresh the screen in order to prevent tearing artifacts " ) ) ;
2016-11-20 12:13:15 +00:00
2021-03-26 08:40:00 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
_rendererTypePopUpDesc = new StaticTextWidget ( boss , prefix + " grRendererTypePopupDesc " , _ ( " Game 3D Renderer: " ) ) ;
else
_rendererTypePopUpDesc = new StaticTextWidget ( boss , prefix + " grRendererTypePopupDesc " , _c ( " Game 3D Renderer: " , " lowres " ) ) ;
2015-12-28 15:42:05 +00:00
_rendererTypePopUp = new PopUpWidget ( boss , prefix + " grRendererTypePopup " ) ;
_rendererTypePopUp - > appendEntry ( _ ( " <default> " ) , Graphics : : kRendererTypeDefault ) ;
_rendererTypePopUp - > appendEntry ( " " ) ;
2022-04-09 21:07:38 +00:00
Common : : Array < Graphics : : RendererTypeDescription > rt = Graphics : : Renderer : : listTypes ( ) ;
for ( Common : : Array < Graphics : : RendererTypeDescription > : : iterator it = rt . begin ( ) ;
it ! = rt . end ( ) ; + + it ) {
if ( g_system - > getOverlayWidth ( ) > 320 ) {
_rendererTypePopUp - > appendEntry ( _ ( it - > description ) , it - > id ) ;
} else {
_rendererTypePopUp - > appendEntry ( _c ( it - > description , " lowres " ) , it - > id ) ;
}
2015-12-28 15:42:05 +00:00
}
2019-05-16 20:23:32 +00:00
2020-10-04 14:02:50 +00:00
_antiAliasPopUpDesc = new StaticTextWidget ( boss , prefix + " grAntiAliasPopupDesc " , _ ( " 3D Anti-aliasing: " ) ) ;
2019-05-16 20:23:32 +00:00
_antiAliasPopUp = new PopUpWidget ( boss , prefix + " grAntiAliasPopup " ) ;
_antiAliasPopUp - > appendEntry ( _ ( " <default> " ) , - 1 ) ;
_antiAliasPopUp - > appendEntry ( " " ) ;
_antiAliasPopUp - > appendEntry ( _ ( " Disabled " ) , 0 ) ;
const Common : : Array < uint > levels = g_system - > getSupportedAntiAliasingLevels ( ) ;
for ( uint i = 0 ; i < levels . size ( ) ; i + + ) {
_antiAliasPopUp - > appendEntry ( Common : : String : : format ( " %dx " , levels [ i ] ) , levels [ i ] ) ;
}
if ( levels . empty ( ) ) {
// Don't show the anti-aliasing selection menu when it is not supported
_antiAliasPopUpDesc - > setVisible ( false ) ;
_antiAliasPopUp - > setVisible ( false ) ;
}
2016-10-17 16:45:12 +00:00
2016-10-12 21:32:36 +00:00
// Filtering checkbox
2020-07-01 18:01:48 +00:00
_filteringCheckbox = new CheckboxWidget ( boss , prefix + " grFilteringCheckbox " , _ ( " Filter graphics " ) , _ ( " Use linear filtering when scaling graphics " ) ) ;
2003-11-04 21:17:33 +00:00
2003-11-05 12:25:42 +00:00
// Aspect ratio checkbox
2020-10-09 17:04:07 +00:00
_aspectCheckbox = new CheckboxWidget ( boss , prefix + " grAspectCheckbox " , _ ( " Aspect ratio correction " ) , _ ( " Correct aspect ratio for games " ) ) ;
2004-02-24 21:56:16 +00:00
2003-11-07 16:01:51 +00:00
_enableGraphicSettings = true ;
2003-11-05 12:25:42 +00:00
}
2003-11-03 00:24:04 +00:00
2022-10-02 20:54:24 +00:00
void OptionsDialog : : setScalerControls ( ) {
bool scalers , shaders ;
if ( _scalerToggleGroup - > getValue ( ) = = kScalerScaler ) {
scalers = true ;
shaders = false ;
} else {
scalers = false ;
shaders = true ;
}
_scalerPopUpDesc - > setEnabled ( scalers ) ;
_scalerPopUp - > setEnabled ( scalers ) ;
_scaleFactorPopUp - > setEnabled ( scalers ) ;
_shaderButton - > setEnabled ( shaders ) ;
_shader - > setEnabled ( shaders ) ;
_shaderClearButton - > setEnabled ( shaders ) ;
}
2010-04-06 09:26:59 +00:00
void OptionsDialog : : addAudioControls ( GuiObject * boss , const Common : : String & prefix ) {
2002-12-12 23:22:48 +00:00
// The MIDI mode popup & a label
2010-09-12 11:43:51 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
_midiPopUpDesc = new StaticTextWidget ( boss , prefix + " auMidiPopupDesc " , _domain = = Common : : ConfigManager : : kApplicationDomain ? _ ( " Preferred device: " ) : _ ( " Music device: " ) , _domain = = Common : : ConfigManager : : kApplicationDomain ? _ ( " Specifies preferred sound device or sound card emulator " ) : _ ( " Specifies output sound device or sound card emulator " ) ) ;
2010-09-12 11:43:51 +00:00
else
2020-07-01 18:01:48 +00:00
_midiPopUpDesc = new StaticTextWidget ( boss , prefix + " auMidiPopupDesc " , _domain = = Common : : ConfigManager : : kApplicationDomain ? _c ( " Preferred dev.: " , " lowres " ) : _c ( " Music device: " , " lowres " ) , _domain = = Common : : ConfigManager : : kApplicationDomain ? _ ( " Specifies preferred sound device or sound card emulator " ) : _ ( " Specifies output sound device or sound card emulator " ) ) ;
2010-06-15 10:54:22 +00:00
_midiPopUp = new PopUpWidget ( boss , prefix + " auMidiPopup " , _ ( " Specifies output sound device or sound card emulator " ) ) ;
2005-07-30 21:11:48 +00:00
2002-12-13 23:29:18 +00:00
// Populate it
2011-10-24 18:29:28 +00:00
const Common : : String allFlags = MidiDriver : : musicType2GUIO ( ( uint32 ) - 1 ) ;
2020-01-05 16:48:04 +00:00
bool hasMidiDefined = ( strpbrk ( _guioptions . c_str ( ) , allFlags . c_str ( ) ) ! = nullptr ) ;
2010-06-21 21:36:36 +00:00
2017-11-11 05:06:42 +00:00
const PluginList p = MusicMan . getPlugins ( ) ;
for ( PluginList : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
MusicDevices i = ( * m ) - > get < MusicPluginObject > ( ) . getDevices ( ) ;
2010-07-04 18:00:46 +00:00
for ( MusicDevices : : iterator d = i . begin ( ) ; d ! = i . end ( ) ; + + d ) {
2011-10-23 14:14:41 +00:00
Common : : String deviceGuiOption = MidiDriver : : musicType2GUIO ( d - > getMusicType ( ) ) ;
2010-07-21 20:37:46 +00:00
2020-07-11 16:05:43 +00:00
if ( ( _domain = = Common : : ConfigManager : : kApplicationDomain & & d - > getMusicType ( ) ! = MT_TOWNS // global dialog - skip useless FM-Towns, C64, Amiga, AppleIIGS and SegaCD options there
& & d - > getMusicType ( ) ! = MT_C64 & & d - > getMusicType ( ) ! = MT_AMIGA & & d - > getMusicType ( ) ! = MT_APPLEIIGS & & d - > getMusicType ( ) ! = MT_PC98 & & d - > getMusicType ( ) ! = MT_SEGACD )
2011-10-23 14:14:41 +00:00
| | ( _domain ! = Common : : ConfigManager : : kApplicationDomain & & ! hasMidiDefined ) // No flags are specified
| | ( _guioptions . contains ( deviceGuiOption ) ) // flag is present
2010-08-11 19:32:07 +00:00
// HACK/FIXME: For now we have to show GM devices, even when the game only has GUIO_MIDIMT32 set,
// else we would not show for example external devices connected via ALSA, since they are always
// marked as General MIDI device.
2011-10-23 14:14:41 +00:00
| | ( deviceGuiOption . contains ( GUIO_MIDIGM ) & & ( _guioptions . contains ( GUIO_MIDIMT32 ) ) )
2010-08-11 19:32:07 +00:00
| | d - > getMusicDriverId ( ) = = " auto " | | d - > getMusicDriverId ( ) = = " null " ) // always add default and null device
2021-04-10 17:08:50 +00:00
_midiPopUp - > appendEntry ( _ ( d - > getCompleteName ( ) ) , d - > getHandle ( ) ) ;
2010-06-21 21:36:36 +00:00
}
}
2009-05-12 18:42:44 +00:00
// The OPL emulator popup & a label
2020-07-01 18:01:48 +00:00
_oplPopUpDesc = new StaticTextWidget ( boss , prefix + " auOPLPopupDesc " , _ ( " AdLib emulator: " ) , _ ( " AdLib is used for music in many games " ) ) ;
2022-05-22 22:23:44 +00:00
if ( ConfMan . isKeyTemporary ( " opl_driver " ) )
2022-09-30 13:39:25 +00:00
_oplPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2010-06-15 10:53:30 +00:00
_oplPopUp = new PopUpWidget ( boss , prefix + " auOPLPopup " , _ ( " AdLib is used for music in many games " ) ) ;
2009-05-12 18:42:44 +00:00
// Populate it
const OPL : : Config : : EmulatorDescription * ed = OPL : : Config : : getAvailable ( ) ;
while ( ed - > name ) {
2020-07-01 18:01:48 +00:00
_oplPopUp - > appendEntry ( _ ( ed - > description ) , ed - > id ) ;
2009-05-12 18:42:44 +00:00
+ + ed ;
}
2005-04-13 00:11:49 +00:00
_enableAudioSettings = true ;
}
2010-04-06 09:26:59 +00:00
void OptionsDialog : : addMIDIControls ( GuiObject * boss , const Common : : String & prefix ) {
2020-07-01 18:01:48 +00:00
_gmDevicePopUpDesc = new StaticTextWidget ( boss , prefix + " auPrefGmPopupDesc " , _ ( " GM device: " ) , _ ( " Specifies default sound device for General MIDI output " ) ) ;
2010-07-24 22:29:17 +00:00
_gmDevicePopUp = new PopUpWidget ( boss , prefix + " auPrefGmPopup " ) ;
// Populate
2017-11-11 05:06:42 +00:00
const PluginList p = MusicMan . getPlugins ( ) ;
2010-10-24 19:15:17 +00:00
// Make sure the null device is the first one in the list to avoid undesired
// auto detection for users who don't have a saved setting yet.
2017-11-11 05:06:42 +00:00
for ( PluginList : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
MusicDevices i = ( * m ) - > get < MusicPluginObject > ( ) . getDevices ( ) ;
2010-07-24 22:29:17 +00:00
for ( MusicDevices : : iterator d = i . begin ( ) ; d ! = i . end ( ) ; + + d ) {
2010-10-24 19:15:17 +00:00
if ( d - > getMusicDriverId ( ) = = " null " )
2020-07-01 18:01:48 +00:00
_gmDevicePopUp - > appendEntry ( _ ( " Don't use General MIDI music " ) , d - > getHandle ( ) ) ;
2010-10-24 19:15:17 +00:00
}
}
// Now we add the other devices.
2017-11-11 05:06:42 +00:00
for ( PluginList : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
MusicDevices i = ( * m ) - > get < MusicPluginObject > ( ) . getDevices ( ) ;
2010-10-24 19:15:17 +00:00
for ( MusicDevices : : iterator d = i . begin ( ) ; d ! = i . end ( ) ; + + d ) {
if ( d - > getMusicType ( ) > = MT_GM ) {
2010-07-24 22:29:17 +00:00
if ( d - > getMusicType ( ) ! = MT_MT32 )
_gmDevicePopUp - > appendEntry ( d - > getCompleteName ( ) , d - > getHandle ( ) ) ;
2010-10-24 19:15:17 +00:00
} else if ( d - > getMusicDriverId ( ) = = " auto " ) {
2020-07-01 18:01:48 +00:00
_gmDevicePopUp - > appendEntry ( _ ( " Use first available device " ) , d - > getHandle ( ) ) ;
2011-06-19 22:59:48 +00:00
}
2010-07-24 22:29:17 +00:00
}
}
if ( ! _domain . equals ( Common : : ConfigManager : : kApplicationDomain ) ) {
_gmDevicePopUpDesc - > setEnabled ( false ) ;
_gmDevicePopUp - > setEnabled ( false ) ;
}
2005-04-10 14:33:44 +00:00
// SoundFont
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
_soundFontButton = new ButtonWidget ( boss , prefix + " mcFontButton " , _ ( " SoundFont: " ) , _ ( " SoundFont is supported by some audio cards, FluidSynth and Timidity " ) , kChooseSoundFontCmd ) ;
2010-08-30 22:24:40 +00:00
else
2020-07-01 18:01:48 +00:00
_soundFontButton = new ButtonWidget ( boss , prefix + " mcFontButton " , _c ( " SoundFont: " , " lowres " ) , _ ( " SoundFont is supported by some audio cards, FluidSynth and Timidity " ) , kChooseSoundFontCmd ) ;
_soundFont = new StaticTextWidget ( boss , prefix + " mcFontPath " , _c ( " None " , " soundfont " ) , _ ( " SoundFont is supported by some audio cards, FluidSynth and Timidity " ) ) ;
2011-10-24 18:34:10 +00:00
2011-10-24 18:50:31 +00:00
_soundFontClearButton = addClearButton ( boss , prefix + " mcFontClearButton " , kClearSoundFontCmd ) ;
2005-04-13 00:11:49 +00:00
2003-11-05 12:25:42 +00:00
// Multi midi setting
2020-07-01 18:01:48 +00:00
_multiMidiCheckbox = new CheckboxWidget ( boss , prefix + " mcMixedCheckbox " , _ ( " Mixed AdLib/MIDI mode " ) , _ ( " Use both MIDI and AdLib sound generation " ) ) ;
2005-07-30 21:11:48 +00:00
2006-06-11 20:51:14 +00:00
// MIDI gain setting (FluidSynth uses this)
2020-07-01 18:01:48 +00:00
_midiGainDesc = new StaticTextWidget ( boss , prefix + " mcMidiGainText " , _ ( " MIDI gain: " ) ) ;
2020-11-15 18:15:58 +00:00
_midiGainSlider = new SliderWidget ( boss , prefix + " mcMidiGainSlider " , Common : : U32String ( ) , kMidiGainChanged ) ;
2006-06-11 20:51:14 +00:00
_midiGainSlider - > setMinValue ( 0 ) ;
_midiGainSlider - > setMaxValue ( 1000 ) ;
2020-06-13 17:36:08 +00:00
_midiGainLabel = new StaticTextWidget ( boss , prefix + " mcMidiGainLabel " , Common : : U32String ( " 1.00 " ) ) ;
2006-06-11 20:51:14 +00:00
2005-04-13 00:11:49 +00:00
_enableMIDISettings = true ;
2003-11-05 12:25:42 +00:00
}
2010-07-24 22:29:17 +00:00
void OptionsDialog : : addMT32Controls ( GuiObject * boss , const Common : : String & prefix ) {
2020-07-01 18:01:48 +00:00
_mt32DevicePopUpDesc = new StaticTextWidget ( boss , prefix + " auPrefMt32PopupDesc " , _ ( " MT-32 Device: " ) , _ ( " Specifies default sound device for Roland MT-32/LAPC1/CM32l/CM64 output " ) ) ;
2010-07-24 22:29:17 +00:00
_mt32DevicePopUp = new PopUpWidget ( boss , prefix + " auPrefMt32Popup " ) ;
// Native mt32 setting
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
_mt32Checkbox = new CheckboxWidget ( boss , prefix + " mcMt32Checkbox " , _ ( " True Roland MT-32 (disable GM emulation) " ) , _ ( " Check if you want to use your real hardware Roland-compatible sound device connected to your computer " ) ) ;
2010-08-30 22:24:40 +00:00
else
2020-07-01 18:01:48 +00:00
_mt32Checkbox = new CheckboxWidget ( boss , prefix + " mcMt32Checkbox " , _c ( " True Roland MT-32 (no GM emulation) " , " lowres " ) , _ ( " Check if you want to use your real hardware Roland-compatible sound device connected to your computer " ) ) ;
2010-07-24 22:29:17 +00:00
// GS Extensions setting
2020-07-01 18:01:48 +00:00
_enableGSCheckbox = new CheckboxWidget ( boss , prefix + " mcGSCheckbox " , _ ( " Roland GS device (enable MT-32 mappings) " ) , _ ( " Check if you want to enable patch mappings to emulate an MT-32 on a Roland GS device " ) ) ;
2010-07-24 22:29:17 +00:00
2017-11-11 05:06:42 +00:00
const PluginList p = MusicMan . getPlugins ( ) ;
2010-10-24 19:15:17 +00:00
// Make sure the null device is the first one in the list to avoid undesired
// auto detection for users who don't have a saved setting yet.
2017-11-11 05:06:42 +00:00
for ( PluginList : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
MusicDevices i = ( * m ) - > get < MusicPluginObject > ( ) . getDevices ( ) ;
2010-10-24 19:15:17 +00:00
for ( MusicDevices : : iterator d = i . begin ( ) ; d ! = i . end ( ) ; + + d ) {
if ( d - > getMusicDriverId ( ) = = " null " )
2020-07-01 18:01:48 +00:00
_mt32DevicePopUp - > appendEntry ( _ ( " Don't use Roland MT-32 music " ) , d - > getHandle ( ) ) ;
2010-10-24 19:15:17 +00:00
}
}
// Now we add the other devices.
2017-11-11 05:06:42 +00:00
for ( PluginList : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
MusicDevices i = ( * m ) - > get < MusicPluginObject > ( ) . getDevices ( ) ;
2010-07-24 22:29:17 +00:00
for ( MusicDevices : : iterator d = i . begin ( ) ; d ! = i . end ( ) ; + + d ) {
2010-10-24 19:15:17 +00:00
if ( d - > getMusicType ( ) > = MT_GM )
2010-07-24 22:29:17 +00:00
_mt32DevicePopUp - > appendEntry ( d - > getCompleteName ( ) , d - > getHandle ( ) ) ;
2010-10-24 19:15:17 +00:00
else if ( d - > getMusicDriverId ( ) = = " auto " )
2020-07-01 18:01:48 +00:00
_mt32DevicePopUp - > appendEntry ( _ ( " Use first available device " ) , d - > getHandle ( ) ) ;
2010-07-24 22:29:17 +00:00
}
}
if ( ! _domain . equals ( Common : : ConfigManager : : kApplicationDomain ) ) {
_mt32DevicePopUpDesc - > setEnabled ( false ) ;
_mt32DevicePopUp - > setEnabled ( false ) ;
2019-02-10 17:15:15 +00:00
}
2010-07-24 22:29:17 +00:00
2010-08-10 16:24:00 +00:00
_enableMT32Settings = true ;
2010-07-24 22:29:17 +00:00
}
2006-05-13 17:30:04 +00:00
// The function has an extra slider range parameter, since both the launcher and SCUMM engine
// make use of the widgets. The launcher range is 0-255. SCUMM's 0-9
2010-04-06 09:26:59 +00:00
void OptionsDialog : : addSubtitleControls ( GuiObject * boss , const Common : : String & prefix , int maxSliderVal ) {
2006-05-13 17:30:04 +00:00
2010-06-15 10:48:39 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 ) {
2020-07-01 18:01:48 +00:00
_subToggleDesc = new StaticTextWidget ( boss , prefix + " subToggleDesc " , _ ( " Text and speech: " ) ) ;
2010-08-30 22:24:40 +00:00
2010-06-15 10:48:39 +00:00
_subToggleGroup = new RadiobuttonGroup ( boss , kSubtitleToggle ) ;
2020-07-01 18:01:48 +00:00
_subToggleSpeechOnly = new RadiobuttonWidget ( boss , prefix + " subToggleSpeechOnly " , _subToggleGroup , kSubtitlesSpeech , _ ( " Speech " ) ) ;
_subToggleSubOnly = new RadiobuttonWidget ( boss , prefix + " subToggleSubOnly " , _subToggleGroup , kSubtitlesSubs , _ ( " Subtitles " ) ) ;
_subToggleSubBoth = new RadiobuttonWidget ( boss , prefix + " subToggleSubBoth " , _subToggleGroup , kSubtitlesBoth , _ ( " Both " ) ) ;
2010-10-12 02:18:11 +00:00
2020-07-01 18:01:48 +00:00
_subSpeedDesc = new StaticTextWidget ( boss , prefix + " subSubtitleSpeedDesc " , _ ( " Subtitle speed: " ) ) ;
2010-06-15 10:48:39 +00:00
} else {
2020-07-01 18:01:48 +00:00
_subToggleDesc = new StaticTextWidget ( boss , prefix + " subToggleDesc " , _c ( " Text and speech: " , " lowres " ) ) ;
2010-08-30 22:24:40 +00:00
2010-06-15 10:48:39 +00:00
_subToggleGroup = new RadiobuttonGroup ( boss , kSubtitleToggle ) ;
2020-07-01 18:01:48 +00:00
_subToggleSpeechOnly = new RadiobuttonWidget ( boss , prefix + " subToggleSpeechOnly " , _subToggleGroup , kSubtitlesSpeech , _ ( " Spch " ) , _ ( " Speech " ) ) ;
_subToggleSubOnly = new RadiobuttonWidget ( boss , prefix + " subToggleSubOnly " , _subToggleGroup , kSubtitlesSubs , _ ( " Subs " ) , _ ( " Subtitles " ) ) ;
_subToggleSubBoth = new RadiobuttonWidget ( boss , prefix + " subToggleSubBoth " , _subToggleGroup , kSubtitlesBoth , _c ( " Both " , " lowres " ) , _ ( " Show subtitles and play speech " ) ) ;
2010-10-12 02:18:11 +00:00
2020-07-01 18:01:48 +00:00
_subSpeedDesc = new StaticTextWidget ( boss , prefix + " subSubtitleSpeedDesc " , _c ( " Subtitle speed: " , " lowres " ) ) ;
2010-06-15 10:48:39 +00:00
}
2022-09-30 13:39:25 +00:00
2022-05-22 22:23:44 +00:00
if ( ConfMan . isKeyTemporary ( " talkspeed " ) )
2022-09-30 13:39:25 +00:00
_subSpeedDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2022-05-22 22:33:00 +00:00
if ( ConfMan . isKeyTemporary ( " subtitles " ) )
2022-09-30 13:39:25 +00:00
_subToggleDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2006-05-13 17:30:04 +00:00
// Subtitle speed
2020-11-15 18:15:58 +00:00
_subSpeedSlider = new SliderWidget ( boss , prefix + " subSubtitleSpeedSlider " , Common : : U32String ( ) , kSubtitleSpeedChanged ) ;
2021-09-30 16:17:49 +00:00
_subSpeedLabel = new StaticTextWidget ( boss , prefix + " subSubtitleSpeedLabel " , Common : : U32String ( " 100% " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleBold , Common : : UNK_LANG , false ) ;
2006-05-13 17:30:04 +00:00
_subSpeedSlider - > setMinValue ( 0 ) ; _subSpeedSlider - > setMaxValue ( maxSliderVal ) ;
_subSpeedLabel - > setFlags ( WIDGET_CLEARBG ) ;
_enableSubtitleSettings = true ;
2021-10-14 18:04:53 +00:00
_enableSubtitleToggle = true ;
2006-05-13 17:30:04 +00:00
}
2010-04-06 09:26:59 +00:00
void OptionsDialog : : addVolumeControls ( GuiObject * boss , const Common : : String & prefix ) {
2005-05-18 16:17:25 +00:00
2003-11-03 00:24:04 +00:00
// Volume controllers
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
_musicVolumeDesc = new StaticTextWidget ( boss , prefix + " vcMusicText " , _ ( " Music volume: " ) ) ;
2010-08-30 22:24:40 +00:00
else
2020-06-13 16:42:25 +00:00
_musicVolumeDesc = new StaticTextWidget ( boss , prefix + " vcMusicText " , _c ( " Music volume: " , " lowres " ) ) ;
2022-09-30 13:39:25 +00:00
if ( ConfMan . isKeyTemporary ( " music_volume " ) )
_musicVolumeDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2020-11-15 18:15:58 +00:00
_musicVolumeSlider = new SliderWidget ( boss , prefix + " vcMusicSlider " , Common : : U32String ( ) , kMusicVolumeChanged ) ;
2021-09-30 16:17:49 +00:00
_musicVolumeLabel = new StaticTextWidget ( boss , prefix + " vcMusicLabel " , Common : : U32String ( " 100% " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleBold , Common : : UNK_LANG , false ) ;
2005-05-18 15:58:39 +00:00
_musicVolumeSlider - > setMinValue ( 0 ) ;
_musicVolumeSlider - > setMaxValue ( Audio : : Mixer : : kMaxMixerVolume ) ;
2003-03-25 15:32:36 +00:00
_musicVolumeLabel - > setFlags ( WIDGET_CLEARBG ) ;
2003-11-01 22:21:18 +00:00
2020-11-15 18:15:58 +00:00
_muteCheckbox = new CheckboxWidget ( boss , prefix + " vcMuteCheckbox " , _ ( " Mute all " ) , Common : : U32String ( ) , kMuteAllChanged ) ;
2009-06-06 17:36:06 +00:00
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
_sfxVolumeDesc = new StaticTextWidget ( boss , prefix + " vcSfxText " , _ ( " SFX volume: " ) , _ ( " Special sound effects volume " ) ) ;
2010-08-30 22:24:40 +00:00
else
2020-07-01 18:01:48 +00:00
_sfxVolumeDesc = new StaticTextWidget ( boss , prefix + " vcSfxText " , _c ( " SFX volume: " , " lowres " ) , _ ( " Special sound effects volume " ) ) ;
2022-05-06 22:51:24 +00:00
if ( ConfMan . isKeyTemporary ( " sfx_volume " ) )
_sfxVolumeDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2010-06-15 10:53:30 +00:00
_sfxVolumeSlider = new SliderWidget ( boss , prefix + " vcSfxSlider " , _ ( " Special sound effects volume " ) , kSfxVolumeChanged ) ;
2021-09-30 16:17:49 +00:00
_sfxVolumeLabel = new StaticTextWidget ( boss , prefix + " vcSfxLabel " , Common : : U32String ( " 100% " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleBold , Common : : UNK_LANG , false ) ;
2005-05-18 15:58:39 +00:00
_sfxVolumeSlider - > setMinValue ( 0 ) ;
_sfxVolumeSlider - > setMaxValue ( Audio : : Mixer : : kMaxMixerVolume ) ;
2003-03-25 15:32:36 +00:00
_sfxVolumeLabel - > setFlags ( WIDGET_CLEARBG ) ;
2003-11-08 23:22:16 +00:00
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
_speechVolumeDesc = new StaticTextWidget ( boss , prefix + " vcSpeechText " , _ ( " Speech volume: " ) ) ;
2010-08-30 22:24:40 +00:00
else
2020-07-01 18:01:48 +00:00
_speechVolumeDesc = new StaticTextWidget ( boss , prefix + " vcSpeechText " , _c ( " Speech volume: " , " lowres " ) ) ;
2022-05-06 22:51:24 +00:00
if ( ConfMan . isKeyTemporary ( " speech_volume " ) )
2022-09-30 13:39:25 +00:00
_speechVolumeDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2020-11-15 18:15:58 +00:00
_speechVolumeSlider = new SliderWidget ( boss , prefix + " vcSpeechSlider " , Common : : U32String ( ) , kSpeechVolumeChanged ) ;
2021-09-30 16:17:49 +00:00
_speechVolumeLabel = new StaticTextWidget ( boss , prefix + " vcSpeechLabel " , Common : : U32String ( " 100% " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleBold , Common : : UNK_LANG , false ) ;
2005-05-18 15:58:39 +00:00
_speechVolumeSlider - > setMinValue ( 0 ) ;
_speechVolumeSlider - > setMaxValue ( Audio : : Mixer : : kMaxMixerVolume ) ;
2004-04-06 11:50:35 +00:00
_speechVolumeLabel - > setFlags ( WIDGET_CLEARBG ) ;
2004-04-05 18:24:36 +00:00
2003-11-07 16:01:51 +00:00
_enableVolumeSettings = true ;
2003-11-05 12:25:42 +00:00
}
2010-07-04 18:24:13 +00:00
bool OptionsDialog : : loadMusicDeviceSetting ( PopUpWidget * popup , Common : : String setting , MusicType preferredType ) {
2010-06-21 21:36:36 +00:00
if ( ! popup | | ! popup - > isEnabled ( ) )
return true ;
2010-07-04 15:06:42 +00:00
if ( _domain ! = Common : : ConfigManager : : kApplicationDomain | | ConfMan . hasKey ( setting , _domain ) | | preferredType ) {
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
const Common : : String drv = ConfMan . get ( setting , ( _domain ! = Common : : ConfigManager : : kApplicationDomain & & ! ConfMan . hasKey ( setting , _domain ) ) ? Common : : ConfigManager : : kApplicationDomain : _domain ) ;
2017-11-11 05:06:42 +00:00
const PluginList p = MusicMan . getPlugins ( ) ;
2010-07-04 18:00:46 +00:00
2017-11-11 05:06:42 +00:00
for ( PluginList : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
MusicDevices i = ( * m ) - > get < MusicPluginObject > ( ) . getDevices ( ) ;
2010-07-04 18:00:46 +00:00
for ( MusicDevices : : iterator d = i . begin ( ) ; d ! = i . end ( ) ; + + d ) {
2010-07-04 17:40:06 +00:00
if ( setting . empty ( ) ? ( preferredType = = d - > getMusicType ( ) ) : ( drv = = d - > getCompleteId ( ) ) ) {
2010-07-04 18:24:13 +00:00
popup - > setSelectedTag ( d - > getHandle ( ) ) ;
2012-03-13 09:40:41 +00:00
return popup - > getSelected ( ) ! = - 1 ;
2010-06-21 21:36:36 +00:00
}
}
}
}
2010-07-04 18:24:13 +00:00
return false ;
2010-06-21 21:36:36 +00:00
}
2010-07-04 18:24:13 +00:00
void OptionsDialog : : saveMusicDeviceSetting ( PopUpWidget * popup , Common : : String setting ) {
2010-06-21 21:36:36 +00:00
if ( ! popup | | ! _enableAudioSettings )
return ;
2010-07-21 18:17:51 +00:00
2017-11-11 05:06:42 +00:00
const PluginList p = MusicMan . getPlugins ( ) ;
2010-06-21 21:36:36 +00:00
bool found = false ;
2017-11-11 05:06:42 +00:00
for ( PluginList : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) & & ! found ; + + m ) {
MusicDevices i = ( * m ) - > get < MusicPluginObject > ( ) . getDevices ( ) ;
2010-07-04 18:00:46 +00:00
for ( MusicDevices : : iterator d = i . begin ( ) ; d ! = i . end ( ) ; + + d ) {
2010-07-04 18:24:13 +00:00
if ( d - > getHandle ( ) = = popup - > getSelectedTag ( ) ) {
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
ConfMan . set ( setting , d - > getCompleteId ( ) , _domain ) ;
2010-06-21 21:36:36 +00:00
found = true ;
break ;
}
}
}
if ( ! found )
ConfMan . removeKey ( setting , _domain ) ;
}
2006-05-13 17:30:04 +00:00
int OptionsDialog : : getSubtitleMode ( bool subtitles , bool speech_mute ) {
2011-10-23 14:14:41 +00:00
if ( _guioptions . contains ( GUIO_NOSUBTITLES ) )
2010-06-15 10:48:39 +00:00
return kSubtitlesSpeech ; // Speech only
2011-10-23 14:14:41 +00:00
if ( _guioptions . contains ( GUIO_NOSPEECH ) )
2010-06-15 10:48:39 +00:00
return kSubtitlesSubs ; // Subtitles only
2009-06-06 17:58:08 +00:00
2006-05-13 17:30:04 +00:00
if ( ! subtitles & & ! speech_mute ) // Speech only
2010-06-15 10:48:39 +00:00
return kSubtitlesSpeech ;
2006-05-13 17:30:04 +00:00
else if ( subtitles & & ! speech_mute ) // Speech and subtitles
2010-06-15 10:48:39 +00:00
return kSubtitlesBoth ;
2006-05-13 17:30:04 +00:00
else if ( subtitles & & speech_mute ) // Subtitles only
2010-06-15 10:48:39 +00:00
return kSubtitlesSubs ;
2007-09-19 08:40:12 +00:00
else
2006-05-13 17:30:04 +00:00
warning ( " Wrong configuration: Both subtitles and speech are off. Assuming subtitles only " ) ;
2010-06-15 10:48:39 +00:00
return kSubtitlesSubs ;
2006-05-13 17:30:04 +00:00
}
2017-01-26 02:36:42 +00:00
void OptionsDialog : : updateMusicVolume ( const int newValue ) const {
_musicVolumeLabel - > setValue ( newValue ) ;
_musicVolumeSlider - > setValue ( newValue ) ;
2018-01-06 13:40:02 +00:00
_musicVolumeLabel - > markAsDirty ( ) ;
_musicVolumeSlider - > markAsDirty ( ) ;
2017-01-26 02:36:42 +00:00
}
void OptionsDialog : : updateSfxVolume ( const int newValue ) const {
_sfxVolumeLabel - > setValue ( newValue ) ;
_sfxVolumeSlider - > setValue ( newValue ) ;
2018-01-06 13:40:02 +00:00
_sfxVolumeLabel - > markAsDirty ( ) ;
_sfxVolumeSlider - > markAsDirty ( ) ;
2017-01-26 02:36:42 +00:00
}
void OptionsDialog : : updateSpeechVolume ( const int newValue ) const {
_speechVolumeLabel - > setValue ( newValue ) ;
_speechVolumeSlider - > setValue ( newValue ) ;
2018-01-06 13:40:02 +00:00
_speechVolumeLabel - > markAsDirty ( ) ;
_speechVolumeSlider - > markAsDirty ( ) ;
2017-01-26 02:36:42 +00:00
}
2006-08-04 13:55:53 +00:00
void OptionsDialog : : reflowLayout ( ) {
2008-08-14 23:17:41 +00:00
if ( _graphicsTabId ! = - 1 & & _tabWidget )
2020-07-01 18:01:48 +00:00
_tabWidget - > setTabTitle ( _graphicsTabId , g_system - > getOverlayWidth ( ) > 320 ? _ ( " Graphics " ) : _ ( " GFX " ) ) ;
2009-08-16 05:38:03 +00:00
Dialog : : reflowLayout ( ) ;
2018-07-21 23:01:01 +00:00
setupGraphicsTab ( ) ;
}
void OptionsDialog : : setupGraphicsTab ( ) {
2021-10-12 12:43:10 +00:00
if ( _graphicsTabId ! = - 1 ) {
setGraphicSettingsState ( _enableGraphicSettings ) ;
}
2018-07-22 11:20:59 +00:00
if ( ! _fullscreenCheckbox )
return ;
2018-07-21 23:01:01 +00:00
_gfxPopUpDesc - > setVisible ( true ) ;
_gfxPopUp - > setVisible ( true ) ;
2018-07-29 12:57:20 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureStretchMode ) ) {
_stretchPopUpDesc - > setVisible ( true ) ;
_stretchPopUp - > setVisible ( true ) ;
} else {
_stretchPopUpDesc - > setVisible ( false ) ;
_stretchPopUp - > setVisible ( false ) ;
}
2018-07-21 23:01:01 +00:00
_fullscreenCheckbox - > setVisible ( true ) ;
2018-07-29 12:57:20 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureFilteringMode ) )
_filteringCheckbox - > setVisible ( true ) ;
else
_filteringCheckbox - > setVisible ( false ) ;
2018-07-21 23:01:01 +00:00
_aspectCheckbox - > setVisible ( true ) ;
_renderModePopUpDesc - > setVisible ( true ) ;
_renderModePopUp - > setVisible ( true ) ;
2021-01-06 23:24:00 +00:00
2022-10-02 20:54:24 +00:00
setScalerControls ( ) ;
2021-01-06 23:24:00 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureScalers ) ) {
_scalerPopUpDesc - > setVisible ( true ) ;
2022-05-17 19:33:12 +00:00
if ( ConfMan . isKeyTemporary ( " scaler " ) | | ConfMan . isKeyTemporary ( " scale_factor " ) )
2022-09-30 13:39:25 +00:00
_scalerPopUpDesc - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2021-01-06 23:24:00 +00:00
_scalerPopUp - > setVisible ( true ) ;
_scaleFactorPopUp - > setVisible ( true ) ;
} else {
_scalerPopUpDesc - > setVisible ( false ) ;
_scalerPopUp - > setVisible ( false ) ;
_scaleFactorPopUp - > setVisible ( false ) ;
}
}
void OptionsDialog : : updateScaleFactors ( uint32 tag ) {
if ( ( int32 ) tag > = 0 ) {
const PluginList & scalerPlugins = ScalerMan . getPlugins ( ) ;
const Common : : Array < uint > & factors = scalerPlugins [ tag ] - > get < ScalerPluginObject > ( ) . getFactors ( ) ;
_scaleFactorPopUp - > clearEntries ( ) ;
for ( Common : : Array < uint > : : const_iterator it = factors . begin ( ) ; it ! = factors . end ( ) ; it + + ) {
_scaleFactorPopUp - > appendEntry ( Common : : U32String : : format ( " %dx " , ( * it ) ) , ( * it ) ) ;
}
2021-11-22 00:01:20 +00:00
if ( g_system - > getScaler ( ) = = tag ) {
_scaleFactorPopUp - > setSelectedTag ( g_system - > getScaleFactor ( ) ) ;
} else {
_scaleFactorPopUp - > setSelectedTag ( scalerPlugins [ tag ] - > get < ScalerPluginObject > ( ) . getDefaultFactor ( ) ) ;
}
2021-01-06 23:24:00 +00:00
} else {
_scaleFactorPopUp - > clearEntries ( ) ;
_scaleFactorPopUp - > appendEntry ( _ ( " <default> " ) ) ;
_scaleFactorPopUp - > setSelected ( 0 ) ;
}
2006-04-19 01:05:28 +00:00
}
2003-11-05 12:25:42 +00:00
# pragma mark -
2002-12-12 23:22:48 +00:00
2016-07-12 08:00:11 +00:00
GlobalOptionsDialog : : GlobalOptionsDialog ( LauncherDialog * launcher )
2019-07-19 11:01:09 +00:00
: OptionsDialog ( Common : : ConfigManager : : kApplicationDomain , " GlobalOptions " ) , CommandSender ( nullptr ) , _launcher ( launcher ) {
2016-10-30 18:36:22 +00:00
# ifdef USE_FLUIDSYNTH
2020-01-05 16:48:04 +00:00
_fluidSynthSettingsDialog = nullptr ;
2016-10-30 18:36:22 +00:00
# endif
2020-01-05 16:48:04 +00:00
_savePath = nullptr ;
_savePathClearButton = nullptr ;
_themePath = nullptr ;
_themePathClearButton = nullptr ;
2021-07-09 16:53:26 +00:00
_iconPath = nullptr ;
_iconPathClearButton = nullptr ;
2020-01-05 16:48:04 +00:00
_extraPath = nullptr ;
_extraPathClearButton = nullptr ;
2016-10-30 18:36:22 +00:00
# ifdef DYNAMIC_MODULES
2020-01-05 16:48:04 +00:00
_pluginsPath = nullptr ;
_pluginsPathClearButton = nullptr ;
2016-10-30 18:36:22 +00:00
# endif
2021-08-02 15:04:23 +00:00
_browserPath = nullptr ;
_browserPathClearButton = nullptr ;
2020-01-05 16:48:04 +00:00
_curTheme = nullptr ;
2021-04-17 17:35:08 +00:00
_guiBasePopUpDesc = nullptr ;
_guiBasePopUp = nullptr ;
2020-01-05 16:48:04 +00:00
_rendererPopUpDesc = nullptr ;
_rendererPopUp = nullptr ;
_autosavePeriodPopUpDesc = nullptr ;
_autosavePeriodPopUp = nullptr ;
_guiLanguagePopUpDesc = nullptr ;
_guiLanguagePopUp = nullptr ;
2018-09-27 05:12:11 +00:00
_guiLanguageUseGameLanguageCheckbox = nullptr ;
2020-01-05 16:48:04 +00:00
_useSystemDialogsCheckbox = nullptr ;
2020-11-26 22:02:41 +00:00
_guiReturnToLauncherAtExit = nullptr ;
2020-12-04 22:07:14 +00:00
_guiConfirmExit = nullptr ;
2016-10-30 18:36:22 +00:00
# ifdef USE_UPDATES
2020-01-05 16:48:04 +00:00
_updatesPopUpDesc = nullptr ;
_updatesPopUp = nullptr ;
2016-10-30 18:36:22 +00:00
# endif
# ifdef USE_CLOUD
# ifdef USE_LIBCURL
_selectedStorageIndex = CloudMan . getStorageIndex ( ) ;
2020-01-05 16:48:04 +00:00
_storagePopUpDesc = nullptr ;
_storagePopUp = nullptr ;
_storageDisabledHint = nullptr ;
_storageEnableButton = nullptr ;
_storageUsernameDesc = nullptr ;
_storageUsername = nullptr ;
_storageUsedSpaceDesc = nullptr ;
_storageUsedSpace = nullptr ;
_storageSyncHint = nullptr ;
_storageLastSyncDesc = nullptr ;
_storageLastSync = nullptr ;
_storageSyncSavesButton = nullptr ;
_storageDownloadHint = nullptr ;
_storageDownloadButton = nullptr ;
_storageDisconnectHint = nullptr ;
_storageDisconnectButton = nullptr ;
2019-07-18 16:10:49 +00:00
_connectingStorage = false ;
2020-01-05 16:48:04 +00:00
_storageWizardNotConnectedHint = nullptr ;
_storageWizardOpenLinkHint = nullptr ;
_storageWizardLink = nullptr ;
_storageWizardCodeHint = nullptr ;
_storageWizardCodeBox = nullptr ;
_storageWizardPasteButton = nullptr ;
_storageWizardConnectButton = nullptr ;
_storageWizardConnectionStatusHint = nullptr ;
2019-07-19 10:04:44 +00:00
_redrawCloudTab = false ;
# endif
# ifdef USE_SDL_NET
2020-01-05 16:48:04 +00:00
_runServerButton = nullptr ;
_serverInfoLabel = nullptr ;
_rootPathButton = nullptr ;
_rootPath = nullptr ;
_rootPathClearButton = nullptr ;
_serverPortDesc = nullptr ;
_serverPort = nullptr ;
_serverPortClearButton = nullptr ;
_featureDescriptionLine1 = nullptr ;
_featureDescriptionLine2 = nullptr ;
2016-10-30 18:36:22 +00:00
_serverWasRunning = false ;
# endif
# endif
2019-07-12 00:08:22 +00:00
# ifdef USE_TTS
_enableTTS = false ;
2020-01-05 16:48:04 +00:00
_ttsCheckbox = nullptr ;
_ttsVoiceSelectionPopUp = nullptr ;
2019-07-12 00:08:22 +00:00
# endif
2021-08-31 19:39:17 +00:00
# ifdef USE_DISCORD
_discordRpcCheckbox = nullptr ;
# endif
2016-10-30 18:36:22 +00:00
}
2007-06-10 14:23:26 +00:00
2016-10-30 18:36:22 +00:00
GlobalOptionsDialog : : ~ GlobalOptionsDialog ( ) {
# ifdef USE_FLUIDSYNTH
delete _fluidSynthSettingsDialog ;
# endif
}
2017-03-04 10:22:41 +00:00
2016-10-30 18:36:22 +00:00
void GlobalOptionsDialog : : build ( ) {
2003-11-05 12:25:42 +00:00
// The tab widget
2008-08-05 23:58:45 +00:00
TabWidget * tab = new TabWidget ( this , " GlobalOptions.TabWidget " ) ;
2017-03-04 10:22:41 +00:00
2017-02-26 17:17:41 +00:00
//
// 1) The graphics tab
//
2021-12-07 19:13:44 +00:00
_graphicsTabId = tab - > addTab ( g_system - > getOverlayWidth ( ) > 320 ? _ ( " Graphics " ) : _ ( " GFX " ) , " GlobalOptions_Graphics " , false ) ;
2019-12-28 09:43:58 +00:00
ScrollContainerWidget * graphicsContainer = new ScrollContainerWidget ( tab , " GlobalOptions_Graphics.Container " , " GlobalOptions_Graphics_Container " , kGraphicsTabContainerReflowCmd ) ;
2018-07-21 23:01:01 +00:00
graphicsContainer - > setTarget ( this ) ;
2019-12-28 09:43:58 +00:00
graphicsContainer - > setBackgroundType ( ThemeEngine : : kWidgetBackgroundNo ) ;
2018-07-21 23:01:01 +00:00
addGraphicControls ( graphicsContainer , " GlobalOptions_Graphics_Container. " ) ;
2017-02-26 17:17:41 +00:00
2017-01-30 20:35:40 +00:00
//
2022-02-05 20:10:20 +00:00
// The control tab (currently visible only for SDL and Vita platform, visibility checking by features
2017-01-30 20:35:40 +00:00
//
2017-02-14 13:13:58 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureTouchpadMode ) | |
2017-02-20 02:14:51 +00:00
g_system - > hasFeature ( OSystem : : kFeatureKbdMouseSpeed ) | |
g_system - > hasFeature ( OSystem : : kFeatureJoystickDeadzone ) ) {
2020-07-01 18:01:48 +00:00
tab - > addTab ( _ ( " Control " ) , " GlobalOptions_Control " ) ;
2017-02-14 13:13:58 +00:00
addControlControls ( tab , " GlobalOptions_Control. " ) ;
2017-02-20 02:14:51 +00:00
}
2003-11-05 12:25:42 +00:00
2020-01-23 09:50:52 +00:00
//
// The Keymap tab
//
Common : : KeymapArray keymaps ;
Common : : Keymap * primaryGlobalKeymap = g_system - > getEventManager ( ) - > getGlobalKeymap ( ) ;
if ( primaryGlobalKeymap & & ! primaryGlobalKeymap - > getActions ( ) . empty ( ) ) {
keymaps . push_back ( primaryGlobalKeymap ) ;
}
2020-01-24 09:58:17 +00:00
keymaps . push_back ( g_system - > getGlobalKeymaps ( ) ) ;
2020-01-23 09:50:52 +00:00
Common : : Keymap * guiKeymap = g_gui . getKeymap ( ) ;
if ( guiKeymap & & ! guiKeymap - > getActions ( ) . empty ( ) ) {
keymaps . push_back ( guiKeymap ) ;
}
if ( ! keymaps . empty ( ) ) {
2021-12-07 19:13:44 +00:00
tab - > addTab ( _ ( " Keymaps " ) , " GlobalOptions_KeyMapper " , false ) ;
2020-01-28 17:44:08 +00:00
addKeyMapperControls ( tab , " GlobalOptions_KeyMapper. " , keymaps , Common : : ConfigManager : : kKeymapperDomain ) ;
2020-01-23 09:50:52 +00:00
}
2020-05-11 11:05:56 +00:00
//
// The backend tab (shown only if the backend implements one)
//
2021-12-07 19:13:44 +00:00
int backendTabId = tab - > addTab ( _ ( " Backend " ) , " GlobalOptions_Backend " , false ) ;
2020-05-11 11:05:56 +00:00
g_system - > registerDefaultSettings ( _domain ) ;
_backendOptions = g_system - > buildBackendOptionsWidget ( tab , " GlobalOptions_Backend.Container " , _domain ) ;
if ( _backendOptions ) {
_backendOptions - > setParentDialog ( this ) ;
} else {
tab - > removeTab ( backendTabId ) ;
}
2003-11-05 12:25:42 +00:00
//
// 2) The audio tab
//
2020-07-01 18:01:48 +00:00
tab - > addTab ( _ ( " Audio " ) , " GlobalOptions_Audio " ) ;
2008-08-06 10:50:28 +00:00
addAudioControls ( tab , " GlobalOptions_Audio. " ) ;
2008-08-05 23:58:45 +00:00
addSubtitleControls ( tab , " GlobalOptions_Audio. " ) ;
2006-05-30 17:49:53 +00:00
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
tab - > addTab ( _ ( " Volume " ) , " GlobalOptions_Volume " ) ;
2010-08-30 22:24:40 +00:00
else
2020-07-01 18:01:48 +00:00
tab - > addTab ( _c ( " Volume " , " lowres " ) , " GlobalOptions_Volume " ) ;
2008-08-05 23:58:45 +00:00
addVolumeControls ( tab , " GlobalOptions_Volume. " ) ;
2006-05-30 17:35:57 +00:00
2003-11-05 01:22:19 +00:00
// TODO: cd drive setting
2005-07-30 21:11:48 +00:00
2005-04-13 00:11:49 +00:00
//
// 3) The MIDI tab
//
2020-07-01 18:01:48 +00:00
_midiTabId = tab - > addTab ( _ ( " MIDI " ) , " GlobalOptions_MIDI " ) ;
2008-08-05 23:58:45 +00:00
addMIDIControls ( tab , " GlobalOptions_MIDI. " ) ;
2002-12-12 23:22:48 +00:00
2002-12-14 01:49:08 +00:00
//
2010-07-24 22:29:17 +00:00
// 4) The MT-32 tab
//
2020-07-01 18:01:48 +00:00
tab - > addTab ( _ ( " MT-32 " ) , " GlobalOptions_MT32 " ) ;
2010-07-24 22:29:17 +00:00
addMT32Controls ( tab , " GlobalOptions_MT32. " ) ;
//
// 5) The Paths tab
2002-12-14 01:49:08 +00:00
//
2010-09-11 16:18:55 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
_pathsTabId = tab - > addTab ( _ ( " Paths " ) , " GlobalOptions_Paths " ) ;
2010-09-11 16:18:55 +00:00
else
2020-07-01 18:01:48 +00:00
_pathsTabId = tab - > addTab ( _c ( " Paths " , " lowres " ) , " GlobalOptions_Paths " ) ;
2020-01-20 23:18:14 +00:00
addPathsControls ( tab , " GlobalOptions_Paths. " , g_system - > getOverlayWidth ( ) < = 320 ) ;
2004-11-15 04:41:51 +00:00
2010-07-24 22:29:17 +00:00
//
// 6) The miscellaneous tab
//
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2021-12-07 19:13:44 +00:00
tab - > addTab ( _ ( " Misc " ) , " GlobalOptions_Misc " , false ) ;
2010-08-30 22:24:40 +00:00
else
2021-12-07 19:13:44 +00:00
tab - > addTab ( _c ( " Misc " , " lowres " ) , " GlobalOptions_Misc " , false ) ;
2020-01-21 14:51:37 +00:00
ScrollContainerWidget * miscContainer = new ScrollContainerWidget ( tab , " GlobalOptions_Misc.Container " , " GlobalOptions_Misc_Container " ) ;
miscContainer - > setTarget ( this ) ;
miscContainer - > setBackgroundType ( ThemeEngine : : kWidgetBackgroundNo ) ;
addMiscControls ( miscContainer , " GlobalOptions_Misc_Container. " , g_system - > getOverlayWidth ( ) < = 320 ) ;
2016-03-29 08:44:46 +00:00
2016-07-05 09:05:30 +00:00
# ifdef USE_CLOUD
2019-07-19 10:04:44 +00:00
# ifdef USE_LIBCURL
2016-06-08 12:56:17 +00:00
//
2019-07-19 10:04:44 +00:00
// 7) The Cloud tab (remote storages)
2016-06-08 12:56:17 +00:00
//
2019-07-30 20:42:09 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2021-12-07 19:13:44 +00:00
tab - > addTab ( _ ( " Cloud " ) , " GlobalOptions_Cloud " , false ) ;
2019-07-30 20:42:09 +00:00
else
2021-12-07 19:13:44 +00:00
tab - > addTab ( _c ( " Cloud " , " lowres " ) , " GlobalOptions_Cloud " , false ) ;
2016-06-08 12:56:17 +00:00
2019-12-28 09:43:58 +00:00
ScrollContainerWidget * container = new ScrollContainerWidget ( tab , " GlobalOptions_Cloud.Container " , " GlobalOptions_Cloud_Container " , kCloudTabContainerReflowCmd ) ;
2016-07-11 08:17:27 +00:00
container - > setTarget ( this ) ;
2019-12-28 09:43:58 +00:00
container - > setBackgroundType ( ThemeEngine : : kWidgetBackgroundNo ) ;
2019-07-19 11:01:09 +00:00
setTarget ( container ) ;
2016-07-11 07:57:46 +00:00
2019-07-30 20:42:09 +00:00
addCloudControls ( container , " GlobalOptions_Cloud_Container. " , g_system - > getOverlayWidth ( ) < = 320 ) ;
2019-07-23 16:46:25 +00:00
# endif // USE_LIBCURL
2016-07-25 07:13:47 +00:00
# ifdef USE_SDL_NET
2019-07-19 10:04:44 +00:00
//
2019-07-21 13:52:16 +00:00
// 8) The LAN tab (local "cloud" webserver)
2019-07-19 10:04:44 +00:00
//
2019-07-30 20:42:09 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
tab - > addTab ( _ ( " LAN " ) , " GlobalOptions_Network " ) ;
2019-07-30 20:42:09 +00:00
else
2020-07-01 18:01:48 +00:00
tab - > addTab ( _c ( " LAN " , " lowres " ) , " GlobalOptions_Network " ) ;
2019-07-30 20:42:09 +00:00
addNetworkControls ( tab , " GlobalOptions_Network. " , g_system - > getOverlayWidth ( ) < = 320 ) ;
2019-07-19 10:04:44 +00:00
# endif // USE_SDL_NET
2016-10-17 16:55:01 +00:00
# endif // USE_CLOUD
2016-06-08 12:56:17 +00:00
2019-07-12 00:08:22 +00:00
//Accessibility
# ifdef USE_TTS
if ( g_system - > getOverlayWidth ( ) > 320 )
2020-07-01 18:01:48 +00:00
tab - > addTab ( _ ( " Accessibility " ) , " GlobalOptions_Accessibility " ) ;
2019-07-12 00:08:22 +00:00
else
2020-07-01 18:01:48 +00:00
tab - > addTab ( _c ( " Accessibility " , " lowres " ) , " GlobalOptions_Accessibility " ) ;
2020-01-20 23:18:14 +00:00
addAccessibilityControls ( tab , " GlobalOptions_Accessibility. " ) ;
2019-07-12 00:08:22 +00:00
# endif // USE_TTS
2020-05-18 18:16:20 +00:00
// Activate the first tab
tab - > setActiveTab ( 0 ) ;
2008-08-14 23:17:41 +00:00
_tabWidget = tab ;
2002-12-14 01:49:08 +00:00
2002-12-12 23:22:48 +00:00
// Add OK & Cancel buttons
2021-04-19 22:09:12 +00:00
new ButtonWidget ( this , " GlobalOptions.Cancel " , _ ( " Cancel " ) , _ ( " Discard changes and close the dialog " ) , kCloseCmd ) ;
new ButtonWidget ( this , " GlobalOptions.Apply " , _ ( " Apply " ) , _ ( " Apply changes without closing the dialog " ) , kApplyCmd ) ;
new ButtonWidget ( this , " GlobalOptions.Ok " , _ ( " OK " ) , _ ( " Apply changes and close the dialog " ) , kOKCmd ) ;
2003-03-25 15:32:36 +00:00
2012-12-27 14:08:54 +00:00
# ifdef USE_FLUIDSYNTH
_fluidSynthSettingsDialog = new FluidSynthSettingsDialog ( ) ;
# endif
2016-10-30 18:36:22 +00:00
OptionsDialog : : build ( ) ;
2003-11-01 22:21:18 +00:00
2018-11-03 19:00:24 +00:00
# if !defined(__DC__)
2022-09-30 13:39:25 +00:00
const auto setPath =
2022-05-24 21:45:45 +00:00
[ & ] ( GUI : : StaticTextWidget * const widget , const Common : : String & pathType , const Common : : U32String & defaultLabel ) {
2022-09-30 13:39:25 +00:00
Common : : String path ( ConfMan . get ( pathType ) ) ;
2022-05-02 12:10:22 +00:00
if ( ConfMan . isKeyTemporary ( pathType ) ) {
widget - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
}
if ( path . empty ( ) | | ! ConfMan . hasKey ( pathType , _domain ) ) {
widget - > setLabel ( defaultLabel ) ;
} else {
widget - > setLabel ( path ) ;
}
} ;
2006-06-11 20:40:22 +00:00
2022-09-30 13:39:25 +00:00
setPath ( _savePath , " savepath " , _ ( " Default " ) ) ;
2022-05-02 12:10:22 +00:00
setPath ( _themePath , " themepath " , _c ( " None " , " path " ) ) ;
2022-06-20 05:47:38 +00:00
setPath ( _iconPath , " iconspath " , _ ( " Default " ) ) ;
2022-05-02 12:10:22 +00:00
setPath ( _extraPath , " extrapath " , _c ( " None " , " path " ) ) ;
2008-05-09 01:58:12 +00:00
# ifdef DYNAMIC_MODULES
Common : : String pluginsPath ( ConfMan . get ( " pluginspath " , _domain ) ) ;
if ( pluginsPath . empty ( ) | | ! ConfMan . hasKey ( " pluginspath " , _domain ) ) {
2010-08-23 19:45:14 +00:00
_pluginsPath - > setLabel ( _c ( " None " , " path " ) ) ;
2008-05-09 01:58:12 +00:00
} else {
_pluginsPath - > setLabel ( pluginsPath ) ;
}
# endif
2003-11-05 12:25:42 +00:00
# endif
2007-02-13 21:06:45 +00:00
// Misc Tab
2021-08-10 22:37:32 +00:00
_guiBasePopUp - > setSelected ( 2 ) ;
int value = ConfMan . getInt ( " gui_scale " ) ;
2021-04-17 17:35:08 +00:00
for ( int i = 0 ; guiBaseLabels [ i ] ; i + + ) {
if ( value = = guiBaseValues [ i ] )
_guiBasePopUp - > setSelected ( i ) ;
}
2007-02-13 21:06:45 +00:00
_autosavePeriodPopUp - > setSelected ( 1 ) ;
2021-04-17 17:35:08 +00:00
value = ConfMan . getInt ( " autosave_period " ) ;
2007-02-13 21:06:45 +00:00
for ( int i = 0 ; savePeriodLabels [ i ] ; i + + ) {
if ( value = = savePeriodValues [ i ] )
_autosavePeriodPopUp - > setSelected ( i ) ;
}
2008-12-22 11:22:15 +00:00
2008-10-29 20:45:28 +00:00
ThemeEngine : : GraphicsMode mode = ThemeEngine : : findMode ( ConfMan . get ( " gui_renderer " ) ) ;
if ( mode = = ThemeEngine : : kGfxDisabled )
mode = ThemeEngine : : _defaultRendererMode ;
_rendererPopUp - > setSelectedTag ( mode ) ;
2016-08-01 09:49:42 +00:00
# ifdef USE_CLOUD
2019-07-19 10:04:44 +00:00
# ifdef USE_SDL_NET
2016-08-01 09:49:42 +00:00
Common : : String rootPath ( ConfMan . get ( " rootpath " , " cloud " ) ) ;
if ( rootPath . empty ( ) | | ! ConfMan . hasKey ( " rootpath " , " cloud " ) ) {
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
_rootPath - > setLabel ( _c ( " None " , " path " ) ) ;
2016-08-01 09:49:42 +00:00
} else {
_rootPath - > setLabel ( rootPath ) ;
}
# endif
2019-07-19 10:04:44 +00:00
# endif
2003-11-05 12:25:42 +00:00
}
2016-10-30 18:36:22 +00:00
void GlobalOptionsDialog : : clean ( ) {
# ifdef USE_FLUIDSYNTH
delete _fluidSynthSettingsDialog ;
2020-01-05 16:48:04 +00:00
_fluidSynthSettingsDialog = nullptr ;
2016-10-30 18:36:22 +00:00
# endif
OptionsDialog : : clean ( ) ;
}
2017-03-04 10:22:41 +00:00
2020-01-20 23:18:14 +00:00
void GlobalOptionsDialog : : addMIDIControls ( GuiObject * boss , const Common : : String & prefix ) {
OptionsDialog : : addMIDIControls ( boss , prefix ) ;
# ifdef USE_FLUIDSYNTH
2020-11-15 18:15:58 +00:00
new ButtonWidget ( boss , prefix + " mcFluidSynthSettings " , _ ( " FluidSynth Settings " ) , Common : : U32String ( ) , kFluidSynthSettingsCmd ) ;
2020-01-20 23:18:14 +00:00
# endif
}
void GlobalOptionsDialog : : addPathsControls ( GuiObject * boss , const Common : : String & prefix , bool lowres ) {
# if !defined(__DC__)
// These two buttons have to be extra wide, or the text will be
// truncated in the small version of the GUI.
// Save game path
if ( ! lowres )
2020-07-01 18:01:48 +00:00
new ButtonWidget ( boss , prefix + " SaveButton " , _ ( " Save Path: " ) , _ ( " Specifies where your saved games are put " ) , kChooseSaveDirCmd ) ;
2020-01-20 23:18:14 +00:00
else
2020-07-01 18:01:48 +00:00
new ButtonWidget ( boss , prefix + " SaveButton " , _c ( " Save Path: " , " lowres " ) , _ ( " Specifies where your saved games are put " ) , kChooseSaveDirCmd ) ;
2022-04-01 12:51:55 +00:00
_savePath = new StaticTextWidget ( boss , prefix + " SavePath " , Common : : U32String ( " /foo/bar " ) , _ ( " Specifies where your saved games are put. A red coloring indicates the value is temporary and will not get saved " ) ) ;
2020-01-20 23:18:14 +00:00
_savePathClearButton = addClearButton ( boss , prefix + " SavePathClearButton " , kSavePathClearCmd ) ;
if ( ! lowres )
2020-11-15 18:15:58 +00:00
new ButtonWidget ( boss , prefix + " ThemeButton " , _ ( " Theme Path: " ) , Common : : U32String ( ) , kChooseThemeDirCmd ) ;
2020-01-20 23:18:14 +00:00
else
2020-11-15 18:15:58 +00:00
new ButtonWidget ( boss , prefix + " ThemeButton " , _c ( " Theme Path: " , " lowres " ) , Common : : U32String ( ) , kChooseThemeDirCmd ) ;
2020-07-01 18:01:48 +00:00
_themePath = new StaticTextWidget ( boss , prefix + " ThemePath " , _c ( " None " , " path " ) ) ;
2020-01-20 23:18:14 +00:00
_themePathClearButton = addClearButton ( boss , prefix + " ThemePathClearButton " , kThemePathClearCmd ) ;
2021-07-09 16:53:26 +00:00
if ( ! lowres )
new ButtonWidget ( boss , prefix + " IconButton " , _ ( " Icon Path: " ) , Common : : U32String ( ) , kChooseIconDirCmd ) ;
else
new ButtonWidget ( boss , prefix + " IconButton " , _c ( " Icon Path: " , " lowres " ) , Common : : U32String ( ) , kChooseIconDirCmd ) ;
2022-06-20 05:47:38 +00:00
_iconPath = new StaticTextWidget ( boss , prefix + " IconPath " , _c ( " Default " , " path " ) ) ;
2021-07-09 16:53:26 +00:00
_iconPathClearButton = addClearButton ( boss , prefix + " IconPathClearButton " , kIconPathClearCmd ) ;
2020-01-20 23:18:14 +00:00
if ( ! lowres )
2020-07-01 18:01:48 +00:00
new ButtonWidget ( boss , prefix + " ExtraButton " , _ ( " Extra Path: " ) , _ ( " Specifies path to additional data used by all games or ScummVM " ) , kChooseExtraDirCmd ) ;
2020-01-20 23:18:14 +00:00
else
2020-07-01 18:01:48 +00:00
new ButtonWidget ( boss , prefix + " ExtraButton " , _c ( " Extra Path: " , " lowres " ) , _ ( " Specifies path to additional data used by all games or ScummVM " ) , kChooseExtraDirCmd ) ;
_extraPath = new StaticTextWidget ( boss , prefix + " ExtraPath " , _c ( " None " , " path " ) , _ ( " Specifies path to additional data used by all games or ScummVM " ) ) ;
2020-01-20 23:18:14 +00:00
_extraPathClearButton = addClearButton ( boss , prefix + " ExtraPathClearButton " , kExtraPathClearCmd ) ;
# ifdef DYNAMIC_MODULES
if ( ! lowres )
2020-11-15 18:15:58 +00:00
new ButtonWidget ( boss , prefix + " PluginsButton " , _ ( " Plugins Path: " ) , Common : : U32String ( ) , kChoosePluginsDirCmd ) ;
2020-01-20 23:18:14 +00:00
else
2020-11-15 18:15:58 +00:00
new ButtonWidget ( boss , prefix + " PluginsButton " , _c ( " Plugins Path: " , " lowres " ) , Common : : U32String ( ) , kChoosePluginsDirCmd ) ;
2020-01-20 23:18:14 +00:00
_pluginsPath = new StaticTextWidget ( boss , prefix + " PluginsPath " , _c ( " None " , " path " ) ) ;
2020-01-22 07:19:38 +00:00
_pluginsPathClearButton = addClearButton ( boss , " GlobalOptions_Paths.PluginsPathClearButton " , kPluginsPathClearCmd ) ;
2020-08-20 04:12:56 +00:00
# endif // DYNAMIC_MODULES
# endif // !defined(__DC__)
2021-04-01 16:18:41 +00:00
2021-04-01 19:17:43 +00:00
Common : : U32String confPath = ConfMan . getCustomConfigFileName ( ) ;
if ( confPath . empty ( ) )
confPath = g_system - > getDefaultConfigFileName ( ) ;
2022-05-24 21:45:45 +00:00
StaticTextWidget * configPathWidget = new StaticTextWidget ( boss , prefix + " ConfigPath " , _ ( " ScummVM config path: " ) + confPath , confPath ) ;
if ( ConfMan . isKeyTemporary ( " config " ) )
2022-09-30 13:39:25 +00:00
configPathWidget - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2021-08-02 15:04:23 +00:00
Common : : U32String browserPath = _ ( " <default> " ) ;
if ( ConfMan . hasKey ( " browser_lastpath " ) )
browserPath = ConfMan . get ( " browser_lastpath " ) ;
// I18N: Referring to the last path memorized when adding a game
_browserPath = new StaticTextWidget ( boss , prefix + " BrowserPath " , _ ( " Last browser path: " ) + browserPath , browserPath ) ;
_browserPathClearButton = addClearButton ( boss , prefix + " BrowserPathClearButton " , kBrowserPathClearCmd ) ;
2020-01-20 23:18:14 +00:00
}
void GlobalOptionsDialog : : addMiscControls ( GuiObject * boss , const Common : : String & prefix , bool lowres ) {
2020-11-15 18:15:58 +00:00
new ButtonWidget ( boss , prefix + " ThemeButton " , _ ( " Theme: " ) , Common : : U32String ( ) , kChooseThemeCmd ) ;
2020-01-20 23:18:14 +00:00
_curTheme = new StaticTextWidget ( boss , prefix + " CurTheme " , g_gui . theme ( ) - > getThemeName ( ) ) ;
2022-05-05 17:32:21 +00:00
if ( ConfMan . isKeyTemporary ( " gui_theme " ) )
2022-09-30 13:39:25 +00:00
_curTheme - > setFontColor ( ThemeEngine : : FontColor : : kFontColorOverride ) ;
2020-01-20 23:18:14 +00:00
2021-04-17 17:35:08 +00:00
_guiBasePopUpDesc = new StaticTextWidget ( boss , prefix + " GUIBasePopupDesc " , _ ( " GUI scale: " ) ) ;
_guiBasePopUp = new PopUpWidget ( boss , prefix + " GUIBasePopup " ) ;
for ( int i = 0 ; guiBaseLabels [ i ] ; i + + ) {
_guiBasePopUp - > appendEntry ( _ ( guiBaseLabels [ i ] ) , guiBaseValues [ i ] ) ;
}
2020-07-01 18:01:48 +00:00
_rendererPopUpDesc = new StaticTextWidget ( boss , prefix + " RendererPopupDesc " , _ ( " GUI renderer: " ) ) ;
2020-01-20 23:18:14 +00:00
_rendererPopUp = new PopUpWidget ( boss , prefix + " RendererPopup " ) ;
if ( ! lowres ) {
for ( uint i = 1 ; i < GUI : : ThemeEngine : : _rendererModesSize ; + + i )
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
_rendererPopUp - > appendEntry ( _ ( GUI : : ThemeEngine : : _rendererModes [ i ] . name ) , GUI : : ThemeEngine : : _rendererModes [ i ] . mode ) ;
2020-01-20 23:18:14 +00:00
} else {
for ( uint i = 1 ; i < GUI : : ThemeEngine : : _rendererModesSize ; + + i )
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
_rendererPopUp - > appendEntry ( _ ( GUI : : ThemeEngine : : _rendererModes [ i ] . shortname ) , GUI : : ThemeEngine : : _rendererModes [ i ] . mode ) ;
2020-01-20 23:18:14 +00:00
}
if ( ! lowres )
2020-07-01 18:01:48 +00:00
_autosavePeriodPopUpDesc = new StaticTextWidget ( boss , prefix + " AutosavePeriodPopupDesc " , _ ( " Autosave: " ) ) ;
2020-01-20 23:18:14 +00:00
else
2020-07-01 18:01:48 +00:00
_autosavePeriodPopUpDesc = new StaticTextWidget ( boss , prefix + " AutosavePeriodPopupDesc " , _c ( " Autosave: " , " lowres " ) ) ;
2020-01-20 23:18:14 +00:00
_autosavePeriodPopUp = new PopUpWidget ( boss , prefix + " AutosavePeriodPopup " ) ;
for ( int i = 0 ; savePeriodLabels [ i ] ; i + + ) {
2020-07-01 18:01:48 +00:00
_autosavePeriodPopUp - > appendEntry ( _ ( savePeriodLabels [ i ] ) , savePeriodValues [ i ] ) ;
2020-01-20 23:18:14 +00:00
}
2020-11-26 22:02:41 +00:00
if ( ! g_system - > hasFeature ( OSystem : : kFeatureNoQuit ) ) {
_guiReturnToLauncherAtExit = new CheckboxWidget ( boss , prefix + " ReturnToLauncherAtExit " ,
_ ( " Always return to the launcher when leaving a game " ) ,
_ ( " Always return to the launcher when leaving a game instead of closing ScummVM. " )
) ;
_guiReturnToLauncherAtExit - > setState ( ConfMan . getBool ( " gui_return_to_launcher_at_exit " , _domain ) ) ;
}
_guiConfirmExit = new CheckboxWidget ( boss , prefix + " ConfirmExit " ,
_ ( " Ask for confirmation on exit " ) ,
_ ( " Ask for permission when closing ScummVM or leaving a game. " )
) ;
_guiConfirmExit - > setState ( ConfMan . getBool ( " confirm_exit " , _domain ) ) ;
2021-08-31 19:39:17 +00:00
# ifdef USE_DISCORD
_discordRpcCheckbox = new CheckboxWidget ( boss , prefix + " DiscordRpc " ,
_ ( " Enable Discord integration " ) ,
_ ( " Show information about the games you are playing on Discord if the Discord client is running. " )
) ;
_discordRpcCheckbox - > setState ( ConfMan . getBool ( " discord_rpc " , _domain ) ) ;
# endif
2020-01-20 23:18:14 +00:00
// TODO: joystick setting
# ifdef USE_TRANSLATION
2020-07-01 18:01:48 +00:00
_guiLanguagePopUpDesc = new StaticTextWidget ( boss , prefix + " GuiLanguagePopupDesc " , _ ( " GUI language: " ) , _ ( " Language of ScummVM GUI " ) ) ;
2020-01-20 23:18:14 +00:00
_guiLanguagePopUp = new PopUpWidget ( boss , prefix + " GuiLanguagePopup " ) ;
# ifdef USE_DETECTLANG
2020-07-01 18:01:48 +00:00
_guiLanguagePopUp - > appendEntry ( _ ( " <default> " ) , Common : : kTranslationAutodetectId ) ;
2020-01-20 23:18:14 +00:00
# endif // USE_DETECTLANG
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
_guiLanguagePopUp - > appendEntry ( " English " , Common : : kTranslationBuiltinId ) ;
_guiLanguagePopUp - > appendEntry ( " " , 0 ) ;
2020-01-20 23:18:14 +00:00
Common : : TLangArray languages = TransMan . getSupportedLanguageNames ( ) ;
Common : : TLangArray : : iterator lang = languages . begin ( ) ;
while ( lang ! = languages . end ( ) ) {
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
_guiLanguagePopUp - > appendEntry ( lang - > name , lang - > id ) ;
2020-01-20 23:18:14 +00:00
lang + + ;
}
// Select the currently configured language or default/English if
// nothing is specified.
if ( ConfMan . hasKey ( " gui_language " ) & & ! ConfMan . get ( " gui_language " ) . empty ( ) )
_guiLanguagePopUp - > setSelectedTag ( TransMan . parseLanguage ( ConfMan . get ( " gui_language " ) ) ) ;
else
# ifdef USE_DETECTLANG
_guiLanguagePopUp - > setSelectedTag ( Common : : kTranslationAutodetectId ) ;
# else // !USE_DETECTLANG
_guiLanguagePopUp - > setSelectedTag ( Common : : kTranslationBuiltinId ) ;
# endif // USE_DETECTLANG
_guiLanguageUseGameLanguageCheckbox = new CheckboxWidget ( boss , prefix + " GuiLanguageUseGameLanguage " ,
2020-08-25 21:10:48 +00:00
_ ( " Switch the ScummVM GUI language to the game language " ) ,
_ ( " When starting a game, change the ScummVM GUI language to the game language. "
2020-01-20 23:18:14 +00:00
" That way, if a game uses the ScummVM save and load dialogs, they are "
" in the same language as the game. " )
) ;
if ( ConfMan . hasKey ( " gui_use_game_language " ) ) {
_guiLanguageUseGameLanguageCheckbox - > setState ( ConfMan . getBool ( " gui_use_game_language " , _domain ) ) ;
}
# endif // USE_TRANSLATION
if ( g_system - > hasFeature ( OSystem : : kFeatureSystemBrowserDialog ) ) {
_useSystemDialogsCheckbox = new CheckboxWidget ( boss , prefix + " UseSystemDialogs " ,
2020-07-01 18:01:48 +00:00
_ ( " Use native system file browser " ) ,
2020-01-20 23:18:14 +00:00
_ ( " Use the native system file browser instead of the ScummVM one to select a file or directory. " )
) ;
_useSystemDialogsCheckbox - > setState ( ConfMan . getBool ( " gui_browser_native " , _domain ) ) ;
}
# ifdef USE_UPDATES
2021-11-13 19:50:57 +00:00
if ( g_system - > getUpdateManager ( ) ) {
_updatesPopUpDesc = new StaticTextWidget ( boss , prefix + " UpdatesPopupDesc " , _ ( " Update check: " ) , _ ( " How often to check ScummVM updates " ) ) ;
_updatesPopUp = new PopUpWidget ( boss , prefix + " UpdatesPopup " ) ;
2020-01-20 23:18:14 +00:00
2021-11-13 19:50:57 +00:00
const int * vals = Common : : UpdateManager : : getUpdateIntervals ( ) ;
while ( * vals ! = - 1 ) {
_updatesPopUp - > appendEntry ( Common : : UpdateManager : : updateIntervalToString ( * vals ) , * vals ) ;
vals + + ;
}
2020-01-20 23:18:14 +00:00
2021-11-13 19:50:57 +00:00
_updatesPopUp - > setSelectedTag ( Common : : UpdateManager : : normalizeInterval ( ConfMan . getInt ( " updates_check " ) ) ) ;
2020-01-20 23:18:14 +00:00
2021-11-13 19:50:57 +00:00
new ButtonWidget ( boss , prefix + " UpdatesCheckManuallyButton " , _ ( " Check now " ) , Common : : U32String ( ) , kUpdatesCheckCmd ) ;
}
2020-08-20 04:12:56 +00:00
# endif // USE_UPDATES
2021-11-16 22:36:21 +00:00
# ifdef USE_CLOUD
# ifdef USE_LIBCURL
new ButtonWidget ( boss , prefix + " UpdateIconsButton " , _ ( " Update Icons " ) , Common : : U32String ( ) , kUpdateIconsCmd ) ;
# endif
# endif
2020-01-20 23:18:14 +00:00
}
2019-07-19 10:04:44 +00:00
# ifdef USE_CLOUD
# ifdef USE_LIBCURL
2019-07-30 20:42:09 +00:00
void GlobalOptionsDialog : : addCloudControls ( GuiObject * boss , const Common : : String & prefix , bool lowres ) {
2020-07-01 18:01:48 +00:00
_storagePopUpDesc = new StaticTextWidget ( boss , prefix + " StoragePopupDesc " , _ ( " Active storage: " ) , _ ( " Active cloud storage " ) ) ;
2021-01-06 22:13:14 +00:00
_storagePopUp = new PopUpWidget ( boss , prefix + " StoragePopup " , Common : : U32String ( ) , kStoragePopUpCmd ) ;
2019-07-19 10:04:44 +00:00
Common : : StringArray list = CloudMan . listStorages ( ) ;
2020-02-09 19:55:36 +00:00
for ( uint32 i = 0 ; i < list . size ( ) ; + + i ) {
_storagePopUp - > appendEntry ( _ ( list [ i ] ) , i ) ;
}
2019-07-19 10:04:44 +00:00
_storagePopUp - > setSelected ( _selectedStorageIndex ) ;
2019-07-18 16:10:49 +00:00
2019-07-30 20:42:09 +00:00
if ( lowres )
2020-07-01 18:01:48 +00:00
_storageDisabledHint = new StaticTextWidget ( boss , prefix + " StorageDisabledHint " , _c ( " 4. Storage is not yet enabled. Verify that username is correct and enable it: " , " lowres " ) ) ;
2019-07-30 20:42:09 +00:00
else
2020-07-01 18:01:48 +00:00
_storageDisabledHint = new StaticTextWidget ( boss , prefix + " StorageDisabledHint " , _ ( " 4. Storage is not yet enabled. Verify that username is correct and enable it: " ) ) ;
_storageEnableButton = new ButtonWidget ( boss , prefix + " StorageEnableButton " , _ ( " Enable storage " ) , _ ( " Confirm you want to use this account for this storage " ) , kEnableStorageCmd ) ;
2019-07-27 15:44:15 +00:00
2020-07-01 18:01:48 +00:00
_storageUsernameDesc = new StaticTextWidget ( boss , prefix + " StorageUsernameDesc " , _ ( " Username: " ) , _ ( " Username used by this storage " ) ) ;
2020-11-15 18:15:58 +00:00
_storageUsername = new StaticTextWidget ( boss , prefix + " StorageUsernameLabel " , _ ( " <none> " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
2019-07-19 10:04:44 +00:00
2020-07-01 18:01:48 +00:00
_storageUsedSpaceDesc = new StaticTextWidget ( boss , prefix + " StorageUsedSpaceDesc " , _ ( " Used space: " ) , _ ( " Space used by ScummVM's saved games on this storage " ) ) ;
2020-11-15 18:15:58 +00:00
_storageUsedSpace = new StaticTextWidget ( boss , prefix + " StorageUsedSpaceLabel " , Common : : U32String ( " 0 bytes " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
2019-07-19 10:04:44 +00:00
2020-07-01 18:01:48 +00:00
_storageLastSyncDesc = new StaticTextWidget ( boss , prefix + " StorageLastSyncDesc " , _ ( " Last sync: " ) , _ ( " When was the last time saved games were synced with this storage " ) ) ;
2020-11-15 18:15:58 +00:00
_storageLastSync = new StaticTextWidget ( boss , prefix + " StorageLastSyncLabel " , _ ( " <never> " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
2019-07-30 20:42:09 +00:00
if ( lowres )
2020-11-15 18:15:58 +00:00
_storageSyncHint = new StaticTextWidget ( boss , prefix + " StorageSyncHint " , _c ( " Saved games sync automatically on launch, after saving and on loading. " , " lowres " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
2019-07-30 20:42:09 +00:00
else
2020-11-15 18:15:58 +00:00
_storageSyncHint = new StaticTextWidget ( boss , prefix + " StorageSyncHint " , _ ( " Saved games sync automatically on launch, after saving and on loading. " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
2020-07-01 18:01:48 +00:00
_storageSyncSavesButton = new ButtonWidget ( boss , prefix + " SyncSavesButton " , _ ( " Sync now " ) , _ ( " Start saved games sync " ) , kSyncSavesStorageCmd ) ;
2019-07-19 10:04:44 +00:00
2019-07-30 20:42:09 +00:00
if ( lowres )
2020-07-01 18:01:48 +00:00
_storageDownloadHint = new StaticTextWidget ( boss , prefix + " StorageDownloadHint " , _c ( " You can download game files from your cloud ScummVM folder: " , " lowres " ) ) ;
2019-07-30 20:42:09 +00:00
else
2020-07-01 18:01:48 +00:00
_storageDownloadHint = new StaticTextWidget ( boss , prefix + " StorageDownloadHint " , _ ( " You can download game files from your cloud ScummVM folder: " ) ) ;
_storageDownloadButton = new ButtonWidget ( boss , prefix + " DownloadButton " , _ ( " Download game files " ) , _ ( " Open downloads manager dialog " ) , kDownloadStorageCmd ) ;
2019-07-19 10:04:44 +00:00
2019-07-30 20:42:09 +00:00
if ( lowres )
2020-07-01 18:01:48 +00:00
_storageDisconnectHint = new StaticTextWidget ( boss , prefix + " StorageDisconnectHint " , _c ( " To change account for this storage, disconnect and connect again: " , " lowres " ) ) ;
2019-07-30 20:42:09 +00:00
else
2020-07-01 18:01:48 +00:00
_storageDisconnectHint = new StaticTextWidget ( boss , prefix + " StorageDisconnectHint " , _ ( " To change account for this storage, disconnect and connect again: " ) ) ;
_storageDisconnectButton = new ButtonWidget ( boss , prefix + " DisconnectButton " , _ ( " Disconnect " ) , _ ( " Stop using this storage on this device " ) , kDisconnectStorageCmd ) ;
2019-07-19 10:04:44 +00:00
2019-07-30 20:42:09 +00:00
if ( lowres )
2020-07-01 18:01:48 +00:00
_storageWizardNotConnectedHint = new StaticTextWidget ( boss , prefix + " StorageWizardNotConnectedHint " , _c ( " This storage is not connected yet! To connect, " , " lowres " ) ) ;
2019-07-30 20:42:09 +00:00
else
2020-07-01 18:01:48 +00:00
_storageWizardNotConnectedHint = new StaticTextWidget ( boss , prefix + " StorageWizardNotConnectedHint " , _ ( " This storage is not connected yet! To connect, " ) ) ;
_storageWizardOpenLinkHint = new StaticTextWidget ( boss , prefix + " StorageWizardOpenLinkHint " , _ ( " 1. Open this link: " ) ) ;
2020-06-13 17:36:08 +00:00
_storageWizardLink = new ButtonWidget ( boss , prefix + " StorageWizardLink " , Common : : U32String ( " https://cloud.scummvm.org/ " ) , _ ( " Open URL " ) , kOpenUrlStorageCmd ) ;
2019-07-30 20:42:09 +00:00
if ( lowres )
2020-07-01 18:01:48 +00:00
_storageWizardCodeHint = new StaticTextWidget ( boss , prefix + " StorageWizardCodeHint " , _c ( " 2. Get the code and enter it here: " , " lowres " ) ) ;
2019-07-30 20:42:09 +00:00
else
2020-07-01 18:01:48 +00:00
_storageWizardCodeHint = new StaticTextWidget ( boss , prefix + " StorageWizardCodeHint " , _ ( " 2. Get the code and enter it here: " ) ) ;
2020-11-15 18:15:58 +00:00
_storageWizardCodeBox = new EditTextWidget ( boss , prefix + " StorageWizardCodeBox " , Common : : U32String ( ) , Common : : U32String ( ) , 0 , 0 , ThemeEngine : : kFontStyleConsole ) ;
2020-07-01 18:01:48 +00:00
_storageWizardPasteButton = new ButtonWidget ( boss , prefix + " StorageWizardPasteButton " , _ ( " Paste " ) , _ ( " Paste code from clipboard " ) , kPasteCodeStorageCmd ) ;
_storageWizardConnectButton = new ButtonWidget ( boss , prefix + " StorageWizardConnectButton " , _ ( " 3. Connect " ) , _ ( " Connect your cloud storage account " ) , kConnectStorageCmd ) ;
2020-06-13 17:36:08 +00:00
_storageWizardConnectionStatusHint = new StaticTextWidget ( boss , prefix + " StorageWizardConnectionStatusHint " , Common : : U32String ( " ... " ) ) ;
2019-07-19 10:04:44 +00:00
setupCloudTab ( ) ;
}
# endif // USE_LIBCURL
# ifdef USE_SDL_NET
2019-07-30 20:42:09 +00:00
void GlobalOptionsDialog : : addNetworkControls ( GuiObject * boss , const Common : : String & prefix , bool lowres ) {
2020-07-01 18:01:48 +00:00
_runServerButton = new ButtonWidget ( boss , prefix + " RunServerButton " , _ ( " Run server " ) , _ ( " Run local webserver " ) , kRunServerCmd ) ;
_serverInfoLabel = new StaticTextWidget ( boss , prefix + " ServerInfoLabel " , _ ( " Not running " ) ) ;
2019-07-19 10:04:44 +00:00
// Root path
2019-07-30 20:42:09 +00:00
if ( lowres )
2020-07-01 18:01:48 +00:00
_rootPathButton = new ButtonWidget ( boss , prefix + " RootPathButton " , _c ( " /root/ Path: " , " lowres " ) , _ ( " Select which directory will be shown as /root/ in the Files Manager " ) , kChooseRootDirCmd ) ;
2019-07-30 20:42:09 +00:00
else
2020-07-01 18:01:48 +00:00
_rootPathButton = new ButtonWidget ( boss , prefix + " RootPathButton " , _ ( " /root/ Path: " ) , _ ( " Select which directory will be shown as /root/ in the Files Manager " ) , kChooseRootDirCmd ) ;
2020-06-13 17:36:08 +00:00
_rootPath = new StaticTextWidget ( boss , prefix + " RootPath " , Common : : U32String ( " /foo/bar " ) , _ ( " Select which directory will be shown as /root/ in the Files Manager " ) ) ;
2019-07-19 10:04:44 +00:00
_rootPathClearButton = addClearButton ( boss , prefix + " RootPathClearButton " , kRootPathClearCmd ) ;
uint32 port = Networking : : LocalWebserver : : getPort ( ) ;
2020-07-01 18:01:48 +00:00
_serverPortDesc = new StaticTextWidget ( boss , prefix + " ServerPortDesc " , _ ( " Server's port: " ) , _ ( " Port for server to use " ) ) ;
2020-11-15 18:15:58 +00:00
_serverPort = new EditTextWidget ( boss , prefix + " ServerPortEditText " , Common : : String : : format ( " %u " , port ) , Common : : U32String ( ) ) ;
2019-07-19 10:04:44 +00:00
_serverPortClearButton = addClearButton ( boss , prefix + " ServerPortClearButton " , kServerPortClearCmd ) ;
2019-07-19 13:06:01 +00:00
2019-07-30 20:42:09 +00:00
if ( lowres ) {
2020-11-15 18:15:58 +00:00
_featureDescriptionLine1 = new StaticTextWidget ( boss , prefix + " FeatureDescriptionLine1 " , _c ( " Run server to manage files with browser (in the same network). " , " lowres " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
_featureDescriptionLine2 = new StaticTextWidget ( boss , prefix + " FeatureDescriptionLine2 " , _c ( " Closing options dialog will stop the server. " , " lowres " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
2019-07-30 20:42:09 +00:00
} else {
2020-11-15 18:15:58 +00:00
_featureDescriptionLine1 = new StaticTextWidget ( boss , prefix + " FeatureDescriptionLine1 " , _ ( " Run server to manage files with browser (in the same network). " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
_featureDescriptionLine2 = new StaticTextWidget ( boss , prefix + " FeatureDescriptionLine2 " , _ ( " Closing options dialog will stop the server. " ) , Common : : U32String ( ) , ThemeEngine : : kFontStyleNormal ) ;
2019-07-30 20:42:09 +00:00
}
2019-10-14 19:11:40 +00:00
2019-07-21 13:52:16 +00:00
reflowNetworkTabLayout ( ) ;
2019-07-19 10:04:44 +00:00
2019-07-18 16:10:49 +00:00
}
2019-07-19 10:04:44 +00:00
# endif // USE_SDL_NET
# endif // USE_CLOUD
2019-07-18 16:10:49 +00:00
2020-01-20 23:18:14 +00:00
# ifdef USE_TTS
void GlobalOptionsDialog : : addAccessibilityControls ( GuiObject * boss , const Common : : String & prefix ) {
_ttsCheckbox = new CheckboxWidget ( boss , prefix + " TTSCheckbox " ,
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
_ ( " Use Text to speech " ) , _ ( " Will read text in gui on mouse over. " ) ) ;
2020-01-20 23:18:14 +00:00
if ( ConfMan . hasKey ( " tts_enabled " ) )
_ttsCheckbox - > setState ( ConfMan . getBool ( " tts_enabled " , _domain ) ) ;
else
_ttsCheckbox - > setState ( false ) ;
_ttsVoiceSelectionPopUp = new PopUpWidget ( boss , prefix + " TTSVoiceSelection " ) ;
Common : : TextToSpeechManager * ttsMan = g_system - > getTextToSpeechManager ( ) ;
Common : : Array < Common : : TTSVoice > voices ;
if ( ttsMan ! = nullptr )
voices = ttsMan - > getVoicesArray ( ) ;
if ( voices . empty ( ) )
2020-06-13 16:42:25 +00:00
_ttsVoiceSelectionPopUp - > appendEntry ( _ ( " None " ) , 0 ) ;
2020-06-21 15:01:39 +00:00
else {
_ttsVoiceSelectionPopUp - > appendEntry ( _ ( " <default> " ) ) ;
for ( unsigned i = 0 ; i < voices . size ( ) ; i + + )
_ttsVoiceSelectionPopUp - > appendEntry ( voices [ i ] . getDescription ( ) , i ) ;
}
2020-01-20 23:18:14 +00:00
2020-06-21 15:01:39 +00:00
if ( ConfMan . hasKey ( " tts_voice " , _domain ) & & ( unsigned ) ConfMan . getInt ( " tts_voice " , _domain ) < voices . size ( ) )
2020-01-20 23:18:14 +00:00
_ttsVoiceSelectionPopUp - > setSelectedTag ( ConfMan . getInt ( " tts_voice " , _domain ) ) ;
else
2020-06-21 15:01:39 +00:00
_ttsVoiceSelectionPopUp - > setSelected ( 0 ) ;
2020-01-20 23:18:14 +00:00
}
2020-08-20 04:12:56 +00:00
# endif // USE_TTS
2020-01-20 23:18:14 +00:00
2021-08-21 21:05:40 +00:00
struct ExistingSave {
MetaEngine * metaEngine ;
Common : : String target ;
SaveStateDescriptor desc ;
ExistingSave ( MetaEngine * _metaEngine , const Common : : String & _target , const SaveStateDescriptor & _desc ) :
metaEngine ( _metaEngine ) ,
target ( _target ) ,
desc ( _desc )
{ }
} ;
bool GlobalOptionsDialog : : updateAutosavePeriod ( int newValue ) {
const int oldAutosavePeriod = ConfMan . getInt ( " autosave_period " ) ;
if ( oldAutosavePeriod ! = 0 | | newValue < = 0 )
return true ;
typedef Common : : Array < ExistingSave > ExistingSaveList ;
ExistingSaveList saveList ;
using Common : : ConfigManager ;
const int maxListSize = 10 ;
bool hasMore = false ;
const ConfigManager : : DomainMap & domains = ConfMan . getGameDomains ( ) ;
for ( ConfigManager : : DomainMap : : const_iterator it = domains . begin ( ) , end = domains . end ( ) ; it ! = end ; + + it ) {
const Common : : String target = it - > _key ;
const ConfigManager : : Domain domain = it - > _value ;
2021-11-11 21:29:40 +00:00
// note that engineid isn't present on games that predate it
// and haven't been run since it was introduced.
const Common : : String engine = domain . getValOrDefault ( " engineid " ) ;
2021-08-21 21:05:40 +00:00
if ( const Plugin * detectionPlugin = EngineMan . findPlugin ( engine ) ) {
if ( const Plugin * plugin = PluginMan . getEngineFromMetaEngine ( detectionPlugin ) ) {
MetaEngine & metaEngine = plugin - > get < MetaEngine > ( ) ;
const int autoSaveSlot = metaEngine . getAutosaveSlot ( ) ;
if ( autoSaveSlot < 0 )
continue ;
SaveStateDescriptor desc = metaEngine . querySaveMetaInfos ( target . c_str ( ) , autoSaveSlot ) ;
if ( desc . getSaveSlot ( ) ! = - 1 & & ! desc . getDescription ( ) . empty ( ) & & ! desc . hasAutosaveName ( ) ) {
if ( saveList . size ( ) > = maxListSize ) {
hasMore = true ;
break ;
}
saveList . push_back ( ExistingSave ( & metaEngine , target , desc ) ) ;
}
}
}
}
2021-08-28 12:45:12 +00:00
if ( ! saveList . empty ( ) ) {
Common : : U32StringArray altButtons ;
altButtons . push_back ( _ ( " Ignore " ) ) ;
altButtons . push_back ( _ ( " Disable autosave " ) ) ;
Common : : U32String message = _ ( " WARNING: Autosave was enabled. Some of your games have existing "
2021-08-21 21:05:40 +00:00
" saved games on the autosave slot. You can either move the "
" existing saves to new slots, disable autosave, or ignore (you "
" will be prompted when autosave is about to overwrite a save). \n "
" List of games: \n " ) ;
2021-08-28 12:45:12 +00:00
for ( ExistingSaveList : : const_iterator it = saveList . begin ( ) , end = saveList . end ( ) ; it ! = end ; + + it )
message + = Common : : U32String ( it - > target ) + Common : : U32String ( " : " ) + it - > desc . getDescription ( ) + " \n " ;
message . deleteLastChar ( ) ;
if ( hasMore )
message + = _ ( " \n And more... " ) ;
GUI : : MessageDialog warn ( message , _ ( " Move " ) , altButtons ) ;
switch ( warn . runModal ( ) ) {
case GUI : : kMessageOK : {
ExistingSaveList failedSaves ;
for ( ExistingSaveList : : const_iterator it = saveList . begin ( ) , end = saveList . end ( ) ; it ! = end ; + + it ) {
if ( it - > metaEngine - > copySaveFileToFreeSlot ( it - > target . c_str ( ) , it - > desc . getSaveSlot ( ) ) ) {
g_system - > getSavefileManager ( ) - > removeSavefile (
2021-08-21 21:05:40 +00:00
it - > metaEngine - > getSavegameFile ( it - > desc . getSaveSlot ( ) , it - > target . c_str ( ) ) ) ;
2021-08-28 12:45:12 +00:00
} else {
failedSaves . push_back ( * it ) ;
}
}
if ( ! failedSaves . empty ( ) ) {
Common : : U32String failMessage = _ ( " ERROR: Failed to move the following saved games: \n " ) ;
for ( ExistingSaveList : : const_iterator it = failedSaves . begin ( ) , end = failedSaves . end ( ) ; it ! = end ; + + it )
failMessage + = Common : : U32String ( it - > target ) + Common : : U32String ( " : " ) + it - > desc . getDescription ( ) + " \n " ;
failMessage . deleteLastChar ( ) ;
GUI : : MessageDialog ( failMessage ) . runModal ( ) ;
2021-08-21 21:05:40 +00:00
}
2021-08-28 12:45:12 +00:00
break ;
2021-08-21 21:05:40 +00:00
}
2021-08-28 12:45:12 +00:00
case GUI : : kMessageAlt :
break ;
case GUI : : kMessageAlt + 1 :
return false ;
2021-08-21 21:05:40 +00:00
}
}
return true ;
}
2016-10-30 15:43:14 +00:00
void GlobalOptionsDialog : : apply ( ) {
2017-03-09 01:29:06 +00:00
OptionsDialog : : apply ( ) ;
bool isRebuildNeeded = false ;
2022-09-30 13:39:25 +00:00
const auto changePath =
2022-05-24 21:45:45 +00:00
[ & ] ( GUI : : StaticTextWidget * const widget , const Common : : String & pathType , const Common : : U32String & defaultLabel ) {
2022-05-02 12:10:22 +00:00
Common : : U32String label ( widget - > getLabel ( ) ) ;
if ( label ! = ConfMan . get ( pathType ) ) {
2022-09-30 13:39:25 +00:00
widget - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2022-05-02 12:10:22 +00:00
if ( label . empty ( ) | | ( label = = defaultLabel ) )
2022-09-30 13:39:25 +00:00
ConfMan . removeKey ( pathType , _domain ) ;
else
ConfMan . set ( pathType , label . encode ( ) , _domain ) ;
}
} ;
changePath ( _savePath , " savepath " , _ ( " Default " ) ) ;
changePath ( _themePath , " themepath " , _c ( " None " , " path " ) ) ;
2022-06-20 05:47:38 +00:00
changePath ( _iconPath , " iconspath " , _ ( " Default " ) ) ;
2022-09-30 13:39:25 +00:00
changePath ( _extraPath , " extrapath " , _c ( " None " , " path " ) ) ;
2016-10-30 18:36:22 +00:00
2008-05-09 01:58:12 +00:00
# ifdef DYNAMIC_MODULES
2020-07-01 18:01:48 +00:00
Common : : U32String pluginsPath ( _pluginsPath - > getLabel ( ) ) ;
2016-10-30 15:43:14 +00:00
if ( ! pluginsPath . empty ( ) & & ( pluginsPath ! = _c ( " None " , " path " ) ) )
2020-07-01 18:01:48 +00:00
ConfMan . set ( " pluginspath " , pluginsPath . encode ( ) , _domain ) ;
2016-10-30 15:43:14 +00:00
else
ConfMan . removeKey ( " pluginspath " , _domain ) ;
2020-08-20 04:12:56 +00:00
# endif // DYNAMIC_MODULES
2016-10-30 18:36:22 +00:00
2016-08-01 09:49:42 +00:00
# ifdef USE_CLOUD
2019-07-19 10:04:44 +00:00
# ifdef USE_SDL_NET
2020-06-13 21:40:03 +00:00
Common : : U32String rootPath ( _rootPath - > getLabel ( ) ) ;
if ( ! rootPath . empty ( ) & & ( rootPath ! = _c ( " None " , " path " ) ) )
ConfMan . set ( " rootpath " , rootPath . encode ( ) , " cloud " ) ;
2016-10-30 15:43:14 +00:00
else
ConfMan . removeKey ( " rootpath " , " cloud " ) ;
2020-08-20 04:12:56 +00:00
# endif // USE_SDL_NET
# endif // USE_CLOUD
2016-10-30 18:36:22 +00:00
2021-08-10 22:37:32 +00:00
int oldGuiScale = ConfMan . getInt ( " gui_scale " ) ;
ConfMan . setInt ( " gui_scale " , _guiBasePopUp - > getSelectedTag ( ) , _domain ) ;
if ( oldGuiScale ! = ( int ) _guiBasePopUp - > getSelectedTag ( ) )
2021-04-17 17:35:08 +00:00
g_gui . computeScaleFactor ( ) ;
2021-08-21 21:05:40 +00:00
const int autosavePeriod = _autosavePeriodPopUp - > getSelectedTag ( ) ;
if ( updateAutosavePeriod ( autosavePeriod ) )
ConfMan . setInt ( " autosave_period " , autosavePeriod , _domain ) ;
else
_autosavePeriodPopUp - > setSelected ( 0 ) ;
2016-10-30 18:36:22 +00:00
2016-03-29 08:53:50 +00:00
# ifdef USE_UPDATES
2016-10-30 15:43:14 +00:00
if ( g_system - > getUpdateManager ( ) ) {
2021-11-13 19:50:57 +00:00
ConfMan . setInt ( " updates_check " , _updatesPopUp - > getSelectedTag ( ) ) ;
2021-11-16 22:36:21 +00:00
2016-10-30 15:43:14 +00:00
if ( _updatesPopUp - > getSelectedTag ( ) = = Common : : UpdateManager : : kUpdateIntervalNotSupported ) {
g_system - > getUpdateManager ( ) - > setAutomaticallyChecksForUpdates ( Common : : UpdateManager : : kUpdateStateDisabled ) ;
} else {
g_system - > getUpdateManager ( ) - > setAutomaticallyChecksForUpdates ( Common : : UpdateManager : : kUpdateStateEnabled ) ;
g_system - > getUpdateManager ( ) - > setUpdateCheckInterval ( _updatesPopUp - > getSelectedTag ( ) ) ;
2016-03-30 17:28:24 +00:00
}
2016-10-30 15:43:14 +00:00
}
2020-08-20 04:12:56 +00:00
# endif // USE_UPDATES
2016-10-30 18:36:22 +00:00
2016-10-16 22:27:59 +00:00
# ifdef USE_CLOUD
2016-07-05 09:05:30 +00:00
# ifdef USE_LIBCURL
2016-10-30 15:43:14 +00:00
if ( CloudMan . getStorageIndex ( ) ! = _selectedStorageIndex ) {
if ( ! CloudMan . switchStorage ( _selectedStorageIndex ) ) {
bool anotherStorageIsWorking = CloudMan . isWorking ( ) ;
2020-06-13 16:42:25 +00:00
Common : : U32String message = _ ( " Failed to change cloud storage! " ) ;
2016-10-30 15:43:14 +00:00
if ( anotherStorageIsWorking ) {
2020-06-13 16:42:25 +00:00
message + = Common : : U32String ( " \n " ) ;
2016-10-30 15:43:14 +00:00
message + = _ ( " Another cloud storage is already active. " ) ;
2016-06-09 07:49:52 +00:00
}
2016-10-30 15:43:14 +00:00
MessageDialog dialog ( message ) ;
dialog . runModal ( ) ;
2016-06-09 07:49:52 +00:00
}
2016-10-30 15:43:14 +00:00
}
2016-10-16 22:27:59 +00:00
# endif // USE_LIBCURL
2016-10-30 18:36:22 +00:00
2016-07-20 09:55:30 +00:00
# ifdef USE_SDL_NET
# ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
2016-10-30 15:43:14 +00:00
// save server's port
uint32 port = Networking : : LocalWebserver : : getPort ( ) ;
if ( _serverPort ) {
uint64 contents = _serverPort - > getEditString ( ) . asUint64 ( ) ;
if ( contents ! = 0 )
port = contents ;
}
ConfMan . setInt ( " local_server_port " , port ) ;
2016-10-16 22:27:59 +00:00
# endif // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
# endif // USE_SDL_NET
# endif // USE_CLOUD
2017-03-04 10:22:41 +00:00
2017-03-09 01:29:06 +00:00
Common : : String oldThemeId = g_gui . theme ( ) - > getThemeId ( ) ;
Common : : String oldThemeName = g_gui . theme ( ) - > getThemeName ( ) ;
2016-10-30 16:25:42 +00:00
if ( ! _newTheme . empty ( ) ) {
2017-03-09 01:29:06 +00:00
ConfMan . set ( " gui_theme " , _newTheme ) ;
}
2016-10-30 16:25:42 +00:00
# ifdef USE_TRANSLATION
2017-03-09 01:29:06 +00:00
int selectedLang = _guiLanguagePopUp - > getSelectedTag ( ) ;
Common : : String oldLang = ConfMan . get ( " gui_language " ) ;
Common : : String newLang = TransMan . getLangById ( selectedLang ) ;
if ( newLang ! = oldLang ) {
TransMan . setLanguage ( newLang ) ;
ConfMan . set ( " gui_language " , newLang ) ;
isRebuildNeeded = true ;
}
2021-09-20 19:07:09 +00:00
bool wantsBuiltinLang = TransMan . currentIsBuiltinLanguage ( ) ;
2018-09-27 05:12:11 +00:00
bool guiUseGameLanguage = _guiLanguageUseGameLanguageCheckbox - > getState ( ) ;
ConfMan . setBool ( " gui_use_game_language " , guiUseGameLanguage , _domain ) ;
2020-08-20 04:12:56 +00:00
# endif // USE_TRANSLATION
2017-03-09 01:29:06 +00:00
2018-12-16 15:56:37 +00:00
if ( _useSystemDialogsCheckbox ) {
ConfMan . setBool ( " gui_browser_native " , _useSystemDialogsCheckbox - > getState ( ) , _domain ) ;
}
2020-11-26 22:02:41 +00:00
if ( _guiReturnToLauncherAtExit ) {
ConfMan . setBool ( " gui_return_to_launcher_at_exit " , _guiReturnToLauncherAtExit - > getState ( ) , _domain ) ;
}
if ( _guiConfirmExit ) {
ConfMan . setBool ( " confirm_exit " , _guiConfirmExit - > getState ( ) , _domain ) ;
}
2021-08-31 19:39:17 +00:00
# ifdef USE_DISCORD
if ( _discordRpcCheckbox ) {
ConfMan . setBool ( " discord_rpc " , _discordRpcCheckbox - > getState ( ) , _domain ) ;
}
# endif // USE_DISCORD
2020-11-26 22:02:41 +00:00
2017-03-09 01:29:06 +00:00
GUI : : ThemeEngine : : GraphicsMode gfxMode = ( GUI : : ThemeEngine : : GraphicsMode ) _rendererPopUp - > getSelectedTag ( ) ;
Common : : String oldGfxConfig = ConfMan . get ( " gui_renderer " ) ;
Common : : String newGfxConfig = GUI : : ThemeEngine : : findModeConfigName ( gfxMode ) ;
if ( newGfxConfig ! = oldGfxConfig ) {
ConfMan . set ( " gui_renderer " , newGfxConfig , _domain ) ;
2016-10-30 16:25:42 +00:00
}
2017-03-09 01:29:06 +00:00
if ( _newTheme . empty ( ) )
_newTheme = oldThemeId ;
if ( ! g_gui . loadNewTheme ( _newTheme , gfxMode , true ) ) {
2020-06-13 16:42:25 +00:00
Common : : U32String errorMessage ;
2017-03-09 01:29:06 +00:00
_curTheme - > setLabel ( oldThemeName ) ;
_newTheme = oldThemeId ;
ConfMan . set ( " gui_theme " , _newTheme ) ;
gfxMode = GUI : : ThemeEngine : : findMode ( oldGfxConfig ) ;
_rendererPopUp - > setSelectedTag ( gfxMode ) ;
newGfxConfig = oldGfxConfig ;
ConfMan . set ( " gui_renderer " , newGfxConfig , _domain ) ;
2017-03-08 23:01:55 +00:00
# ifdef USE_TRANSLATION
2021-09-20 19:02:41 +00:00
// One reason for failing to load the theme is if we want a language other than
// the builtin language and the theme does not have unicode fonts for those.
// We can detect this case as it falls back to the builtin language.
2021-09-20 19:07:09 +00:00
bool themeLangIssue = ( ! wantsBuiltinLang & & TransMan . currentIsBuiltinLanguage ( ) ) ;
2017-03-09 01:29:06 +00:00
TransMan . setLanguage ( oldLang ) ;
_guiLanguagePopUp - > setSelectedTag ( selectedLang ) ;
ConfMan . set ( " gui_language " , oldLang ) ;
2017-03-08 23:01:55 +00:00
2021-09-20 19:02:41 +00:00
if ( themeLangIssue )
2017-03-09 01:29:06 +00:00
errorMessage = _ ( " Theme does not support selected language! " ) ;
else
2020-08-20 04:12:56 +00:00
# endif // USE_TRANSLATION
2017-03-09 01:29:06 +00:00
errorMessage = _ ( " Theme cannot be loaded! " ) ;
2017-03-08 23:01:55 +00:00
2017-03-09 01:29:06 +00:00
g_gui . loadNewTheme ( _newTheme , gfxMode , true ) ;
errorMessage + = _ ( " \n Misc settings will be restored. " ) ;
MessageDialog error ( errorMessage ) ;
error . runModal ( ) ;
}
2021-04-25 05:05:02 +00:00
2021-05-03 14:47:30 +00:00
# ifdef USE_TTS
2019-07-14 21:39:26 +00:00
Common : : TextToSpeechManager * ttsMan = g_system - > getTextToSpeechManager ( ) ;
2019-11-13 20:09:21 +00:00
if ( ttsMan ) {
2022-04-10 19:31:35 +00:00
ttsMan - > enable ( _ttsCheckbox - > getState ( ) ) ;
2020-08-20 04:12:56 +00:00
# ifdef USE_TRANSLATION
2019-11-13 20:09:21 +00:00
if ( newLang ! = oldLang ) {
2021-07-16 20:52:48 +00:00
ttsMan - > setLanguage ( newLang ) ;
2020-09-06 15:23:57 +00:00
_ttsVoiceSelectionPopUp - > setSelected ( 0 ) ;
2019-07-14 21:39:26 +00:00
}
2020-08-20 04:12:56 +00:00
# else
ttsMan - > setLanguage ( " en " ) ;
# endif // USE_TRANSLATION
2019-11-13 20:09:21 +00:00
int volume = ( ConfMan . getInt ( " speech_volume " , " scummvm " ) * 100 ) / 256 ;
if ( ConfMan . hasKey ( " mute " , " scummvm " ) & & ConfMan . getBool ( " mute " , " scummvm " ) )
volume = 0 ;
ttsMan - > setVolume ( volume ) ;
ConfMan . setBool ( " tts_enabled " , _ttsCheckbox - > getState ( ) , _domain ) ;
2020-06-21 15:01:39 +00:00
unsigned selectedVoice = _ttsVoiceSelectionPopUp - > getSelectedTag ( ) ;
2019-11-13 20:09:21 +00:00
ConfMan . setInt ( " tts_voice " , selectedVoice , _domain ) ;
2020-06-21 15:01:39 +00:00
if ( selectedVoice > = ttsMan - > getVoicesArray ( ) . size ( ) )
selectedVoice = ttsMan - > getDefaultVoice ( ) ;
2019-11-13 20:09:21 +00:00
ttsMan - > setVoice ( selectedVoice ) ;
2019-07-14 17:28:04 +00:00
}
2021-05-03 14:47:30 +00:00
# endif // USE_TTS
2017-03-08 23:01:55 +00:00
2017-03-09 01:29:06 +00:00
if ( isRebuildNeeded ) {
2020-07-17 19:21:27 +00:00
g_gui . setLanguageRTL ( ) ;
2020-01-05 16:48:04 +00:00
if ( _launcher ! = nullptr )
2017-03-08 23:01:55 +00:00
_launcher - > rebuild ( ) ;
2019-12-28 09:43:58 +00:00
rebuild ( ) ;
2017-03-08 23:01:55 +00:00
}
2016-10-30 18:36:22 +00:00
2017-03-09 01:29:06 +00:00
_newTheme . clear ( ) ;
// Save config file
ConfMan . flushToDisk ( ) ;
2016-10-30 15:43:14 +00:00
}
void GlobalOptionsDialog : : close ( ) {
2016-10-17 16:55:01 +00:00
# if defined(USE_CLOUD) && defined(USE_SDL_NET)
2016-07-24 05:13:20 +00:00
if ( LocalServer . isRunning ( ) ) {
LocalServer . stop ( ) ;
}
# endif
2007-06-11 07:35:52 +00:00
OptionsDialog : : close ( ) ;
2002-12-12 23:22:48 +00:00
}
2003-03-06 19:52:54 +00:00
void GlobalOptionsDialog : : handleCommand ( CommandSender * sender , uint32 cmd , uint32 data ) {
2003-03-25 15:32:36 +00:00
switch ( cmd ) {
2005-08-10 18:30:55 +00:00
case kChooseSaveDirCmd : {
2020-07-01 18:01:48 +00:00
BrowserDialog browser ( _ ( " Select directory for saved games " ) , true ) ;
2005-08-10 18:30:55 +00:00
if ( browser . runModal ( ) > 0 ) {
2003-03-25 15:32:36 +00:00
// User made his choice...
2008-10-02 16:58:59 +00:00
Common : : FSNode dir ( browser . getResult ( ) ) ;
2007-09-18 20:16:33 +00:00
if ( dir . isWritable ( ) ) {
2007-06-14 18:40:27 +00:00
_savePath - > setLabel ( dir . getPath ( ) ) ;
} else {
2010-06-15 10:44:51 +00:00
MessageDialog error ( _ ( " The chosen directory cannot be written to. Please select another one. " ) ) ;
2007-06-14 18:40:27 +00:00
error . runModal ( ) ;
return ;
2007-09-19 08:40:12 +00:00
}
2018-01-06 15:13:29 +00:00
g_gui . scheduleTopDialogRedraw ( ) ;
2003-03-25 15:32:36 +00:00
}
break ;
2005-08-10 18:30:55 +00:00
}
2006-06-11 20:40:22 +00:00
case kChooseThemeDirCmd : {
2020-07-01 18:01:48 +00:00
BrowserDialog browser ( _ ( " Select directory for GUI themes " ) , true ) ;
2006-06-11 20:40:22 +00:00
if ( browser . runModal ( ) > 0 ) {
// User made his choice...
2008-10-02 16:58:59 +00:00
Common : : FSNode dir ( browser . getResult ( ) ) ;
2007-06-05 21:02:35 +00:00
_themePath - > setLabel ( dir . getPath ( ) ) ;
2018-01-06 15:13:29 +00:00
g_gui . scheduleTopDialogRedraw ( ) ;
2006-06-11 20:40:22 +00:00
}
break ;
}
2021-07-09 16:53:26 +00:00
case kChooseIconDirCmd : {
BrowserDialog browser ( _ ( " Select directory for GUI launcher thumbnails " ) , true ) ;
if ( browser . runModal ( ) > 0 ) {
// User made his choice...
Common : : FSNode dir ( browser . getResult ( ) ) ;
_iconPath - > setLabel ( dir . getPath ( ) ) ;
g_gui . scheduleTopDialogRedraw ( ) ;
}
break ;
}
2005-08-10 18:30:55 +00:00
case kChooseExtraDirCmd : {
2020-07-01 18:01:48 +00:00
BrowserDialog browser ( _ ( " Select directory for extra files " ) , true ) ;
2005-08-10 18:30:55 +00:00
if ( browser . runModal ( ) > 0 ) {
2004-11-15 04:41:51 +00:00
// User made his choice...
2008-10-02 16:58:59 +00:00
Common : : FSNode dir ( browser . getResult ( ) ) ;
2007-06-05 21:02:35 +00:00
_extraPath - > setLabel ( dir . getPath ( ) ) ;
2018-01-06 15:13:29 +00:00
g_gui . scheduleTopDialogRedraw ( ) ;
2004-11-15 04:41:51 +00:00
}
break ;
2005-08-10 18:30:55 +00:00
}
2008-05-09 01:58:12 +00:00
# ifdef DYNAMIC_MODULES
case kChoosePluginsDirCmd : {
2020-07-01 18:01:48 +00:00
BrowserDialog browser ( _ ( " Select directory for plugins " ) , true ) ;
2008-05-09 01:58:12 +00:00
if ( browser . runModal ( ) > 0 ) {
// User made his choice...
2008-10-02 16:58:59 +00:00
Common : : FSNode dir ( browser . getResult ( ) ) ;
2008-05-09 01:58:12 +00:00
_pluginsPath - > setLabel ( dir . getPath ( ) ) ;
2018-01-06 15:13:29 +00:00
g_gui . scheduleTopDialogRedraw ( ) ;
2008-05-09 01:58:12 +00:00
}
break ;
}
2016-08-01 09:49:42 +00:00
# endif
# ifdef USE_CLOUD
2019-07-19 10:04:44 +00:00
# ifdef USE_SDL_NET
2016-08-01 09:49:42 +00:00
case kChooseRootDirCmd : {
2020-07-01 18:01:48 +00:00
BrowserDialog browser ( _ ( " Select directory for Files Manager /root/ " ) , true ) ;
2016-08-01 09:49:42 +00:00
if ( browser . runModal ( ) > 0 ) {
// User made his choice...
Common : : FSNode dir ( browser . getResult ( ) ) ;
Common : : String path = dir . getPath ( ) ;
if ( path . empty ( ) )
path = " / " ; // absolute root
_rootPath - > setLabel ( path ) ;
2018-01-06 15:13:29 +00:00
g_gui . scheduleTopDialogRedraw ( ) ;
2016-08-01 09:49:42 +00:00
}
break ;
}
2021-11-18 22:33:13 +00:00
# endif
2021-11-16 22:36:21 +00:00
2021-11-18 22:33:13 +00:00
# ifdef USE_LIBCURL
2021-11-16 22:36:21 +00:00
case kUpdateIconsCmd : {
DownloadIconsDialog dia ;
2022-06-28 00:17:06 +00:00
dia . runModal ( ) ;
2021-11-16 22:36:21 +00:00
break ;
}
2019-07-19 10:04:44 +00:00
# endif
2021-11-18 22:33:13 +00:00
2008-05-09 01:58:12 +00:00
# endif
2011-10-24 18:34:10 +00:00
case kThemePathClearCmd :
2020-07-01 18:01:48 +00:00
_themePath - > setLabel ( _c ( " None " , " path " ) ) ;
2011-10-24 18:34:10 +00:00
break ;
2021-07-09 16:53:26 +00:00
case kIconPathClearCmd :
2022-06-20 05:47:38 +00:00
_iconPath - > setLabel ( _ ( " Default " ) ) ;
2021-07-09 16:53:26 +00:00
break ;
2011-10-24 18:34:10 +00:00
case kExtraPathClearCmd :
2020-07-01 18:01:48 +00:00
_extraPath - > setLabel ( _c ( " None " , " path " ) ) ;
2011-10-24 18:34:10 +00:00
break ;
case kSavePathClearCmd :
2020-07-01 18:01:48 +00:00
_savePath - > setLabel ( _ ( " Default " ) ) ;
2011-10-24 18:34:10 +00:00
break ;
2020-01-04 14:33:57 +00:00
# ifdef DYNAMIC_MODULES
case kPluginsPathClearCmd :
_pluginsPath - > setLabel ( _c ( " None " , " path " ) ) ;
break ;
# endif
2021-08-02 15:04:23 +00:00
case kBrowserPathClearCmd :
ConfMan . removeKey ( " browser_lastpath " , Common : : ConfigManager : : kApplicationDomain ) ;
ConfMan . flushToDisk ( ) ;
_browserPath - > setLabel ( _ ( " Last browser path: " ) + _ ( " <default> " ) ) ;
break ;
2016-08-01 09:49:42 +00:00
# ifdef USE_CLOUD
2019-07-19 10:04:44 +00:00
# ifdef USE_SDL_NET
2016-08-01 09:49:42 +00:00
case kRootPathClearCmd :
2020-07-01 18:01:48 +00:00
_rootPath - > setLabel ( _c ( " None " , " path " ) ) ;
2016-08-01 09:49:42 +00:00
break ;
2019-07-19 10:04:44 +00:00
# endif
2016-08-01 09:49:42 +00:00
# endif
2022-06-30 23:11:46 +00:00
case kChooseShaderCmd : {
BrowserDialog browser ( _ ( " Select shader " ) , false ) ;
if ( browser . runModal ( ) > 0 ) {
// User made his choice...
Common : : FSNode file ( browser . getResult ( ) ) ;
_shader - > setLabel ( file . getPath ( ) ) ;
if ( ! file . getPath ( ) . empty ( ) & & ( file . getPath ( ) . decode ( ) ! = _c ( " None " , " path " ) ) )
_shaderClearButton - > setEnabled ( true ) ;
else
_shaderClearButton - > setEnabled ( false ) ;
g_gui . scheduleTopDialogRedraw ( ) ;
}
break ;
}
2005-08-10 18:30:55 +00:00
case kChooseSoundFontCmd : {
2020-07-01 18:01:48 +00:00
BrowserDialog browser ( _ ( " Select SoundFont " ) , false ) ;
2005-08-10 18:30:55 +00:00
if ( browser . runModal ( ) > 0 ) {
2005-04-10 14:33:44 +00:00
// User made his choice...
2008-10-02 16:58:59 +00:00
Common : : FSNode file ( browser . getResult ( ) ) ;
2007-06-05 21:02:35 +00:00
_soundFont - > setLabel ( file . getPath ( ) ) ;
2007-02-13 21:41:49 +00:00
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
if ( ! file . getPath ( ) . empty ( ) & & ( file . getPath ( ) . decode ( ) ! = _c ( " None " , " path " ) ) )
2007-02-13 21:41:49 +00:00
_soundFontClearButton - > setEnabled ( true ) ;
else
_soundFontClearButton - > setEnabled ( false ) ;
2018-01-06 15:13:29 +00:00
g_gui . scheduleTopDialogRedraw ( ) ;
2005-04-10 14:33:44 +00:00
}
break ;
2005-08-10 18:30:55 +00:00
}
2016-06-08 12:56:17 +00:00
case kChooseThemeCmd :
{
2006-10-08 18:22:28 +00:00
ThemeBrowser browser ;
if ( browser . runModal ( ) > 0 ) {
// User made his choice...
2016-10-30 16:25:42 +00:00
_newTheme = browser . getSelected ( ) ;
_curTheme - > setLabel ( browser . getSelectedName ( ) ) ;
2022-09-30 13:39:25 +00:00
_curTheme - > setFontColor ( ThemeEngine : : FontColor : : kFontColorNormal ) ;
2006-10-08 18:22:28 +00:00
}
break ;
}
2016-07-11 08:17:27 +00:00
# ifdef USE_CLOUD
2019-07-19 10:04:44 +00:00
# ifdef USE_LIBCURL
case kCloudTabContainerReflowCmd : {
2016-07-11 08:17:27 +00:00
setupCloudTab ( ) ;
break ;
2019-07-19 10:04:44 +00:00
}
2021-01-06 22:13:14 +00:00
case kStoragePopUpCmd : {
2019-07-19 10:58:04 +00:00
if ( _storageWizardCodeBox )
2020-11-15 18:15:58 +00:00
_storageWizardCodeBox - > setEditString ( Common : : U32String ( ) ) ;
2017-02-26 18:44:09 +00:00
// update container's scrollbar
reflowLayout ( ) ;
2016-06-08 12:56:17 +00:00
break ;
}
2019-07-27 15:44:15 +00:00
case kEnableStorageCmd : {
CloudMan . enableStorage ( ) ;
_redrawCloudTab = true ;
// also, automatically start saves sync when user enables the storage
}
2019-08-03 13:27:57 +00:00
// fall through
2019-07-18 16:10:49 +00:00
case kSyncSavesStorageCmd : {
CloudMan . syncSaves (
new Common : : Callback < GlobalOptionsDialog , Cloud : : Storage : : BoolResponse > ( this , & GlobalOptionsDialog : : storageSavesSyncedCallback )
) ;
break ;
}
case kDownloadStorageCmd : {
DownloadDialog dialog ( _selectedStorageIndex , _launcher ) ;
2016-06-09 11:00:05 +00:00
dialog . runModal ( ) ;
break ;
}
2019-07-18 16:10:49 +00:00
case kOpenUrlStorageCmd : {
Common : : String url = " https://cloud.scummvm.org/ " ;
switch ( _selectedStorageIndex ) {
case Cloud : : kStorageDropboxId :
2021-01-04 08:28:29 +00:00
url + = " dropbox?refresh_token=true " ;
2019-07-18 16:10:49 +00:00
break ;
case Cloud : : kStorageOneDriveId :
url + = " onedrive " ;
break ;
case Cloud : : kStorageGoogleDriveId :
url + = " gdrive " ;
break ;
case Cloud : : kStorageBoxId :
url + = " box " ;
break ;
2019-10-03 05:03:46 +00:00
default :
break ;
2019-07-18 16:10:49 +00:00
}
if ( ! g_system - > openUrl ( url ) ) {
MessageDialog alert ( _ ( " Failed to open URL! \n Please navigate to this page manually. " ) ) ;
alert . runModal ( ) ;
}
break ;
}
case kPasteCodeStorageCmd : {
if ( g_system - > hasTextInClipboard ( ) ) {
2020-06-15 15:37:22 +00:00
Common : : U32String message = g_system - > getTextFromClipboard ( ) ;
2019-07-18 16:10:49 +00:00
if ( ! message . empty ( ) ) {
_storageWizardCodeBox - > setEditString ( message ) ;
_redrawCloudTab = true ;
}
}
break ;
}
case kConnectStorageCmd : {
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
Common : : String code = " " ;
2019-07-18 16:10:49 +00:00
if ( _storageWizardCodeBox )
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
code = _storageWizardCodeBox - > getEditString ( ) . encode ( ) ;
2019-07-18 16:10:49 +00:00
if ( code . size ( ) = = 0 )
return ;
if ( CloudMan . isWorking ( ) ) {
bool cancel = true ;
MessageDialog alert ( _ ( " Another Storage is working now. Do you want to interrupt it? " ) , _ ( " Yes " ) , _ ( " No " ) ) ;
if ( alert . runModal ( ) = = GUI : : kMessageOK ) {
if ( CloudMan . isDownloading ( ) )
CloudMan . cancelDownload ( ) ;
if ( CloudMan . isSyncing ( ) )
CloudMan . cancelSync ( ) ;
// I believe it still would return `true` here, but just in case
if ( CloudMan . isWorking ( ) ) {
MessageDialog alert2 ( _ ( " Wait until current Storage finishes up and try again. " ) ) ;
alert2 . runModal ( ) ;
} else {
cancel = false ;
}
}
if ( cancel ) {
return ;
}
}
if ( _storageWizardConnectionStatusHint )
2020-07-01 18:01:48 +00:00
_storageWizardConnectionStatusHint - > setLabel ( _ ( " Connecting... " ) ) ;
2019-07-18 16:10:49 +00:00
CloudMan . connectStorage (
GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.
- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-07-20 12:36:37 +00:00
_selectedStorageIndex , code ,
2019-07-18 16:10:49 +00:00
new Common : : Callback < GlobalOptionsDialog , Networking : : ErrorResponse > ( this , & GlobalOptionsDialog : : storageConnectionCallback )
2016-07-20 07:02:18 +00:00
) ;
2019-07-18 16:10:49 +00:00
_connectingStorage = true ;
_redrawCloudTab = true ;
2016-06-09 12:49:17 +00:00
break ;
}
2019-07-18 16:10:49 +00:00
case kDisconnectStorageCmd : {
2019-07-19 10:58:04 +00:00
if ( _storageWizardCodeBox )
2020-11-15 18:15:58 +00:00
_storageWizardCodeBox - > setEditString ( Common : : U32String ( ) ) ;
2019-07-19 10:58:04 +00:00
2019-07-18 16:10:49 +00:00
if ( _selectedStorageIndex = = CloudMan . getStorageIndex ( ) & & CloudMan . isWorking ( ) ) {
bool cancel = true ;
MessageDialog alert ( _ ( " This Storage is working now. Do you want to interrupt it? " ) , _ ( " Yes " ) , _ ( " No " ) ) ;
if ( alert . runModal ( ) = = GUI : : kMessageOK ) {
if ( CloudMan . isDownloading ( ) )
CloudMan . cancelDownload ( ) ;
if ( CloudMan . isSyncing ( ) )
CloudMan . cancelSync ( ) ;
// I believe it still would return `true` here, but just in case
if ( CloudMan . isWorking ( ) ) {
MessageDialog alert2 ( _ ( " Wait until current Storage finishes up and try again. " ) ) ;
alert2 . runModal ( ) ;
} else {
cancel = false ;
}
}
if ( cancel ) {
return ;
}
2016-07-22 12:48:46 +00:00
}
2019-07-18 16:10:49 +00:00
CloudMan . disconnectStorage ( _selectedStorageIndex ) ;
_redrawCloudTab = true ;
2019-07-19 11:01:09 +00:00
sendCommand ( kSetPositionCmd , 0 ) ;
2019-07-18 16:10:49 +00:00
break ;
}
2016-10-16 22:27:59 +00:00
# endif // USE_LIBCURL
2016-07-05 07:11:29 +00:00
# ifdef USE_SDL_NET
2019-07-19 10:04:44 +00:00
case kRunServerCmd : {
2016-07-20 09:55:30 +00:00
# ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
2019-07-19 10:04:44 +00:00
// save server's port
uint32 port = Networking : : LocalWebserver : : getPort ( ) ;
if ( _serverPort ) {
uint64 contents = _serverPort - > getEditString ( ) . asUint64 ( ) ;
if ( contents ! = 0 )
port = contents ;
}
ConfMan . setInt ( " local_server_port " , port ) ;
ConfMan . flushToDisk ( ) ;
2016-10-16 22:27:59 +00:00
# endif // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
2016-07-20 09:55:30 +00:00
2019-07-19 10:04:44 +00:00
if ( LocalServer . isRunning ( ) )
LocalServer . stopOnIdle ( ) ;
else
LocalServer . start ( ) ;
2016-07-20 10:48:50 +00:00
2019-07-19 10:04:44 +00:00
break ;
}
2016-07-20 10:48:50 +00:00
case kServerPortClearCmd : {
if ( _serverPort ) {
_serverPort - > setEditString ( Common : : String : : format ( " %u " , Networking : : LocalWebserver : : DEFAULT_SERVER_PORT ) ) ;
}
2018-01-06 15:13:29 +00:00
g_gui . scheduleTopDialogRedraw ( ) ;
2016-07-20 10:48:50 +00:00
break ;
}
2016-10-16 22:27:59 +00:00
# endif // USE_SDL_NET
# endif // USE_CLOUD
2012-12-27 14:08:54 +00:00
# ifdef USE_FLUIDSYNTH
case kFluidSynthSettingsCmd :
_fluidSynthSettingsDialog - > runModal ( ) ;
break ;
2016-03-31 11:59:01 +00:00
# endif
# ifdef USE_UPDATES
case kUpdatesCheckCmd :
if ( g_system - > getUpdateManager ( ) )
g_system - > getUpdateManager ( ) - > checkForUpdates ( ) ;
break ;
2005-01-10 20:53:16 +00:00
# endif
2003-03-25 15:32:36 +00:00
default :
2003-11-05 12:25:42 +00:00
OptionsDialog : : handleCommand ( sender , cmd , data ) ;
2002-12-12 23:22:48 +00:00
}
}
2003-11-10 23:40:48 +00:00
2016-06-09 12:49:17 +00:00
void GlobalOptionsDialog : : handleTickle ( ) {
OptionsDialog : : handleTickle ( ) ;
# ifdef USE_CLOUD
2019-07-19 10:04:44 +00:00
# ifdef USE_LIBCURL
2016-06-09 12:49:17 +00:00
if ( _redrawCloudTab ) {
2019-08-03 21:43:53 +00:00
reflowLayout ( ) ; // recalculates scrollbar as well
2016-06-09 12:49:17 +00:00
_redrawCloudTab = false ;
}
2019-07-19 10:04:44 +00:00
# endif // USE_LIBCURL
# ifdef USE_SDL_NET
if ( LocalServer . isRunning ( ) ! = _serverWasRunning ) {
_serverWasRunning = ! _serverWasRunning ;
2019-07-21 13:52:16 +00:00
reflowNetworkTabLayout ( ) ;
2019-07-19 10:04:44 +00:00
}
# endif // USE_SDL_NET
# endif // USE_CLOUD
2016-06-09 12:49:17 +00:00
}
2012-02-24 21:20:50 +00:00
void GlobalOptionsDialog : : reflowLayout ( ) {
2017-02-26 18:44:09 +00:00
int firstVisible = _tabWidget - > getFirstVisible ( ) ;
2012-02-24 21:20:50 +00:00
int activeTab = _tabWidget - > getActiveTab ( ) ;
if ( _midiTabId ! = - 1 ) {
_tabWidget - > setActiveTab ( _midiTabId ) ;
2022-06-30 22:44:36 +00:00
bool enabled = _soundFontClearButton - > isEnabled ( ) ;
2012-02-24 21:20:50 +00:00
_tabWidget - > removeWidget ( _soundFontClearButton ) ;
2020-01-05 16:48:04 +00:00
_soundFontClearButton - > setNext ( nullptr ) ;
2012-02-24 21:20:50 +00:00
delete _soundFontClearButton ;
_soundFontClearButton = addClearButton ( _tabWidget , " GlobalOptions_MIDI.mcFontClearButton " , kClearSoundFontCmd ) ;
2022-06-30 22:44:36 +00:00
_soundFontClearButton - > setEnabled ( enabled ) ;
2012-02-24 21:20:50 +00:00
}
if ( _pathsTabId ! = - 1 ) {
_tabWidget - > setActiveTab ( _pathsTabId ) ;
_tabWidget - > removeWidget ( _savePathClearButton ) ;
2020-01-05 16:48:04 +00:00
_savePathClearButton - > setNext ( nullptr ) ;
2012-02-24 21:20:50 +00:00
delete _savePathClearButton ;
_savePathClearButton = addClearButton ( _tabWidget , " GlobalOptions_Paths.SavePathClearButton " , kSavePathClearCmd ) ;
_tabWidget - > removeWidget ( _themePathClearButton ) ;
2020-01-05 16:48:04 +00:00
_themePathClearButton - > setNext ( nullptr ) ;
2012-02-24 21:20:50 +00:00
delete _themePathClearButton ;
_themePathClearButton = addClearButton ( _tabWidget , " GlobalOptions_Paths.ThemePathClearButton " , kThemePathClearCmd ) ;
2021-07-09 16:53:26 +00:00
_tabWidget - > removeWidget ( _iconPathClearButton ) ;
_iconPathClearButton - > setNext ( nullptr ) ;
delete _iconPathClearButton ;
_iconPathClearButton = addClearButton ( _tabWidget , " GlobalOptions_Paths.IconPathClearButton " , kIconPathClearCmd ) ;
2012-02-24 21:20:50 +00:00
_tabWidget - > removeWidget ( _extraPathClearButton ) ;
2020-01-05 16:48:04 +00:00
_extraPathClearButton - > setNext ( nullptr ) ;
2012-02-24 21:20:50 +00:00
delete _extraPathClearButton ;
_extraPathClearButton = addClearButton ( _tabWidget , " GlobalOptions_Paths.ExtraPathClearButton " , kExtraPathClearCmd ) ;
2021-08-02 15:04:23 +00:00
_tabWidget - > removeWidget ( _browserPathClearButton ) ;
_browserPathClearButton - > setNext ( nullptr ) ;
delete _browserPathClearButton ;
_browserPathClearButton = addClearButton ( _tabWidget , " GlobalOptions_Paths.BrowserPathClearButton " , kBrowserPathClearCmd ) ;
2012-02-24 21:20:50 +00:00
}
_tabWidget - > setActiveTab ( activeTab ) ;
2017-02-26 18:44:09 +00:00
_tabWidget - > setFirstVisible ( firstVisible ) ;
2012-02-24 21:20:50 +00:00
OptionsDialog : : reflowLayout ( ) ;
2016-07-05 09:05:30 +00:00
# ifdef USE_CLOUD
2019-07-19 10:04:44 +00:00
# ifdef USE_LIBCURL
2016-07-05 08:12:35 +00:00
setupCloudTab ( ) ;
2019-07-19 10:04:44 +00:00
# endif // USE_LIBCURL
# ifdef USE_SDL_NET
2019-07-21 13:52:16 +00:00
reflowNetworkTabLayout ( ) ;
2019-07-19 10:04:44 +00:00
# endif // USE_SDL_NET
# endif // USE_CLOUD
2012-02-24 21:20:50 +00:00
}
2016-07-05 09:05:30 +00:00
# ifdef USE_CLOUD
# ifdef USE_LIBCURL
2019-07-19 10:04:44 +00:00
void GlobalOptionsDialog : : setupCloudTab ( ) {
_selectedStorageIndex = ( _storagePopUp ? _storagePopUp - > getSelectedTag ( ) : ( uint32 ) Cloud : : kStorageNoneId ) ;
2016-07-21 05:44:36 +00:00
2016-07-12 16:11:07 +00:00
if ( _storagePopUpDesc ) _storagePopUpDesc - > setVisible ( true ) ;
if ( _storagePopUp ) _storagePopUp - > setVisible ( true ) ;
2016-06-09 07:49:52 +00:00
2019-07-18 16:10:49 +00:00
Common : : String username = CloudMan . getStorageUsername ( _selectedStorageIndex ) ;
bool storageConnected = ( username ! = " " ) ;
2016-06-09 07:49:52 +00:00
bool shown = ( _selectedStorageIndex ! = Cloud : : kStorageNoneId ) ;
2019-07-18 16:10:49 +00:00
bool shownConnectedInfo = ( shown & & storageConnected ) ;
2019-07-27 15:44:15 +00:00
bool showingCurrentStorage = ( shownConnectedInfo & & _selectedStorageIndex = = CloudMan . getStorageIndex ( ) ) ;
bool enabled = ( shownConnectedInfo & & CloudMan . isStorageEnabled ( ) ) ;
2019-07-19 10:04:44 +00:00
// there goes layout for connected Storage
2019-07-27 15:44:15 +00:00
if ( _storageDisabledHint ) _storageDisabledHint - > setVisible ( showingCurrentStorage & & ! enabled ) ;
if ( _storageEnableButton ) _storageEnableButton - > setVisible ( showingCurrentStorage & & ! enabled ) ;
// calculate shift
int16 x , y ;
2020-05-09 19:04:53 +00:00
int16 w , h ;
2019-07-27 15:44:15 +00:00
int16 shiftUp = 0 ;
if ( ! showingCurrentStorage | | enabled ) {
// "storage is disabled" hint is not shown, shift everything up
2020-06-06 10:35:37 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.StorageDisabledHint " , x , y , w , h ) )
2019-07-27 15:44:15 +00:00
warning ( " GlobalOptions_Cloud_Container.StorageUsernameDesc's position is undefined " ) ;
shiftUp = y ;
2020-06-06 10:35:37 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.StorageUsernameDesc " , x , y , w , h ) )
2019-07-27 15:44:15 +00:00
warning ( " GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint's position is undefined " ) ;
shiftUp = y - shiftUp ;
}
2019-07-18 16:10:49 +00:00
if ( _storageUsernameDesc ) _storageUsernameDesc - > setVisible ( shownConnectedInfo ) ;
2016-06-09 06:41:51 +00:00
if ( _storageUsername ) {
_storageUsername - > setLabel ( username ) ;
2019-07-18 16:10:49 +00:00
_storageUsername - > setVisible ( shownConnectedInfo ) ;
2016-06-09 06:41:51 +00:00
}
2019-07-18 16:10:49 +00:00
if ( _storageUsedSpaceDesc ) _storageUsedSpaceDesc - > setVisible ( shownConnectedInfo ) ;
2016-06-09 06:41:51 +00:00
if ( _storageUsedSpace ) {
2016-06-09 07:49:52 +00:00
uint64 usedSpace = CloudMan . getStorageUsedSpace ( _selectedStorageIndex ) ;
2019-07-15 11:35:24 +00:00
Common : : String usedSpaceNumber , usedSpaceUnits ;
usedSpaceNumber = Common : : getHumanReadableBytes ( usedSpace , usedSpaceUnits ) ;
2020-09-08 20:23:47 +00:00
_storageUsedSpace - > setLabel ( Common : : U32String : : format ( " %s %S " , usedSpaceNumber . c_str ( ) , _ ( usedSpaceUnits ) . c_str ( ) ) ) ;
2019-07-18 16:10:49 +00:00
_storageUsedSpace - > setVisible ( shownConnectedInfo ) ;
2016-06-09 06:41:51 +00:00
}
2019-07-18 16:10:49 +00:00
if ( _storageSyncHint ) {
_storageSyncHint - > setVisible ( shownConnectedInfo ) ;
_storageSyncHint - > setEnabled ( false ) ;
}
if ( _storageLastSyncDesc ) _storageLastSyncDesc - > setVisible ( shownConnectedInfo ) ;
2016-06-09 06:41:51 +00:00
if ( _storageLastSync ) {
2020-06-13 16:42:25 +00:00
Common : : U32String sync = CloudMan . getStorageLastSync ( _selectedStorageIndex ) ;
2016-06-09 06:41:51 +00:00
if ( sync = = " " ) {
2016-07-22 12:48:46 +00:00
if ( _selectedStorageIndex = = CloudMan . getStorageIndex ( ) & & CloudMan . isSyncing ( ) )
sync = _ ( " <right now> " ) ;
else
sync = _ ( " <never> " ) ;
2016-06-09 06:41:51 +00:00
}
_storageLastSync - > setLabel ( sync ) ;
2019-07-18 16:10:49 +00:00
_storageLastSync - > setVisible ( shownConnectedInfo ) ;
}
2019-07-27 15:44:15 +00:00
if ( _storageSyncSavesButton ) {
_storageSyncSavesButton - > setVisible ( showingCurrentStorage ) ;
_storageSyncSavesButton - > setEnabled ( enabled ) ;
}
2019-07-18 16:10:49 +00:00
2019-07-27 15:44:15 +00:00
bool showDownloadButton = ( showingCurrentStorage & & _selectedStorageIndex ! = Cloud : : kStorageGoogleDriveId ) ; // cannot download via Google Drive
2019-07-19 10:04:44 +00:00
if ( _storageDownloadHint ) _storageDownloadHint - > setVisible ( showDownloadButton ) ;
2019-07-27 15:44:15 +00:00
if ( _storageDownloadButton ) {
_storageDownloadButton - > setVisible ( showDownloadButton ) ;
_storageDownloadButton - > setEnabled ( enabled ) ;
}
2019-07-19 10:04:44 +00:00
if ( _storageDisconnectHint ) _storageDisconnectHint - > setVisible ( shownConnectedInfo ) ;
if ( _storageDisconnectButton ) _storageDisconnectButton - > setVisible ( shownConnectedInfo ) ;
2019-07-27 15:44:15 +00:00
int16 disconnectWidgetsAdditionalShift = 0 ;
if ( ! showDownloadButton ) {
2020-06-06 10:35:37 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.StorageDownloadHint " , x , y , w , h ) )
2019-07-27 15:44:15 +00:00
warning ( " GlobalOptions_Cloud_Container.StorageDownloadHint's position is undefined " ) ;
disconnectWidgetsAdditionalShift = y ;
2020-06-06 10:35:37 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.StorageDisconnectHint " , x , y , w , h ) )
2019-07-27 15:44:15 +00:00
warning ( " GlobalOptions_Cloud_Container.DownloadButton's position is undefined " ) ;
disconnectWidgetsAdditionalShift = y - disconnectWidgetsAdditionalShift ;
}
shiftWidget ( _storageUsernameDesc , " GlobalOptions_Cloud_Container.StorageUsernameDesc " , 0 , - shiftUp ) ;
shiftWidget ( _storageUsername , " GlobalOptions_Cloud_Container.StorageUsernameLabel " , 0 , - shiftUp ) ;
shiftWidget ( _storageUsedSpaceDesc , " GlobalOptions_Cloud_Container.StorageUsedSpaceDesc " , 0 , - shiftUp ) ;
shiftWidget ( _storageUsedSpace , " GlobalOptions_Cloud_Container.StorageUsedSpaceLabel " , 0 , - shiftUp ) ;
shiftWidget ( _storageSyncHint , " GlobalOptions_Cloud_Container.StorageSyncHint " , 0 , - shiftUp ) ;
shiftWidget ( _storageLastSyncDesc , " GlobalOptions_Cloud_Container.StorageLastSyncDesc " , 0 , - shiftUp ) ;
shiftWidget ( _storageLastSync , " GlobalOptions_Cloud_Container.StorageLastSyncLabel " , 0 , - shiftUp ) ;
shiftWidget ( _storageSyncSavesButton , " GlobalOptions_Cloud_Container.SyncSavesButton " , 0 , - shiftUp ) ;
shiftWidget ( _storageDownloadHint , " GlobalOptions_Cloud_Container.StorageDownloadHint " , 0 , - shiftUp ) ;
shiftWidget ( _storageDownloadButton , " GlobalOptions_Cloud_Container.DownloadButton " , 0 , - shiftUp ) ;
shiftWidget ( _storageDisconnectHint , " GlobalOptions_Cloud_Container.StorageDisconnectHint " , 0 , - shiftUp - disconnectWidgetsAdditionalShift ) ;
shiftWidget ( _storageDisconnectButton , " GlobalOptions_Cloud_Container.DisconnectButton " , 0 , - shiftUp - disconnectWidgetsAdditionalShift ) ;
2019-07-18 16:10:49 +00:00
2019-07-19 10:04:44 +00:00
// there goes layout for non-connected Storage (connection wizard)
2019-07-18 16:10:49 +00:00
2019-07-19 10:55:39 +00:00
shown = ( ! shownConnectedInfo & & shown ) ;
bool wizardEnabled = ! _connectingStorage ;
if ( _storageWizardNotConnectedHint ) _storageWizardNotConnectedHint - > setVisible ( shown ) ;
if ( _storageWizardOpenLinkHint ) _storageWizardOpenLinkHint - > setVisible ( shown ) ;
if ( _storageWizardLink ) {
_storageWizardLink - > setVisible ( shown ) ;
_storageWizardLink - > setEnabled ( g_system - > hasFeature ( OSystem : : kFeatureOpenUrl ) & & wizardEnabled ) ;
}
if ( _storageWizardCodeHint ) _storageWizardCodeHint - > setVisible ( shown ) ;
if ( _storageWizardCodeBox ) {
_storageWizardCodeBox - > setVisible ( shown ) ;
_storageWizardCodeBox - > setEnabled ( wizardEnabled ) ;
}
if ( _storageWizardPasteButton ) {
_storageWizardPasteButton - > setVisible ( shown & & g_system - > hasFeature ( OSystem : : kFeatureClipboardSupport ) ) ;
_storageWizardPasteButton - > setEnabled ( wizardEnabled ) ;
}
if ( _storageWizardConnectButton ) {
_storageWizardConnectButton - > setVisible ( shown ) ;
_storageWizardConnectButton - > setEnabled ( wizardEnabled ) ;
}
if ( _storageWizardConnectionStatusHint ) {
_storageWizardConnectionStatusHint - > setVisible ( shown & & _storageWizardConnectionStatusHint - > getLabel ( ) ! = " ... " ) ;
_storageWizardConnectionStatusHint - > setEnabled ( wizardEnabled ) ;
}
2019-07-19 10:04:44 +00:00
2019-07-19 10:55:39 +00:00
if ( ! shownConnectedInfo ) {
2020-06-06 10:35:37 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.StorageDisabledHint " , x , y , w , h ) )
2019-07-19 10:04:44 +00:00
warning ( " GlobalOptions_Cloud_Container.StorageUsernameDesc's position is undefined " ) ;
shiftUp = y ;
2020-06-06 10:35:37 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint " , x , y , w , h ) )
2019-07-19 10:04:44 +00:00
warning ( " GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint's position is undefined " ) ;
shiftUp = y - shiftUp ;
shiftWidget ( _storageWizardNotConnectedHint , " GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint " , 0 , - shiftUp ) ;
shiftWidget ( _storageWizardOpenLinkHint , " GlobalOptions_Cloud_Container.StorageWizardOpenLinkHint " , 0 , - shiftUp ) ;
shiftWidget ( _storageWizardLink , " GlobalOptions_Cloud_Container.StorageWizardLink " , 0 , - shiftUp ) ;
shiftWidget ( _storageWizardCodeHint , " GlobalOptions_Cloud_Container.StorageWizardCodeHint " , 0 , - shiftUp ) ;
shiftWidget ( _storageWizardCodeBox , " GlobalOptions_Cloud_Container.StorageWizardCodeBox " , 0 , - shiftUp ) ;
shiftWidget ( _storageWizardPasteButton , " GlobalOptions_Cloud_Container.StorageWizardPasteButton " , 0 , - shiftUp ) ;
shiftWidget ( _storageWizardConnectButton , " GlobalOptions_Cloud_Container.StorageWizardConnectButton " , 0 , - shiftUp ) ;
shiftWidget ( _storageWizardConnectionStatusHint , " GlobalOptions_Cloud_Container.StorageWizardConnectionStatusHint " , 0 , - shiftUp ) ;
2016-06-09 06:41:51 +00:00
}
2019-07-19 10:04:44 +00:00
}
void GlobalOptionsDialog : : shiftWidget ( Widget * widget , const char * widgetName , int32 xOffset , int32 yOffset ) {
if ( ! widget ) return ;
2016-07-05 07:11:29 +00:00
int16 x , y ;
2020-05-09 19:04:53 +00:00
int16 w , h ;
2020-06-06 10:35:37 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( widgetName , x , y , w , h ) )
2019-07-19 10:04:44 +00:00
warning ( " %s's position is undefined " , widgetName ) ;
2016-07-05 10:31:52 +00:00
2019-07-19 10:04:44 +00:00
widget - > setPos ( x + xOffset , y + yOffset ) ;
}
# endif // USE_LIBCURL
# ifdef USE_SDL_NET
2019-07-21 13:52:16 +00:00
void GlobalOptionsDialog : : reflowNetworkTabLayout ( ) {
2016-07-05 10:31:52 +00:00
bool serverIsRunning = LocalServer . isRunning ( ) ;
2016-07-21 05:44:36 +00:00
2016-07-05 10:31:52 +00:00
if ( _runServerButton ) {
2016-07-12 16:11:07 +00:00
_runServerButton - > setVisible ( true ) ;
2020-07-01 18:01:48 +00:00
_runServerButton - > setLabel ( _ ( serverIsRunning ? " Stop server " : " Run server " ) ) ;
_runServerButton - > setTooltip ( _ ( serverIsRunning ? " Stop local webserver " : " Run local webserver " ) ) ;
2016-07-05 10:31:52 +00:00
}
if ( _serverInfoLabel ) {
2016-07-12 16:11:07 +00:00
_serverInfoLabel - > setVisible ( true ) ;
2016-07-22 12:48:46 +00:00
if ( serverIsRunning )
_serverInfoLabel - > setLabel ( LocalServer . getAddress ( ) ) ;
else
2020-07-01 18:01:48 +00:00
_serverInfoLabel - > setLabel ( _ ( " Not running " ) ) ;
2016-07-05 10:31:52 +00:00
}
2019-07-19 10:04:44 +00:00
if ( _rootPathButton ) _rootPathButton - > setVisible ( true ) ;
2019-10-14 19:11:40 +00:00
if ( _rootPath ) _rootPath - > setVisible ( true ) ;
2019-07-19 10:04:44 +00:00
if ( _rootPathClearButton ) _rootPathClearButton - > setVisible ( true ) ;
2016-07-20 09:55:30 +00:00
# ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
if ( _serverPortDesc ) {
_serverPortDesc - > setVisible ( true ) ;
_serverPortDesc - > setEnabled ( ! serverIsRunning ) ;
}
if ( _serverPort ) {
_serverPort - > setVisible ( true ) ;
_serverPort - > setEnabled ( ! serverIsRunning ) ;
}
2016-07-20 10:48:50 +00:00
if ( _serverPortClearButton ) {
_serverPortClearButton - > setVisible ( true ) ;
_serverPortClearButton - > setEnabled ( ! serverIsRunning ) ;
}
2016-10-16 22:27:59 +00:00
# else // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
2016-07-22 12:48:46 +00:00
if ( _serverPortDesc )
_serverPortDesc - > setVisible ( false ) ;
if ( _serverPort )
_serverPort - > setVisible ( false ) ;
if ( _serverPortClearButton )
_serverPortClearButton - > setVisible ( false ) ;
2016-10-16 22:27:59 +00:00
# endif // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
2019-07-19 13:06:01 +00:00
// if port override isn't supported, there will be a gap between these lines and options -- it's OK
if ( _featureDescriptionLine1 ) {
_featureDescriptionLine1 - > setVisible ( true ) ;
_featureDescriptionLine1 - > setEnabled ( false ) ;
}
if ( _featureDescriptionLine2 ) {
_featureDescriptionLine2 - > setVisible ( true ) ;
_featureDescriptionLine2 - > setEnabled ( false ) ;
}
2016-06-09 12:49:17 +00:00
}
2019-07-19 10:04:44 +00:00
# endif // USE_SDL_NET
2016-10-16 22:27:59 +00:00
2016-07-05 09:05:30 +00:00
# ifdef USE_LIBCURL
2019-07-18 16:10:49 +00:00
void GlobalOptionsDialog : : storageConnectionCallback ( Networking : : ErrorResponse response ) {
2020-06-22 17:59:25 +00:00
Common : : U32String message ( " ... " ) ;
2019-07-18 16:10:49 +00:00
if ( ! response . failed & & ! response . interrupted ) {
// success
g_system - > displayMessageOnOSD ( _ ( " Storage connected. " ) ) ;
} else {
message = _ ( " Failed to connect storage. " ) ;
if ( response . failed ) {
2020-06-13 16:42:25 +00:00
message = _ ( " Failed to connect storage: " ) + _ ( response . response . c_str ( ) ) ;
2019-07-18 16:10:49 +00:00
}
}
if ( _storageWizardConnectionStatusHint )
_storageWizardConnectionStatusHint - > setLabel ( message ) ;
2016-06-09 12:49:17 +00:00
_redrawCloudTab = true ;
2019-07-18 16:10:49 +00:00
_connectingStorage = false ;
2016-06-09 12:49:17 +00:00
}
2019-07-18 16:10:49 +00:00
void GlobalOptionsDialog : : storageSavesSyncedCallback ( Cloud : : Storage : : BoolResponse response ) {
2016-06-09 12:49:17 +00:00
_redrawCloudTab = true ;
2016-06-09 06:41:51 +00:00
}
2016-07-20 07:02:18 +00:00
void GlobalOptionsDialog : : storageErrorCallback ( Networking : : ErrorResponse response ) {
2016-07-23 06:52:27 +00:00
debug ( 9 , " GlobalOptionsDialog: error response (%s, %ld): " , ( response . failed ? " failed " : " interrupted " ) , response . httpResponseCode ) ;
debug ( 9 , " %s " , response . response . c_str ( ) ) ;
2016-07-20 07:02:18 +00:00
if ( ! response . interrupted )
g_system - > displayMessageOnOSD ( _ ( " Request failed. \n Check your Internet connection. " ) ) ;
}
2016-10-16 22:27:59 +00:00
# endif // USE_LIBCURL
# endif // USE_CLOUD
2016-06-09 06:41:51 +00:00
2022-10-01 22:11:28 +00:00
/****************************
* Shader test screen
2022-10-01 23:24:28 +00:00
*
* Based on Testcard project ( https : //sourceforge.net/projects/testcard/)
*
* Testpattern is a simple monitor test pattern generator
* Copyright 2003 Jason Giglio < jgiglio @ netmar . com >
*
* Licensed under GPLv2 +
2022-10-01 22:11:28 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
enum {
2022-10-01 23:24:28 +00:00
BLACK = 0 , WHITE , RED , GREEN , BLUE , CYAN , MAGENTA ,
YELLOW , GRAY1 , GREEN1 , GREEN2 , RED1 , BLUE1 , BLUE2 ,
YELLOW1 , RED2 , GRAY2 , GRAY3 , GRAY4 , GRAY5 , GRAY6 ,
2022-10-01 23:15:50 +00:00
TRANSCOLOR ,
2022-10-01 22:11:28 +00:00
} ;
const uint32 paletteSrc [ ] = {
2022-10-01 23:24:28 +00:00
0x000000 , 0xffffff , 0xFF0000 , 0x00FF00 , 0x0000FF , 0x00FFFF , 0xFF00FF ,
0xFFFF00 , 0x7F7F7F , 0x00C896 , 0x649632 , 0xC83264 , 0x6464FF , 0x6496FF ,
0xC86400 , 0xE10000 , 0x333333 , 0x666666 , 0x999999 , 0xCCCCCC , 0xBFBFBF ,
2022-10-01 23:15:50 +00:00
0xFE00FE ,
2022-10-01 22:11:28 +00:00
} ;
2022-10-01 23:15:50 +00:00
static void boxColor ( Graphics : : Surface & surface , int x1 , int y1 , int x2 , int y2 , int color ) {
surface . fillRect ( Common : : Rect ( x1 , y1 , x2 + 1 , y2 + 1 ) , color ) ;
}
2022-10-01 22:11:28 +00:00
static void squaremesh ( Graphics : : Surface & surface , int xres , int yres , int width , int height , int gapsize , int meshcolor , int squarecolor ) {
2022-10-01 23:18:09 +00:00
int centerx = xres / 2 ;
int centery = yres / 2 ;
2022-10-01 22:11:28 +00:00
2022-10-01 23:18:09 +00:00
boxColor ( surface , 0 , 0 , xres , yres , squarecolor ) ;
for ( int x = centerx % ( width + gapsize ) + width / 2 - ( width + gapsize ) ; x < xres ; x + = gapsize + width ) {
boxColor ( surface , x , 0 , x + gapsize - 1 , yres - 1 , meshcolor ) ;
}
for ( int y = centery % ( height + gapsize ) + height / 2 - ( height + gapsize ) ; y < yres ; y + = gapsize + height ) {
boxColor ( surface , 0 , y , xres - 1 , y + gapsize - 1 , meshcolor ) ;
}
2022-10-01 22:11:28 +00:00
}
static void frame ( Graphics : : Surface & surface , int x1 , int y1 , int x2 , int y2 , int x3 , int y3 , int x4 , int y4 , int color ) {
2022-10-01 23:18:09 +00:00
boxColor ( surface , x1 , y1 , x2 , y3 , color ) ; //top
boxColor ( surface , x1 , y4 , x2 , y2 , color ) ; //bottom
boxColor ( surface , x1 , y1 , x3 , y2 , color ) ; //left
boxColor ( surface , x4 , y1 , x2 , y2 , color ) ; //right
2022-10-01 22:11:28 +00:00
}
static void drawRow ( Graphics : : Surface & surface , int offsety , int colors [ ] , int numColors , int gap , int vsize , int xres , int offsetx ) {
2022-10-01 23:24:28 +00:00
int boxsize = ( xres - ( numColors + 1 ) * gap ) / numColors ; //-gaps between boxes
2022-10-01 23:18:09 +00:00
offsetx + = gap + 1 ;
2022-10-01 23:24:28 +00:00
for ( int x = 0 ; x < numColors ; x + + ) {
2022-10-01 23:18:09 +00:00
boxColor ( surface , offsetx , offsety , offsetx + boxsize - 1 , offsety + vsize - 1 , colors [ x ] ) ;
offsetx + = ( boxsize + gap ) ;
}
2022-10-01 22:11:28 +00:00
}
static void circleColorNoblend ( Graphics : : Surface & surface , double x , double y , double r , int color , bool invert ) {
2022-10-01 23:18:09 +00:00
int sx ;
r + = 0.49 ;
for ( sx = ( int ) round ( x - r ) ; sx < ( int ) round ( x + r ) + 1 ; sx + + ) {
double h = sqrt ( r * r - pow ( sx - x , 2 ) ) ;
if ( invert ) {
surface . vLine ( sx , 0 , - 1 + ( int ) ceil ( y - h ) , color ) ;
surface . vLine ( sx , 1 + ( int ) floor ( y + h ) , surface . h , color ) ;
} else
surface . vLine ( sx , ( int ) ceil ( y - h ) , ( int ) floor ( y + h ) , color ) ;
}
if ( invert & & sx < surface . w )
boxColor ( surface , sx , 0 , surface . w - 1 , surface . h - 1 , color ) ;
if ( invert & & ( int ) round ( x - r ) > 0 )
boxColor ( surface , 0 , 0 , - 1 + ( int ) round ( x - r ) , surface . h - 1 , color ) ;
2022-10-01 22:11:28 +00:00
}
static void blacksquareinwhitecircle ( Graphics : : Surface & surface , int x1 , int y1 , int gapsize , int rwidth , int rheight ) {
2022-10-01 23:18:09 +00:00
double c1y = y1 - ( gapsize + 1.0 ) / 2.0 ;
double c1x = x1 - ( gapsize + 1.0 ) / 2.0 ;
circleColorNoblend ( surface , c1x , c1y , rwidth * 1.5 , WHITE , false ) ;
boxColor ( surface , x1 - rwidth - gapsize , y1 - rheight - gapsize , x1 + rwidth - 1 , y1 + rheight - 1 , BLACK ) ;
boxColor ( surface , x1 - rwidth - gapsize , y1 - gapsize , x1 + rwidth - 1 , y1 - 1 , WHITE ) ;
boxColor ( surface , x1 - gapsize , y1 - rheight - gapsize , x1 - 1 , y1 + rheight - 1 , WHITE ) ;
circleColorNoblend ( surface , c1x , c1y , gapsize + 1 , WHITE , false ) ;
2022-10-01 22:11:28 +00:00
}
2022-10-02 08:24:48 +00:00
static void drawTestPattern ( ) {
int xres = 320 , yres = 240 ;
2022-10-01 15:22:24 +00:00
g_system - > beginGFXTransaction ( ) ;
g_system - > initSize ( xres , yres ) ;
g_system - > endGFXTransaction ( ) ;
2022-10-01 22:11:28 +00:00
byte palette [ ARRAYSIZE ( paletteSrc ) * 3 ] ;
for ( int i = 0 ; i < ARRAYSIZE ( paletteSrc ) ; i + + ) {
palette [ i * 3 + 0 ] = ( paletteSrc [ i ] > > 16 ) & 0xFF ;
palette [ i * 3 + 1 ] = ( paletteSrc [ i ] > > 8 ) & 0xFF ;
2022-10-01 23:18:09 +00:00
palette [ i * 3 + 2 ] = ( paletteSrc [ i ] ) & 0xFF ;
2022-10-01 22:11:28 +00:00
}
2022-10-01 15:22:24 +00:00
g_system - > getPaletteManager ( ) - > setPalette ( palette , 0 , ARRAYSIZE ( palette ) / 3 ) ;
2022-10-01 22:11:28 +00:00
Graphics : : Surface surface ;
surface . create ( xres , yres , Graphics : : PixelFormat : : createFormatCLUT8 ( ) ) ;
surface . fillRect ( Common : : Rect ( 0 , 0 , xres , yres ) , 0 ) ;
2022-10-01 23:18:09 +00:00
int squaresize = 8 ;
int gapsize = 2 ;
int width , height ;
int rwidth , rheight ;
int xsquares , ysquares ;
int xcenter = xres / 2 - xres % 2 ;
bool cont = true ;
while ( cont ) {
if ( squaresize > 8 ) {
if ( xsquares < 6 | | ysquares < 6 ) {
squaresize - = 4 ;
cont = false ;
}
}
squaresize + = 2 ;
width = xres % 2 + squaresize ;
height = yres % 2 + squaresize ;
rwidth = width + gapsize ;
rheight = height + gapsize ;
xsquares = ( xres - rwidth - gapsize - 16 ) / rwidth / 2 ;
ysquares = ( yres - rheight - gapsize - 16 ) / rheight / 2 ;
}
squaremesh ( surface , xres , yres , width , height , gapsize , WHITE , GRAY1 ) ;
int startx = xres / 2 - width / 2 - width % 2 - xsquares * rwidth - gapsize - 1 ;
int starty = yres / 2 - height / 2 - height % 2 - ysquares * rheight - gapsize - 1 ;
int endx = startx + rwidth * ( 2 * xsquares + 1 ) + gapsize + 1 ;
int endy = starty + rheight * ( 2 * ysquares + 1 ) + gapsize + 1 ;
int i ;
frame ( surface , 0 , 0 , xres , yres , 1 , 1 , xres - 2 , yres - 2 , WHITE ) ;
frame ( surface , 2 , 2 , xres - 3 , yres - 3 , startx , starty , endx , endy , BLACK ) ;
for ( i = 0 ; i < ysquares * 2 + 1 ; i + + ) {
if ( i % 2 = = 0 ) {
boxColor ( surface , 0 , starty + gapsize + i * rheight , startx - 2 , starty + gapsize + ( i + 1 ) * rheight - 1 , WHITE ) ;
boxColor ( surface , endx + 2 , starty + gapsize + i * rheight , xres - 1 , starty + gapsize + ( i + 1 ) * rheight - 1 , WHITE ) ;
}
}
for ( i = 0 ; i < xsquares * 2 + 1 ; i + + ) {
if ( i % 2 = = 0 ) {
boxColor ( surface , startx + gapsize + i * rwidth , 0 , startx + gapsize + ( i + 1 ) * rwidth - 1 , starty - 2 , WHITE ) ;
boxColor ( surface , startx + gapsize + i * rwidth , endy + 2 , startx + gapsize + ( i + 1 ) * rwidth - 1 , yres - 1 , WHITE ) ;
}
}
int monosize = 6 ;
int x1 = xres / 2 - width / 2 - width % 2 - rwidth * monosize - rwidth ; //left
int y1 = yres / 2 - height / 2 - height % 2 - rheight * ( monosize - 1 ) ; //up
int x2 = x1 + rwidth * ( monosize * 2 + 2 ) + width - 1 ; //right
int y2 = y1 + ( monosize * 2 - 1 ) * rheight - gapsize - 1 ; //bottom
if ( xsquares - 1 > monosize ) {
boxColor ( surface , x1 , y1 , x1 + width - 1 , yres / 2 , GREEN1 ) ; //up left
boxColor ( surface , x2 - width + 1 , y1 , x2 , yres / 2 , GREEN2 ) ; //up right
boxColor ( surface , x1 , yres / 2 + yres % 2 , x1 + width - 1 , y2 , RED1 ) ; //bottom left
boxColor ( surface , x2 - width + 1 , yres / 2 + yres % 2 , x2 , y2 , BLUE1 ) ; //bottom right
if ( monosize > 2 ) {
boxColor ( surface , x1 + width , y1 , x1 + rwidth + width - 1 , y1 + 2 * rheight - gapsize - 1 , BLUE2 ) ; //up left small
boxColor ( surface , x1 + width , y2 - rheight * 2 + gapsize + 1 , x1 + rwidth + width - 1 , y2 , YELLOW1 ) ; //bottom left small
boxColor ( surface , x2 - rwidth - width + 1 , y1 , x2 - width , y1 + 2 * rheight - gapsize - 1 , BLUE2 ) ; //up right small
boxColor ( surface , x2 - rwidth - width + 1 , y2 - rheight * 2 + gapsize + 1 , x2 - width , y2 , YELLOW1 ) ; //bottom right small
}
}
if ( xsquares - 4 > monosize ) {
blacksquareinwhitecircle ( surface , x1 - rwidth * 2 , y1 + rheight , gapsize , rwidth , rheight ) ;
blacksquareinwhitecircle ( surface , x2 + rwidth * 2 + gapsize + 1 , y1 + rheight , gapsize , rwidth , rheight ) ;
blacksquareinwhitecircle ( surface , x1 - rwidth * 2 , y2 - height + 1 , gapsize , rwidth , rheight ) ;
blacksquareinwhitecircle ( surface , x2 + rwidth * 2 + gapsize + 1 , y2 - height + 1 , gapsize , rwidth , rheight ) ;
}
int monoradius = monosize * rwidth + gapsize ;
2022-10-01 23:15:50 +00:00
Graphics : : Surface monoscope ;
monoscope . create ( xres , yres , Graphics : : PixelFormat : : createFormatCLUT8 ( ) ) ;
2022-10-01 22:11:28 +00:00
2022-10-01 23:18:09 +00:00
// two bottom rows
boxColor ( monoscope , x1 , y2 - rheight + gapsize / 2 + 1 , x2 , y2 + rheight + gapsize / 2 + 1 , YELLOW ) ;
boxColor ( monoscope , xcenter - rwidth / 2 , y2 - rheight + gapsize / 2 + 1 , xcenter - rwidth / 2 + rwidth , y2 + rheight + gapsize / 2 + 1 , RED2 ) ;
boxColor ( monoscope , x1 , y2 - 2 * rheight + gapsize / 2 + 1 , x2 , y2 - rheight + gapsize / 2 , WHITE ) ;
boxColor ( monoscope , xres / 2 - rwidth * 3 , y2 - 2 * rheight + gapsize / 2 + 1 , xres / 2 + rwidth * 3 , y2 - rheight + gapsize / 2 , BLACK ) ;
// two top rows
boxColor ( monoscope , x1 , y2 - 12 * rheight + gapsize / 2 + 1 , x2 , y2 - rheight * 10 + gapsize / 2 , WHITE ) ;
boxColor ( monoscope , xres / 2 - rwidth * 2 , y2 - 11 * rheight + gapsize / 2 + 1 , xres / 2 + rwidth * 2 , y2 - rheight * 10 + gapsize / 2 , BLACK ) ;
boxColor ( monoscope , x1 , y2 - 10 * rheight + gapsize / 2 + 1 , x2 , y2 - rheight * 9 + gapsize / 2 , BLACK ) ;
boxColor ( monoscope , xres / 2 - rwidth * 3 , y2 - 10 * rheight + gapsize / 2 + 1 , xres / 2 + rwidth * 3 , y2 - rheight * 9 + gapsize / 2 , WHITE ) ;
// color (gray) bars
int greyColors [ ] = { BLACK , GRAY2 , GRAY3 , GRAY4 , GRAY5 , WHITE } ;
drawRow ( monoscope , y2 - 3 * rheight + gapsize / 2 + 1 , greyColors , 6 , 0 , rheight , monosize * ( rwidth * 2 ) + 6 , xres / 2 - rwidth * monosize - 4 ) ;
boxColor ( monoscope , x1 , y2 - 6 * rheight + gapsize / 2 + 1 , x2 , y2 - 3 * rheight + gapsize / 2 , BLACK ) ;
int topColors [ ] = { YELLOW , CYAN , GREEN , MAGENTA , RED , BLUE } ;
drawRow ( monoscope , y2 - 8 * rheight + gapsize / 2 + 1 , topColors , 6 , 0 , 2 * rheight , monosize * ( rwidth * 2 ) + 6 , xres / 2 - rwidth * monosize - 4 ) ;
// periodic gray and white
int periodsize = monosize * ( rwidth * 2 ) * 11 / 16 / 6 ;
int blacksize = periodsize * 6 / 11 ;
boxColor ( monoscope , x1 , y2 - 9 * rheight + gapsize / 2 + 1 , x2 , y2 - 8 * rheight + gapsize / 2 , GRAY6 ) ;
for ( i = 0 ; i < 5 ; i + + ) {
boxColor ( monoscope , xres / 2 + i * periodsize , y2 - 9 * rheight + gapsize / 2 + 1 , xres / 2 + i * periodsize + blacksize - 1 , y2 - 8 * rheight + gapsize / 2 , BLACK ) ;
boxColor ( monoscope , xres / 2 - ( i + 1 ) * periodsize , y2 - 9 * rheight + gapsize / 2 + 1 , xres / 2 - ( i + 1 ) * periodsize + blacksize - 1 , y2 - 8 * rheight + gapsize / 2 , BLACK ) ;
}
// small lines
int xmin = xcenter - rwidth / 2 - rwidth * 4 ;
int xmax = xcenter - rwidth / 2 + rwidth * 5 ;
int step ;
int alternatingColors [ ] = { WHITE , BLACK } ;
int blackorwhite = 0 ;
for ( i = xmin ; i < xmax ; i + + ) {
step = 6 * ( xmax - i - 1 ) / ( xmax - xmin ) + 1 ;
boxColor ( monoscope , i , y2 - 5 * rheight + gapsize / 2 + 1 , i + step - 1 , y2 - 3 * rheight + gapsize / 2 , alternatingColors [ blackorwhite + + % 2 ] ) ;
i + = step - 1 ;
}
// horizontal middle part
boxColor ( monoscope , xcenter - rwidth / 2 , y2 - 7 * rheight + gapsize / 2 + 1 , xres / 2 + xres % 2 + rwidth / 2 - 1 , y2 - 4 * rheight + gapsize / 2 , BLACK ) ;
boxColor ( monoscope , xres / 2 + xres % 2 - 1 , y2 - 7 * rheight + gapsize / 2 + 1 , xres / 2 , y2 - 4 * rheight + gapsize / 2 , WHITE ) ;
boxColor ( monoscope , x1 , yres / 2 + yres % 2 - 1 , x2 , yres / 2 , WHITE ) ;
// vertical lines in the middle
for ( i = x1 - gapsize ; i < x2 + gapsize ; i + = rwidth ) {
boxColor ( monoscope , i , y2 - 6 * rheight + gapsize / 2 + 1 , i + gapsize - 1 , y2 - 5 * rheight + gapsize / 2 , WHITE ) ;
}
circleColorNoblend ( monoscope , ( xres - 1.0 ) / 2.0 , ( yres - 1.0 ) / 2.0 , 3 , WHITE , false ) ;
circleColorNoblend ( monoscope , ( xres - 1.0 ) / 2.0 , ( yres - 1.0 ) / 2.0 , monoradius , TRANSCOLOR , true ) ;
2022-10-01 22:11:28 +00:00
2022-10-01 23:15:50 +00:00
for ( int y = 0 ; y < yres ; y + + ) {
byte * src = ( byte * ) monoscope . getBasePtr ( 0 , y ) ;
byte * dst = ( byte * ) surface . getBasePtr ( 0 , y ) ;
2022-10-01 22:11:28 +00:00
2022-10-01 23:15:50 +00:00
for ( int x = 0 ; x < xres ; x + + ) {
if ( * src ! = TRANSCOLOR )
* dst = * src ;
dst + + , src + + ;
}
}
monoscope . free ( ) ;
2022-10-01 15:22:24 +00:00
2022-10-01 23:15:50 +00:00
Graphics : : AmigaFont font ;
y2 + = ( rheight - font . getFontHeight ( ) ) / 2 ;
2022-10-01 23:18:09 +00:00
font . drawString ( & surface , " ScummVM " , xres / 2 - rwidth * 2 , y2 - 11 * rheight + gapsize / 2 + 1 , rwidth * 4 , WHITE , Graphics : : kTextAlignCenter ) ;
font . drawString ( & surface , gScummVMVersion , xres / 2 - rwidth * 3 , y2 - 2 * rheight + gapsize / 2 + 1 , rwidth * 6 , WHITE ) ;
2022-10-01 23:15:50 +00:00
g_system - > copyRectToScreen ( surface . getPixels ( ) , surface . pitch , 0 , 0 , xres , yres ) ;
2022-10-01 15:22:24 +00:00
g_system - > updateScreen ( ) ;
2022-10-01 23:15:50 +00:00
surface . free ( ) ;
2022-10-01 15:22:24 +00:00
}
2022-10-01 09:52:48 +00:00
bool OptionsDialog : : testGraphicsSettings ( ) {
2022-10-02 08:24:48 +00:00
drawTestPattern ( ) ;
2022-10-01 15:22:24 +00:00
2022-10-01 09:52:48 +00:00
// And display the error
2022-10-02 08:24:48 +00:00
GUI : : CountdownMessageDialog dialog ( _ ( " A test pattern should be displayed. \n Do you want to keep these shader scalar settings? " ) ,
2022-10-01 10:42:36 +00:00
10000 ,
_ ( " Yes " ) , _ ( " No " ) , Graphics : : kTextAlignCenter ,
2022-10-01 23:29:52 +00:00
_ ( " Reverting automatically in %d seconds " ) ) ;
2022-10-01 09:52:48 +00:00
2022-10-01 14:57:25 +00:00
g_gui . displayTopDialogOnly ( true ) ;
bool retval = ( dialog . runModal ( ) = = GUI : : kMessageOK ) ;
g_gui . displayTopDialogOnly ( false ) ;
2022-10-01 23:15:50 +00:00
// Clear screen so we do not see any artefacts
g_system - > fillScreen ( BLACK ) ;
g_system - > updateScreen ( ) ;
2022-10-01 14:57:25 +00:00
return retval ;
2022-10-01 09:52:48 +00:00
}
2003-11-10 23:40:48 +00:00
} // End of namespace GUI