Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
magcius committed Jul 22, 2013
1 parent bc17798 commit f693488
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 4 additions & 5 deletions Source/Core/DolphinWX/Src/InputConfigDiag.cpp
Expand Up @@ -292,14 +292,16 @@ void GamepadPage::LoadDefaults(wxCommandEvent&)
UpdateGUI();
}

void ControlDialog::SetControl(wxCommandEvent&)
bool ControlDialog::Validate()
{
control_reference->expression = WxStrToStr(textctrl->GetValue());

std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);

UpdateGUI();

return (control_reference->parse_error == EXPRESSION_PARSE_SUCCESS);
}

void GamepadPage::SetDevice(wxCommandEvent&)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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"));
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/DolphinWX/Src/InputConfigDiag.h
Expand Up @@ -89,9 +89,10 @@ class ControlDialog : public wxDialog

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();
Expand Down

0 comments on commit f693488

Please sign in to comment.