Merge pull request #1018 from willkuer/GenericGSSetting

gsdx: Generic GSSetting
This commit is contained in:
Gregory Hainaut 2016-01-19 16:23:19 +01:00
commit 9ac6cd503d
5 changed files with 18 additions and 18 deletions

View File

@ -164,7 +164,7 @@ void GSDialog::SetTextAsInt(UINT id, int i)
SetText(id, buff); SetText(id, buff);
} }
void GSDialog::ComboBoxInit(UINT id, const vector<GSSetting>& settings, uint32 selid, uint32 maxid) void GSDialog::ComboBoxInit(UINT id, const vector<GSSetting>& settings, int32_t selectionValue, int32_t maxValue)
{ {
HWND hWnd = GetDlgItem(m_hWnd, id); HWND hWnd = GetDlgItem(m_hWnd, id);
@ -174,7 +174,7 @@ void GSDialog::ComboBoxInit(UINT id, const vector<GSSetting>& settings, uint32 s
{ {
const GSSetting& s = settings[i]; const GSSetting& s = settings[i];
if(s.id <= maxid) if(s.value <= maxValue)
{ {
string str(s.name); string str(s.name);
@ -183,7 +183,7 @@ void GSDialog::ComboBoxInit(UINT id, const vector<GSSetting>& settings, uint32 s
str = str + " (" + s.note + ")"; str = str + " (" + s.note + ")";
} }
ComboBoxAppend(id, str.c_str(), (LPARAM)s.id, s.id == selid); ComboBoxAppend(id, str.c_str(), (LPARAM)s.value, s.value == selectionValue);
} }
} }

View File

@ -51,7 +51,7 @@ public:
void SetText(UINT id, const char* str); void SetText(UINT id, const char* str);
void SetTextAsInt(UINT id, int i); void SetTextAsInt(UINT id, int i);
void ComboBoxInit(UINT id, const vector<GSSetting>& settings, uint32 selid, uint32 maxid = ~0); void ComboBoxInit(UINT id, const vector<GSSetting>& settings, int32_t selectionValue, int32_t maxValue = INT32_MAX);
int ComboBoxAppend(UINT id, const char* str, LPARAM data = 0, bool select = false); int ComboBoxAppend(UINT id, const char* str, LPARAM data = 0, bool select = false);
bool ComboBoxGetSelData(UINT id, INT_PTR& data); bool ComboBoxGetSelData(UINT id, INT_PTR& data);
void ComboBoxFixDroppedWidth(UINT id); void ComboBoxFixDroppedWidth(UINT id);

View File

@ -54,15 +54,15 @@ void CB_ChangedComboBox(GtkComboBox *combo, gpointer user_data)
vector<GSSetting>* s = (vector<GSSetting>*)g_object_get_data(G_OBJECT(combo), "Settings"); vector<GSSetting>* s = (vector<GSSetting>*)g_object_get_data(G_OBJECT(combo), "Settings");
try { try {
theApp.SetConfig((char*)user_data, s->at(p).id); theApp.SetConfig((char*)user_data, s->at(p).value);
} catch (...) { } catch (...) {
} }
} }
GtkWidget* CreateComboBoxFromVector(const vector<GSSetting>& s, const char* opt_name, int opt_default = 0) GtkWidget* CreateComboBoxFromVector(const vector<GSSetting>& s, const char* opt_name, int32_t opt_default = 0)
{ {
GtkWidget* combo_box = gtk_combo_box_text_new(); GtkWidget* combo_box = gtk_combo_box_text_new();
int opt_value = theApp.GetConfig(opt_name, opt_default); int32_t opt_value = theApp.GetConfig(opt_name, opt_default);
int opt_position = 0; int opt_position = 0;
for(size_t i = 0; i < s.size(); i++) for(size_t i = 0; i < s.size(); i++)
@ -73,7 +73,7 @@ GtkWidget* CreateComboBoxFromVector(const vector<GSSetting>& s, const char* opt_
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_box), label.c_str()); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_box), label.c_str());
if ((int)s[i].id == opt_value) if (s[i].value == opt_value)
opt_position = i; opt_position = i;
} }

View File

@ -25,16 +25,16 @@
struct GSSetting struct GSSetting
{ {
uint32 id; int32_t value;
std::string name; std::string name;
std::string note; std::string note;
template< typename T>
GSSetting(uint32 id, const char* name, const char* note) explicit GSSetting(T value, const char* name, const char* note) :
value(static_cast<int32_t>(value)),
name(name),
note(note)
{ {
this->id = id;
this->name = name;
this->note = note;
} }
}; };

View File

@ -321,8 +321,8 @@ void GSSettingsDlg::UpdateRenderers()
{ {
GSSetting r = theApp.m_gs_renderers[i]; GSSetting r = theApp.m_gs_renderers[i];
GSRendererType renderer = static_cast<GSRendererType>(r.id); GSRendererType renderer = static_cast<GSRendererType>(r.value);
if(renderer == GSRendererType::DX1011_HW || renderer == GSRendererType::DX1011_SW || renderer == GSRendererType::DX1011_Null || renderer == GSRendererType::DX1011_OpenCL) if(renderer == GSRendererType::DX1011_HW || renderer == GSRendererType::DX1011_SW || renderer == GSRendererType::DX1011_Null || renderer == GSRendererType::DX1011_OpenCL)
{ {
if(level < D3D_FEATURE_LEVEL_10_0) continue; if(level < D3D_FEATURE_LEVEL_10_0) continue;
@ -335,13 +335,13 @@ void GSSettingsDlg::UpdateRenderers()
renderers.push_back(r); renderers.push_back(r);
if (static_cast<GSRendererType>(r.id) == renderer_setting) if (static_cast<GSRendererType>(r.value) == renderer_setting)
{ {
renderer_sel = renderer_setting; renderer_sel = renderer_setting;
} }
} }
ComboBoxInit(IDC_RENDERER, renderers, static_cast<uint32>(renderer_sel)); ComboBoxInit(IDC_RENDERER, renderers, static_cast<int32_t>(renderer_sel));
} }
void GSSettingsDlg::UpdateControls() void GSSettingsDlg::UpdateControls()