2014-07-29 11:14:25 -06:00
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
2014-02-10 11:54:46 -07:00
# pragma once
2010-11-15 02:54:07 -07:00
2014-02-22 15:36:30 -07:00
# include <cstddef>
2011-04-29 17:11:18 -06:00
# include <map>
2014-02-17 03:18:15 -07:00
# include <string>
# include <vector>
2014-07-29 11:14:25 -06:00
# include <wx/button.h>
2010-11-15 02:54:07 -07:00
# include <wx/checkbox.h>
2014-02-22 15:36:30 -07:00
# include <wx/choice.h>
# include <wx/defs.h>
# include <wx/dialog.h>
# include <wx/event.h>
# include <wx/msgdlg.h>
# include <wx/radiobut.h>
2010-11-15 02:54:07 -07:00
# include <wx/spinctrl.h>
2014-02-18 18:56:29 -07:00
# include <wx/stattext.h>
2014-02-22 15:36:30 -07:00
# include <wx/string.h>
# include <wx/translation.h>
# include <wx/window.h>
2011-03-22 18:54:31 -06:00
2014-02-22 15:36:30 -07:00
# include "Common/CommonTypes.h"
# include "Common/SysConf.h"
2014-02-17 03:18:15 -07:00
# include "Core/ConfigManager.h"
2014-05-23 07:45:14 -06:00
# include "Core/Core.h"
2014-02-22 15:36:30 -07:00
# include "Core/CoreParameter.h"
2014-07-29 11:14:25 -06:00
# include "DolphinWX/PostProcessingConfigDiag.h"
2014-02-17 03:18:15 -07:00
# include "DolphinWX/WxUtils.h"
2014-07-29 11:14:25 -06:00
# include "VideoCommon/PostProcessing.h"
2014-02-22 15:36:30 -07:00
# include "VideoCommon/VideoBackendBase.h"
2014-02-17 03:18:15 -07:00
# include "VideoCommon/VideoConfig.h"
2011-06-02 13:32:34 -06:00
2014-02-22 15:36:30 -07:00
class wxBoxSizer ;
class wxControl ;
class wxPanel ;
2011-04-25 14:06:45 -06:00
template < typename W >
class BoolSetting : public W
2010-11-15 02:54:07 -07:00
{
2011-04-05 16:46:57 -06:00
public :
2011-04-25 14:06:45 -06:00
BoolSetting ( wxWindow * parent , const wxString & label , const wxString & tooltip , bool & setting , bool reverse = false , long style = 0 ) ;
2011-03-27 16:23:44 -06:00
2010-11-15 02:54:07 -07:00
void UpdateValue ( wxCommandEvent & ev )
{
m_setting = ( ev . GetInt ( ) ! = 0 ) ^ m_reverse ;
2010-11-21 07:47:28 -07:00
ev . Skip ( ) ;
2010-11-15 02:54:07 -07:00
}
private :
bool & m_setting ;
const bool m_reverse ;
} ;
2011-04-25 14:06:45 -06:00
typedef BoolSetting < wxCheckBox > SettingCheckBox ;
typedef BoolSetting < wxRadioButton > SettingRadioButton ;
2011-02-12 02:10:11 -07:00
template < typename T >
class IntegerSetting : public wxSpinCtrl
{
public :
IntegerSetting ( wxWindow * parent , const wxString & label , T & setting , int minVal , int maxVal , long style = 0 ) ;
void UpdateValue ( wxCommandEvent & ev )
{
m_setting = ev . GetInt ( ) ;
ev . Skip ( ) ;
}
private :
T & m_setting ;
} ;
typedef IntegerSetting < u32 > U32Setting ;
2011-04-25 14:06:45 -06:00
class SettingChoice : public wxChoice
{
public :
2014-03-09 14:14:26 -06:00
SettingChoice ( wxWindow * parent , int & setting , const wxString & tooltip , int num = 0 , const wxString choices [ ] = nullptr , long style = 0 ) ;
2011-04-25 14:06:45 -06:00
void UpdateValue ( wxCommandEvent & ev ) ;
private :
int & m_setting ;
} ;
2011-02-20 16:42:21 -07:00
2010-11-15 02:54:07 -07:00
class VideoConfigDiag : public wxDialog
{
public :
2011-03-21 13:57:31 -06:00
VideoConfigDiag ( wxWindow * parent , const std : : string & title , const std : : string & ininame ) ;
2010-11-15 02:54:07 -07:00
2011-03-21 13:57:31 -06:00
protected :
2011-06-02 13:32:34 -06:00
void Event_Backend ( wxCommandEvent & ev )
{
VideoBackend * new_backend = g_available_video_backends [ ev . GetInt ( ) ] ;
if ( g_video_backend ! = new_backend )
{
2014-07-07 16:47:57 -06:00
bool do_switch = ! Core : : IsRunning ( ) ;
2011-06-03 22:34:44 -06:00
if ( new_backend - > GetName ( ) = = " Software Renderer " )
2011-06-02 13:32:34 -06:00
{
do_switch = ( wxYES = = wxMessageBox ( _ ( " Software rendering is an order of magnitude slower than using the other backends. \n It's only useful for debugging purposes. \n Do you really want to enable software rendering? If unsure, select 'No'. " ) ,
2011-06-03 22:34:44 -06:00
_ ( " Warning " ) , wxYES_NO | wxNO_DEFAULT | wxICON_EXCLAMATION , wxGetActiveWindow ( ) ) ) ;
2011-06-02 13:32:34 -06:00
}
if ( do_switch )
{
2011-06-03 22:34:44 -06:00
// TODO: Only reopen the dialog if the software backend is
// selected (make sure to reinitialize backend info)
2011-06-02 13:32:34 -06:00
// reopen the dialog
Close ( ) ;
g_video_backend = new_backend ;
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . m_strVideoBackend = g_video_backend - > GetName ( ) ;
g_video_backend - > ShowConfig ( GetParent ( ) ) ;
}
else
{
// Select current backend again
2013-02-28 01:39:06 -07:00
choice_backend - > SetStringSelection ( StrToWxStr ( g_video_backend - > GetName ( ) ) ) ;
2011-06-02 13:32:34 -06:00
}
}
ev . Skip ( ) ;
}
2010-11-21 07:47:28 -07:00
void Event_Adapter ( wxCommandEvent & ev ) { ev . Skip ( ) ; } // TODO
2011-06-02 17:28:47 -06:00
void Event_DisplayResolution ( wxCommandEvent & ev ) ;
2011-06-02 13:32:34 -06:00
void Event_ProgressiveScan ( wxCommandEvent & ev )
{
SConfig : : GetInstance ( ) . m_SYSCONF - > SetData ( " IPL.PGS " , ev . GetInt ( ) ) ;
2012-12-22 23:53:15 -07:00
SConfig : : GetInstance ( ) . m_LocalCoreStartupParameter . bProgressive = ev . IsChecked ( ) ;
2011-06-02 13:32:34 -06:00
ev . Skip ( ) ;
}
2011-04-29 08:37:47 -06:00
void Event_Stc ( wxCommandEvent & ev )
{
int samples [ ] = { 0 , 512 , 128 } ;
2011-12-26 14:04:59 -07:00
vconfig . iSafeTextureCache_ColorSamples = samples [ ev . GetInt ( ) ] ;
2011-04-29 08:37:47 -06:00
ev . Skip ( ) ;
}
2011-04-25 14:06:45 -06:00
void Event_PPShader ( wxCommandEvent & ev )
{
const int sel = ev . GetInt ( ) ;
if ( sel )
2013-02-27 21:37:38 -07:00
vconfig . sPostProcessingShader = WxStrToStr ( ev . GetString ( ) ) ;
2011-04-25 14:06:45 -06:00
else
vconfig . sPostProcessingShader . clear ( ) ;
2011-06-02 13:32:34 -06:00
2014-07-29 10:47:56 -06:00
// Should we enable the configuration button?
PostProcessingShaderConfiguration postprocessing_shader ;
postprocessing_shader . LoadShader ( vconfig . sPostProcessingShader ) ;
button_config_pp - > Enable ( postprocessing_shader . HasOptions ( ) ) ;
ev . Skip ( ) ;
}
void Event_ConfigurePPShader ( wxCommandEvent & ev )
{
PostProcessingConfigDiag dialog ( this , vconfig . sPostProcessingShader ) ;
dialog . ShowModal ( ) ;
2011-04-25 14:06:45 -06:00
ev . Skip ( ) ;
}
2010-11-15 02:54:07 -07:00
2011-02-13 06:42:59 -07:00
void Event_ClickClose ( wxCommandEvent & ) ;
void Event_Close ( wxCloseEvent & ) ;
2011-04-25 14:06:45 -06:00
// Enables/disables UI elements depending on current config
void OnUpdateUI ( wxUpdateUIEvent & ev )
{
// Anti-aliasing
choice_aamode - > Enable ( vconfig . backend_info . AAModes . size ( ) > 1 ) ;
text_aamode - > Enable ( vconfig . backend_info . AAModes . size ( ) > 1 ) ;
2014-07-19 12:18:03 -06:00
// Borderless Fullscreen
borderless_fullscreen - > Enable ( vconfig . backend_info . bSupportsExclusiveFullscreen ) ;
borderless_fullscreen - > Show ( vconfig . backend_info . bSupportsExclusiveFullscreen ) ;
2011-04-25 14:06:45 -06:00
// EFB copy
efbcopy_texture - > Enable ( vconfig . bEFBCopyEnable ) ;
efbcopy_ram - > Enable ( vconfig . bEFBCopyEnable ) ;
cache_efb_copies - > Enable ( vconfig . bEFBCopyEnable & & ! vconfig . bCopyEFBToTexture ) ;
2011-03-21 13:57:31 -06:00
2011-04-25 14:06:45 -06:00
// XFB
virtual_xfb - > Enable ( vconfig . bUseXFB ) ;
real_xfb - > Enable ( vconfig . bUseXFB ) ;
2013-10-28 23:23:17 -06:00
2011-04-25 14:06:45 -06:00
ev . Skip ( ) ;
}
2011-03-21 13:57:31 -06:00
2011-04-29 17:11:18 -06:00
// Creates controls and connects their enter/leave window events to Evt_Enter/LeaveControl
SettingCheckBox * CreateCheckBox ( wxWindow * parent , const wxString & label , const wxString & description , bool & setting , bool reverse = false , long style = 0 ) ;
2014-03-09 14:14:26 -06:00
SettingChoice * CreateChoice ( wxWindow * parent , int & setting , const wxString & description , int num = 0 , const wxString choices [ ] = nullptr , long style = 0 ) ;
2011-04-29 17:11:18 -06:00
SettingRadioButton * CreateRadioButton ( wxWindow * parent , const wxString & label , const wxString & description , bool & setting , bool reverse = false , long style = 0 ) ;
// Same as above but only connects enter/leave window events
wxControl * RegisterControl ( wxControl * const control , const wxString & description ) ;
void Evt_EnterControl ( wxMouseEvent & ev ) ;
void Evt_LeaveControl ( wxMouseEvent & ev ) ;
void CreateDescriptionArea ( wxPanel * const page , wxBoxSizer * const sizer ) ;
2011-06-02 13:32:34 -06:00
wxChoice * choice_backend ;
wxChoice * choice_display_resolution ;
2011-03-21 13:57:31 -06:00
wxStaticText * text_aamode ;
2011-04-25 14:06:45 -06:00
SettingChoice * choice_aamode ;
2011-03-21 13:57:31 -06:00
2014-07-29 11:14:25 -06:00
wxButton * button_config_pp ;
2014-07-19 12:18:03 -06:00
SettingCheckBox * borderless_fullscreen ;
2011-03-21 13:57:31 -06:00
SettingRadioButton * efbcopy_texture ;
SettingRadioButton * efbcopy_ram ;
SettingCheckBox * cache_efb_copies ;
SettingRadioButton * virtual_xfb ;
SettingRadioButton * real_xfb ;
2011-04-29 17:11:18 -06:00
std : : map < wxWindow * , wxString > ctrl_descs ; // maps setting controls to their descriptions
std : : map < wxWindow * , wxStaticText * > desc_texts ; // maps dialog tabs (which are the parents of the setting controls) to their description text objects
2011-04-25 14:06:45 -06:00
VideoConfig & vconfig ;
2011-03-21 13:57:31 -06:00
std : : string ininame ;
2010-11-15 02:54:07 -07:00
} ;