Skip to content

Commit

Permalink
Prepare for having different extensions dialogs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aldelaro5 committed Nov 20, 2016
1 parent be71a74 commit b71bf95
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 69 deletions.
73 changes: 11 additions & 62 deletions Source/Core/DolphinWX/InputConfigDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,18 @@ void InputConfigDialog::ConfigExtension(wxCommandEvent& event)
ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension;

// show config diag, if "none" isn't selected
if (ex->switch_extension)
switch (ex->switch_extension)
{
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 EXT_NUNCHUK:
break;
case EXT_ClASSIC:
break;
case EXT_GUITAR:
break;
case EXT_DRUMS:
break;
case EXT_TURNTABLE:
break;
}
}

Expand Down Expand Up @@ -1117,48 +1108,6 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
eventsink->control_groups.push_back(this);
}

ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller,
InputConfigDialog* const parent,
std::vector<ControlGroupBox*>* 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);
Expand Down
7 changes: 0 additions & 7 deletions Source/Core/DolphinWX/InputConfigDiag.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,6 @@ class ControlGroupBox : public wxStaticBoxSizer
double m_scale;
};

class ControlGroupsSizer : public wxBoxSizer
{
public:
ControlGroupsSizer(ControllerEmu* const controller, InputConfigDialog* const parent,
std::vector<ControlGroupBox*>* const groups = nullptr);
};

class InputConfigDialog : public wxDialog
{
public:
Expand Down
11 changes: 11 additions & 0 deletions Source/Core/InputCommon/ControllerEmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ enum
SETTING_DEADZONE,
};

enum
{
EXT_NONE,

EXT_NUNCHUK,
EXT_ClASSIC,
EXT_GUITAR,
EXT_DRUMS,
EXT_TURNTABLE
};

const char* const named_directions[] = {"Up", "Down", "Left", "Right"};

class ControllerEmu
Expand Down

0 comments on commit b71bf95

Please sign in to comment.