2008-09-23 05:43:52 +00:00
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
# include <string>
# include <vector>
# include "Globals.h"
# include "ConfigMain.h"
# include "PluginManager.h"
BEGIN_EVENT_TABLE ( CConfigMain , wxDialog )
EVT_CLOSE ( CConfigMain : : OnClose )
2008-11-04 09:56:25 +00:00
EVT_BUTTON ( ID_CLOSE , CConfigMain : : CloseClick )
2008-10-30 21:01:20 +00:00
EVT_CHECKBOX ( ID_ALLWAYS_HLEBIOS , CConfigMain : : CoreSettingsChanged )
EVT_CHECKBOX ( ID_USEDYNAREC , CConfigMain : : CoreSettingsChanged )
EVT_CHECKBOX ( ID_USEDUALCORE , CConfigMain : : CoreSettingsChanged )
EVT_CHECKBOX ( ID_LOCKTHREADS , CConfigMain : : CoreSettingsChanged )
EVT_CHECKBOX ( ID_OPTIMIZEQUANTIZERS , CConfigMain : : CoreSettingsChanged )
EVT_CHECKBOX ( ID_IDLESKIP , CConfigMain : : CoreSettingsChanged )
EVT_CHECKBOX ( ID_ENABLECHEATS , CConfigMain : : CoreSettingsChanged )
EVT_CHOICE ( ID_GC_SRAM_LNG , CConfigMain : : GCSettingsChanged )
EVT_CHOICE ( ID_WII_BT_BAR , CConfigMain : : WiiSettingsChanged )
EVT_CHECKBOX ( ID_WII_IPL_SSV , CConfigMain : : WiiSettingsChanged )
EVT_CHECKBOX ( ID_WII_IPL_PGS , CConfigMain : : WiiSettingsChanged )
EVT_CHECKBOX ( ID_WII_IPL_E60 , CConfigMain : : WiiSettingsChanged )
EVT_CHOICE ( ID_WII_IPL_AR , CConfigMain : : WiiSettingsChanged )
EVT_CHOICE ( ID_WII_IPL_LNG , CConfigMain : : WiiSettingsChanged )
2008-10-14 02:56:03 +00:00
EVT_LISTBOX ( ID_ISOPATHS , CConfigMain : : ISOPathsSelectionChanged )
2008-09-24 00:27:50 +00:00
EVT_BUTTON ( ID_ADDISOPATH , CConfigMain : : AddRemoveISOPaths )
EVT_BUTTON ( ID_REMOVEISOPATH , CConfigMain : : AddRemoveISOPaths )
2008-09-23 05:43:52 +00:00
EVT_FILEPICKER_CHANGED ( ID_DEFAULTISO , CConfigMain : : DefaultISOChanged )
EVT_DIRPICKER_CHANGED ( ID_DVDROOT , CConfigMain : : DVDRootChanged )
EVT_CHOICE ( ID_GRAPHIC_CB , CConfigMain : : OnSelectionChanged )
EVT_BUTTON ( ID_GRAPHIC_CONFIG , CConfigMain : : OnConfig )
EVT_CHOICE ( ID_DSP_CB , CConfigMain : : OnSelectionChanged )
EVT_BUTTON ( ID_DSP_CONFIG , CConfigMain : : OnConfig )
EVT_CHOICE ( ID_PAD_CB , CConfigMain : : OnSelectionChanged )
EVT_BUTTON ( ID_PAD_CONFIG , CConfigMain : : OnConfig )
EVT_CHOICE ( ID_WIIMOTE_CB , CConfigMain : : OnSelectionChanged )
EVT_BUTTON ( ID_WIIMOTE_CONFIG , CConfigMain : : OnConfig )
END_EVENT_TABLE ( )
CConfigMain : : CConfigMain ( wxWindow * parent , wxWindowID id , const wxString & title , const wxPoint & position , const wxSize & size , long style )
: wxDialog ( parent , id , title , position , size , style )
{
2008-10-14 02:56:03 +00:00
bRefreshList = false ;
2008-11-04 09:56:25 +00:00
2008-10-30 21:01:20 +00:00
// Load Wii SYSCONF
pStream = NULL ;
2008-11-12 04:54:17 +00:00
pStream = fopen ( FULL_WII_USER_DIR " shared2/sys/SYSCONF " , " rb " ) ;
2008-10-30 21:01:20 +00:00
if ( pStream ! = NULL )
{
fread ( m_SYSCONF , 1 , 0x4000 , pStream ) ;
fclose ( pStream ) ;
}
else
{
PanicAlert ( " Could not read Wii SYSCONF " ) ;
}
2008-09-23 05:43:52 +00:00
CreateGUIControls ( ) ;
}
CConfigMain : : ~ CConfigMain ( )
{
}
void CConfigMain : : CreateGUIControls ( )
{
2008-11-04 09:56:25 +00:00
// Why does this not work? some restriction is needed so that huge
// ISO paths dont cause the dialog to become gargantuan
SetMaxSize ( wxSize ( 350 , 350 ) ) ;
2008-09-23 05:43:52 +00:00
Notebook = new wxNotebook ( this , ID_NOTEBOOK , wxDefaultPosition , wxDefaultSize ) ;
GeneralPage = new wxPanel ( Notebook , ID_GENERALPAGE , wxDefaultPosition , wxDefaultSize ) ;
2008-10-25 12:02:37 +00:00
Notebook - > AddPage ( GeneralPage , wxT ( " Core " ) ) ;
2008-10-30 21:01:20 +00:00
GamecubePage = new wxPanel ( Notebook , ID_GAMECUBEPAGE , wxDefaultPosition , wxDefaultSize ) ;
Notebook - > AddPage ( GamecubePage , wxT ( " Gamecube " ) ) ;
WiiPage = new wxPanel ( Notebook , ID_WIIPAGE , wxDefaultPosition , wxDefaultSize ) ;
Notebook - > AddPage ( WiiPage , wxT ( " Wii " ) ) ;
2008-09-23 05:43:52 +00:00
PathsPage = new wxPanel ( Notebook , ID_PATHSPAGE , wxDefaultPosition , wxDefaultSize ) ;
Notebook - > AddPage ( PathsPage , wxT ( " Paths " ) ) ;
PluginPage = new wxPanel ( Notebook , ID_PLUGINPAGE , wxDefaultPosition , wxDefaultSize ) ;
Notebook - > AddPage ( PluginPage , wxT ( " Plugins " ) ) ;
2008-11-04 09:56:25 +00:00
m_Close = new wxButton ( this , ID_CLOSE , wxT ( " Close " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-09-23 05:43:52 +00:00
wxBoxSizer * sButtons ;
sButtons = new wxBoxSizer ( wxHORIZONTAL ) ;
sButtons - > Add ( 0 , 0 , 1 , wxEXPAND , 5 ) ;
2008-11-04 09:56:25 +00:00
sButtons - > Add ( m_Close , 0 , wxALL , 5 ) ;
2008-09-23 05:43:52 +00:00
wxBoxSizer * sMain ;
sMain = new wxBoxSizer ( wxVERTICAL ) ;
sMain - > Add ( Notebook , 1 , wxEXPAND | wxALL , 5 ) ;
sMain - > Add ( sButtons , 0 , wxEXPAND , 5 ) ;
this - > SetSizer ( sMain ) ;
this - > Layout ( ) ;
2008-10-30 21:01:20 +00:00
// Core page
sbBasic = new wxStaticBoxSizer ( wxVERTICAL , GeneralPage , wxT ( " Basic Settings " ) ) ;
UseDualCore = new wxCheckBox ( GeneralPage , ID_USEDUALCORE , wxT ( " Enable Dual Core " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
UseDualCore - > SetValue ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bUseDualCore ) ;
SkipIdle = new wxCheckBox ( GeneralPage , ID_IDLESKIP , wxT ( " Enable Idle Skipping " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
SkipIdle - > SetValue ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bSkipIdle ) ;
2008-11-04 09:56:25 +00:00
EnableCheats = new wxCheckBox ( GeneralPage , ID_ENABLECHEATS , wxT ( " Enable Cheats " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-10-30 21:01:20 +00:00
EnableCheats - > SetValue ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bEnableCheats ) ;
sbAdvanced = new wxStaticBoxSizer ( wxVERTICAL , GeneralPage , wxT ( " Advanced Settings " ) ) ;
2008-09-23 05:43:52 +00:00
AllwaysHLEBIOS = new wxCheckBox ( GeneralPage , ID_ALLWAYS_HLEBIOS , wxT ( " HLE the BIOS all the time " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
AllwaysHLEBIOS - > SetValue ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bHLEBios ) ;
2008-10-25 12:02:37 +00:00
UseDynaRec = new wxCheckBox ( GeneralPage , ID_USEDYNAREC , wxT ( " Enable Dynamic Recompilation " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-09-23 05:43:52 +00:00
UseDynaRec - > SetValue ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bUseJIT ) ;
LockThreads = new wxCheckBox ( GeneralPage , ID_LOCKTHREADS , wxT ( " Lock threads to cores " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
LockThreads - > SetValue ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bLockThreads ) ;
2008-10-25 12:02:37 +00:00
OptimizeQuantizers = new wxCheckBox ( GeneralPage , ID_OPTIMIZEQUANTIZERS , wxT ( " Optimize Quantizers " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-09-23 05:43:52 +00:00
OptimizeQuantizers - > SetValue ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bOptimizeQuantizers ) ;
2008-10-30 21:01:20 +00:00
sGeneral = new wxBoxSizer ( wxVERTICAL ) ;
sbBasic - > Add ( UseDualCore , 0 , wxALL , 5 ) ;
sbBasic - > Add ( SkipIdle , 0 , wxALL , 5 ) ;
sbBasic - > Add ( EnableCheats , 0 , wxALL , 5 ) ;
2008-10-31 05:40:52 +00:00
sGeneral - > Add ( sbBasic , 0 , wxEXPAND | wxALL , 5 ) ;
sGeneral - > AddStretchSpacer ( ) ;
2008-10-30 21:01:20 +00:00
sbAdvanced - > Add ( AllwaysHLEBIOS , 0 , wxALL , 5 ) ;
sbAdvanced - > Add ( UseDynaRec , 0 , wxALL , 5 ) ;
sbAdvanced - > Add ( LockThreads , 0 , wxALL , 5 ) ;
sbAdvanced - > Add ( OptimizeQuantizers , 0 , wxALL , 5 ) ;
2008-10-31 05:40:52 +00:00
sGeneral - > Add ( sbAdvanced , 0 , wxEXPAND | wxALL , 5 ) ;
2008-09-23 05:43:52 +00:00
GeneralPage - > SetSizer ( sGeneral ) ;
sGeneral - > Layout ( ) ;
2008-10-30 21:01:20 +00:00
// Gamecube page
2008-10-31 05:40:52 +00:00
sbGamecubeIPLSettings = new wxStaticBoxSizer ( wxVERTICAL , GamecubePage , wxT ( " IPL Settings " ) ) ;
2008-10-30 21:01:20 +00:00
arrayStringFor_GCSystemLang . Add ( wxT ( " English " ) ) ;
arrayStringFor_GCSystemLang . Add ( wxT ( " German " ) ) ;
arrayStringFor_GCSystemLang . Add ( wxT ( " French " ) ) ;
arrayStringFor_GCSystemLang . Add ( wxT ( " Spanish " ) ) ;
arrayStringFor_GCSystemLang . Add ( wxT ( " Italian " ) ) ;
arrayStringFor_GCSystemLang . Add ( wxT ( " Dutch " ) ) ;
GCSystemLangText = new wxStaticText ( GamecubePage , ID_GC_SRAM_LNG_TEXT , wxT ( " System Language: " ) , wxDefaultPosition , wxDefaultSize ) ;
GCSystemLang = new wxChoice ( GamecubePage , ID_GC_SRAM_LNG , wxDefaultPosition , wxDefaultSize , arrayStringFor_GCSystemLang , 0 , wxDefaultValidator ) ;
GCSystemLang - > SetSelection ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . SelectedLanguage ) ;
2008-10-31 05:40:52 +00:00
sGamecube = new wxBoxSizer ( wxVERTICAL ) ;
sGamecubeIPLSettings = new wxGridBagSizer ( 0 , 0 ) ;
sGamecubeIPLSettings - > Add ( GCSystemLangText , wxGBPosition ( 0 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
sGamecubeIPLSettings - > Add ( GCSystemLang , wxGBPosition ( 0 , 1 ) , wxGBSpan ( 1 , 1 ) , wxALL , 5 ) ;
sbGamecubeIPLSettings - > Add ( sGamecubeIPLSettings ) ;
sGamecube - > Add ( sbGamecubeIPLSettings , 0 , wxEXPAND | wxALL , 5 ) ;
GamecubePage - > SetSizer ( sGamecube ) ;
sGamecube - > Layout ( ) ;
2008-10-30 21:01:20 +00:00
// Wii SYSCONF page
sbWiimoteSettings = new wxStaticBoxSizer ( wxVERTICAL , WiiPage , wxT ( " Wiimote Settings " ) ) ;
arrayStringFor_WiiSensBarPos . Add ( wxT ( " Bottom " ) ) ; arrayStringFor_WiiSensBarPos . Add ( wxT ( " Top " ) ) ;
WiiSensBarPosText = new wxStaticText ( WiiPage , ID_WII_BT_BAR_TEXT , wxT ( " Sensor Bar Position: " ) , wxDefaultPosition , wxDefaultSize ) ;
WiiSensBarPos = new wxChoice ( WiiPage , ID_WII_BT_BAR , wxDefaultPosition , wxDefaultSize , arrayStringFor_WiiSensBarPos , 0 , wxDefaultValidator ) ;
WiiSensBarPos - > SetSelection ( m_SYSCONF [ BT_BAR ] ) ;
sbWiiIPLSettings = new wxStaticBoxSizer ( wxVERTICAL , WiiPage , wxT ( " IPL Settings " ) ) ;
WiiScreenSaver = new wxCheckBox ( WiiPage , ID_WII_IPL_SSV , wxT ( " Enable Screen Saver (burn-in reduction) " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-10-30 21:42:47 +00:00
WiiScreenSaver - > SetValue ( m_SYSCONF [ IPL_SSV ] ! = 0 ) ;
2008-10-30 21:01:20 +00:00
WiiProgressiveScan = new wxCheckBox ( WiiPage , ID_WII_IPL_PGS , wxT ( " Enable Progressive Scan " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-10-30 21:42:47 +00:00
WiiProgressiveScan - > SetValue ( m_SYSCONF [ IPL_PGS ] ! = 0 ) ;
2008-10-30 21:01:20 +00:00
WiiEuRGB60 = new wxCheckBox ( WiiPage , ID_WII_IPL_E60 , wxT ( " Use EuRGB60 Mode (PAL6) " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-10-30 21:42:47 +00:00
WiiEuRGB60 - > SetValue ( m_SYSCONF [ IPL_E60 ] ! = 0 ) ;
2008-10-30 21:01:20 +00:00
arrayStringFor_WiiAspectRatio . Add ( wxT ( " 4:3 " ) ) ; arrayStringFor_WiiAspectRatio . Add ( wxT ( " 16:9 " ) ) ;
WiiAspectRatioText = new wxStaticText ( WiiPage , ID_WII_IPL_AR_TEXT , wxT ( " Aspect Ratio: " ) , wxDefaultPosition , wxDefaultSize ) ;
WiiAspectRatio = new wxChoice ( WiiPage , ID_WII_IPL_AR , wxDefaultPosition , wxDefaultSize , arrayStringFor_WiiAspectRatio , 0 , wxDefaultValidator ) ;
WiiAspectRatio - > SetSelection ( m_SYSCONF [ IPL_AR ] ) ;
2008-10-30 21:42:47 +00:00
arrayStringFor_WiiSystemLang = arrayStringFor_GCSystemLang ;
arrayStringFor_WiiSystemLang . Insert ( wxT ( " Japanese " ) , 0 ) ;
2008-10-30 21:01:20 +00:00
WiiSystemLangText = new wxStaticText ( WiiPage , ID_WII_IPL_LNG_TEXT , wxT ( " System Language: " ) , wxDefaultPosition , wxDefaultSize ) ;
2008-10-30 21:42:47 +00:00
WiiSystemLang = new wxChoice ( WiiPage , ID_WII_IPL_LNG , wxDefaultPosition , wxDefaultSize , arrayStringFor_WiiSystemLang , 0 , wxDefaultValidator ) ;
2008-10-30 21:01:20 +00:00
WiiSystemLang - > SetSelection ( m_SYSCONF [ IPL_LNG ] ) ;
sWii = new wxBoxSizer ( wxVERTICAL ) ;
sWiimoteSettings = new wxGridBagSizer ( 0 , 0 ) ;
sWiimoteSettings - > Add ( WiiSensBarPosText , wxGBPosition ( 0 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
sWiimoteSettings - > Add ( WiiSensBarPos , wxGBPosition ( 0 , 1 ) , wxGBSpan ( 1 , 1 ) , wxALL , 5 ) ;
sbWiimoteSettings - > Add ( sWiimoteSettings ) ;
2008-10-31 05:40:52 +00:00
sWii - > Add ( sbWiimoteSettings , 0 , wxEXPAND | wxALL , 5 ) ;
2008-10-30 21:01:20 +00:00
sWiiIPLSettings = new wxGridBagSizer ( 0 , 0 ) ;
sWiiIPLSettings - > Add ( WiiScreenSaver , wxGBPosition ( 0 , 0 ) , wxGBSpan ( 1 , 2 ) , wxALL , 5 ) ;
sWiiIPLSettings - > Add ( WiiProgressiveScan , wxGBPosition ( 1 , 0 ) , wxGBSpan ( 1 , 2 ) , wxALL , 5 ) ;
sWiiIPLSettings - > Add ( WiiEuRGB60 , wxGBPosition ( 2 , 0 ) , wxGBSpan ( 1 , 2 ) , wxALL , 5 ) ;
sWiiIPLSettings - > Add ( WiiAspectRatioText , wxGBPosition ( 3 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
sWiiIPLSettings - > Add ( WiiAspectRatio , wxGBPosition ( 3 , 1 ) , wxGBSpan ( 1 , 1 ) , wxALL , 5 ) ;
sWiiIPLSettings - > Add ( WiiSystemLangText , wxGBPosition ( 4 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
sWiiIPLSettings - > Add ( WiiSystemLang , wxGBPosition ( 4 , 1 ) , wxGBSpan ( 1 , 1 ) , wxALL , 5 ) ;
sbWiiIPLSettings - > Add ( sWiiIPLSettings ) ;
2008-10-31 05:40:52 +00:00
sWii - > Add ( sbWiiIPLSettings , 0 , wxEXPAND | wxALL , 5 ) ;
2008-10-30 21:01:20 +00:00
WiiPage - > SetSizer ( sWii ) ;
sWii - > Layout ( ) ;
2008-09-23 05:43:52 +00:00
// Paths page
2008-10-30 21:01:20 +00:00
sbISOPaths = new wxStaticBoxSizer ( wxVERTICAL , PathsPage , wxT ( " ISO Directories " ) ) ;
2008-09-24 07:04:56 +00:00
for ( u32 i = 0 ; i < SConfig : : GetInstance ( ) . m_ISOFolder . size ( ) ; i + + )
2008-09-24 00:27:50 +00:00
{
arrayStringFor_ISOPaths . Add ( wxString ( SConfig : : GetInstance ( ) . m_ISOFolder [ i ] . c_str ( ) , wxConvUTF8 ) ) ;
}
2008-10-31 05:40:52 +00:00
ISOPaths = new wxListBox ( PathsPage , ID_ISOPATHS , wxDefaultPosition , wxDefaultSize , arrayStringFor_ISOPaths , wxLB_SINGLE , wxDefaultValidator ) ;
2008-09-23 05:43:52 +00:00
AddISOPath = new wxButton ( PathsPage , ID_ADDISOPATH , wxT ( " Add... " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
RemoveISOPath = new wxButton ( PathsPage , ID_REMOVEISOPATH , wxT ( " Remove " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2008-10-14 02:56:03 +00:00
RemoveISOPath - > Enable ( false ) ;
2008-09-23 05:43:52 +00:00
DefaultISOText = new wxStaticText ( PathsPage , ID_DEFAULTISO_TEXT , wxT ( " Default ISO: " ) , wxDefaultPosition , wxDefaultSize ) ;
DefaultISO = new wxFilePickerCtrl ( PathsPage , ID_DEFAULTISO , wxEmptyString , wxT ( " Choose a default ISO: " ) ,
wxString : : Format ( wxT ( " All GC/Wii images (gcm, iso, gcz)|*.gcm;*.iso;*.gcz|All files (%s)|%s " ) , wxFileSelectorDefaultWildcardStr , wxFileSelectorDefaultWildcardStr ) ,
wxDefaultPosition , wxDefaultSize , wxFLP_USE_TEXTCTRL | wxFLP_FILE_MUST_EXIST | wxFLP_OPEN ) ;
2008-09-23 06:59:35 +00:00
DefaultISO - > SetPath ( wxString : : FromAscii ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strDefaultGCM . c_str ( ) ) ) ;
2008-09-23 05:43:52 +00:00
DVDRootText = new wxStaticText ( PathsPage , ID_DVDROOT_TEXT , wxT ( " DVD Root: " ) , wxDefaultPosition , wxDefaultSize ) ;
DVDRoot = new wxDirPickerCtrl ( PathsPage , ID_DVDROOT , wxEmptyString , wxT ( " Choose a DVD root directory: " ) , wxDefaultPosition , wxDefaultSize , wxDIRP_USE_TEXTCTRL ) ;
2008-09-23 06:59:35 +00:00
DVDRoot - > SetPath ( wxString : : FromAscii ( SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strDVDRoot . c_str ( ) ) ) ;
2008-09-23 05:43:52 +00:00
2008-10-31 05:40:52 +00:00
sPaths = new wxBoxSizer ( wxVERTICAL ) ;
2008-11-11 18:39:09 +00:00
sbISOPaths - > Add ( ISOPaths , 1 , wxEXPAND | wxALL , 0 ) ;
2008-10-31 05:40:52 +00:00
sISOButtons = new wxBoxSizer ( wxHORIZONTAL ) ;
sISOButtons - > AddStretchSpacer ( 1 ) ;
2008-11-11 18:39:09 +00:00
sISOButtons - > Add ( AddISOPath , 0 , wxALL , 0 ) ;
sISOButtons - > Add ( RemoveISOPath , 0 , wxALL , 0 ) ;
2008-10-31 05:40:52 +00:00
sbISOPaths - > Add ( sISOButtons , 0 , wxEXPAND | wxALL , 5 ) ;
sPaths - > Add ( sbISOPaths , 1 , wxEXPAND | wxALL , 5 ) ;
sOtherPaths = new wxGridBagSizer ( 0 , 0 ) ;
sOtherPaths - > AddGrowableCol ( 1 ) ;
sOtherPaths - > Add ( DefaultISOText , wxGBPosition ( 0 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
sOtherPaths - > Add ( DefaultISO , wxGBPosition ( 0 , 1 ) , wxGBSpan ( 1 , 1 ) , wxEXPAND | wxALL , 5 ) ;
sOtherPaths - > Add ( DVDRootText , wxGBPosition ( 1 , 0 ) , wxGBSpan ( 1 , 1 ) , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
sOtherPaths - > Add ( DVDRoot , wxGBPosition ( 1 , 1 ) , wxGBSpan ( 1 , 1 ) , wxEXPAND | wxALL , 5 ) ;
sPaths - > Add ( sOtherPaths , 0 , wxEXPAND | wxALL , 5 ) ;
2008-09-23 05:43:52 +00:00
PathsPage - > SetSizer ( sPaths ) ;
sPaths - > Layout ( ) ;
// Plugin page
2008-10-31 05:40:52 +00:00
sbGraphicsPlugin = new wxStaticBoxSizer ( wxHORIZONTAL , PluginPage , wxT ( " Graphics " ) ) ;
2008-09-23 05:43:52 +00:00
GraphicSelection = new wxChoice ( PluginPage , ID_GRAPHIC_CB , wxDefaultPosition , wxDefaultSize , NULL , 0 , wxDefaultValidator ) ;
GraphicConfig = new wxButton ( PluginPage , ID_GRAPHIC_CONFIG , wxT ( " Config... " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-10-31 05:40:52 +00:00
sbDSPPlugin = new wxStaticBoxSizer ( wxHORIZONTAL , PluginPage , wxT ( " DSP " ) ) ;
2008-09-23 05:43:52 +00:00
DSPSelection = new wxChoice ( PluginPage , ID_DSP_CB , wxDefaultPosition , wxDefaultSize , NULL , 0 , wxDefaultValidator ) ;
DSPConfig = new wxButton ( PluginPage , ID_DSP_CONFIG , wxT ( " Config... " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-10-31 05:40:52 +00:00
sbPadPlugin = new wxStaticBoxSizer ( wxHORIZONTAL , PluginPage , wxT ( " Pad " ) ) ;
2008-09-23 05:43:52 +00:00
PADSelection = new wxChoice ( PluginPage , ID_PAD_CB , wxDefaultPosition , wxDefaultSize , NULL , 0 , wxDefaultValidator ) ;
PADConfig = new wxButton ( PluginPage , ID_PAD_CONFIG , wxT ( " Config... " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-10-31 05:40:52 +00:00
sbWiimotePlugin = new wxStaticBoxSizer ( wxHORIZONTAL , PluginPage , wxT ( " Wiimote " ) ) ;
2008-09-23 05:43:52 +00:00
WiimoteSelection = new wxChoice ( PluginPage , ID_WIIMOTE_CB , wxDefaultPosition , wxDefaultSize , NULL , 0 , wxDefaultValidator ) ;
WiimoteConfig = new wxButton ( PluginPage , ID_WIIMOTE_CONFIG , wxT ( " Config... " ) , wxDefaultPosition , wxDefaultSize , 0 , wxDefaultValidator ) ;
2008-10-31 05:40:52 +00:00
FillChoiceBox ( GraphicSelection , PLUGIN_TYPE_VIDEO , SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strVideoPlugin ) ;
FillChoiceBox ( DSPSelection , PLUGIN_TYPE_DSP , SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strDSPPlugin ) ;
FillChoiceBox ( PADSelection , PLUGIN_TYPE_PAD , SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strPadPlugin ) ;
2008-09-23 05:43:52 +00:00
FillChoiceBox ( WiimoteSelection , PLUGIN_TYPE_WIIMOTE , SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strWiimotePlugin ) ;
2008-10-31 05:40:52 +00:00
sPlugins = new wxBoxSizer ( wxVERTICAL ) ;
sbGraphicsPlugin - > Add ( GraphicSelection , 1 , wxEXPAND | wxALL , 5 ) ;
sbGraphicsPlugin - > Add ( GraphicConfig , 0 , wxALL , 5 ) ;
sPlugins - > Add ( sbGraphicsPlugin , 0 , wxEXPAND | wxALL , 5 ) ;
2008-09-23 05:43:52 +00:00
2008-10-31 05:40:52 +00:00
sbDSPPlugin - > Add ( DSPSelection , 1 , wxEXPAND | wxALL , 5 ) ;
sbDSPPlugin - > Add ( DSPConfig , 0 , wxALL , 5 ) ;
sPlugins - > Add ( sbDSPPlugin , 0 , wxEXPAND | wxALL , 5 ) ;
2008-09-23 05:43:52 +00:00
2008-10-31 05:40:52 +00:00
sbPadPlugin - > Add ( PADSelection , 1 , wxEXPAND | wxALL , 5 ) ;
sbPadPlugin - > Add ( PADConfig , 0 , wxALL , 5 ) ;
sPlugins - > Add ( sbPadPlugin , 0 , wxEXPAND | wxALL , 5 ) ;
2008-09-23 05:43:52 +00:00
2008-10-31 05:40:52 +00:00
sbWiimotePlugin - > Add ( WiimoteSelection , 1 , wxEXPAND | wxALL , 5 ) ;
sbWiimotePlugin - > Add ( WiimoteConfig , 0 , wxALL , 5 ) ;
sPlugins - > Add ( sbWiimotePlugin , 0 , wxEXPAND | wxALL , 5 ) ;
2008-09-23 05:43:52 +00:00
PluginPage - > SetSizer ( sPlugins ) ;
sPlugins - > Layout ( ) ;
Fit ( ) ;
2008-11-04 09:56:25 +00:00
Center ( ) ;
2008-09-23 05:43:52 +00:00
}
void CConfigMain : : OnClose ( wxCloseEvent & WXUNUSED ( event ) )
{
Destroy ( ) ;
2008-11-04 09:56:25 +00:00
// Save Wii SYSCONF
pStream = NULL ;
2008-11-12 04:54:17 +00:00
pStream = fopen ( FULL_WII_USER_DIR " shared2/sys/SYSCONF " , " wb " ) ;
2008-11-04 09:56:25 +00:00
if ( pStream ! = NULL )
2008-09-23 05:43:52 +00:00
{
2008-11-04 09:56:25 +00:00
fwrite ( m_SYSCONF , 1 , 0x4000 , pStream ) ;
fclose ( pStream ) ;
2008-09-23 05:43:52 +00:00
}
2008-11-04 09:56:25 +00:00
else
{
PanicAlert ( " Could not write to Wii SYSCONF " ) ;
}
2008-11-05 12:02:35 +00:00
// save the config... dolphin crashes by far to often to save the settings on closing only
SConfig : : GetInstance ( ) . SaveSettings ( ) ;
2008-11-04 09:56:25 +00:00
}
void CConfigMain : : CloseClick ( wxCommandEvent & WXUNUSED ( event ) )
{
Close ( ) ;
2008-09-23 05:43:52 +00:00
}
2008-10-30 21:01:20 +00:00
void CConfigMain : : CoreSettingsChanged ( wxCommandEvent & event )
2008-09-23 05:43:52 +00:00
{
2008-10-30 21:01:20 +00:00
switch ( event . GetId ( ) )
{
case ID_ALLWAYS_HLEBIOS :
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bHLEBios = AllwaysHLEBIOS - > IsChecked ( ) ;
break ;
case ID_USEDYNAREC :
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bUseJIT = UseDynaRec - > IsChecked ( ) ;
break ;
case ID_USEDUALCORE :
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bUseDualCore = UseDualCore - > IsChecked ( ) ;
break ;
case ID_LOCKTHREADS :
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bLockThreads = LockThreads - > IsChecked ( ) ;
break ;
case ID_OPTIMIZEQUANTIZERS :
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bOptimizeQuantizers = OptimizeQuantizers - > IsChecked ( ) ;
break ;
case ID_IDLESKIP :
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bSkipIdle = SkipIdle - > IsChecked ( ) ;
break ;
case ID_ENABLECHEATS :
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bEnableCheats = EnableCheats - > IsChecked ( ) ;
break ;
}
2008-09-23 05:43:52 +00:00
}
2008-10-30 21:01:20 +00:00
void CConfigMain : : GCSettingsChanged ( wxCommandEvent & event )
2008-10-25 10:11:35 +00:00
{
2008-10-30 21:01:20 +00:00
switch ( event . GetId ( ) )
{
case ID_GC_SRAM_LNG :
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . SelectedLanguage = GCSystemLang - > GetSelection ( ) ;
break ;
}
2008-10-25 10:11:35 +00:00
}
2008-10-30 21:01:20 +00:00
void CConfigMain : : WiiSettingsChanged ( wxCommandEvent & event )
2008-09-23 05:43:52 +00:00
{
2008-10-30 21:01:20 +00:00
switch ( event . GetId ( ) )
{
case ID_WII_BT_BAR :
m_SYSCONF [ BT_BAR ] = WiiSensBarPos - > GetSelection ( ) ;
break ;
case ID_WII_IPL_AR :
m_SYSCONF [ IPL_AR ] = WiiAspectRatio - > GetSelection ( ) ;
break ;
case ID_WII_IPL_SSV :
m_SYSCONF [ IPL_SSV ] = WiiScreenSaver - > IsChecked ( ) ;
break ;
case ID_WII_IPL_LNG :
m_SYSCONF [ IPL_LNG ] = WiiSystemLang - > GetSelection ( ) ;
break ;
case ID_WII_IPL_PGS :
m_SYSCONF [ IPL_PGS ] = WiiProgressiveScan - > IsChecked ( ) ;
break ;
case ID_WII_IPL_E60 :
m_SYSCONF [ IPL_E60 ] = WiiEuRGB60 - > IsChecked ( ) ;
break ;
}
2008-09-23 05:43:52 +00:00
}
2008-10-14 02:56:03 +00:00
void CConfigMain : : ISOPathsSelectionChanged ( wxCommandEvent & WXUNUSED ( event ) )
{
if ( ! ISOPaths - > GetStringSelection ( ) . empty ( ) )
{
RemoveISOPath - > Enable ( true ) ;
}
else
{
RemoveISOPath - > Enable ( false ) ;
}
}
2008-09-24 00:27:50 +00:00
void CConfigMain : : AddRemoveISOPaths ( wxCommandEvent & event )
{
2008-10-14 02:56:03 +00:00
if ( event . GetId ( ) = = ID_ADDISOPATH )
2008-09-24 00:27:50 +00:00
{
wxString dirHome ;
wxGetHomeDir ( & dirHome ) ;
wxDirDialog dialog ( this , _T ( " Choose a directory to add " ) , dirHome , wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ) ;
if ( dialog . ShowModal ( ) = = wxID_OK )
{
2008-11-03 01:06:07 +00:00
if ( ISOPaths - > FindString ( dialog . GetPath ( ) ) ! = - 1 )
{
wxMessageBox ( _ ( " The chosen directory is already in the list " ) , _ ( " Error " ) , wxOK ) ;
}
else
{
bRefreshList = true ;
ISOPaths - > Append ( dialog . GetPath ( ) ) ;
}
2008-09-24 00:27:50 +00:00
}
}
else
{
2008-10-14 02:56:03 +00:00
bRefreshList = true ;
2008-09-24 00:27:50 +00:00
ISOPaths - > Delete ( ISOPaths - > GetSelection ( ) ) ;
}
2008-10-14 02:56:03 +00:00
// Save changes right away
2008-09-24 00:27:50 +00:00
SConfig : : GetInstance ( ) . m_ISOFolder . clear ( ) ;
2008-10-14 02:56:03 +00:00
for ( unsigned int i = 0 ; i < ISOPaths - > GetCount ( ) ; i + + )
2008-09-24 00:27:50 +00:00
SConfig : : GetInstance ( ) . m_ISOFolder . push_back ( std : : string ( ISOPaths - > GetStrings ( ) [ i ] . ToAscii ( ) ) ) ;
}
2008-09-23 05:43:52 +00:00
void CConfigMain : : DefaultISOChanged ( wxFileDirPickerEvent & WXUNUSED ( event ) )
{
2008-09-23 06:59:35 +00:00
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strDefaultGCM = DefaultISO - > GetPath ( ) . ToAscii ( ) ;
2008-09-23 05:43:52 +00:00
}
void CConfigMain : : DVDRootChanged ( wxFileDirPickerEvent & WXUNUSED ( event ) )
{
2008-09-23 06:59:35 +00:00
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strDVDRoot = DVDRoot - > GetPath ( ) . ToAscii ( ) ;
2008-09-23 05:43:52 +00:00
}
void CConfigMain : : OnSelectionChanged ( wxCommandEvent & WXUNUSED ( event ) )
{
2008-11-04 09:56:25 +00:00
GetFilename ( GraphicSelection , SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strVideoPlugin ) ;
GetFilename ( DSPSelection , SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strDSPPlugin ) ;
GetFilename ( PADSelection , SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strPadPlugin ) ;
GetFilename ( WiimoteSelection , SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strWiimotePlugin ) ;
2008-09-23 05:43:52 +00:00
}
void CConfigMain : : OnConfig ( wxCommandEvent & event )
{
switch ( event . GetId ( ) )
{
case ID_GRAPHIC_CONFIG :
CallConfig ( GraphicSelection ) ;
break ;
case ID_DSP_CONFIG :
CallConfig ( DSPSelection ) ;
break ;
case ID_PAD_CONFIG :
CallConfig ( PADSelection ) ;
break ;
case ID_WIIMOTE_CONFIG :
CallConfig ( WiimoteSelection ) ;
break ;
}
}
void CConfigMain : : FillChoiceBox ( wxChoice * _pChoice , int _PluginType , const std : : string & _SelectFilename )
{
_pChoice - > Clear ( ) ;
int Index = - 1 ;
const CPluginInfos & rInfos = CPluginManager : : GetInstance ( ) . GetPluginInfos ( ) ;
for ( size_t i = 0 ; i < rInfos . size ( ) ; i + + )
{
const PLUGIN_INFO & rPluginInfo = rInfos [ i ] . GetPluginInfo ( ) ;
if ( rPluginInfo . Type = = _PluginType )
{
wxString temp ;
temp = wxString : : FromAscii ( rInfos [ i ] . GetPluginInfo ( ) . Name ) ;
int NewIndex = _pChoice - > Append ( temp , ( void * ) & rInfos [ i ] ) ;
if ( rInfos [ i ] . GetFileName ( ) = = _SelectFilename )
{
Index = NewIndex ;
}
}
}
_pChoice - > Select ( Index ) ;
}
void CConfigMain : : CallConfig ( wxChoice * _pChoice )
{
int Index = _pChoice - > GetSelection ( ) ;
if ( Index > = 0 )
{
const CPluginInfo * pInfo = static_cast < CPluginInfo * > ( _pChoice - > GetClientData ( Index ) ) ;
if ( pInfo ! = NULL )
CPluginManager : : GetInstance ( ) . OpenConfig ( ( HWND ) this - > GetHandle ( ) , pInfo - > GetFileName ( ) . c_str ( ) ) ;
}
}
bool CConfigMain : : GetFilename ( wxChoice * _pChoice , std : : string & _rFilename )
{
_rFilename . clear ( ) ;
int Index = _pChoice - > GetSelection ( ) ;
printf ( " %i \n " , Index ) ;
if ( Index > = 0 )
{
const CPluginInfo * pInfo = static_cast < CPluginInfo * > ( _pChoice - > GetClientData ( Index ) ) ;
_rFilename = pInfo - > GetFileName ( ) ;
printf ( " %s \n " , _rFilename . c_str ( ) ) ;
return ( true ) ;
}
return ( false ) ;
}