From f693488c8a523ce7a26e928840baf8a9fcaa9aed Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 22 Jul 2013 02:48:07 -0400 Subject: [PATCH] InputConfigDiag: Save the configuration when pressing "OK" This fixes a common UI complaint of the control dialog UI. Also, don't close the dialog if we have an error with the expression. --- Source/Core/DolphinWX/Src/InputConfigDiag.cpp | 9 ++++----- Source/Core/DolphinWX/Src/InputConfigDiag.h | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinWX/Src/InputConfigDiag.cpp b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp index 33471f9d9b..574834f940 100644 --- a/Source/Core/DolphinWX/Src/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp @@ -292,7 +292,7 @@ void GamepadPage::LoadDefaults(wxCommandEvent&) UpdateGUI(); } -void ControlDialog::SetControl(wxCommandEvent&) +bool ControlDialog::Validate() { control_reference->expression = WxStrToStr(textctrl->GetValue()); @@ -300,6 +300,8 @@ void ControlDialog::SetControl(wxCommandEvent&) g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); UpdateGUI(); + + return (control_reference->parse_error == EXPRESSION_PARSE_SUCCESS); } void GamepadPage::SetDevice(wxCommandEvent&) @@ -533,7 +535,6 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent) wxButton* const detect_button = new wxButton(this, -1, control_reference->is_input ? _("Detect") : _("Test")); wxButton* const clear_button = new wxButton(this, -1, _("Clear")); - wxButton* const set_button = new wxButton(this, -1, _("Set")); wxButton* const select_button = new wxButton(this, -1, _("Select")); select_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ControlDialog::SetSelectedControl, this); @@ -571,7 +572,6 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent) detect_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ControlDialog::DetectControl, this); clear_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ControlDialog::ClearControl, this); - set_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ControlDialog::SetControl, this); range_slider->Bind(wxEVT_SCROLL_CHANGED, &GamepadPage::AdjustControlOption, parent); wxStaticText* const range_label = new wxStaticText(this, -1, _("Range")); @@ -587,8 +587,7 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent) ctrls_sizer->Add(control_lbox, 1, wxEXPAND, 0); ctrls_sizer->Add(button_sizer, 0, wxEXPAND, 0); - wxSizer* const bottom_btns_sizer = CreateButtonSizer(wxOK); - bottom_btns_sizer->Prepend(set_button, 0, wxRIGHT, 5); + wxSizer* const bottom_btns_sizer = CreateButtonSizer(wxOK|wxAPPLY); bottom_btns_sizer->Prepend(clear_button, 0, wxLEFT, 5); main_szr->Add(range_sizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 5); diff --git a/Source/Core/DolphinWX/Src/InputConfigDiag.h b/Source/Core/DolphinWX/Src/InputConfigDiag.h index 0a355c1d2f..7d337ed0de 100644 --- a/Source/Core/DolphinWX/Src/InputConfigDiag.h +++ b/Source/Core/DolphinWX/Src/InputConfigDiag.h @@ -89,9 +89,10 @@ public: wxStaticBoxSizer* CreateControlChooser(GamepadPage* const parent); + virtual bool Validate(); + void DetectControl(wxCommandEvent& event); void ClearControl(wxCommandEvent& event); - void SetControl(wxCommandEvent& event); void SetDevice(wxCommandEvent& event); void UpdateGUI();