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
*
* 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 2
* of the License , or ( at your option ) any later version .
*
* 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
* along with this program ; if not , write to the Free Software
2005-10-18 01:30:26 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
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"
2016-10-30 18:59:47 +00:00
# include "gui/launcher.h"
2002-12-12 23:22:48 +00:00
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"
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"
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"
2016-06-09 11:00:05 +00:00
# include "gui/storagewizarddialog.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
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 ' ,
2011-10-24 18:34:10 +00:00
kThemePathClearCmd = ' clth ' ,
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 ' ,
2016-03-31 11:59:01 +00:00
kChooseThemeCmd = ' chtf ' ,
2017-02-20 02:14:51 +00:00
kUpdatesCheckCmd = ' updc ' ,
kKbdMouseSpeedChanged = ' kmsc ' ,
kJoystickDeadzoneChanged = ' jodc '
2002-12-12 23:22:48 +00:00
} ;
2010-06-15 10:48:39 +00:00
enum {
kSubtitlesSpeech ,
kSubtitlesSubs ,
kSubtitlesBoth
} ;
2016-04-10 10:52:53 +00:00
# ifdef GUI_ENABLE_KEYSDIALOG
2005-01-27 21:35:14 +00:00
enum {
kChooseKeyMappingCmd = ' chma '
} ;
# endif
2012-12-27 14:08:54 +00:00
# ifdef USE_FLUIDSYNTH
enum {
kFluidSynthSettingsCmd = ' flst '
} ;
# endif
2016-07-05 09:05:30 +00:00
# ifdef USE_CLOUD
2016-06-08 12:56:17 +00:00
enum {
2016-06-09 12:49:17 +00:00
kConfigureStorageCmd = ' cfst ' ,
2016-07-03 14:09:51 +00:00
kRefreshStorageCmd = ' rfst ' ,
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 ' ,
kRootPathClearCmd = ' clrp '
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
2010-06-15 10:44:51 +00:00
static const char * savePeriodLabels [ ] = { _s ( " Never " ) , _s ( " every 5 mins " ) , _s ( " every 10 mins " ) , _s ( " every 15 mins " ) , _s ( " every 30 mins " ) , 0 } ;
2007-02-13 21:06:45 +00:00
static const int savePeriodValues [ ] = { 0 , 5 * 60 , 10 * 60 , 15 * 60 , 30 * 60 , - 1 } ;
2014-06-20 12:41:20 +00:00
static const char * outputRateLabels [ ] = { _s ( " <default> " ) , _s ( " 8 kHz " ) , _s ( " 11 kHz " ) , _s ( " 22 kHz " ) , _s ( " 44 kHz " ) , _s ( " 48 kHz " ) , 0 } ;
2009-07-29 09:19:56 +00:00
static const int outputRateValues [ ] = { 0 , 8000 , 11025 , 22050 , 44100 , 48000 , - 1 } ;
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
2017-03-04 10:22:41 +00:00
static const char * kbdMouseSpeedLabels [ ] = { " 3 " , " 5 " , " 8 " , " 10 " , " 13 " , " 15 " , " 18 " , " 20 " , 0 } ;
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 )
2012-02-24 21:20:50 +00:00
: Dialog ( x , y , w , h ) , _domain ( domain ) , _graphicsTabId ( - 1 ) , _midiTabId ( - 1 ) , _pathsTabId ( - 1 ) , _tabWidget ( 0 ) {
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 )
2016-10-22 20:02:03 +00:00
: Dialog ( name ) , _domain ( domain ) , _graphicsTabId ( - 1 ) , _midiTabId ( - 1 ) , _pathsTabId ( - 1 ) , _tabWidget ( 0 ) {
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 ;
2017-01-31 20:44:50 +00:00
_onscreenCheckbox = 0 ;
2017-01-30 20:35:40 +00:00
_touchpadCheckbox = 0 ;
2017-02-14 15:38:44 +00:00
_swapMenuAndBackBtnsCheckbox = 0 ;
2017-02-20 02:14:51 +00:00
_kbdMouseSpeedDesc = 0 ;
_kbdMouseSpeedSlider = 0 ;
_kbdMouseSpeedLabel = 0 ;
_joystickDeadzoneDesc = 0 ;
_joystickDeadzoneSlider = 0 ;
_joystickDeadzoneLabel = 0 ;
2006-03-07 19:02:42 +00:00
_enableGraphicSettings = false ;
_gfxPopUp = 0 ;
2010-11-16 09:26:35 +00:00
_gfxPopUpDesc = 0 ;
2006-03-07 19:02:42 +00:00
_renderModePopUp = 0 ;
2010-11-16 09:26:35 +00:00
_renderModePopUpDesc = 0 ;
2006-03-07 19:02:42 +00:00
_fullscreenCheckbox = 0 ;
2016-10-12 21:32:36 +00:00
_filteringCheckbox = 0 ;
2006-03-07 19:02:42 +00:00
_aspectCheckbox = 0 ;
_enableAudioSettings = false ;
2006-04-04 22:32:43 +00:00
_midiPopUp = 0 ;
2010-11-16 09:26:35 +00:00
_midiPopUpDesc = 0 ;
2009-05-12 18:42:44 +00:00
_oplPopUp = 0 ;
2010-11-16 09:26:35 +00:00
_oplPopUpDesc = 0 ;
2007-03-10 13:39:38 +00:00
_outputRatePopUp = 0 ;
2010-11-16 09:26:35 +00:00
_outputRatePopUpDesc = 0 ;
2006-03-07 19:02:42 +00:00
_enableMIDISettings = false ;
2010-07-24 22:29:17 +00:00
_gmDevicePopUp = 0 ;
2010-11-16 09:26:35 +00:00
_gmDevicePopUpDesc = 0 ;
_soundFont = 0 ;
_soundFontButton = 0 ;
_soundFontClearButton = 0 ;
2006-03-07 19:02:42 +00:00
_multiMidiCheckbox = 0 ;
2010-11-16 09:26:35 +00:00
_midiGainDesc = 0 ;
_midiGainSlider = 0 ;
_midiGainLabel = 0 ;
2010-07-24 22:29:17 +00:00
_enableMT32Settings = false ;
2006-03-07 19:02:42 +00:00
_mt32Checkbox = 0 ;
2010-07-24 22:29:17 +00:00
_mt32DevicePopUp = 0 ;
2010-11-16 09:26:35 +00:00
_mt32DevicePopUpDesc = 0 ;
2006-03-07 19:02:42 +00:00
_enableGSCheckbox = 0 ;
_enableVolumeSettings = false ;
2006-05-13 17:30:04 +00:00
_musicVolumeDesc = 0 ;
2006-03-07 19:02:42 +00:00
_musicVolumeSlider = 0 ;
_musicVolumeLabel = 0 ;
2006-05-13 17:30:04 +00:00
_sfxVolumeDesc = 0 ;
2006-03-07 19:02:42 +00:00
_sfxVolumeSlider = 0 ;
_sfxVolumeLabel = 0 ;
2006-05-13 17:30:04 +00:00
_speechVolumeDesc = 0 ;
2006-03-07 19:02:42 +00:00
_speechVolumeSlider = 0 ;
_speechVolumeLabel = 0 ;
2009-06-06 17:36:06 +00:00
_muteCheckbox = 0 ;
2016-06-01 09:18:17 +00:00
_enableSubtitleSettings = false ;
2006-05-13 17:30:04 +00:00
_subToggleDesc = 0 ;
2010-06-15 11:32:08 +00:00
_subToggleGroup = 0 ;
2010-06-15 10:48:39 +00:00
_subToggleSubOnly = 0 ;
_subToggleSpeechOnly = 0 ;
_subToggleSubBoth = 0 ;
2006-05-13 17:30:04 +00:00
_subSpeedDesc = 0 ;
_subSpeedSlider = 0 ;
_subSpeedLabel = 0 ;
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 : : kFeatureOnScreenControl ) ) {
if ( ConfMan . hasKey ( " onscreen_control " , _domain ) ) {
bool onscreenState = g_system - > getFeatureState ( OSystem : : kFeatureOnScreenControl ) ;
if ( _onscreenCheckbox ! = 0 )
_onscreenCheckbox - > setState ( onscreenState ) ;
}
2017-01-31 20:44:50 +00:00
}
2017-02-14 13:13:58 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureTouchpadMode ) ) {
if ( ConfMan . hasKey ( " touchpad_mouse_mode " , _domain ) ) {
bool touchpadState = g_system - > getFeatureState ( OSystem : : kFeatureTouchpadMode ) ;
if ( _touchpadCheckbox ! = 0 )
_touchpadCheckbox - > setState ( touchpadState ) ;
}
2017-01-30 20:35:40 +00:00
}
2017-02-14 15:38:44 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureSwapMenuAndBackButtons ) ) {
2017-02-18 16:02:46 +00:00
if ( ConfMan . hasKey ( " swap_menu_and_back_buttons " , _domain ) ) {
2017-02-14 15:38:44 +00:00
bool state = g_system - > getFeatureState ( OSystem : : kFeatureSwapMenuAndBackButtons ) ;
if ( _swapMenuAndBackBtnsCheckbox ! = 0 )
_swapMenuAndBackBtnsCheckbox - > setState ( state ) ;
}
}
2017-02-20 02:14:51 +00:00
if ( g_system - > hasFeature ( OSystem : : kFeatureKbdMouseSpeed ) ) {
if ( ConfMan . hasKey ( " kbdmouse_speed " , _domain ) ) {
int value = ConfMan . getInt ( " kbdmouse_speed " , _domain ) ;
2017-02-27 22:19:05 +00:00
if ( _kbdMouseSpeedSlider & & value < ARRAYSIZE ( kbdMouseSpeedLabels ) - 1 & & value > = 0 ) {
2017-02-20 02:14:51 +00:00
_kbdMouseSpeedSlider - > setValue ( value ) ;
2017-02-26 17:17:41 +00:00
_kbdMouseSpeedLabel - > setLabel ( _ ( kbdMouseSpeedLabels [ value ] ) ) ;
2017-02-20 02:14:51 +00:00
}
}
}
if ( g_system - > hasFeature ( OSystem : : kFeatureJoystickDeadzone ) ) {
if ( ConfMan . hasKey ( " joystick_deadzone " , _domain ) ) {
int value = ConfMan . getInt ( " joystick_deadzone " , _domain ) ;
if ( _joystickDeadzoneSlider ! = 0 ) {
_joystickDeadzoneSlider - > setValue ( value ) ;
_joystickDeadzoneLabel - > setValue ( value ) ;
}
}
}
2009-06-06 17:58:08 +00:00
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
}
2016-04-10 10:52:53 +00:00
# ifdef GUI_ONLY_FULLSCREEN
2008-12-16 22:54:38 +00:00
_fullscreenCheckbox - > setState ( true ) ;
_fullscreenCheckbox - > setEnabled ( false ) ;
2016-04-10 10:52:53 +00:00
# else // !GUI_ONLY_FULLSCREEN
2003-11-07 16:01:51 +00:00
// Fullscreen setting
2004-03-15 02:28:47 +00:00
_fullscreenCheckbox - > setState ( ConfMan . getBool ( " fullscreen " , _domain ) ) ;
2016-10-09 09:05:01 +00:00
# endif // GUI_ONLY_FULLSCREEN
2005-07-30 21:11:48 +00:00
2016-10-12 21:32:36 +00:00
// Filtering setting
if ( g_system - > hasFeature ( OSystem : : kFeatureFilteringMode ) )
_filteringCheckbox - > setState ( ConfMan . getBool ( " filtering " , _domain ) ) ;
else
_filteringCheckbox - > setVisible ( false ) ;
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
2003-11-05 12:25:42 +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
2007-03-10 13:39:38 +00:00
if ( _outputRatePopUp ) {
_outputRatePopUp - > setSelected ( 1 ) ;
int value = ConfMan . getInt ( " output_rate " , _domain ) ;
for ( int i = 0 ; outputRateLabels [ i ] ; i + + ) {
if ( value = = outputRateValues [ i ] )
_outputRatePopUp - > setSelected ( i ) ;
}
}
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 ) ) ;
2003-11-08 23:22:16 +00:00
2010-04-06 09:26:59 +00:00
Common : : String soundFont ( ConfMan . get ( " soundfont " , _domain ) ) ;
2007-02-13 21:41:49 +00:00
if ( soundFont . empty ( ) | | ! ConfMan . hasKey ( " soundfont " , _domain ) ) {
2010-08-23 19:45:14 +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 ) ) ;
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 ) ) ;
// GS extensions setting
_enableGSCheckbox - > setState ( ConfMan . getBool ( " enable_gs " , _domain ) ) ;
}
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 ) ;
delete w ;
}
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 ) ;
setFocusWidget ( _firstWidget ) ;
}
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 ) {
if ( ConfMan . getBool ( " filtering " , _domain ) ! = _filteringCheckbox - > getState ( ) )
graphicsModeChanged = true ;
if ( ConfMan . getBool ( " fullscreen " , _domain ) ! = _fullscreenCheckbox - > getState ( ) )
graphicsModeChanged = true ;
if ( ConfMan . getBool ( " aspect_ratio " , _domain ) ! = _aspectCheckbox - > getState ( ) )
graphicsModeChanged = true ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
ConfMan . setBool ( " filtering " , _filteringCheckbox - > getState ( ) , _domain ) ;
ConfMan . setBool ( " fullscreen " , _fullscreenCheckbox - > getState ( ) , _domain ) ;
ConfMan . setBool ( " aspect_ratio " , _aspectCheckbox - > getState ( ) , _domain ) ;
2017-03-04 10:22:41 +00:00
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 ( ) ) {
if ( ConfMan . get ( " gfx_mode " , _domain ) ! = gm - > name )
graphicsModeChanged = true ;
ConfMan . set ( " gfx_mode " , gm - > name , _domain ) ;
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
}
2016-10-30 15:43:14 +00:00
if ( ! isSet )
ConfMan . removeKey ( " gfx_mode " , _domain ) ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
if ( ( int32 ) _renderModePopUp - > getSelectedTag ( ) > = 0 )
ConfMan . set ( " render_mode " , Common : : getRenderModeCode ( ( Common : : RenderMode ) _renderModePopUp - > getSelectedTag ( ) ) , _domain ) ;
} else {
ConfMan . removeKey ( " fullscreen " , _domain ) ;
ConfMan . removeKey ( " filtering " , _domain ) ;
ConfMan . removeKey ( " aspect_ratio " , _domain ) ;
ConfMan . removeKey ( " gfx_mode " , _domain ) ;
ConfMan . removeKey ( " render_mode " , _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
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 ( ) ) ;
2017-03-04 10:22: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 ) ) ;
2017-03-04 10:22:41 +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.
//
// This fixes bug #3303501 "Switching from HQ2x->HQ3x crashes ScummVM"
//
// 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.
Common : : String 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
}
2016-10-30 15:43:14 +00:00
message + = " \n " ;
message + = _ ( " the video 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 ) ;
message + = " \n " ;
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 ) ;
message + = " \n " ;
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 ) ;
message + = " \n " ;
message + = _ ( " the filtering setting could not be changed " ) ;
2010-06-28 23:41:43 +00:00
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
// And display the error
GUI : : MessageDialog dialog ( message ) ;
dialog . runModal ( ) ;
2010-06-27 16:58:06 +00:00
}
2016-10-30 15:43:14 +00:00
}
2017-02-26 17:17:41 +00:00
// Control options
if ( _enableControlSettings ) {
if ( g_system - > hasFeature ( OSystem : : kFeatureOnScreenControl ) ) {
if ( ConfMan . getBool ( " onscreen_control " , _domain ) ! = _onscreenCheckbox - > getState ( ) ) {
g_system - > setFeatureState ( OSystem : : kFeatureOnScreenControl , _onscreenCheckbox - > getState ( ) ) ;
}
}
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 : : kFeatureSwapMenuAndBackButtons ) ) {
if ( ConfMan . getBool ( " swap_menu_and_back_buttons " , _domain ) ! = _swapMenuAndBackBtnsCheckbox - > getState ( ) ) {
g_system - > setFeatureState ( OSystem : : kFeatureSwapMenuAndBackButtons , _swapMenuAndBackBtnsCheckbox - > 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
2016-10-30 15:43:14 +00:00
if ( ed )
ConfMan . set ( " opl_driver " , ed - > name , _domain ) ;
else
2009-05-12 18:42:44 +00:00
ConfMan . removeKey ( " opl_driver " , _domain ) ;
2016-10-30 15:43:14 +00:00
} else {
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
if ( _outputRatePopUp ) {
if ( _enableAudioSettings ) {
if ( _outputRatePopUp - > getSelectedTag ( ) ! = 0 )
ConfMan . setInt ( " output_rate " , _outputRatePopUp - > getSelectedTag ( ) , _domain ) ;
else
2007-03-10 13:39:38 +00:00
ConfMan . removeKey ( " output_rate " , _domain ) ;
2016-10-30 15:43:14 +00:00
} else {
ConfMan . removeKey ( " output_rate " , _domain ) ;
2007-03-10 13:39:38 +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
2016-10-30 15:43:14 +00:00
ConfMan . setBool ( " multi_midi " , _multiMidiCheckbox - > getState ( ) , _domain ) ;
ConfMan . setInt ( " midi_gain " , _midiGainSlider - > getValue ( ) , _domain ) ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
Common : : String soundFont ( _soundFont - > getLabel ( ) ) ;
if ( ! soundFont . empty ( ) & & ( soundFont ! = _c ( " None " , " soundfont " ) ) )
ConfMan . set ( " soundfont " , soundFont , _domain ) ;
else
2006-04-16 18:17:53 +00:00
ConfMan . removeKey ( " soundfont " , _domain ) ;
2016-10-30 15:43:14 +00:00
} else {
ConfMan . removeKey ( " gm_device " , _domain ) ;
ConfMan . removeKey ( " multi_midi " , _domain ) ;
ConfMan . removeKey ( " midi_gain " , _domain ) ;
ConfMan . removeKey ( " soundfont " , _domain ) ;
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 ) ;
ConfMan . setBool ( " enable_gs " , _enableGSCheckbox - > getState ( ) , _domain ) ;
} else {
ConfMan . removeKey ( " mt32_device " , _domain ) ;
ConfMan . removeKey ( " native_mt32 " , _domain ) ;
ConfMan . removeKey ( " enable_gs " , _domain ) ;
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 ) {
bool subtitles , speech_mute ;
int talkspeed ;
int sliderMaxValue = _subSpeedSlider - > getMaxValue ( ) ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
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 ;
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
ConfMan . setBool ( " subtitles " , subtitles , _domain ) ;
ConfMan . setBool ( " speech_mute " , 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)
talkspeed = ( _subSpeedSlider - > getValue ( ) * 255 + sliderMaxValue / 2 ) / sliderMaxValue ;
ConfMan . setInt ( " talkspeed " , talkspeed , _domain ) ;
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
} else {
ConfMan . removeKey ( " subtitles " , _domain ) ;
ConfMan . removeKey ( " talkspeed " , _domain ) ;
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 ( ) {
if ( getResult ( ) )
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 ) {
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 ) ) ;
2006-06-11 20:51:14 +00:00
_midiGainLabel - > draw ( ) ;
break ;
2017-01-26 02:36:42 +00:00
case kMusicVolumeChanged : {
const int newValue = _musicVolumeSlider - > getValue ( ) ;
_musicVolumeLabel - > setValue ( newValue ) ;
2003-11-05 12:25:42 +00:00
_musicVolumeLabel - > draw ( ) ;
2017-01-26 02:36:42 +00:00
if ( _guioptions . contains ( GUIO_LINKMUSICTOSFX ) ) {
updateSfxVolume ( newValue ) ;
if ( _guioptions . contains ( GUIO_LINKSPEECHTOSFX ) ) {
updateSpeechVolume ( newValue ) ;
}
}
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 ( ) ) ;
_sfxVolumeLabel - > draw ( ) ;
2017-01-26 02:36:42 +00:00
if ( _guioptions . contains ( GUIO_LINKMUSICTOSFX ) ) {
updateMusicVolume ( newValue ) ;
}
if ( _guioptions . contains ( GUIO_LINKSPEECHTOSFX ) ) {
updateSpeechVolume ( newValue ) ;
}
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 ) ;
2004-04-06 11:50:35 +00:00
_speechVolumeLabel - > draw ( ) ;
2017-01-26 02:36:42 +00:00
if ( _guioptions . contains ( GUIO_LINKSPEECHTOSFX ) ) {
updateSfxVolume ( newValue ) ;
if ( _guioptions . contains ( GUIO_LINKMUSICTOSFX ) ) {
updateMusicVolume ( newValue ) ;
}
}
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 ( ) ) ;
_subSpeedLabel - > draw ( ) ;
break ;
2009-01-14 18:17:19 +00:00
case kClearSoundFontCmd :
2010-08-23 19:45:14 +00:00
_soundFont - > setLabel ( _c ( " None " , " soundfont " ) ) ;
2009-01-14 18:17:19 +00:00
_soundFontClearButton - > setEnabled ( false ) ;
draw ( ) ;
break ;
2017-02-20 02:14:51 +00:00
case kKbdMouseSpeedChanged :
2017-03-04 10:22:41 +00:00
_kbdMouseSpeedLabel - > setLabel ( _ ( kbdMouseSpeedLabels [ _kbdMouseSpeedSlider - > getValue ( ) ] ) ) ;
2017-02-20 02:14:51 +00:00
_kbdMouseSpeedLabel - > draw ( ) ;
break ;
case kJoystickDeadzoneChanged :
_joystickDeadzoneLabel - > setValue ( _joystickDeadzoneSlider - > getValue ( ) ) ;
_joystickDeadzoneLabel - > draw ( ) ;
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
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 ) ;
2016-10-12 21:32:36 +00:00
_filteringCheckbox - > setEnabled ( enabled ) ;
2016-04-10 10:52:53 +00:00
# ifndef GUI_ENABLE_KEYSDIALOG
2003-11-07 16:01:51 +00:00
_fullscreenCheckbox - > setEnabled ( enabled ) ;
2011-10-23 19:44:39 +00:00
if ( _guioptions . contains ( GUIO_NOASPECT ) )
_aspectCheckbox - > setEnabled ( false ) ;
else
_aspectCheckbox - > setEnabled ( enabled ) ;
2004-01-26 07:36:47 +00:00
# endif
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 ) ;
bool hasMidiDefined = ( strpbrk ( _guioptions . c_str ( ) , allFlags . c_str ( ) ) ! = NULL ) ;
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 ) ;
}
2009-06-06 17:52:44 +00:00
_outputRatePopUpDesc - > setEnabled ( enabled ) ;
2007-03-10 13:39:38 +00:00
_outputRatePopUp - > 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 ;
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 ) {
// Show On-Screen control
if ( g_system - > hasFeature ( OSystem : : kFeatureOnScreenControl ) )
_onscreenCheckbox = new CheckboxWidget ( boss , prefix + " grOnScreenCheckbox " , _ ( " Show On-screen control " ) ) ;
2017-03-04 10:22:41 +00:00
2017-02-20 02:14:51 +00:00
// Touchpad Mouse mode
if ( g_system - > hasFeature ( OSystem : : kFeatureTouchpadMode ) )
_touchpadCheckbox = new CheckboxWidget ( boss , prefix + " grTouchpadCheckbox " , _ ( " Touchpad mouse mode " ) ) ;
// Swap menu and back buttons
if ( g_system - > hasFeature ( OSystem : : kFeatureSwapMenuAndBackButtons ) )
_swapMenuAndBackBtnsCheckbox = new CheckboxWidget ( boss , prefix + " grSwapMenuAndBackBtnsCheckbox " , _ ( " Swap Menu and Back buttons " ) ) ;
// Keyboard and joystick mouse speed
if ( g_system - > hasFeature ( OSystem : : kFeatureKbdMouseSpeed ) ) {
if ( g_system - > getOverlayWidth ( ) > 320 )
2017-02-26 17:17:41 +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
2017-02-26 17:17:41 +00:00
_kbdMouseSpeedDesc = new StaticTextWidget ( boss , prefix + " grKbdMouseSpeedDesc " , _c ( " Pointer Speed: " , " lowres " ) , _ ( " Speed for keyboard/joystick mouse pointer control " ) ) ;
_kbdMouseSpeedSlider = new SliderWidget ( boss , prefix + " grKbdMouseSpeedSlider " , _ ( " Speed for keyboard/joystick mouse pointer control " ) , kKbdMouseSpeedChanged ) ;
2017-02-20 02:14:51 +00:00
_kbdMouseSpeedLabel = new StaticTextWidget ( boss , prefix + " grKbdMouseSpeedLabel " , " " ) ;
_kbdMouseSpeedSlider - > setMinValue ( 0 ) ;
_kbdMouseSpeedSlider - > setMaxValue ( 7 ) ;
_kbdMouseSpeedLabel - > setFlags ( WIDGET_CLEARBG ) ;
}
// Joystick deadzone
if ( g_system - > hasFeature ( OSystem : : kFeatureJoystickDeadzone ) ) {
if ( g_system - > getOverlayWidth ( ) > 320 )
2017-02-26 17:17:41 +00:00
_joystickDeadzoneDesc = new StaticTextWidget ( boss , prefix + " grJoystickDeadzoneDesc " , _ ( " Joy Deadzone: " ) , _ ( " Analog joystick Deadzone " ) ) ;
2017-02-20 02:14:51 +00:00
else
2017-02-26 17:17:41 +00:00
_joystickDeadzoneDesc = new StaticTextWidget ( boss , prefix + " grJoystickDeadzoneDesc " , _c ( " Joy Deadzone: " , " lowres " ) , _ ( " Analog joystick Deadzone " ) ) ;
_joystickDeadzoneSlider = new SliderWidget ( boss , prefix + " grJoystickDeadzoneSlider " , _ ( " Analog joystick Deadzone " ) , kJoystickDeadzoneChanged ) ;
2017-02-20 02:14:51 +00:00
_joystickDeadzoneLabel = new StaticTextWidget ( boss , prefix + " grJoystickDeadzoneLabel " , " " ) ;
_joystickDeadzoneSlider - > setMinValue ( 1 ) ;
_joystickDeadzoneSlider - > setMaxValue ( 10 ) ;
_joystickDeadzoneLabel - > setFlags ( WIDGET_CLEARBG ) ;
}
_enableControlSettings = true ;
}
2006-05-13 17:30:04 +00:00
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
2010-06-15 10:44:51 +00:00
_gfxPopUpDesc = new StaticTextWidget ( boss , prefix + " grModePopupDesc " , _ ( " Graphics mode: " ) ) ;
2009-06-06 17:52:44 +00:00
_gfxPopUp = new PopUpWidget ( boss , prefix + " grModePopup " ) ;
2003-11-03 05:27:53 +00:00
2010-06-15 10:44:51 +00:00
_gfxPopUp - > appendEntry ( _ ( " <default> " ) ) ;
2003-11-05 01:15:10 +00:00
_gfxPopUp - > appendEntry ( " " ) ;
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 ( ) ;
2012-02-19 15:26:09 +00:00
bool renderingTypeDefined = ( strpbrk ( _guioptions . c_str ( ) , allFlags . c_str ( ) ) ! = NULL ) ;
2010-06-15 10:53:30 +00:00
_renderModePopUpDesc = new StaticTextWidget ( boss , prefix + " grRenderPopupDesc " , _ ( " Render mode: " ) , _ ( " Special dithering modes supported by some games " ) ) ;
_renderModePopUp = new PopUpWidget ( boss , prefix + " grRenderPopup " , _ ( " Special dithering modes supported by some games " ) ) ;
2010-06-15 10:44:51 +00:00
_renderModePopUp - > appendEntry ( _ ( " <default> " ) , Common : : kRenderDefault ) ;
2005-02-20 00:17:22 +00:00
_renderModePopUp - > appendEntry ( " " ) ;
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
}
2003-11-05 12:25:42 +00:00
// Fullscreen checkbox
2010-06-15 10:47:31 +00:00
_fullscreenCheckbox = new CheckboxWidget ( boss , prefix + " grFullscreenCheckbox " , _ ( " Fullscreen mode " ) ) ;
2016-10-17 16:45:12 +00:00
2016-10-12 21:32:36 +00:00
// Filtering checkbox
_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
2010-06-15 10:53:30 +00:00
_aspectCheckbox = new CheckboxWidget ( boss , prefix + " grAspectCheckbox " , _ ( " Aspect ratio correction " ) , _ ( " Correct aspect ratio for 320x200 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
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 )
_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 " ) ) ;
else
2010-10-12 00:26:17 +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 ) ;
bool hasMidiDefined = ( strpbrk ( _guioptions . c_str ( ) , allFlags . c_str ( ) ) ! = NULL ) ;
2010-06-21 21:36:36 +00:00
const MusicPlugin : : List p = MusicMan . getPlugins ( ) ;
2010-07-04 18:00:46 +00:00
for ( MusicPlugin : : List : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
2010-06-21 21:36:36 +00:00
MusicDevices i = ( * * m ) - > 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
2010-08-11 18:54:56 +00:00
if ( ( _domain = = Common : : ConfigManager : : kApplicationDomain & & d - > getMusicType ( ) ! = MT_TOWNS // global dialog - skip useless FM-Towns, C64, Amiga, AppleIIGS options there
2010-10-24 19:15:17 +00:00
& & d - > getMusicType ( ) ! = MT_C64 & & d - > getMusicType ( ) ! = MT_AMIGA & & d - > getMusicType ( ) ! = MT_APPLEIIGS & & d - > getMusicType ( ) ! = MT_PC98 )
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
_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
2010-06-15 10:53:30 +00:00
_oplPopUpDesc = new StaticTextWidget ( boss , prefix + " auOPLPopupDesc " , _ ( " AdLib emulator: " ) , _ ( " AdLib is used for music in many games " ) ) ;
_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 ) {
2010-06-15 10:44:51 +00:00
_oplPopUp - > appendEntry ( _ ( ed - > description ) , ed - > id ) ;
2009-05-12 18:42:44 +00:00
+ + ed ;
}
2007-03-10 13:39:38 +00:00
// Sample rate settings
2010-06-15 10:53:30 +00:00
_outputRatePopUpDesc = new StaticTextWidget ( boss , prefix + " auSampleRatePopupDesc " , _ ( " Output rate: " ) , _ ( " Higher value specifies better sound quality but may be not supported by your soundcard " ) ) ;
_outputRatePopUp = new PopUpWidget ( boss , prefix + " auSampleRatePopup " , _ ( " Higher value specifies better sound quality but may be not supported by your soundcard " ) ) ;
2007-03-10 13:39:38 +00:00
for ( int i = 0 ; outputRateLabels [ i ] ; i + + ) {
2010-06-15 10:44:51 +00:00
_outputRatePopUp - > appendEntry ( _ ( outputRateLabels [ i ] ) , outputRateValues [ i ] ) ;
2007-03-10 13:39:38 +00:00
}
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 ) {
2010-07-24 22:29:17 +00:00
_gmDevicePopUpDesc = new StaticTextWidget ( boss , prefix + " auPrefGmPopupDesc " , _ ( " GM Device: " ) , _ ( " Specifies default sound device for General MIDI output " ) ) ;
_gmDevicePopUp = new PopUpWidget ( boss , prefix + " auPrefGmPopup " ) ;
// Populate
const MusicPlugin : : List 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.
2010-07-24 22:29:17 +00:00
for ( MusicPlugin : : List : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
MusicDevices i = ( * * m ) - > getDevices ( ) ;
for ( MusicDevices : : iterator d = i . begin ( ) ; d ! = i . end ( ) ; + + d ) {
2010-10-24 19:15:17 +00:00
if ( d - > getMusicDriverId ( ) = = " null " )
_gmDevicePopUp - > appendEntry ( _ ( " Don't use General MIDI music " ) , d - > getHandle ( ) ) ;
}
}
// Now we add the other devices.
for ( MusicPlugin : : List : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
MusicDevices i = ( * * m ) - > getDevices ( ) ;
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 " ) {
_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 )
2014-06-29 14:34:40 +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
2014-06-29 14:34:40 +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
2010-06-15 10:53:30 +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)
2010-06-15 10:44:51 +00:00
_midiGainDesc = new StaticTextWidget ( boss , prefix + " mcMidiGainText " , _ ( " MIDI gain: " ) ) ;
2010-06-15 10:52:35 +00:00
_midiGainSlider = new SliderWidget ( boss , prefix + " mcMidiGainSlider " , 0 , kMidiGainChanged ) ;
2006-06-11 20:51:14 +00:00
_midiGainSlider - > setMinValue ( 0 ) ;
_midiGainSlider - > setMaxValue ( 1000 ) ;
_midiGainLabel = new StaticTextWidget ( boss , prefix + " mcMidiGainLabel " , " 1.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 ) {
_mt32DevicePopUpDesc = new StaticTextWidget ( boss , prefix + " auPrefMt32PopupDesc " , _ ( " MT-32 Device: " ) , _ ( " Specifies default sound device for Roland MT-32/LAPC1/CM32l/CM64 output " ) ) ;
_mt32DevicePopUp = new PopUpWidget ( boss , prefix + " auPrefMt32Popup " ) ;
// Native mt32 setting
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
_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 " ) ) ;
else
2010-10-12 00:26:17 +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
2013-03-23 19:50:58 +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
const MusicPlugin : : List 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.
for ( MusicPlugin : : List : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
2011-06-19 22:59:48 +00:00
MusicDevices i = ( * * m ) - > getDevices ( ) ;
2010-10-24 19:15:17 +00:00
for ( MusicDevices : : iterator d = i . begin ( ) ; d ! = i . end ( ) ; + + d ) {
if ( d - > getMusicDriverId ( ) = = " null " )
_mt32DevicePopUp - > appendEntry ( _ ( " Don't use Roland MT-32 music " ) , d - > getHandle ( ) ) ;
}
}
// Now we add the other devices.
2010-07-24 22:29:17 +00:00
for ( MusicPlugin : : List : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
MusicDevices i = ( * * m ) - > getDevices ( ) ;
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 " )
_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 ) ;
}
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 ) {
2010-08-30 22:24:40 +00:00
_subToggleDesc = new StaticTextWidget ( boss , prefix + " subToggleDesc " , _ ( " Text and Speech: " ) ) ;
2010-06-15 10:48:39 +00:00
_subToggleGroup = new RadiobuttonGroup ( boss , kSubtitleToggle ) ;
_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
2010-08-30 22:24:40 +00:00
_subSpeedDesc = new StaticTextWidget ( boss , prefix + " subSubtitleSpeedDesc " , _ ( " Subtitle speed: " ) ) ;
2010-06-15 10:48:39 +00:00
} else {
2010-08-30 22:24:40 +00:00
_subToggleDesc = new StaticTextWidget ( boss , prefix + " subToggleDesc " , _c ( " Text and Speech: " , " lowres " ) ) ;
2010-06-15 10:48:39 +00:00
_subToggleGroup = new RadiobuttonGroup ( boss , kSubtitleToggle ) ;
2010-06-15 10:53:30 +00:00
_subToggleSpeechOnly = new RadiobuttonWidget ( boss , prefix + " subToggleSpeechOnly " , _subToggleGroup , kSubtitlesSpeech , _ ( " Spch " ) , _ ( " Speech " ) ) ;
_subToggleSubOnly = new RadiobuttonWidget ( boss , prefix + " subToggleSubOnly " , _subToggleGroup , kSubtitlesSubs , _ ( " Subs " ) , _ ( " Subtitles " ) ) ;
2010-08-30 22:24:40 +00:00
_subToggleSubBoth = new RadiobuttonWidget ( boss , prefix + " subToggleSubBoth " , _subToggleGroup , kSubtitlesBoth , _c ( " Both " , " lowres " ) , _ ( " Show subtitles and play speech " ) ) ;
2010-10-12 02:18:11 +00:00
2010-08-30 22:24:40 +00:00
_subSpeedDesc = new StaticTextWidget ( boss , prefix + " subSubtitleSpeedDesc " , _c ( " Subtitle speed: " , " lowres " ) ) ;
2010-06-15 10:48:39 +00:00
}
2006-05-13 17:30:04 +00:00
// Subtitle speed
2010-06-15 10:52:35 +00:00
_subSpeedSlider = new SliderWidget ( boss , prefix + " subSubtitleSpeedSlider " , 0 , kSubtitleSpeedChanged ) ;
2006-05-13 17:30:04 +00:00
_subSpeedLabel = new StaticTextWidget ( boss , prefix + " subSubtitleSpeedLabel " , " 100% " ) ;
_subSpeedSlider - > setMinValue ( 0 ) ; _subSpeedSlider - > setMaxValue ( maxSliderVal ) ;
_subSpeedLabel - > setFlags ( WIDGET_CLEARBG ) ;
_enableSubtitleSettings = true ;
}
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 )
_musicVolumeDesc = new StaticTextWidget ( boss , prefix + " vcMusicText " , _ ( " Music volume: " ) ) ;
else
_musicVolumeDesc = new StaticTextWidget ( boss , prefix + " vcMusicText " , _c ( " Music volume: " , " lowres " ) ) ;
2010-06-15 10:52:35 +00:00
_musicVolumeSlider = new SliderWidget ( boss , prefix + " vcMusicSlider " , 0 , kMusicVolumeChanged ) ;
2006-03-24 01:24:26 +00:00
_musicVolumeLabel = new StaticTextWidget ( boss , prefix + " vcMusicLabel " , " 100% " ) ;
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
2010-06-15 10:52:35 +00:00
_muteCheckbox = new CheckboxWidget ( boss , prefix + " vcMuteCheckbox " , _ ( " Mute All " ) , 0 , kMuteAllChanged ) ;
2009-06-06 17:36:06 +00:00
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
_sfxVolumeDesc = new StaticTextWidget ( boss , prefix + " vcSfxText " , _ ( " SFX volume: " ) , _ ( " Special sound effects volume " ) ) ;
else
_sfxVolumeDesc = new StaticTextWidget ( boss , prefix + " vcSfxText " , _c ( " SFX volume: " , " lowres " ) , _ ( " Special sound effects volume " ) ) ;
2010-06-15 10:53:30 +00:00
_sfxVolumeSlider = new SliderWidget ( boss , prefix + " vcSfxSlider " , _ ( " Special sound effects volume " ) , kSfxVolumeChanged ) ;
2006-03-24 01:24:26 +00:00
_sfxVolumeLabel = new StaticTextWidget ( boss , prefix + " vcSfxLabel " , " 100% " ) ;
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 )
_speechVolumeDesc = new StaticTextWidget ( boss , prefix + " vcSpeechText " , _ ( " Speech volume: " ) ) ;
else
_speechVolumeDesc = new StaticTextWidget ( boss , prefix + " vcSpeechText " , _c ( " Speech volume: " , " lowres " ) ) ;
2010-06-15 10:52:35 +00:00
_speechVolumeSlider = new SliderWidget ( boss , prefix + " vcSpeechSlider " , 0 , kSpeechVolumeChanged ) ;
2006-03-24 01:24:26 +00:00
_speechVolumeLabel = new StaticTextWidget ( boss , prefix + " vcSpeechLabel " , " 100% " ) ;
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
}
2012-02-27 20:50:01 +00:00
void OptionsDialog : : addEngineControls ( GuiObject * boss , const Common : : String & prefix , const ExtraGuiOptions & engineOptions ) {
// Note: up to 7 engine options can currently fit on screen (the most that
// can fit in a 320x200 screen with the classic theme).
// TODO: Increase this number by including the checkboxes inside a scroll
// widget. The appropriate number of checkboxes will need to be added to
// the theme files.
uint i = 1 ;
ExtraGuiOptions : : const_iterator iter ;
for ( iter = engineOptions . begin ( ) ; iter ! = engineOptions . end ( ) ; + + iter , + + i ) {
Common : : String id = Common : : String : : format ( " %d " , i ) ;
2012-09-26 02:17:31 +00:00
_engineCheckboxes . push_back ( new CheckboxWidget ( boss ,
2012-02-27 20:50:01 +00:00
prefix + " customOption " + id + " Checkbox " , _ ( iter - > label ) , _ ( iter - > tooltip ) ) ) ;
}
}
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 ) {
2010-07-21 18:17:51 +00:00
const Common : : String drv = ConfMan . get ( setting , ( _domain ! = Common : : ConfigManager : : kApplicationDomain & & ! ConfMan . hasKey ( setting , _domain ) ) ? Common : : ConfigManager : : kApplicationDomain : _domain ) ;
2010-06-21 21:36:36 +00:00
const MusicPlugin : : List p = MusicMan . getPlugins ( ) ;
2010-07-04 18:00:46 +00:00
2010-07-04 18:24:13 +00:00
for ( MusicPlugin : : List : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) ; + + m ) {
2010-06-21 21:36:36 +00:00
MusicDevices i = ( * * m ) - > 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
2010-06-21 21:36:36 +00:00
const MusicPlugin : : List p = MusicMan . getPlugins ( ) ;
bool found = false ;
2010-07-04 18:00:46 +00:00
for ( MusicPlugin : : List : : const_iterator m = p . begin ( ) ; m ! = p . end ( ) & & ! found ; + + m ) {
2010-06-21 21:36:36 +00:00
MusicDevices i = ( * * m ) - > 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 ( ) ) {
2010-06-21 21:36:36 +00:00
ConfMan . set ( setting , d - > getCompleteId ( ) , _domain ) ;
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 ) ;
_musicVolumeLabel - > draw ( ) ;
_musicVolumeSlider - > draw ( ) ;
}
void OptionsDialog : : updateSfxVolume ( const int newValue ) const {
_sfxVolumeLabel - > setValue ( newValue ) ;
_sfxVolumeSlider - > setValue ( newValue ) ;
_sfxVolumeLabel - > draw ( ) ;
_sfxVolumeSlider - > draw ( ) ;
}
void OptionsDialog : : updateSpeechVolume ( const int newValue ) const {
_speechVolumeLabel - > setValue ( newValue ) ;
_speechVolumeSlider - > setValue ( newValue ) ;
_speechVolumeLabel - > draw ( ) ;
_speechVolumeSlider - > draw ( ) ;
}
2006-08-04 13:55:53 +00:00
void OptionsDialog : : reflowLayout ( ) {
2008-08-14 23:17:41 +00:00
if ( _graphicsTabId ! = - 1 & & _tabWidget )
2010-06-15 10:44:51 +00:00
_tabWidget - > setTabTitle ( _graphicsTabId , g_system - > getOverlayWidth ( ) > 320 ? _ ( " Graphics " ) : _ ( " GFX " ) ) ;
2009-08-16 05:38:03 +00:00
Dialog : : reflowLayout ( ) ;
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 )
: OptionsDialog ( Common : : ConfigManager : : kApplicationDomain , " GlobalOptions " ) , _launcher ( launcher ) {
2016-10-30 18:36:22 +00:00
# ifdef GUI_ENABLE_KEYSDIALOG
_keysDialog = 0 ;
# endif
# ifdef USE_FLUIDSYNTH
_fluidSynthSettingsDialog = 0 ;
# endif
_savePath = 0 ;
_savePathClearButton = 0 ;
_themePath = 0 ;
_themePathClearButton = 0 ;
_extraPath = 0 ;
_extraPathClearButton = 0 ;
# ifdef DYNAMIC_MODULES
_pluginsPath = 0 ;
# endif
_curTheme = 0 ;
_rendererPopUpDesc = 0 ;
_rendererPopUp = 0 ;
_autosavePeriodPopUpDesc = 0 ;
_autosavePeriodPopUp = 0 ;
_guiLanguagePopUpDesc = 0 ;
_guiLanguagePopUp = 0 ;
# ifdef USE_UPDATES
_updatesPopUpDesc = 0 ;
_updatesPopUp = 0 ;
# endif
# ifdef USE_CLOUD
# ifdef USE_LIBCURL
_selectedStorageIndex = CloudMan . getStorageIndex ( ) ;
# else
_selectedStorageIndex = 0 ;
# endif
_storagePopUpDesc = 0 ;
_storagePopUp = 0 ;
_storageUsernameDesc = 0 ;
_storageUsername = 0 ;
_storageUsedSpaceDesc = 0 ;
_storageUsedSpace = 0 ;
_storageLastSyncDesc = 0 ;
_storageLastSync = 0 ;
_storageConnectButton = 0 ;
_storageRefreshButton = 0 ;
_storageDownloadButton = 0 ;
_runServerButton = 0 ;
_serverInfoLabel = 0 ;
_rootPathButton = 0 ;
_rootPath = 0 ;
_rootPathClearButton = 0 ;
_serverPortDesc = 0 ;
_serverPort = 0 ;
_serverPortClearButton = 0 ;
_redrawCloudTab = false ;
# ifdef USE_SDL_NET
_serverWasRunning = false ;
# endif
# endif
}
2007-06-10 14:23:26 +00:00
2016-10-30 18:36:22 +00:00
GlobalOptionsDialog : : ~ GlobalOptionsDialog ( ) {
# ifdef GUI_ENABLE_KEYSDIALOG
delete _keysDialog ;
# endif
# 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
//
_graphicsTabId = tab - > addTab ( g_system - > getOverlayWidth ( ) > 320 ? _ ( " Graphics " ) : _ ( " GFX " ) ) ;
addGraphicControls ( tab , " GlobalOptions_Graphics. " ) ;
2017-01-30 20:35:40 +00:00
//
2017-02-20 02:14:51 +00:00
// The control tab (currently visible only for AndroidSDL, 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-14 15:38:44 +00:00
g_system - > hasFeature ( OSystem : : kFeatureOnScreenControl ) | |
2017-02-20 02:14:51 +00:00
g_system - > hasFeature ( OSystem : : kFeatureSwapMenuAndBackButtons ) | |
g_system - > hasFeature ( OSystem : : kFeatureKbdMouseSpeed ) | |
g_system - > hasFeature ( OSystem : : kFeatureJoystickDeadzone ) ) {
2017-02-14 13:13:58 +00:00
tab - > addTab ( _ ( " Control " ) ) ;
addControlControls ( tab , " GlobalOptions_Control. " ) ;
2017-02-20 02:14:51 +00:00
}
2003-11-05 12:25:42 +00:00
//
// 2) The audio tab
//
2010-06-15 10:44:51 +00:00
tab - > addTab ( _ ( " 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 )
tab - > addTab ( _ ( " Volume " ) ) ;
else
tab - > addTab ( _c ( " Volume " , " lowres " ) ) ;
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
//
2012-02-24 21:20:50 +00:00
_midiTabId = tab - > addTab ( _ ( " MIDI " ) ) ;
2008-08-05 23:58:45 +00:00
addMIDIControls ( tab , " GlobalOptions_MIDI. " ) ;
2002-12-12 23:22:48 +00:00
2016-03-22 22:33:09 +00:00
# ifdef USE_FLUIDSYNTH
new ButtonWidget ( tab , " GlobalOptions_MIDI.mcFluidSynthSettings " , _ ( " FluidSynth Settings " ) , 0 , kFluidSynthSettingsCmd ) ;
# endif
2002-12-14 01:49:08 +00:00
//
2010-07-24 22:29:17 +00:00
// 4) The MT-32 tab
//
tab - > addTab ( _ ( " MT-32 " ) ) ;
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 )
2012-02-24 21:20:50 +00:00
_pathsTabId = tab - > addTab ( _ ( " Paths " ) ) ;
2010-09-11 16:18:55 +00:00
else
2012-02-24 21:20:50 +00:00
_pathsTabId = tab - > addTab ( _c ( " Paths " , " lowres " ) ) ;
2003-11-03 00:24:04 +00:00
# if !( defined(__DC__) || defined(__GP32__) )
2005-08-17 20:29:21 +00:00
// These two buttons have to be extra wide, or the text will be
// truncated in the small version of the GUI.
2003-11-03 00:24:04 +00:00
// Save game path
2010-09-11 16:18:55 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
2014-08-19 18:42:20 +00:00
new ButtonWidget ( tab , " GlobalOptions_Paths.SaveButton " , _ ( " Save Path: " ) , _ ( " Specifies where your saved games are put " ) , kChooseSaveDirCmd ) ;
2010-09-11 16:18:55 +00:00
else
2014-08-19 18:42:20 +00:00
new ButtonWidget ( tab , " GlobalOptions_Paths.SaveButton " , _c ( " Save Path: " , " lowres " ) , _ ( " Specifies where your saved games are put " ) , kChooseSaveDirCmd ) ;
_savePath = new StaticTextWidget ( tab , " GlobalOptions_Paths.SavePath " , " /foo/bar " , _ ( " Specifies where your saved games are put " ) ) ;
2004-11-15 04:41:51 +00:00
2011-10-24 18:50:31 +00:00
_savePathClearButton = addClearButton ( tab , " GlobalOptions_Paths.SavePathClearButton " , kSavePathClearCmd ) ;
2011-10-24 18:34:10 +00:00
2010-09-11 16:18:55 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
new ButtonWidget ( tab , " GlobalOptions_Paths.ThemeButton " , _ ( " Theme Path: " ) , 0 , kChooseThemeDirCmd ) ;
else
new ButtonWidget ( tab , " GlobalOptions_Paths.ThemeButton " , _c ( " Theme Path: " , " lowres " ) , 0 , kChooseThemeDirCmd ) ;
2010-08-23 19:45:14 +00:00
_themePath = new StaticTextWidget ( tab , " GlobalOptions_Paths.ThemePath " , _c ( " None " , " path " ) ) ;
2006-06-11 20:40:22 +00:00
2011-10-24 18:50:31 +00:00
_themePathClearButton = addClearButton ( tab , " GlobalOptions_Paths.ThemePathClearButton " , kThemePathClearCmd ) ;
2011-10-24 18:34:10 +00:00
2010-09-11 16:18:55 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
new ButtonWidget ( tab , " GlobalOptions_Paths.ExtraButton " , _ ( " Extra Path: " ) , _ ( " Specifies path to additional data used by all games or ScummVM " ) , kChooseExtraDirCmd ) ;
else
new ButtonWidget ( tab , " GlobalOptions_Paths.ExtraButton " , _c ( " Extra Path: " , " lowres " ) , _ ( " Specifies path to additional data used by all games or ScummVM " ) , kChooseExtraDirCmd ) ;
2010-08-23 19:45:14 +00:00
_extraPath = new StaticTextWidget ( tab , " GlobalOptions_Paths.ExtraPath " , _c ( " None " , " path " ) , _ ( " Specifies path to additional data used by all games or ScummVM " ) ) ;
2008-05-09 01:58:12 +00:00
2011-10-24 18:50:31 +00:00
_extraPathClearButton = addClearButton ( tab , " GlobalOptions_Paths.ExtraPathClearButton " , kExtraPathClearCmd ) ;
2011-10-24 18:34:10 +00:00
2008-05-09 01:58:12 +00:00
# ifdef DYNAMIC_MODULES
2010-09-11 16:18:55 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
new ButtonWidget ( tab , " GlobalOptions_Paths.PluginsButton " , _ ( " Plugins Path: " ) , 0 , kChoosePluginsDirCmd ) ;
else
new ButtonWidget ( tab , " GlobalOptions_Paths.PluginsButton " , _c ( " Plugins Path: " , " lowres " ) , 0 , kChoosePluginsDirCmd ) ;
2010-08-23 19:45:14 +00:00
_pluginsPath = new StaticTextWidget ( tab , " GlobalOptions_Paths.PluginsPath " , _c ( " None " , " path " ) ) ;
2008-05-09 01:58:12 +00:00
# endif
2003-04-03 16:01:03 +00:00
# endif
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 )
tab - > addTab ( _ ( " Misc " ) ) ;
else
tab - > addTab ( _c ( " Misc " , " lowres " ) ) ;
2006-10-08 18:22:28 +00:00
2010-06-15 10:52:35 +00:00
new ButtonWidget ( tab , " GlobalOptions_Misc.ThemeButton " , _ ( " Theme: " ) , 0 , kChooseThemeCmd ) ;
2008-08-05 23:58:45 +00:00
_curTheme = new StaticTextWidget ( tab , " GlobalOptions_Misc.CurTheme " , g_gui . theme ( ) - > getThemeName ( ) ) ;
2008-12-22 11:22:15 +00:00
2006-10-08 18:22:28 +00:00
2010-06-15 10:44:51 +00:00
_rendererPopUpDesc = new StaticTextWidget ( tab , " GlobalOptions_Misc.RendererPopupDesc " , _ ( " GUI Renderer: " ) ) ;
2009-06-06 17:52:44 +00:00
_rendererPopUp = new PopUpWidget ( tab , " GlobalOptions_Misc.RendererPopup " ) ;
2008-12-22 11:22:15 +00:00
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 ) {
for ( uint i = 1 ; i < GUI : : ThemeEngine : : _rendererModesSize ; + + i )
_rendererPopUp - > appendEntry ( _ ( GUI : : ThemeEngine : : _rendererModes [ i ] . name ) , GUI : : ThemeEngine : : _rendererModes [ i ] . mode ) ;
} else {
for ( uint i = 1 ; i < GUI : : ThemeEngine : : _rendererModesSize ; + + i )
2010-09-12 11:43:51 +00:00
_rendererPopUp - > appendEntry ( _ ( GUI : : ThemeEngine : : _rendererModes [ i ] . shortname ) , GUI : : ThemeEngine : : _rendererModes [ i ] . mode ) ;
2010-08-30 22:24:40 +00:00
}
2008-12-22 11:22:15 +00:00
2010-08-30 22:24:40 +00:00
if ( g_system - > getOverlayWidth ( ) > 320 )
_autosavePeriodPopUpDesc = new StaticTextWidget ( tab , " GlobalOptions_Misc.AutosavePeriodPopupDesc " , _ ( " Autosave: " ) ) ;
else
_autosavePeriodPopUpDesc = new StaticTextWidget ( tab , " GlobalOptions_Misc.AutosavePeriodPopupDesc " , _c ( " Autosave: " , " lowres " ) ) ;
2009-06-06 17:52:44 +00:00
_autosavePeriodPopUp = new PopUpWidget ( tab , " GlobalOptions_Misc.AutosavePeriodPopup " ) ;
2007-02-13 21:06:45 +00:00
for ( int i = 0 ; savePeriodLabels [ i ] ; i + + ) {
2010-06-15 10:44:51 +00:00
_autosavePeriodPopUp - > appendEntry ( _ ( savePeriodLabels [ i ] ) , savePeriodValues [ i ] ) ;
2007-02-13 21:06:45 +00:00
}
2016-04-10 10:52:53 +00:00
# ifdef GUI_ENABLE_KEYSDIALOG
2010-06-15 10:52:35 +00:00
new ButtonWidget ( tab , " GlobalOptions_Misc.KeysButton " , _ ( " Keys " ) , 0 , kChooseKeyMappingCmd ) ;
2008-12-17 21:19:46 +00:00
# endif
2003-11-03 00:24:04 +00:00
// TODO: joystick setting
2003-11-08 23:22:16 +00:00
2010-06-15 19:20:58 +00:00
# ifdef USE_TRANSLATION
2010-06-15 10:53:30 +00:00
_guiLanguagePopUpDesc = new StaticTextWidget ( tab , " GlobalOptions_Misc.GuiLanguagePopupDesc " , _ ( " GUI Language: " ) , _ ( " Language of ScummVM GUI " ) ) ;
2010-06-15 10:44:51 +00:00
_guiLanguagePopUp = new PopUpWidget ( tab , " GlobalOptions_Misc.GuiLanguagePopup " ) ;
2010-06-15 19:20:58 +00:00
# ifdef USE_DETECTLANG
2010-06-15 10:44:51 +00:00
_guiLanguagePopUp - > appendEntry ( _ ( " <default> " ) , Common : : kTranslationAutodetectId ) ;
2010-06-15 19:20:58 +00:00
# endif // USE_DETECTLANG
2010-08-23 22:46:05 +00:00
_guiLanguagePopUp - > appendEntry ( " English " , Common : : kTranslationBuiltinId ) ;
2010-06-15 10:44:51 +00:00
_guiLanguagePopUp - > appendEntry ( " " , 0 ) ;
2010-07-31 15:46:43 +00:00
Common : : TLangArray languages = TransMan . getSupportedLanguageNames ( ) ;
2010-06-15 10:44:51 +00:00
Common : : TLangArray : : iterator lang = languages . begin ( ) ;
while ( lang ! = languages . end ( ) ) {
_guiLanguagePopUp - > appendEntry ( lang - > name , lang - > id ) ;
lang + + ;
}
2010-06-26 15:25:47 +00:00
// Select the currently configured language or default/English if
// nothing is specified.
if ( ConfMan . hasKey ( " gui_language " ) )
_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
2010-06-15 10:44:51 +00:00
2010-06-15 19:20:58 +00:00
# endif // USE_TRANSLATION
2010-06-15 10:44:51 +00:00
2016-03-29 08:44:46 +00:00
# ifdef USE_UPDATES
_updatesPopUpDesc = new StaticTextWidget ( tab , " GlobalOptions_Misc.UpdatesPopupDesc " , _ ( " Update check: " ) , _ ( " How often to check ScummVM updates " ) ) ;
_updatesPopUp = new PopUpWidget ( tab , " GlobalOptions_Misc.UpdatesPopup " ) ;
2016-03-31 07:31:57 +00:00
const int * vals = Common : : UpdateManager : : getUpdateIntervals ( ) ;
while ( * vals ! = - 1 ) {
_updatesPopUp - > appendEntry ( Common : : UpdateManager : : updateIntervalToString ( * vals ) , * vals ) ;
vals + + ;
}
2016-03-29 08:53:50 +00:00
2016-04-01 19:32:16 +00:00
_updatesPopUp - > setSelectedTag ( Common : : UpdateManager : : normalizeInterval ( ConfMan . getInt ( " updates_check " ) ) ) ;
2016-03-31 11:59:01 +00:00
new ButtonWidget ( tab , " GlobalOptions_Misc.UpdatesCheckManuallyButton " , _ ( " Check now " ) , 0 , kUpdatesCheckCmd ) ;
2016-03-29 08:44:46 +00:00
# endif
2016-07-05 09:05:30 +00:00
# ifdef USE_CLOUD
2016-06-08 12:56:17 +00:00
//
// 7) The cloud tab
//
if ( g_system - > getOverlayWidth ( ) > 320 )
tab - > addTab ( _ ( " Cloud " ) ) ;
else
tab - > addTab ( _c ( " Cloud " , " lowres " ) ) ;
2016-07-11 08:17:27 +00:00
ScrollContainerWidget * container = new ScrollContainerWidget ( tab , " GlobalOptions_Cloud.Container " , kCloudTabContainerReflowCmd ) ;
container - > setTarget ( this ) ;
2016-07-11 07:57:46 +00:00
_storagePopUpDesc = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.StoragePopupDesc " , _ ( " Storage: " ) , _ ( " Active cloud storage " ) ) ;
_storagePopUp = new PopUpWidget ( container , " GlobalOptions_Cloud_Container.StoragePopup " ) ;
2016-10-17 16:55:01 +00:00
# ifdef USE_LIBCURL
2016-06-09 09:55:53 +00:00
Common : : StringArray list = CloudMan . listStorages ( ) ;
for ( uint32 i = 0 ; i < list . size ( ) ; + + i )
_storagePopUp - > appendEntry ( list [ i ] , i ) ;
2016-07-05 07:11:29 +00:00
# else
_storagePopUp - > appendEntry ( _ ( " <none> " ) , 0 ) ;
# endif
2016-06-09 09:55:53 +00:00
_storagePopUp - > setSelected ( _selectedStorageIndex ) ;
2016-06-09 06:41:51 +00:00
2016-07-11 07:57:46 +00:00
_storageUsernameDesc = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.StorageUsernameDesc " , _ ( " Username: " ) , _ ( " Username used by this storage " ) ) ;
_storageUsername = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.StorageUsernameLabel " , " <none> " ) ;
2016-06-09 06:41:51 +00:00
2016-09-18 15:39:11 +00:00
_storageUsedSpaceDesc = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.StorageUsedSpaceDesc " , _ ( " Used space: " ) , _ ( " Space used by ScummVM's saved games on this storage " ) ) ;
2016-07-11 07:57:46 +00:00
_storageUsedSpace = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.StorageUsedSpaceLabel " , " 0 bytes " ) ;
2016-06-09 06:41:51 +00:00
2016-09-18 15:39:11 +00:00
_storageLastSyncDesc = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.StorageLastSyncDesc " , _ ( " Last sync time: " ) , _ ( " When the last saved games sync for this storage occured " ) ) ;
2016-07-11 07:57:46 +00:00
_storageLastSync = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.StorageLastSyncLabel " , " <never> " ) ;
2016-06-09 06:41:51 +00:00
2016-07-11 07:57:46 +00:00
_storageConnectButton = new ButtonWidget ( container , " GlobalOptions_Cloud_Container.ConnectButton " , _ ( " Connect " ) , _ ( " Open wizard dialog to connect your cloud storage account " ) , kConfigureStorageCmd ) ;
_storageRefreshButton = new ButtonWidget ( container , " GlobalOptions_Cloud_Container.RefreshButton " , _ ( " Refresh " ) , _ ( " Refresh current cloud storage information (username and usage) " ) , kRefreshStorageCmd ) ;
2016-09-04 22:24:30 +00:00
_storageDownloadButton = new ButtonWidget ( container , " GlobalOptions_Cloud_Container.DownloadButton " , _ ( " Download " ) , _ ( " Open downloads manager dialog " ) , kDownloadStorageCmd ) ;
2016-06-09 11:00:05 +00:00
2016-07-11 07:57:46 +00:00
_runServerButton = new ButtonWidget ( container , " GlobalOptions_Cloud_Container.RunServerButton " , _ ( " Run server " ) , _ ( " Run local webserver " ) , kRunServerCmd ) ;
_serverInfoLabel = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.ServerInfoLabel " , _ ( " Not running " ) ) ;
2016-07-05 07:11:29 +00:00
2016-08-01 09:49:42 +00:00
// Root path
if ( g_system - > getOverlayWidth ( ) > 320 )
2016-09-04 22:24:30 +00:00
_rootPathButton = new ButtonWidget ( container , " GlobalOptions_Cloud_Container.RootPathButton " , _ ( " /root/ Path: " ) , _ ( " Specifies which directory the Files Manager can access " ) , kChooseRootDirCmd ) ;
2016-08-01 09:49:42 +00:00
else
2016-09-04 22:24:30 +00:00
_rootPathButton = new ButtonWidget ( container , " GlobalOptions_Cloud_Container.RootPathButton " , _c ( " /root/ Path: " , " lowres " ) , _ ( " Specifies which directory the Files Manager can access " ) , kChooseRootDirCmd ) ;
_rootPath = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.RootPath " , " /foo/bar " , _ ( " Specifies which directory the Files Manager can access " ) ) ;
2016-08-01 09:49:42 +00:00
_rootPathClearButton = addClearButton ( container , " GlobalOptions_Cloud_Container.RootPathClearButton " , kRootPathClearCmd ) ;
2016-07-25 07:13:47 +00:00
# ifdef USE_SDL_NET
2016-07-20 09:55:30 +00:00
uint32 port = Networking : : LocalWebserver : : getPort ( ) ;
2016-07-25 07:13:47 +00:00
# else
uint32 port = 0 ; // the following widgets are hidden anyway
# endif
2016-09-04 22:24:30 +00:00
_serverPortDesc = new StaticTextWidget ( container , " GlobalOptions_Cloud_Container.ServerPortDesc " , _ ( " Server's port: " ) , _ ( " Which port is used by the server \n Auth with server is not available with non-default port " ) ) ;
2016-07-20 09:55:30 +00:00
_serverPort = new EditTextWidget ( container , " GlobalOptions_Cloud_Container.ServerPortEditText " , Common : : String : : format ( " %u " , port ) , 0 ) ;
2016-07-20 10:48:50 +00:00
_serverPortClearButton = addClearButton ( container , " GlobalOptions_Cloud_Container.ServerPortClearButton " , kServerPortClearCmd ) ;
2016-07-20 09:55:30 +00:00
2016-06-09 06:41:51 +00:00
setupCloudTab ( ) ;
2016-10-17 16:55:01 +00:00
# endif // USE_CLOUD
2016-06-08 12:56:17 +00:00
2003-11-05 12:25:42 +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
2010-06-15 10:52:35 +00:00
new ButtonWidget ( this , " GlobalOptions.Cancel " , _ ( " Cancel " ) , 0 , kCloseCmd ) ;
2016-10-30 15:43:14 +00:00
new ButtonWidget ( this , " GlobalOptions.Apply " , _ ( " Apply " ) , 0 , kApplyCmd ) ;
2010-06-15 10:52:35 +00:00
new ButtonWidget ( this , " GlobalOptions.Ok " , _ ( " OK " ) , 0 , kOKCmd ) ;
2003-03-25 15:32:36 +00:00
2016-04-10 10:52:53 +00:00
# ifdef GUI_ENABLE_KEYSDIALOG
2005-07-05 20:22:56 +00:00
_keysDialog = new KeysDialog ( ) ;
2005-01-10 20:53:16 +00:00
# endif
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
2009-03-06 00:28:39 +00:00
# if !( defined(__DC__) || defined(__GP32__) )
2003-11-05 12:25:42 +00:00
// Set _savePath to the current save path
2006-06-11 20:40:22 +00:00
Common : : String savePath ( ConfMan . get ( " savepath " , _domain ) ) ;
Common : : String themePath ( ConfMan . get ( " themepath " , _domain ) ) ;
2004-11-15 04:41:51 +00:00
Common : : String extraPath ( ConfMan . get ( " extrapath " , _domain ) ) ;
2007-03-08 17:05:58 +00:00
if ( savePath . empty ( ) | | ! ConfMan . hasKey ( " savepath " , _domain ) ) {
2011-10-24 22:16:14 +00:00
_savePath - > setLabel ( _ ( " Default " ) ) ;
2003-11-05 12:25:42 +00:00
} else {
2007-03-08 17:05:58 +00:00
_savePath - > setLabel ( savePath ) ;
2003-11-05 12:25:42 +00:00
}
2004-11-15 04:41:51 +00:00
2006-06-11 20:40:22 +00:00
if ( themePath . empty ( ) | | ! ConfMan . hasKey ( " themepath " , _domain ) ) {
2010-08-23 19:45:14 +00:00
_themePath - > setLabel ( _c ( " None " , " path " ) ) ;
2006-06-11 20:40:22 +00:00
} else {
_themePath - > setLabel ( themePath ) ;
}
2006-03-28 09:42:54 +00:00
if ( extraPath . empty ( ) | | ! ConfMan . hasKey ( " extrapath " , _domain ) ) {
2010-08-23 19:45:14 +00:00
_extraPath - > setLabel ( _c ( " None " , " path " ) ) ;
2004-11-15 04:41:51 +00:00
} else {
_extraPath - > setLabel ( extraPath ) ;
}
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
_autosavePeriodPopUp - > setSelected ( 1 ) ;
int value = ConfMan . getInt ( " autosave_period " ) ;
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
Common : : String rootPath ( ConfMan . get ( " rootpath " , " cloud " ) ) ;
if ( rootPath . empty ( ) | | ! ConfMan . hasKey ( " rootpath " , " cloud " ) ) {
_rootPath - > setLabel ( _c ( " None " , " path " ) ) ;
} else {
_rootPath - > setLabel ( rootPath ) ;
}
# endif
2003-11-05 12:25:42 +00:00
}
2016-10-30 18:36:22 +00:00
void GlobalOptionsDialog : : clean ( ) {
# ifdef GUI_ENABLE_KEYSDIALOG
delete _keysDialog ;
_keysDialog = 0 ;
# endif
# ifdef USE_FLUIDSYNTH
delete _fluidSynthSettingsDialog ;
_fluidSynthSettingsDialog = 0 ;
# endif
OptionsDialog : : clean ( ) ;
}
2017-03-04 10:22:41 +00:00
2016-10-30 15:43:14 +00:00
void GlobalOptionsDialog : : apply ( ) {
Common : : String savePath ( _savePath - > getLabel ( ) ) ;
if ( ! savePath . empty ( ) & & ( savePath ! = _ ( " Default " ) ) )
ConfMan . set ( " savepath " , savePath , _domain ) ;
else
ConfMan . removeKey ( " savepath " , _domain ) ;
2016-10-30 18:36:22 +00:00
2016-10-30 15:43:14 +00:00
Common : : String themePath ( _themePath - > getLabel ( ) ) ;
if ( ! themePath . empty ( ) & & ( themePath ! = _c ( " None " , " path " ) ) )
ConfMan . set ( " themepath " , themePath , _domain ) ;
else
ConfMan . removeKey ( " themepath " , _domain ) ;
2016-10-30 18:36:22 +00:00
2016-10-30 15:43:14 +00:00
Common : : String extraPath ( _extraPath - > getLabel ( ) ) ;
if ( ! extraPath . empty ( ) & & ( extraPath ! = _c ( " None " , " path " ) ) )
ConfMan . set ( " extrapath " , extraPath , _domain ) ;
else
ConfMan . removeKey ( " extrapath " , _domain ) ;
2016-10-30 18:36:22 +00:00
2008-05-09 01:58:12 +00:00
# ifdef DYNAMIC_MODULES
2016-10-30 15:43:14 +00:00
Common : : String pluginsPath ( _pluginsPath - > getLabel ( ) ) ;
if ( ! pluginsPath . empty ( ) & & ( pluginsPath ! = _c ( " None " , " path " ) ) )
ConfMan . set ( " pluginspath " , pluginsPath , _domain ) ;
else
ConfMan . removeKey ( " pluginspath " , _domain ) ;
2008-05-09 01:58:12 +00:00
# endif
2016-10-30 18:36:22 +00:00
2016-08-01 09:49:42 +00:00
# ifdef USE_CLOUD
2016-10-30 15:43:14 +00:00
Common : : String rootPath ( _rootPath - > getLabel ( ) ) ;
if ( ! rootPath . empty ( ) & & ( rootPath ! = _c ( " None " , " path " ) ) )
ConfMan . set ( " rootpath " , rootPath , " cloud " ) ;
else
ConfMan . removeKey ( " rootpath " , " cloud " ) ;
2016-08-01 09:49:42 +00:00
# endif
2016-10-30 18:36:22 +00:00
2016-10-30 15:43:14 +00:00
ConfMan . setInt ( " autosave_period " , _autosavePeriodPopUp - > getSelectedTag ( ) , _domain ) ;
2016-10-30 18:36:22 +00:00
2016-10-30 15:43:14 +00:00
GUI : : ThemeEngine : : GraphicsMode selected = ( GUI : : ThemeEngine : : GraphicsMode ) _rendererPopUp - > getSelectedTag ( ) ;
const char * cfg = GUI : : ThemeEngine : : findModeConfigName ( selected ) ;
if ( ! ConfMan . get ( " gui_renderer " ) . equalsIgnoreCase ( cfg ) ) {
// FIXME: Actually, any changes (including the theme change) should
// only become active *after* the options dialog has closed.
g_gui . loadNewTheme ( g_gui . theme ( ) - > getThemeId ( ) , selected ) ;
ConfMan . set ( " gui_renderer " , cfg , _domain ) ;
}
2010-06-15 19:20:58 +00:00
# ifdef USE_TRANSLATION
2016-10-30 15:43:14 +00:00
Common : : String oldLang = ConfMan . get ( " gui_language " ) ;
int selLang = _guiLanguagePopUp - > getSelectedTag ( ) ;
2016-10-30 18:36:22 +00:00
2016-10-30 15:43:14 +00:00
ConfMan . set ( " gui_language " , TransMan . getLangById ( selLang ) ) ;
2016-10-30 18:36:22 +00:00
2016-10-30 15:43:14 +00:00
Common : : String newLang = ConfMan . get ( " gui_language " ) . c_str ( ) ;
if ( newLang ! = oldLang ) {
// Activate the selected language
TransMan . setLanguage ( selLang ) ;
2016-10-30 18:59:47 +00:00
// Rebuild the Launcher and Options dialogs
2016-10-30 15:43:14 +00:00
g_gui . loadNewTheme ( g_gui . theme ( ) - > getThemeId ( ) , ThemeEngine : : kGfxDisabled , true ) ;
2016-10-30 18:36:22 +00:00
rebuild ( ) ;
2016-10-30 18:59:47 +00:00
if ( _launcher ! = 0 )
_launcher - > rebuild ( ) ;
2016-10-30 15:43:14 +00:00
}
2010-06-15 19:20:58 +00:00
# endif // USE_TRANSLATION
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
ConfMan . setInt ( " updates_check " , _updatesPopUp - > getSelectedTag ( ) ) ;
2016-10-30 18:36:22 +00:00
2016-10-30 15:43:14 +00:00
if ( g_system - > getUpdateManager ( ) ) {
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
}
2016-03-29 08:53:50 +00:00
# endif
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 ( ) ;
Common : : String message = _ ( " Failed to change cloud storage! " ) ;
if ( anotherStorageIsWorking ) {
message + = " \n " ;
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
2016-10-30 16:25:42 +00:00
if ( ! _newTheme . empty ( ) ) {
# ifdef USE_TRANSLATION
Common : : String lang = TransMan . getCurrentLanguage ( ) ;
# endif
Common : : String oldTheme = g_gui . theme ( ) - > getThemeId ( ) ;
if ( g_gui . loadNewTheme ( _newTheme ) ) {
# ifdef USE_TRANSLATION
// If the charset has changed, it means the font were not found for the
// new theme. Since for the moment we do not support change of translation
// language without restarting, we let the user know about this.
if ( lang ! = TransMan . getCurrentLanguage ( ) ) {
TransMan . setLanguage ( lang . c_str ( ) ) ;
g_gui . loadNewTheme ( oldTheme ) ;
_curTheme - > setLabel ( g_gui . theme ( ) - > getThemeName ( ) ) ;
MessageDialog error ( _ ( " The theme you selected does not support your current language. If you want to use this theme you need to switch to another language first. " ) ) ;
error . runModal ( ) ;
} else {
# endif
ConfMan . set ( " gui_theme " , _newTheme ) ;
# ifdef USE_TRANSLATION
}
# endif
}
draw ( ) ;
_newTheme . clear ( ) ;
}
2016-10-30 18:36:22 +00:00
2016-10-30 15:43:14 +00:00
OptionsDialog : : apply ( ) ;
}
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 : {
2014-08-19 18:42:20 +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
}
2005-04-16 17:55:09 +00:00
draw ( ) ;
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 : {
2010-06-15 10:44:51 +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 ( ) ) ;
2006-06-11 20:40:22 +00:00
draw ( ) ;
}
break ;
}
2005-08-10 18:30:55 +00:00
case kChooseExtraDirCmd : {
2010-06-15 10:44:51 +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 ( ) ) ;
2005-04-16 17:55:09 +00:00
draw ( ) ;
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 : {
2010-06-15 10:44:51 +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 ( ) ) ;
draw ( ) ;
}
break ;
}
2016-08-01 09:49:42 +00:00
# endif
# ifdef USE_CLOUD
case kChooseRootDirCmd : {
BrowserDialog browser ( _ ( " Select directory for Files Manager /root/ " ) , true ) ;
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 ) ;
draw ( ) ;
}
break ;
}
2008-05-09 01:58:12 +00:00
# endif
2011-10-24 18:34:10 +00:00
case kThemePathClearCmd :
_themePath - > setLabel ( _c ( " None " , " path " ) ) ;
break ;
case kExtraPathClearCmd :
_extraPath - > setLabel ( _c ( " None " , " path " ) ) ;
break ;
case kSavePathClearCmd :
2011-10-24 22:16:14 +00:00
_savePath - > setLabel ( _ ( " Default " ) ) ;
2011-10-24 18:34:10 +00:00
break ;
2016-08-01 09:49:42 +00:00
# ifdef USE_CLOUD
case kRootPathClearCmd :
_rootPath - > setLabel ( _c ( " None " , " path " ) ) ;
break ;
# endif
2005-08-10 18:30:55 +00:00
case kChooseSoundFontCmd : {
2010-06-15 10:44:51 +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
2010-08-23 19:45:14 +00:00
if ( ! file . getPath ( ) . empty ( ) & & ( file . getPath ( ) ! = _c ( " None " , " path " ) ) )
2007-02-13 21:41:49 +00:00
_soundFontClearButton - > setEnabled ( true ) ;
else
_soundFontClearButton - > setEnabled ( false ) ;
2005-04-16 17:55:09 +00:00
draw ( ) ;
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 ( ) ) ;
2006-10-08 18:22:28 +00:00
}
break ;
}
2016-07-11 08:17:27 +00:00
# ifdef USE_CLOUD
case kCloudTabContainerReflowCmd :
setupCloudTab ( ) ;
break ;
2016-07-05 09:05:30 +00:00
# ifdef USE_LIBCURL
2016-06-09 09:55:53 +00:00
case kPopUpItemSelectedCmd :
2016-06-08 12:56:17 +00:00
{
2017-02-26 18:44:09 +00:00
// update container's scrollbar
reflowLayout ( ) ;
2016-06-08 12:56:17 +00:00
break ;
}
2016-06-09 11:00:05 +00:00
case kConfigureStorageCmd :
{
2016-07-20 10:48:50 +00:00
# ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
// save server's port
uint32 port = Networking : : LocalWebserver : : getPort ( ) ;
if ( _serverPort ) {
uint64 contents = _serverPort - > getEditString ( ) . asUint64 ( ) ;
2016-07-22 12:48:46 +00:00
if ( contents ! = 0 )
port = contents ;
2016-07-20 10:48:50 +00:00
}
ConfMan . setInt ( " local_server_port " , port ) ;
ConfMan . flushToDisk ( ) ;
2016-10-16 22:27:59 +00:00
# endif // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
2016-06-09 11:00:05 +00:00
StorageWizardDialog dialog ( _selectedStorageIndex ) ;
dialog . runModal ( ) ;
2016-07-11 08:17:27 +00:00
//update container's scrollbar
reflowLayout ( ) ;
2016-06-09 11:00:05 +00:00
break ;
}
2016-06-09 12:49:17 +00:00
case kRefreshStorageCmd :
{
2016-07-20 07:02:18 +00:00
CloudMan . info (
new Common : : Callback < GlobalOptionsDialog , Cloud : : Storage : : StorageInfoResponse > ( this , & GlobalOptionsDialog : : storageInfoCallback ) ,
new Common : : Callback < GlobalOptionsDialog , Networking : : ErrorResponse > ( this , & GlobalOptionsDialog : : storageErrorCallback )
) ;
2016-06-09 12:49:17 +00:00
Common : : String dir = CloudMan . savesDirectoryPath ( ) ;
2016-07-22 12:48:46 +00:00
if ( dir . lastChar ( ) = = ' / ' )
dir . deleteLastChar ( ) ;
2016-07-20 07:02:18 +00:00
CloudMan . listDirectory (
dir ,
new Common : : Callback < GlobalOptionsDialog , Cloud : : Storage : : ListDirectoryResponse > ( this , & GlobalOptionsDialog : : storageListDirectoryCallback ) ,
new Common : : Callback < GlobalOptionsDialog , Networking : : ErrorResponse > ( this , & GlobalOptionsDialog : : storageErrorCallback )
) ;
2016-06-09 12:49:17 +00:00
break ;
}
2016-07-03 14:09:51 +00:00
case kDownloadStorageCmd :
2016-07-22 12:48:46 +00:00
{
DownloadDialog dialog ( _selectedStorageIndex , _launcher ) ;
dialog . runModal ( ) ;
break ;
}
2016-10-16 22:27:59 +00:00
# endif // USE_LIBCURL
2016-07-05 07:11:29 +00:00
# ifdef USE_SDL_NET
case kRunServerCmd :
2016-07-22 12:48:46 +00:00
{
2016-07-20 09:55:30 +00:00
# ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
2016-07-22 12:48:46 +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
2016-07-22 12:48:46 +00:00
if ( LocalServer . isRunning ( ) )
LocalServer . stopOnIdle ( ) ;
else
LocalServer . start ( ) ;
break ;
}
2016-07-20 10:48:50 +00:00
case kServerPortClearCmd : {
if ( _serverPort ) {
_serverPort - > setEditString ( Common : : String : : format ( " %u " , Networking : : LocalWebserver : : DEFAULT_SERVER_PORT ) ) ;
}
draw ( ) ;
break ;
}
2016-10-16 22:27:59 +00:00
# endif // USE_SDL_NET
# endif // USE_CLOUD
2016-04-10 10:52:53 +00:00
# ifdef GUI_ENABLE_KEYSDIALOG
2005-01-10 20:53:16 +00:00
case kChooseKeyMappingCmd :
_keysDialog - > runModal ( ) ;
break ;
2012-12-27 14:08:54 +00:00
# endif
# 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
2016-07-05 10:31:52 +00:00
# ifdef USE_SDL_NET
if ( LocalServer . isRunning ( ) ! = _serverWasRunning ) {
_serverWasRunning = ! _serverWasRunning ;
_redrawCloudTab = true ;
}
# endif
2016-06-09 12:49:17 +00:00
if ( _redrawCloudTab ) {
setupCloudTab ( ) ;
draw ( ) ;
_redrawCloudTab = false ;
}
# endif
}
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 ) ;
_tabWidget - > removeWidget ( _soundFontClearButton ) ;
_soundFontClearButton - > setNext ( 0 ) ;
delete _soundFontClearButton ;
_soundFontClearButton = addClearButton ( _tabWidget , " GlobalOptions_MIDI.mcFontClearButton " , kClearSoundFontCmd ) ;
}
if ( _pathsTabId ! = - 1 ) {
_tabWidget - > setActiveTab ( _pathsTabId ) ;
_tabWidget - > removeWidget ( _savePathClearButton ) ;
_savePathClearButton - > setNext ( 0 ) ;
delete _savePathClearButton ;
_savePathClearButton = addClearButton ( _tabWidget , " GlobalOptions_Paths.SavePathClearButton " , kSavePathClearCmd ) ;
_tabWidget - > removeWidget ( _themePathClearButton ) ;
_themePathClearButton - > setNext ( 0 ) ;
delete _themePathClearButton ;
_themePathClearButton = addClearButton ( _tabWidget , " GlobalOptions_Paths.ThemePathClearButton " , kThemePathClearCmd ) ;
_tabWidget - > removeWidget ( _extraPathClearButton ) ;
_extraPathClearButton - > setNext ( 0 ) ;
delete _extraPathClearButton ;
_extraPathClearButton = addClearButton ( _tabWidget , " GlobalOptions_Paths.ExtraPathClearButton " , kExtraPathClearCmd ) ;
}
_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
2016-07-05 08:12:35 +00:00
setupCloudTab ( ) ;
2016-07-05 09:05:30 +00:00
# endif
2012-02-24 21:20:50 +00:00
}
2016-07-05 09:05:30 +00:00
# ifdef USE_CLOUD
2016-06-09 06:41:51 +00:00
void GlobalOptionsDialog : : setupCloudTab ( ) {
2016-07-05 07:11:29 +00:00
int serverLabelPosition = - 1 ; //no override
2016-07-05 09:05:30 +00:00
# ifdef USE_LIBCURL
2017-02-28 20:22:38 +00:00
_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
bool shown = ( _selectedStorageIndex ! = Cloud : : kStorageNoneId ) ;
if ( _storageUsernameDesc ) _storageUsernameDesc - > setVisible ( shown ) ;
2016-06-09 06:41:51 +00:00
if ( _storageUsername ) {
2016-06-09 07:49:52 +00:00
Common : : String username = CloudMan . getStorageUsername ( _selectedStorageIndex ) ;
2016-07-22 12:48:46 +00:00
if ( username = = " " )
username = _ ( " <none> " ) ;
2016-06-09 06:41:51 +00:00
_storageUsername - > setLabel ( username ) ;
2016-06-09 07:49:52 +00:00
_storageUsername - > setVisible ( shown ) ;
2016-06-09 06:41:51 +00:00
}
2016-06-09 07:49:52 +00:00
if ( _storageUsedSpaceDesc ) _storageUsedSpaceDesc - > setVisible ( shown ) ;
2016-06-09 06:41:51 +00:00
if ( _storageUsedSpace ) {
2016-06-09 07:49:52 +00:00
uint64 usedSpace = CloudMan . getStorageUsedSpace ( _selectedStorageIndex ) ;
2016-06-09 06:41:51 +00:00
_storageUsedSpace - > setLabel ( Common : : String : : format ( _ ( " %llu bytes " ) , usedSpace ) ) ;
2016-06-09 07:49:52 +00:00
_storageUsedSpace - > setVisible ( shown ) ;
2016-06-09 06:41:51 +00:00
}
2016-06-09 07:49:52 +00:00
if ( _storageLastSyncDesc ) _storageLastSyncDesc - > setVisible ( shown ) ;
2016-06-09 06:41:51 +00:00
if ( _storageLastSync ) {
2016-06-09 07:49:52 +00:00
Common : : String 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 ) ;
2016-06-09 07:49:52 +00:00
_storageLastSync - > setVisible ( shown ) ;
2016-06-09 06:41:51 +00:00
}
2016-07-22 12:48:46 +00:00
if ( _storageConnectButton )
_storageConnectButton - > setVisible ( shown ) ;
if ( _storageRefreshButton )
_storageRefreshButton - > setVisible ( shown & & _selectedStorageIndex = = CloudMan . getStorageIndex ( ) ) ;
if ( _storageDownloadButton )
_storageDownloadButton - > setVisible ( shown & & _selectedStorageIndex = = CloudMan . getStorageIndex ( ) ) ;
if ( ! shown )
serverLabelPosition = ( _storageUsernameDesc ? _storageUsernameDesc - > getRelY ( ) : 0 ) ;
2016-10-16 22:27:59 +00:00
# else // USE_LIBCURL
2016-07-05 07:11:29 +00:00
_selectedStorageIndex = 0 ;
2016-07-21 05:44:36 +00:00
2016-07-22 12:48:46 +00:00
if ( _storagePopUpDesc )
_storagePopUpDesc - > setVisible ( false ) ;
if ( _storagePopUp )
_storagePopUp - > setVisible ( false ) ;
if ( _storageUsernameDesc )
_storageUsernameDesc - > setVisible ( false ) ;
if ( _storageUsernameDesc )
_storageUsernameDesc - > setVisible ( false ) ;
if ( _storageUsername )
_storageUsername - > setVisible ( false ) ;
if ( _storageUsedSpaceDesc )
_storageUsedSpaceDesc - > setVisible ( false ) ;
if ( _storageUsedSpace )
_storageUsedSpace - > setVisible ( false ) ;
if ( _storageLastSyncDesc )
_storageLastSyncDesc - > setVisible ( false ) ;
if ( _storageLastSync )
_storageLastSync - > setVisible ( false ) ;
if ( _storageConnectButton )
_storageConnectButton - > setVisible ( false ) ;
if ( _storageRefreshButton )
_storageRefreshButton - > setVisible ( false ) ;
if ( _storageDownloadButton )
_storageDownloadButton - > setVisible ( false ) ;
2016-07-05 07:11:29 +00:00
2016-07-05 08:12:35 +00:00
serverLabelPosition = ( _storagePopUpDesc ? _storagePopUpDesc - > getRelY ( ) : 0 ) ;
2016-10-16 22:27:59 +00:00
# endif // USE_LIBCURL
2016-07-05 07:11:29 +00:00
# ifdef USE_SDL_NET
//determine original widget's positions
int16 x , y ;
uint16 w , h ;
2016-08-01 09:49:42 +00:00
int serverButtonY , serverInfoY ;
int serverRootButtonY , serverRootY , serverRootClearButtonY ;
int serverPortDescY , serverPortY , serverPortClearButtonY ;
2016-07-11 07:57:46 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.RunServerButton " , x , y , w , h ) )
warning ( " GlobalOptions_Cloud_Container.RunServerButton's position is undefined " ) ;
2016-07-05 07:11:29 +00:00
serverButtonY = y ;
2016-07-11 07:57:46 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.ServerInfoLabel " , x , y , w , h ) )
warning ( " GlobalOptions_Cloud_Container.ServerInfoLabel's position is undefined " ) ;
2016-07-05 07:11:29 +00:00
serverInfoY = y ;
2016-08-01 09:49:42 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.RootPathButton " , x , y , w , h ) )
warning ( " GlobalOptions_Cloud_Container.RootPathButton's position is undefined " ) ;
serverRootButtonY = y ;
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.RootPath " , x , y , w , h ) )
warning ( " GlobalOptions_Cloud_Container.RootPath's position is undefined " ) ;
serverRootY = y ;
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.RootPathClearButton " , x , y , w , h ) )
warning ( " GlobalOptions_Cloud_Container.RootPathClearButton's position is undefined " ) ;
serverRootClearButtonY = y ;
2016-07-20 09:55:30 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.ServerPortDesc " , x , y , w , h ) )
warning ( " GlobalOptions_Cloud_Container.ServerPortDesc's position is undefined " ) ;
serverPortDescY = y ;
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.ServerPortEditText " , x , y , w , h ) )
warning ( " GlobalOptions_Cloud_Container.ServerPortEditText's position is undefined " ) ;
serverPortY = y ;
2016-07-20 10:48:50 +00:00
if ( ! g_gui . xmlEval ( ) - > getWidgetData ( " GlobalOptions_Cloud_Container.ServerPortClearButton " , x , y , w , h ) )
warning ( " GlobalOptions_Cloud_Container.ServerPortClearButton's position is undefined " ) ;
serverPortClearButtonY = y ;
2016-07-05 10:31:52 +00:00
bool serverIsRunning = LocalServer . isRunning ( ) ;
2016-07-21 05:44:36 +00:00
2016-07-22 12:48:46 +00:00
if ( serverLabelPosition < 0 )
serverLabelPosition = serverInfoY ;
2016-07-05 10:31:52 +00:00
if ( _runServerButton ) {
2016-07-12 16:11:07 +00:00
_runServerButton - > setVisible ( true ) ;
2016-07-05 10:31:52 +00:00
_runServerButton - > setPos ( _runServerButton - > getRelX ( ) , serverLabelPosition + serverButtonY - serverInfoY ) ;
_runServerButton - > setLabel ( _ ( serverIsRunning ? " Stop server " : " Run server " ) ) ;
2016-07-26 17:08:08 +00:00
_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-05 10:31:52 +00:00
_serverInfoLabel - > setPos ( _serverInfoLabel - > getRelX ( ) , serverLabelPosition ) ;
2016-07-22 12:48:46 +00:00
if ( serverIsRunning )
_serverInfoLabel - > setLabel ( LocalServer . getAddress ( ) ) ;
else
_serverInfoLabel - > setLabel ( _ ( " Not running " ) ) ;
2016-07-05 10:31:52 +00:00
}
2016-08-01 09:49:42 +00:00
if ( _rootPathButton ) {
_rootPathButton - > setVisible ( true ) ;
_rootPathButton - > setPos ( _rootPathButton - > getRelX ( ) , serverLabelPosition + serverRootButtonY - serverInfoY ) ;
}
if ( _rootPath ) {
_rootPath - > setVisible ( true ) ;
_rootPath - > setPos ( _rootPath - > getRelX ( ) , serverLabelPosition + serverRootY - serverInfoY ) ;
}
if ( _rootPathClearButton ) {
_rootPathClearButton - > setVisible ( true ) ;
_rootPathClearButton - > setPos ( _rootPathClearButton - > getRelX ( ) , serverLabelPosition + serverRootClearButtonY - serverInfoY ) ;
}
2016-07-20 09:55:30 +00:00
# ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
if ( _serverPortDesc ) {
_serverPortDesc - > setVisible ( true ) ;
_serverPortDesc - > setPos ( _serverPortDesc - > getRelX ( ) , serverLabelPosition + serverPortDescY - serverInfoY ) ;
_serverPortDesc - > setEnabled ( ! serverIsRunning ) ;
}
if ( _serverPort ) {
_serverPort - > setVisible ( true ) ;
_serverPort - > setPos ( _serverPort - > getRelX ( ) , serverLabelPosition + serverPortY - serverInfoY ) ;
_serverPort - > setEnabled ( ! serverIsRunning ) ;
}
2016-07-20 10:48:50 +00:00
if ( _serverPortClearButton ) {
_serverPortClearButton - > setVisible ( true ) ;
_serverPortClearButton - > setPos ( _serverPortClearButton - > getRelX ( ) , serverLabelPosition + serverPortClearButtonY - serverInfoY ) ;
_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
# else // USE_SDL_NET
2016-07-22 12:48:46 +00:00
if ( _runServerButton )
_runServerButton - > setVisible ( false ) ;
2017-01-10 06:27:09 +00:00
if ( _serverInfoLabel ) {
_serverInfoLabel - > setPos ( _serverInfoLabel - > getRelX ( ) , serverLabelPosition ) ; // Prevent compiler warning from serverLabelPosition being unused.
2016-07-22 12:48:46 +00:00
_serverInfoLabel - > setVisible ( false ) ;
2017-01-10 06:27:09 +00:00
}
2016-08-01 09:49:42 +00:00
if ( _rootPathButton )
_rootPathButton - > setVisible ( false ) ;
if ( _rootPath )
_rootPath - > setVisible ( false ) ;
if ( _rootPathClearButton )
_rootPathClearButton - > setVisible ( false ) ;
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 // USE_SDL_NET
2016-06-09 12:49:17 +00:00
}
2016-10-16 22:27:59 +00:00
2016-07-05 09:05:30 +00:00
# ifdef USE_LIBCURL
2016-06-09 12:49:17 +00:00
void GlobalOptionsDialog : : storageInfoCallback ( Cloud : : Storage : : StorageInfoResponse response ) {
//we could've used response.value.email()
//but Storage already notified CloudMan
//so we just set the flag to redraw our cloud tab
_redrawCloudTab = true ;
}
void GlobalOptionsDialog : : storageListDirectoryCallback ( Cloud : : Storage : : ListDirectoryResponse response ) {
Common : : Array < Cloud : : StorageFile > & files = response . value ;
uint64 totalSize = 0 ;
for ( uint32 i = 0 ; i < files . size ( ) ; + + i )
if ( ! files [ i ] . isDirectory ( ) )
2016-07-21 05:44:36 +00:00
totalSize + = files [ i ] . size ( ) ;
2016-06-09 12:49:17 +00:00
CloudMan . setStorageUsedSpace ( CloudMan . getStorageIndex ( ) , totalSize ) ;
_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
2003-11-10 23:40:48 +00:00
} // End of namespace GUI