TASInputDlg: Replace some for loops with range-based for loops.

This commit is contained in:
Lioncash 2014-12-06 16:54:42 -05:00
parent 12eb2caa65
commit d09130e3d2
1 changed files with 36 additions and 35 deletions

View File

@ -162,10 +162,10 @@ void TASInputDlg::CreateWiiLayout(int num)
m_ext_szr->Add(m_c_stick_szr); m_ext_szr->Add(m_c_stick_szr);
m_ext_szr->Add(nunchukaxisBox); m_ext_szr->Add(nunchukaxisBox);
for (unsigned int i = 0; i < 10; ++i) for (Control* const control : m_controls)
{ {
if (m_controls[i] != nullptr) if (control != nullptr)
m_controls[i]->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
} }
for (unsigned int i = 4; i < 14; ++i) for (unsigned int i = 4; i < 14; ++i)
@ -224,10 +224,10 @@ void TASInputDlg::CreateGCLayout()
shoulder_box->Add(m_r_cont.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_r_cont.slider, 0, wxALIGN_CENTER_VERTICAL);
shoulder_box->Add(m_r_cont.text, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_r_cont.text, 0, wxALIGN_CENTER_VERTICAL);
for (unsigned int i = 0; i < 10; ++i) for (Control* const control : m_controls)
{ {
if (m_controls[i] != nullptr) if (control != nullptr)
m_controls[i]->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
} }
wxStaticBoxSizer* const m_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); wxStaticBoxSizer* const m_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons"));
@ -348,19 +348,19 @@ TASInputDlg::Button TASInputDlg::CreateButton(const std::string& name)
void TASInputDlg::ResetValues() void TASInputDlg::ResetValues()
{ {
for (unsigned int i = 0; i < 14; ++i) for (Button* const button : m_buttons)
{ {
if (m_buttons[i] != nullptr) if (button != nullptr)
m_buttons[i]->checkbox->SetValue(false); button->checkbox->SetValue(false);
} }
for (unsigned int i = 0; i < 10; ++i) for (Control* const control : m_controls)
{ {
if (m_controls[i] != nullptr) if (control != nullptr)
{ {
m_controls[i]->value = m_controls[i]->default_value; control->value = control->default_value;
m_controls[i]->slider->SetValue(m_controls[i]->default_value); control->slider->SetValue(control->default_value);
m_controls[i]->text->SetValue(std::to_string(m_controls[i]->default_value)); control->text->SetValue(std::to_string(control->default_value));
} }
} }
} }
@ -656,10 +656,10 @@ void TASInputDlg::UpdateFromSliders(wxCommandEvent& event)
{ {
wxTextCtrl* text = nullptr; wxTextCtrl* text = nullptr;
for (unsigned int i = 0; i < 10; ++i) for (Control* const control : m_controls)
{ {
if (m_controls[i] != nullptr && event.GetId() == m_controls[i]->slider_id) if (control != nullptr && event.GetId() == control->slider_id)
text = m_controls[i]->text; text = control->text;
} }
int value = ((wxSlider*) event.GetEventObject())->GetValue(); int value = ((wxSlider*) event.GetEventObject())->GetValue();
@ -674,15 +674,16 @@ void TASInputDlg::UpdateFromText(wxCommandEvent& event)
if (!((wxTextCtrl*) event.GetEventObject())->GetValue().ToULong(&value)) if (!((wxTextCtrl*) event.GetEventObject())->GetValue().ToULong(&value))
return; return;
for (unsigned int i = 0; i < 10; ++i) for (Control* const control : m_controls)
{ {
if (m_controls[i] != nullptr && event.GetId() == m_controls[i]->text_id) if (control != nullptr && event.GetId() == control->text_id)
{ {
int v = value > m_controls[i]->range ? m_controls[i]->range : value; int v = (value > control->range) ? control->range : value;
m_controls[i]->slider->SetValue(v); control->slider->SetValue(v);
m_controls[i]->value = v; control->value = v;
} }
} }
if (m_controls[2] != nullptr) if (m_controls[2] != nullptr)
{ {
int x = m_c_stick.x_cont.value; int x = m_c_stick.x_cont.value;
@ -720,9 +721,9 @@ bool TASInputDlg::TASHasFocus()
if (!m_has_layout) if (!m_has_layout)
return false; return false;
//allows numbers to be used as hotkeys //allows numbers to be used as hotkeys
for (unsigned int i = 0; i < 10; ++i) for (Control* const control : m_controls)
{ {
if (m_controls[i] != nullptr && wxWindow::FindFocus() == m_controls[i]->text) if (control != nullptr && wxWindow::FindFocus() == control->text)
return false; return false;
} }
@ -758,13 +759,13 @@ void TASInputDlg::OnMouseUpR(wxMouseEvent& event)
void TASInputDlg::OnRightClickSlider(wxMouseEvent& event) void TASInputDlg::OnRightClickSlider(wxMouseEvent& event)
{ {
for (unsigned int i = 0; i < 10; ++i) for (Control* const control : m_controls)
{ {
if (m_controls[i] != nullptr && event.GetId() == m_controls[i]->slider_id) if (control != nullptr && event.GetId() == control->slider_id)
{ {
m_controls[i]->value = m_controls[i]->default_value; control->value = control->default_value;
m_controls[i]->slider->SetValue(m_controls[i]->default_value); control->slider->SetValue(control->default_value);
m_controls[i]->text->SetValue(std::to_string(m_controls[i]->default_value)); control->text->SetValue(std::to_string(control->default_value));
} }
} }
} }
@ -813,10 +814,10 @@ void TASInputDlg::SetTurbo(wxMouseEvent& event)
{ {
Button* button = nullptr; Button* button = nullptr;
for (unsigned int i = 0; i < 14; ++i) for (Button* const btn : m_buttons)
{ {
if (m_buttons[i] != nullptr && event.GetId() == m_buttons[i]->id) if (btn != nullptr && event.GetId() == btn->id)
button = m_buttons[i]; button = btn;
} }
if (event.LeftDown()) if (event.LeftDown())
@ -844,10 +845,10 @@ void TASInputDlg::ButtonTurbo()
if (frame != Movie::g_currentFrame) if (frame != Movie::g_currentFrame)
{ {
frame = Movie::g_currentFrame; frame = Movie::g_currentFrame;
for (unsigned int i = 0; i < 14; ++i) for (Button* const button : m_buttons)
{ {
if (m_buttons[i] != nullptr && m_buttons[i]->turbo_on) if (button != nullptr && button->turbo_on)
m_buttons[i]->checkbox->SetValue(!m_buttons[i]->checkbox->GetValue()); button->checkbox->SetValue(!button->checkbox->GetValue());
} }
} }
} }