Clean up InputConfigDiag.cpp.

Changes a bunch of for+iterator loops into foreach loops.
This commit is contained in:
Lioncash
2014-02-01 18:15:18 -05:00
parent 557015626a
commit c31a623780

View File

@ -148,29 +148,25 @@ void InputConfigDialog::UpdateProfileComboBox()
const CFileSearch::XStringVector& sv = cfs.GetFileNames(); const CFileSearch::XStringVector& sv = cfs.GetFileNames();
wxArrayString strs; wxArrayString strs;
CFileSearch::XStringVector::const_iterator si = sv.begin(), for (auto si = sv.cbegin(); si != sv.cend(); ++si)
se = sv.end();
for (; si!=se; ++si)
{ {
std::string str(si->begin() + si->find_last_of('/') + 1 , si->end() - 4) ; std::string str(si->begin() + si->find_last_of('/') + 1 , si->end() - 4) ;
strs.push_back(StrToWxStr(str)); strs.push_back(StrToWxStr(str));
} }
std::vector< GamepadPage* >::iterator i = m_padpages.begin(), for (GamepadPage* page : m_padpages)
e = m_padpages.end();
for (; i != e; ++i)
{ {
(*i)->profile_cbox->Clear(); page->profile_cbox->Clear();
(*i)->profile_cbox->Append(strs); page->profile_cbox->Append(strs);
} }
} }
void InputConfigDialog::UpdateControlReferences() void InputConfigDialog::UpdateControlReferences()
{ {
std::vector< GamepadPage* >::iterator i = m_padpages.begin(), for (GamepadPage* page : m_padpages)
e = m_padpages.end(); {
for (; i != e; ++i) page->controller->UpdateReferences(g_controller_interface);
(*i)->controller->UpdateReferences(g_controller_interface); }
} }
void InputConfigDialog::ClickSave(wxCommandEvent& event) void InputConfigDialog::ClickSave(wxCommandEvent& event)
@ -188,21 +184,17 @@ void ControlDialog::UpdateListContents()
{ {
if (control_reference->is_input) if (control_reference->is_input)
{ {
// for inputs for (Device::Input* input : dev->Inputs())
std::vector<Device::Input*>::const_iterator {
i = dev->Inputs().begin(), control_lbox->Append(StrToWxStr(input->GetName()));
e = dev->Inputs().end(); }
for (; i!=e; ++i)
control_lbox->Append(StrToWxStr((*i)->GetName()));
} }
else else // It's an output
{ {
// for outputs for (Device::Output* output : dev->Outputs())
std::vector<Device::Output*>::const_iterator {
i = dev->Outputs().begin(), control_lbox->Append(StrToWxStr(output->GetName()));
e = dev->Outputs().end(); }
for (; i!=e; ++i)
control_lbox->Append(StrToWxStr((*i)->GetName()));
} }
} }
} }
@ -242,24 +234,19 @@ void GamepadPage::UpdateGUI()
{ {
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString())); device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));
std::vector< ControlGroupBox* >::const_iterator g = control_groups.begin(), for (ControlGroupBox* cgBox : control_groups)
ge = control_groups.end();
for (; g!=ge; ++g)
{ {
// buttons for (ControlButton* button : cgBox->control_buttons)
std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin() {
, e = (*g)->control_buttons.end(); wxString expr = StrToWxStr(button->control_reference->expression);
for (; i!=e; ++i) {
wxString expr = StrToWxStr((*i)->control_reference->expression);
expr.Replace("&", "&&"); expr.Replace("&", "&&");
(*i)->SetLabel(expr); button->SetLabel(expr);
} }
// cboxes for (PadSetting* padSetting : cgBox->options)
std::vector<PadSetting*>::const_iterator si = (*g)->options.begin() {
, se = (*g)->options.end(); padSetting->UpdateGUI();
for (; si!=se; ++si) }
(*si)->UpdateGUI();
} }
} }
@ -338,9 +325,10 @@ void ControlDialog::ClearControl(wxCommandEvent&)
inline bool IsAlphabetic(wxString &str) inline bool IsAlphabetic(wxString &str)
{ {
for (wxString::const_iterator it = str.begin(); it != str.end(); ++it) for (wxUniChar c : str)
if (!isalpha(*it)) if (!isalpha(c))
return false; return false;
return true; return true;
} }
@ -419,7 +407,9 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
expr = wxString::Format("%c(%s)", op, selection); expr = wxString::Format("%c(%s)", op, selection);
} }
else else
{
expr = wxString::Format(" %c %s", op, device_expr); expr = wxString::Format(" %c %s", op, device_expr);
}
textctrl->WriteText(expr); textctrl->WriteText(expr);
control_reference->expression = textctrl->GetValue(); control_reference->expression = textctrl->GetValue();
@ -601,7 +591,7 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent)
void GamepadPage::GetProfilePath(std::string& path) void GamepadPage::GetProfilePath(std::string& path)
{ {
const wxString& name = profile_cbox->GetValue(); const wxString& name = profile_cbox->GetValue();
if (false == name.empty()) if (!name.empty())
{ {
// TODO: check for dumb characters maybe // TODO: check for dumb characters maybe
@ -619,7 +609,7 @@ void GamepadPage::LoadProfile(wxCommandEvent&)
std::string fname; std::string fname;
GamepadPage::GetProfilePath(fname); GamepadPage::GetProfilePath(fname);
if (false == File::Exists(fname)) if (!File::Exists(fname))
return; return;
IniFile inifile; IniFile inifile;
@ -638,7 +628,7 @@ void GamepadPage::SaveProfile(wxCommandEvent&)
GamepadPage::GetProfilePath(fname); GamepadPage::GetProfilePath(fname);
File::CreateFullPath(fname); File::CreateFullPath(fname);
if (false == fname.empty()) if (!fname.empty())
{ {
IniFile inifile; IniFile inifile;
controller->SaveConfig(inifile.GetOrCreateSection("Profile")); controller->SaveConfig(inifile.GetOrCreateSection("Profile"));
@ -671,21 +661,18 @@ void GamepadPage::DeleteProfile(wxCommandEvent&)
void InputConfigDialog::UpdateDeviceComboBox() void InputConfigDialog::UpdateDeviceComboBox()
{ {
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
e = m_padpages.end();
DeviceQualifier dq; DeviceQualifier dq;
for (; i != e; ++i) for (GamepadPage* page : m_padpages)
{ {
(*i)->device_cbox->Clear(); page->device_cbox->Clear();
std::vector<Device*>::const_iterator
di = g_controller_interface.Devices().begin(), for (Device* d : g_controller_interface.Devices())
de = g_controller_interface.Devices().end();
for (; di!=de; ++di)
{ {
dq.FromDevice(*di); dq.FromDevice(d);
(*i)->device_cbox->Append(StrToWxStr(dq.ToString())); page->device_cbox->Append(StrToWxStr(dq.ToString()));
} }
(*i)->device_cbox->SetValue(StrToWxStr((*i)->controller->default_device.ToString()));
page->device_cbox->SetValue(StrToWxStr(page->controller->default_device.ToString()));
} }
} }
@ -706,11 +693,8 @@ void GamepadPage::RefreshDevices(wxCommandEvent&)
ControlGroupBox::~ControlGroupBox() ControlGroupBox::~ControlGroupBox()
{ {
std::vector<PadSetting*>::const_iterator for (PadSetting* padSetting : options)
i = options.begin(), delete padSetting;
e = options.end();
for (; i!=e; ++i)
delete *i;
} }
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, GamepadPage* const eventsink) ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, GamepadPage* const eventsink)