From 03e0cae9b7151cf60c26b6ef0385398fa81ab733 Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Sun, 20 Nov 2016 00:49:31 -0500 Subject: [PATCH] Prepare for having different extensions dialogs Just setting up a switch on the type so that different dialogs can be instantiated. This also makes the extension type an enum because I don't see why not here and finally, it removes ControlGroupSizer. This removal allows to not dynamically generate the UI, but instead, let the specialised constructors do the layout. --- .../Core/DolphinWX/Input/InputConfigDiag.cpp | 88 ++++++------------- Source/Core/DolphinWX/Input/InputConfigDiag.h | 7 -- 2 files changed, 26 insertions(+), 69 deletions(-) diff --git a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp index 2b4f3f5b49..74cb503531 100644 --- a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp @@ -42,6 +42,7 @@ #include "Core/HW/GCKeyboard.h" #include "Core/HW/GCPad.h" #include "Core/HW/Wiimote.h" +#include "Core/HW/WiimoteEmu/WiimoteEmu.h" #include "Core/HotkeyManager.h" #include "DolphinWX/DolphinSlider.h" #include "DolphinWX/Input/InputConfigDiag.h" @@ -58,28 +59,33 @@ void InputConfigDialog::ConfigExtension(wxCommandEvent& event) { ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension; + int extension_type = ex->switch_extension; + // show config diag, if "none" isn't selected - if (ex->switch_extension) + switch (extension_type) { - wxDialog dlg(this, wxID_ANY, - wxGetTranslation(StrToWxStr(ex->attachments[ex->switch_extension]->GetName()))); - - wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL); - const std::size_t orig_size = control_groups.size(); - - ControlGroupsSizer* const szr = - new ControlGroupsSizer(ex->attachments[ex->switch_extension].get(), this, &control_groups); - const int space5 = FromDIP(5); - main_szr->Add(szr, 0, wxLEFT, space5); - main_szr->Add(dlg.CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT, space5); - main_szr->AddSpacer(space5); - dlg.SetSizerAndFit(main_szr); - dlg.Center(); - - dlg.ShowModal(); - - // remove the new groups that were just added, now that the window closed - control_groups.resize(orig_size); + case WiimoteEmu::EXT_NUNCHUK: + { + } + break; + case WiimoteEmu::EXT_CLASSIC: + { + } + break; + case WiimoteEmu::EXT_GUITAR: + { + } + break; + case WiimoteEmu::EXT_DRUMS: + { + } + break; + case WiimoteEmu::EXT_TURNTABLE: + { + } + break; + default: + break; } } @@ -1127,48 +1133,6 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin eventsink->control_groups.push_back(this); } -ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, - InputConfigDialog* const parent, - std::vector* groups) - : wxBoxSizer(wxHORIZONTAL) -{ - const int space5 = parent->FromDIP(5); - size_t col_size = 0; - - wxBoxSizer* stacked_groups = nullptr; - for (auto& group : controller->groups) - { - ControlGroupBox* control_group_box = new ControlGroupBox(group.get(), parent, parent); - - 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) - { - if (stacked_groups) - { - Add(stacked_groups, 0, wxBOTTOM, space5); - AddSpacer(space5); - } - - stacked_groups = new wxBoxSizer(wxVERTICAL); - stacked_groups->Add(control_group_box, 0, wxEXPAND); - - col_size = grp_size; - } - else - { - stacked_groups->Add(control_group_box, 0, wxEXPAND); - } - - if (groups) - groups->push_back(control_group_box); - } - - if (stacked_groups) - Add(stacked_groups, 0, wxBOTTOM, space5); -} - wxBoxSizer* InputConfigDialog::CreateDeviceChooserGroupBox() { const int space3 = FromDIP(3); diff --git a/Source/Core/DolphinWX/Input/InputConfigDiag.h b/Source/Core/DolphinWX/Input/InputConfigDiag.h index 10cfe95b49..97ccde2aae 100644 --- a/Source/Core/DolphinWX/Input/InputConfigDiag.h +++ b/Source/Core/DolphinWX/Input/InputConfigDiag.h @@ -192,13 +192,6 @@ public: double m_scale; }; -class ControlGroupsSizer : public wxBoxSizer -{ -public: - ControlGroupsSizer(ControllerEmu* const controller, InputConfigDialog* const parent, - std::vector* const groups = nullptr); -}; - class InputConfigDialog : public wxDialog { public: