Merge pull request #1662 from lioncash/tas

TASInputDlg: General cleanup.
This commit is contained in:
Ryan Houdek 2014-12-07 00:58:58 -06:00
commit a48abd7bd2
1 changed files with 55 additions and 60 deletions

View File

@ -159,13 +159,13 @@ void TASInputDlg::CreateWiiLayout(int num)
m_c = CreateButton("C");
m_z = CreateButton("Z");
m_ext_szr->Add(m_c_stick_szr);
m_ext_szr->Add(m_c_stick_szr, 0, wxLEFT | wxBOTTOM | wxRIGHT, 5);
m_ext_szr->Add(nunchukaxisBox);
for (unsigned int i = 0; i < 10; ++i)
for (Control* const control : m_controls)
{
if (m_controls[i] != nullptr)
m_controls[i]->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
if (control != nullptr)
control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
}
for (unsigned int i = 4; i < 14; ++i)
@ -176,9 +176,9 @@ void TASInputDlg::CreateWiiLayout(int num)
m_buttons_box->Add(m_buttons_grid);
m_buttons_box->Add(m_buttons_dpad);
m_wiimote_szr->Add(m_main_stick_szr);
m_wiimote_szr->Add(axisBox);
m_wiimote_szr->Add(m_buttons_box);
m_wiimote_szr->Add(m_main_stick_szr, 0, wxALL, 5);
m_wiimote_szr->Add(axisBox, 0, wxTOP | wxRIGHT, 5);
m_wiimote_szr->Add(m_buttons_box, 0, wxTOP | wxRIGHT, 5);
m_main_szr->Add(m_wiimote_szr);
m_main_szr->Add(m_ext_szr);
if (m_ext == 1)
@ -224,10 +224,10 @@ void TASInputDlg::CreateGCLayout()
shoulder_box->Add(m_r_cont.slider, 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)
m_controls[i]->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
if (control != nullptr)
control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
}
wxStaticBoxSizer* const m_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons"));
@ -250,16 +250,10 @@ void TASInputDlg::CreateGCLayout()
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
top_box->AddSpacer(5);
top_box->Add(main_box);
top_box->AddSpacer(5);
top_box->Add(c_box);
top_box->AddSpacer(5);
bottom_box->AddSpacer(5);
bottom_box->Add(shoulder_box);
bottom_box->AddSpacer(5);
bottom_box->Add(m_buttons_box);
bottom_box->AddSpacer(5);
top_box->Add(main_box, 0, wxALL, 5);
top_box->Add(c_box, 0, wxTOP | wxRIGHT, 5);
bottom_box->Add(shoulder_box, 0, wxLEFT | wxRIGHT, 5);
bottom_box->Add(m_buttons_box, 0, wxBOTTOM, 5);
main_szr->Add(top_box);
main_szr->Add(bottom_box);
SetSizerAndFit(main_szr);
@ -289,7 +283,7 @@ TASInputDlg::Control TASInputDlg::CreateControl(long style, int width, int heigh
TASInputDlg::Stick TASInputDlg::CreateStick(int id_stick, int xRange, int yRange, u32 defaultX, u32 defaultY, bool reverseX, bool reverseY)
{
Stick tempStick;
tempStick.bitmap = new wxStaticBitmap(this, id_stick, CreateStickBitmap(128,128), wxDefaultPosition, wxDefaultSize);
tempStick.bitmap = new wxStaticBitmap(this, id_stick, CreateStickBitmap(128, 128));
tempStick.bitmap->Bind(wxEVT_MOTION, &TASInputDlg::OnMouseDownL, this);
tempStick.bitmap->Bind(wxEVT_LEFT_DOWN, &TASInputDlg::OnMouseDownL, this);
tempStick.bitmap->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnMouseUpR, this);
@ -308,7 +302,7 @@ wxStaticBoxSizer* TASInputDlg::CreateStickLayout(Stick* tempStick, const wxStrin
temp_xslider_box->Add(tempStick->x_cont.slider, 0, wxALIGN_TOP);
temp_xslider_box->Add(tempStick->x_cont.text, 0, wxALIGN_TOP);
temp_stick_box->Add(temp_xslider_box);
temp_stick_box->Add(tempStick->bitmap,0, wxALL|wxCenter,3);
temp_stick_box->Add(tempStick->bitmap, 0, wxALL | wxALIGN_CENTER, 3);
temp_box->Add(temp_stick_box);
temp_yslider_box->Add(tempStick->y_cont.slider, 0, wxALIGN_CENTER_VERTICAL);
temp_yslider_box->Add(tempStick->y_cont.text, 0, wxALIGN_CENTER_VERTICAL);
@ -329,16 +323,16 @@ wxStaticBoxSizer* TASInputDlg::CreateAccelLayout(Control* x, Control* y, Control
yBox->Add(y->text, 0, wxALIGN_CENTER_VERTICAL);
zBox->Add(z->slider, 0, wxALIGN_CENTER_VERTICAL);
zBox->Add(z->text, 0, wxALIGN_CENTER_VERTICAL);
temp_box->Add(xBox);
temp_box->Add(yBox);
temp_box->Add(zBox);
temp_box->Add(xBox, 0, wxLEFT | wxBOTTOM | wxRIGHT, 5);
temp_box->Add(yBox, 0, wxRIGHT, 5);
temp_box->Add(zBox, 0, wxRIGHT, 5);
return temp_box;
}
TASInputDlg::Button TASInputDlg::CreateButton(const std::string& name)
{
Button temp;
wxCheckBox* checkbox = new wxCheckBox(this, m_eleID++, name, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxCheckBoxNameStr);
wxCheckBox* checkbox = new wxCheckBox(this, m_eleID++, name);
checkbox->Bind(wxEVT_RIGHT_DOWN, &TASInputDlg::SetTurbo, this);
checkbox->Bind(wxEVT_LEFT_DOWN, &TASInputDlg::SetTurbo, this);
temp.checkbox = checkbox;
@ -348,19 +342,19 @@ TASInputDlg::Button TASInputDlg::CreateButton(const std::string& name)
void TASInputDlg::ResetValues()
{
for (unsigned int i = 0; i < 14; ++i)
for (Button* const button : m_buttons)
{
if (m_buttons[i] != nullptr)
m_buttons[i]->checkbox->SetValue(false);
if (button != nullptr)
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;
m_controls[i]->slider->SetValue(m_controls[i]->default_value);
m_controls[i]->text->SetValue(std::to_string(m_controls[i]->default_value));
control->value = control->default_value;
control->slider->SetValue(control->default_value);
control->text->SetValue(std::to_string(control->default_value));
}
}
}
@ -656,10 +650,10 @@ void TASInputDlg::UpdateFromSliders(wxCommandEvent& event)
{
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)
text = m_controls[i]->text;
if (control != nullptr && event.GetId() == control->slider_id)
text = control->text;
}
int value = ((wxSlider*) event.GetEventObject())->GetValue();
@ -674,15 +668,16 @@ void TASInputDlg::UpdateFromText(wxCommandEvent& event)
if (!((wxTextCtrl*) event.GetEventObject())->GetValue().ToULong(&value))
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;
m_controls[i]->slider->SetValue(v);
m_controls[i]->value = v;
int v = (value > control->range) ? control->range : value;
control->slider->SetValue(v);
control->value = v;
}
}
if (m_controls[2] != nullptr)
{
int x = m_c_stick.x_cont.value;
@ -710,7 +705,7 @@ void TASInputDlg::OnCloseWindow(wxCloseEvent& event)
if (event.CanVeto())
{
event.Skip(false);
this->Show(false);
Show(false);
ResetValues();
}
}
@ -720,9 +715,9 @@ bool TASInputDlg::TASHasFocus()
if (!m_has_layout)
return false;
//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;
}
@ -753,18 +748,18 @@ void TASInputDlg::OnMouseUpR(wxMouseEvent& event)
stick->x_cont.slider->SetValue(stick->x_cont.default_value);
stick->y_cont.slider->SetValue(stick->y_cont.default_value);
event.Skip(true);
event.Skip();
}
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;
m_controls[i]->slider->SetValue(m_controls[i]->default_value);
m_controls[i]->text->SetValue(std::to_string(m_controls[i]->default_value));
control->value = control->default_value;
control->slider->SetValue(control->default_value);
control->text->SetValue(std::to_string(control->default_value));
}
}
}
@ -806,17 +801,17 @@ void TASInputDlg::OnMouseDownL(wxMouseEvent& event)
stick->x_cont.slider->SetValue(stick->x_cont.value);
stick->y_cont.slider->SetValue(stick->y_cont.value);
event.Skip(true);
event.Skip();
}
void TASInputDlg::SetTurbo(wxMouseEvent& event)
{
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)
button = m_buttons[i];
if (btn != nullptr && event.GetId() == btn->id)
button = btn;
}
if (event.LeftDown())
@ -824,7 +819,7 @@ void TASInputDlg::SetTurbo(wxMouseEvent& event)
if (button)
button->turbo_on = false;
event.Skip(true);
event.Skip();
return;
}
@ -834,7 +829,7 @@ void TASInputDlg::SetTurbo(wxMouseEvent& event)
button->turbo_on = !button->turbo_on;
}
event.Skip(true);
event.Skip();
}
void TASInputDlg::ButtonTurbo()
@ -844,10 +839,10 @@ void TASInputDlg::ButtonTurbo()
if (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)
m_buttons[i]->checkbox->SetValue(!m_buttons[i]->checkbox->GetValue());
if (button != nullptr && button->turbo_on)
button->checkbox->SetValue(!button->checkbox->GetValue());
}
}
}