mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-01 02:29:59 -06:00
ControllerEmu: Split the Setting class
The Setting class was used for both numeric values and booleans, and other parts of the code had hacks to make it work with booleans. By splitting Setting into NumericSetting and BooleanSetting, it is clear which settings are numeric, and which are boolean, so there is no need to guess by checking the default values or anything like that. Also, booleans are stored as booleans in config files, instead of 1.0.
This commit is contained in:
@ -100,8 +100,8 @@ void PadSettingExtension::UpdateValue()
|
||||
}
|
||||
|
||||
PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent,
|
||||
ControllerEmu::ControlGroup::Setting* const _setting)
|
||||
: PadSetting(new wxCheckBox(parent, wxID_ANY, wxGetTranslation(StrToWxStr(_setting->name)))),
|
||||
ControllerEmu::ControlGroup::BooleanSetting* const _setting)
|
||||
: PadSetting(new wxCheckBox(parent, wxID_ANY, wxGetTranslation(StrToWxStr(_setting->m_name)))),
|
||||
setting(_setting)
|
||||
{
|
||||
UpdateGUI();
|
||||
@ -109,13 +109,12 @@ PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent,
|
||||
|
||||
void PadSettingCheckBox::UpdateGUI()
|
||||
{
|
||||
((wxCheckBox*)wxcontrol)->SetValue(!!setting->GetValue());
|
||||
((wxCheckBox*)wxcontrol)->SetValue(setting->GetValue());
|
||||
}
|
||||
|
||||
void PadSettingCheckBox::UpdateValue()
|
||||
{
|
||||
// 0.01 so its saved to the ini file as just 1. :(
|
||||
setting->SetValue(0.01 * ((wxCheckBox*)wxcontrol)->GetValue());
|
||||
setting->SetValue(((wxCheckBox*)wxcontrol)->GetValue());
|
||||
}
|
||||
|
||||
void PadSettingSpin::UpdateGUI()
|
||||
@ -827,13 +826,13 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
wxBITMAP_TYPE_BMP);
|
||||
|
||||
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
|
||||
for (auto& groupSetting : group->settings)
|
||||
for (auto& groupSetting : group->numeric_settings)
|
||||
{
|
||||
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
|
||||
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
|
||||
options.push_back(setting);
|
||||
szr->Add(
|
||||
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->name))));
|
||||
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->m_name))));
|
||||
szr->Add(setting->wxcontrol, 0, wxLEFT, 0);
|
||||
}
|
||||
|
||||
@ -856,7 +855,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
static_bitmap = new wxStaticBitmap(parent, wxID_ANY, bitmap, wxDefaultPosition, wxDefaultSize,
|
||||
wxBITMAP_TYPE_BMP);
|
||||
|
||||
PadSettingSpin* const threshold_cbox = new PadSettingSpin(parent, group->settings[0].get());
|
||||
auto* const threshold_cbox = new PadSettingSpin(parent, group->numeric_settings[0].get());
|
||||
threshold_cbox->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
|
||||
|
||||
threshold_cbox->wxcontrol->SetToolTip(
|
||||
@ -865,9 +864,9 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
options.push_back(threshold_cbox);
|
||||
|
||||
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
szr->Add(
|
||||
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(group->settings[0]->name))),
|
||||
0, wxCENTER | wxRIGHT, 3);
|
||||
szr->Add(new wxStaticText(parent, wxID_ANY,
|
||||
wxGetTranslation(StrToWxStr(group->numeric_settings[0]->m_name))),
|
||||
0, wxCENTER | wxRIGHT, 3);
|
||||
szr->Add(threshold_cbox->wxcontrol, 0, wxRIGHT, 3);
|
||||
|
||||
Add(szr, 0, wxALL | wxCENTER, 3);
|
||||
@ -893,14 +892,15 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
static_bitmap = new wxStaticBitmap(parent, wxID_ANY, bitmap, wxDefaultPosition, wxDefaultSize,
|
||||
wxBITMAP_TYPE_BMP);
|
||||
|
||||
for (auto& groupSetting : group->settings)
|
||||
for (auto& groupSetting : group->numeric_settings)
|
||||
{
|
||||
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
|
||||
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
|
||||
options.push_back(setting);
|
||||
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
szr->Add(new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->name))),
|
||||
0, wxCENTER | wxRIGHT, 3);
|
||||
szr->Add(
|
||||
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->m_name))), 0,
|
||||
wxCENTER | wxRIGHT, 3);
|
||||
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
|
||||
Add(szr, 0, wxALL | wxCENTER, 3);
|
||||
}
|
||||
@ -926,35 +926,32 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
default:
|
||||
{
|
||||
// options
|
||||
for (auto& groupSetting : group->settings)
|
||||
for (auto& groupSetting : group->boolean_settings)
|
||||
{
|
||||
if (groupSetting->high == DEFAULT_HIGH_VALUE)
|
||||
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting.get());
|
||||
if (groupSetting->m_name == "Iterative Input")
|
||||
{
|
||||
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting.get());
|
||||
if (groupSetting->is_iterate == true)
|
||||
{
|
||||
setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustSettingUI, eventsink);
|
||||
groupSetting->value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustSetting, eventsink);
|
||||
}
|
||||
options.push_back(setting_cbox);
|
||||
Add(setting_cbox->wxcontrol, 0, wxALL | wxLEFT, 5);
|
||||
setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustSettingUI, eventsink);
|
||||
groupSetting->SetValue(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
|
||||
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
|
||||
options.push_back(setting);
|
||||
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
szr->Add(
|
||||
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->name))), 0,
|
||||
wxCENTER | wxRIGHT, 3);
|
||||
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
|
||||
Add(szr, 0, wxALL | wxCENTER, 3);
|
||||
setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustSetting, eventsink);
|
||||
}
|
||||
options.push_back(setting_cbox);
|
||||
Add(setting_cbox->wxcontrol, 0, wxALL | wxLEFT, 5);
|
||||
}
|
||||
for (auto& groupSetting : group->numeric_settings)
|
||||
{
|
||||
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
|
||||
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
|
||||
options.push_back(setting);
|
||||
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
szr->Add(
|
||||
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->m_name))), 0,
|
||||
wxCENTER | wxRIGHT, 3);
|
||||
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
|
||||
Add(szr, 0, wxALL | wxCENTER, 3);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -980,7 +977,8 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
|
||||
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->ui_name)));
|
||||
control_group->Add(control_group_box);
|
||||
|
||||
const size_t grp_size = group->controls.size() + group->settings.size();
|
||||
const size_t grp_size =
|
||||
group->controls.size() + group->numeric_settings.size() + group->boolean_settings.size();
|
||||
col_size += grp_size;
|
||||
if (col_size > 8 || nullptr == stacked_groups)
|
||||
{
|
||||
|
Reference in New Issue
Block a user