From 59a14df340b5b68207957e1fdfff275f47f039c7 Mon Sep 17 00:00:00 2001 From: konstin Date: Sat, 21 Jun 2014 17:16:23 +0200 Subject: [PATCH] fix track group spinner --- src/guiengine/widgets/spinner_widget.cpp | 6 +++--- src/states_screens/dialogs/random_gp_dialog.cpp | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/guiengine/widgets/spinner_widget.cpp b/src/guiengine/widgets/spinner_widget.cpp index 31a8ad3d2..d6a53e6f8 100644 --- a/src/guiengine/widgets/spinner_widget.cpp +++ b/src/guiengine/widgets/spinner_widget.cpp @@ -160,7 +160,7 @@ void SpinnerWidget::add() { label->setText(m_labels[m_value].c_str() ); } - + } @@ -174,7 +174,7 @@ void SpinnerWidget::add() m_children[2].m_id = m_children[2].m_element->getID(); // refresh display - + setValue(m_value); } @@ -333,7 +333,7 @@ void SpinnerWidget::setValue(const int new_value) assert(new_value >= 0); assert(new_value < (int)m_labels.size()); - m_children[1].m_element->setText(m_labels[new_value].c_str() ); + m_children[1].m_element->setText(m_labels[new_value].c_str()); } else if (m_text.size() > 0 && m_children.size() > 0) { diff --git a/src/states_screens/dialogs/random_gp_dialog.cpp b/src/states_screens/dialogs/random_gp_dialog.cpp index 32763e357..41ab3facb 100644 --- a/src/states_screens/dialogs/random_gp_dialog.cpp +++ b/src/states_screens/dialogs/random_gp_dialog.cpp @@ -35,7 +35,7 @@ typedef GUIEngine::SpinnerWidget Spinner; RandomGPInfoDialog::RandomGPInfoDialog() { // Defaults - loading selection from last time frrom a file would be better - m_number_of_tracks = 2; // We can assume that there are at least 2 standart tracks + m_number_of_tracks = 2; // We can assume that there are at least 2 standard tracks m_trackgroup = "standard"; m_use_reverse = NO_REVERSE; @@ -78,20 +78,23 @@ void RandomGPInfoDialog::addSpinners() m_widgets.push_back(spinner); spinner->add(); spinner->move(left, m_under_title, trackgroup_width, SPINNER_HEIGHT); - // Fill it with with all the track group names + // Fill it with all the track group names spinner->addLabel("all"); + int index_standard; const std::vector& groups = track_manager->getAllTrackGroups(); - for (unsigned int i = 1; i < groups.size() + 1; i++) + for (unsigned int i = 0; i < groups.size() + 1; i++) { // FIXME: The NULL check is necessary until #1348 on github is fixed if (groups[i].c_str() != NULL) { spinner->addLabel(stringw(groups[i].c_str())); if(groups[i] == "standard") - spinner->setValue(i); + index_standard = i+1; } } - spinner->setValue(1); // Let's just hope it's right ... + // The value can only be set here because SpinnerWidget resets the value + // every time a label is added + spinner->setValue(index_standard); // Number of laps chooser spinner = new Spinner(false);