mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
* One Window 3-State changes (VideoSettings GUI):
- Added final support to string type (planned implementation reaches 100%) - Added support to post processing shaders (OpenGL backend) - Code Maintenance: - Reorganized the class hierarchy - General polishing... deleted some redundant code git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7437 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -28,57 +28,81 @@ enum tmp_TypeClass {
|
||||
allow_3State
|
||||
};
|
||||
|
||||
template <typename U>
|
||||
class BoolSettingCB : public wxCheckBox
|
||||
struct _pattern
|
||||
{
|
||||
protected:
|
||||
_pattern(bool *state, const tmp_TypeClass type);
|
||||
|
||||
bool *m_uistate;
|
||||
const tmp_TypeClass _type;
|
||||
|
||||
public:
|
||||
BoolSettingCB(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool reverse = false, long style = 0);
|
||||
/*
|
||||
Couldn't make this a pure abstract class since wxWidgets in use(v.2.8.x) is buggy;
|
||||
oddly, CommandEventHandler fails to connect&retrieve the correct target function.
|
||||
Newer wxWidgets versions don't have this problem...
|
||||
*/
|
||||
//virtual void UpdateValue(wxCommandEvent& ev) = 0;
|
||||
//virtual void UpdateUIState(bool state) = 0;
|
||||
//virtual void ChangeRefDataMember(tmp_MemberClass type, void *newRef) = 0;
|
||||
|
||||
tmp_TypeClass getTypeClass()
|
||||
{
|
||||
// This method returns what kind of support has the Object (2State or 3State).
|
||||
// NOTE: this doesn't return a run-time Control-state, since a 3State Control
|
||||
// can to switch to 2State and vice-versa, while an Object 2State only can't.
|
||||
return _type;
|
||||
}
|
||||
};
|
||||
|
||||
class SettingCheckBox : public _pattern, public wxCheckBox
|
||||
{
|
||||
DECLARE_CLASS(SettingCheckBox)
|
||||
|
||||
public:
|
||||
SettingCheckBox(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool reverse = false, long style = 0);
|
||||
|
||||
// overload constructor
|
||||
BoolSettingCB(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool &def_setting, bool &state, bool reverse = false, long style = 0);
|
||||
SettingCheckBox(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool &def_setting, bool &state, bool reverse = false, long style = 0);
|
||||
|
||||
void UpdateValue(wxCommandEvent& ev)
|
||||
{
|
||||
m_setting = (ev.GetInt() != 0) ^ m_reverse;
|
||||
if (_type == only_2State)
|
||||
{
|
||||
m_setting = (ev.GetInt() != 0) ^ m_reverse;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool style = (this->GetWindowStyle() == (wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER));
|
||||
|
||||
if (style)
|
||||
{
|
||||
// changing state value should be done here, never outside this block
|
||||
UpdateUIState(ev.GetInt() != wxCHK_UNDETERMINED);
|
||||
}
|
||||
|
||||
m_setting = (ev.GetInt() == wxCHK_CHECKED);
|
||||
if (m_uistate)
|
||||
{
|
||||
// if state = false and Checkbox ctrl allow 3RD STATE, then data = default_data
|
||||
m_setting = (style && !*m_uistate) ? *d_setting : m_setting;
|
||||
}
|
||||
|
||||
m_setting = m_setting ^ m_reverse;
|
||||
|
||||
if (!style && m_uistate) // this guarantees bidirectional access to default value
|
||||
if (!*m_uistate) *d_setting = m_setting;
|
||||
}
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
void UpdateValue_variant(wxCommandEvent& ev)
|
||||
void UpdateUIState(bool state)
|
||||
{
|
||||
bool style = (this->GetWindowStyle() == (wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER));
|
||||
|
||||
if (style)
|
||||
if (m_uistate && this->GetWindowStyle() == (wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER))
|
||||
{
|
||||
// changing state value should be done here, never outside this block
|
||||
UpdateUIState(ev.GetInt() != wxCHK_UNDETERMINED);
|
||||
}
|
||||
|
||||
m_setting = (ev.GetInt() == wxCHK_CHECKED);
|
||||
if (m_state)
|
||||
{
|
||||
// if state = false and Checkbox ctrl allow 3RD STATE, then data = default_data
|
||||
m_setting = (style && !*m_state) ? *d_setting : m_setting;
|
||||
}
|
||||
|
||||
m_setting = m_setting ^ m_reverse;
|
||||
|
||||
if (!style && m_state) // this guarantees bidirectional access to default value
|
||||
if (!*m_state) *d_setting = m_setting;
|
||||
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
// manual updating with an optional value if 'enter_updating' is passed and state is true
|
||||
void UpdateUIState(bool state, bool enter_updating = false, bool value = false)
|
||||
{
|
||||
if (m_state && this->GetWindowStyle() == (wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER))
|
||||
{
|
||||
*m_state = state;
|
||||
if (!*m_state)
|
||||
*m_uistate = state;
|
||||
if (!*m_uistate)
|
||||
m_setting = *d_setting ^ m_reverse;
|
||||
|
||||
if (enter_updating && *m_state)
|
||||
m_setting = value ^ m_reverse;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,33 +114,121 @@ public:
|
||||
d_setting = (bool*)newRef;
|
||||
break;
|
||||
case State:
|
||||
m_state = (bool*)newRef;
|
||||
m_uistate = (bool*)newRef;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// This method returns what kind of support has the Object (2State or 3State).
|
||||
// NOTE: this doesn't return a run-time Control-state, since a 3State Control
|
||||
// can to switch to 2State and vice-versa, while a 2State Object only can't.
|
||||
tmp_TypeClass getTypeClass()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
bool &m_setting;
|
||||
bool *d_setting;
|
||||
bool *m_state;
|
||||
const bool m_reverse;
|
||||
const tmp_TypeClass type;
|
||||
};
|
||||
|
||||
template <typename W>
|
||||
class BoolSettingRB : public wxRadioButton
|
||||
template <typename V>
|
||||
class SettingChoice : public _pattern, public wxChoice
|
||||
{
|
||||
DECLARE_CLASS(SettingChoice)
|
||||
|
||||
public:
|
||||
BoolSettingRB(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool reverse = false, long style = 0);
|
||||
SettingChoice(wxWindow* parent, V &setting, const wxString& tooltip, int num = 0, const wxString choices[] = NULL, long style = 0);
|
||||
|
||||
// overload constructor
|
||||
SettingChoice(wxWindow* parent, V &setting, V &def_setting, bool &state, int &cur_index, const wxString& tooltip, int num = 0, const wxString choices[] = NULL, long style = 0);
|
||||
|
||||
void UpdateValue(wxCommandEvent& ev)
|
||||
{
|
||||
m_setting = ev.GetInt();
|
||||
if (_type == allow_3State)
|
||||
{
|
||||
if (m_index != 0) // Choice ctrl with 3RD option
|
||||
{
|
||||
// changing state value should be done here, never outside this block
|
||||
if (m_setting == 0)
|
||||
{
|
||||
UpdateUIState(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateUIState(true);
|
||||
m_setting -= 1;
|
||||
}
|
||||
}
|
||||
else // Choice ctrl without 3RD option
|
||||
{
|
||||
if (m_uistate)
|
||||
if (!*m_uistate) *d_setting = m_setting;
|
||||
}
|
||||
}
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
void UpdateUIState(bool state)
|
||||
{
|
||||
if (m_uistate && m_index != 0)
|
||||
{
|
||||
*m_uistate = state;
|
||||
if (!*m_uistate)
|
||||
m_setting = *d_setting;
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeRefDataMember(tmp_MemberClass type, void *newRef)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Def_Data:
|
||||
d_setting = (V*)newRef;
|
||||
break;
|
||||
case State:
|
||||
m_uistate = (bool*)newRef;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
V &m_setting;
|
||||
V *d_setting;
|
||||
int &m_index;
|
||||
};
|
||||
|
||||
// partial specialization (SettingChoice template)
|
||||
void SettingChoice<std::string>::UpdateValue(wxCommandEvent& ev)
|
||||
{
|
||||
m_setting = ev.GetString().mb_str();
|
||||
if (_type == allow_3State)
|
||||
{
|
||||
if (m_index != 0) // Choice ctrl with 3RD option
|
||||
{
|
||||
// changing state value should be done here, never outside this block
|
||||
if (ev.GetInt() == 0)
|
||||
{
|
||||
UpdateUIState(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateUIState(true);
|
||||
if (ev.GetInt() == 1) m_setting.clear();
|
||||
}
|
||||
}
|
||||
else // Choice ctrl without 3RD option
|
||||
{
|
||||
if (m_uistate)
|
||||
if (!*m_uistate) *d_setting = m_setting;
|
||||
}
|
||||
}
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
typedef SettingChoice<int> IntSettingChoice;
|
||||
typedef SettingChoice<std::string> StringSettingChoice;
|
||||
|
||||
class SettingRadioButton : public _pattern, public wxRadioButton
|
||||
{
|
||||
DECLARE_CLASS(SettingRadioButton)
|
||||
|
||||
public:
|
||||
SettingRadioButton(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool reverse = false, long style = 0);
|
||||
|
||||
void UpdateValue(wxCommandEvent& ev)
|
||||
{
|
||||
@ -124,14 +236,15 @@ public:
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
void UpdateUIState(bool state) {}
|
||||
void ChangeRefDataMember(tmp_MemberClass type, void *newRef) {}
|
||||
|
||||
|
||||
private:
|
||||
bool &m_setting;
|
||||
const bool m_reverse;
|
||||
};
|
||||
|
||||
typedef BoolSettingCB<wxCheckBox> SettingCheckBox;
|
||||
typedef BoolSettingRB<wxRadioButton> SettingRadioButton;
|
||||
|
||||
template <typename T>
|
||||
class IntegerSetting : public wxSpinCtrl
|
||||
{
|
||||
@ -149,60 +262,6 @@ private:
|
||||
|
||||
typedef IntegerSetting<u32> U32Setting;
|
||||
|
||||
class SettingChoice : public wxChoice
|
||||
{
|
||||
public:
|
||||
SettingChoice(wxWindow* parent, int &setting, const wxString& tooltip, int num = 0, const wxString choices[] = NULL, long style = 0);
|
||||
|
||||
// overload constructor
|
||||
SettingChoice(wxWindow* parent, int &setting, int &def_setting, bool &state, int &cur_index, const wxString& tooltip, int num = 0, const wxString choices[] = NULL, long style = 0);
|
||||
|
||||
void UpdateValue(wxCommandEvent& ev);
|
||||
void UpdateValue_variant(wxCommandEvent& ev);
|
||||
|
||||
// manual updating with an optional value if 'enter_updating' is passed and state is true
|
||||
void UpdateUIState(bool state, bool enter_updating = false, int value = 0)
|
||||
{
|
||||
if (m_state && m_index != 0)
|
||||
{
|
||||
*m_state = state;
|
||||
if (!*m_state)
|
||||
m_setting = *d_setting;
|
||||
|
||||
if (enter_updating && *m_state)
|
||||
m_setting = value;
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeRefDataMember(tmp_MemberClass type, void *newRef)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Def_Data:
|
||||
d_setting = (int*)newRef;
|
||||
break;
|
||||
case State:
|
||||
m_state = (bool*)newRef;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// This method returns what kind of support has the Object (2State or 3State).
|
||||
// NOTE: this doesn't return a run-time Control-state, since a 3State Control
|
||||
// can to switch to 2State and vice-versa, while a 2State Object only can't.
|
||||
tmp_TypeClass getTypeClass()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
private:
|
||||
int &m_setting;
|
||||
int *d_setting;
|
||||
int &m_index;
|
||||
bool *m_state;
|
||||
const tmp_TypeClass type;
|
||||
};
|
||||
|
||||
class CGameListCtrl;
|
||||
|
||||
class VideoConfigDiag : public wxDialog
|
||||
@ -218,16 +277,6 @@ protected:
|
||||
void Event_StcNormal(wxCommandEvent &ev) { cur_vconfig.iSafeTextureCache_ColorSamples = 512; ev.Skip(); }
|
||||
void Event_StcFast(wxCommandEvent &ev) { cur_vconfig.iSafeTextureCache_ColorSamples = 128; ev.Skip(); }
|
||||
|
||||
void Event_PPShader(wxCommandEvent &ev)
|
||||
{
|
||||
const int sel = ev.GetInt();
|
||||
if (sel)
|
||||
cur_vconfig.sPostProcessingShader = ev.GetString().mb_str();
|
||||
else
|
||||
cur_vconfig.sPostProcessingShader.clear();
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
void Event_ClickClose(wxCommandEvent&);
|
||||
void Event_ClickDefault(wxCommandEvent&);
|
||||
void Event_Close(wxCloseEvent&);
|
||||
@ -244,17 +293,17 @@ protected:
|
||||
void ChangeStyle();
|
||||
|
||||
// Don't mess with keeping two comboboxes in sync, use only one CB instead..
|
||||
SettingChoice* profile_cb; // "General" tab
|
||||
SettingChoice<int>* profile_cb; // "General" tab
|
||||
wxStaticText* profile_text; // "Advanced" tab
|
||||
|
||||
SettingChoice* choice_adapter;
|
||||
SettingChoice* choice_aspect;
|
||||
IntSettingChoice* choice_adapter;
|
||||
IntSettingChoice* choice_aspect;
|
||||
SettingCheckBox* widescreen_hack;
|
||||
SettingCheckBox* vsync;
|
||||
|
||||
SettingChoice* anisotropic_filtering;
|
||||
IntSettingChoice* anisotropic_filtering;
|
||||
wxStaticText* text_aamode;
|
||||
SettingChoice* choice_aamode;
|
||||
IntSettingChoice* choice_aamode;
|
||||
|
||||
SettingCheckBox* native_mips;
|
||||
SettingCheckBox* efb_scaled_copy;
|
||||
@ -263,7 +312,7 @@ protected:
|
||||
SettingCheckBox* force_filtering;
|
||||
SettingCheckBox* _3d_vision;
|
||||
|
||||
SettingChoice* choice_efbscale;
|
||||
IntSettingChoice* choice_efbscale;
|
||||
SettingCheckBox* efbaccess_enable;
|
||||
SettingCheckBox* emulate_efb_format_changes;
|
||||
|
||||
@ -307,7 +356,7 @@ protected:
|
||||
SettingCheckBox* dlcache;
|
||||
SettingCheckBox* hotkeys;
|
||||
SettingCheckBox* ompdecoder;
|
||||
wxChoice* choice_ppshader;
|
||||
StringSettingChoice* choice_ppshader;
|
||||
|
||||
wxButton* btn_default;
|
||||
// TODO: Add options for
|
||||
|
Reference in New Issue
Block a user