diff --git a/src/states_screens/track_info_screen.cpp b/src/states_screens/track_info_screen.cpp index 84d9dfdfd..280ba1766 100644 --- a/src/states_screens/track_info_screen.cpp +++ b/src/states_screens/track_info_screen.cpp @@ -65,8 +65,8 @@ void TrackInfoScreen::loadedFromFile() { m_target_type_spinner = getWidget("target-type-spinner"); m_target_type_label = getWidget ("target-type-text"); - m_target_value_spinner = getWidget("target-value-spinner"); - m_target_value_label = getWidget("target-value-text"); + m_target_value_spinner = getWidget("target-value-spinner"); + m_target_value_label = getWidget("target-value-text"); m_ai_kart_spinner = getWidget("ai-spinner"); m_option = getWidget("option"); m_record_race = getWidget("record"); @@ -138,12 +138,51 @@ void TrackInfoScreen::init() if (image != NULL) screenshot->setImage(image); + m_target_type_spinner->setVisible(false); + m_target_type_label->setVisible(false); + m_target_value_spinner->setVisible(false); + m_target_value_label->setVisible(false); + + // Soccer options + // ------------- + const bool is_soccer = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER; + if (is_soccer) + { + m_target_type_spinner->setVisible(true); + m_target_type_label->setVisible(true); + m_target_value_spinner->setVisible(true); + m_target_value_label->setVisible(true); + + if (UserConfigParams::m_num_goals <= 0) + UserConfigParams::m_num_goals = UserConfigParams::m_num_goals.getDefaultValue(); + + if (UserConfigParams::m_soccer_time_limit <= 0) + UserConfigParams::m_soccer_time_limit = UserConfigParams::m_soccer_time_limit.getDefaultValue(); + + m_target_type_spinner->clearLabels(); + m_target_type_spinner->addLabel(_("Time limit")); + m_target_type_spinner->addLabel(_("Goals limit")); + m_target_type_spinner->setValue(UserConfigParams::m_soccer_use_time_limit ? 0 : 1); + + if (UserConfigParams::m_soccer_use_time_limit) + { + m_target_value_label->setText(_("Maximum time (min.)"), false); + m_target_value_spinner->setValue(UserConfigParams::m_soccer_time_limit); + } + else + { + m_target_value_label->setText(_("Number of goals to win"), false); + m_target_value_spinner->setValue(UserConfigParams::m_num_goals); + } + } + // Lap count m_lap_spinner // ----------------------- - m_target_value_spinner->setVisible(has_laps); - m_target_value_label->setVisible(has_laps); if (has_laps) { + m_target_value_spinner->setVisible(true); + m_target_value_label->setVisible(true); + if (UserConfigParams::m_artist_debug_mode) m_target_value_spinner->setMin(0); else @@ -259,37 +298,6 @@ void TrackInfoScreen::init() m_record_race->setState(false); } - bool is_soccer = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER; - m_target_type_spinner->setVisible(is_soccer); - m_target_type_label->setVisible(is_soccer); - if (is_soccer) - { - if (UserConfigParams::m_num_goals <= 0) - UserConfigParams::m_num_goals = UserConfigParams::m_num_goals.getDefaultValue(); - - if (UserConfigParams::m_soccer_time_limit <= 0) - UserConfigParams::m_soccer_time_limit = UserConfigParams::m_soccer_time_limit.getDefaultValue(); - - m_target_type_spinner->clearLabels(); - m_target_type_spinner->addLabel(_("Time limit")); - m_target_type_spinner->addLabel(_("Goals limit")); - m_target_type_spinner->setValue(UserConfigParams::m_soccer_use_time_limit ? 0 : 1); - - m_target_value_spinner->setVisible(true); - m_target_value_label->setVisible(true); - - if (UserConfigParams::m_soccer_use_time_limit) - { - m_target_value_label->setText(_("Maximum time (min.)"), false); - m_target_value_spinner->setValue(UserConfigParams::m_soccer_time_limit); - } - else - { - m_target_value_label->setText(_("Number of goals to win"), false); - m_target_value_spinner->setValue(UserConfigParams::m_num_goals); - } - } - // ---- High Scores m_highscore_label->setVisible(has_highscores); @@ -449,7 +457,7 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name, } else if (name == "target-type-spinner") { - bool timed = m_target_type_spinner->getValue() == 0; + const bool timed = m_target_type_spinner->getValue() == 0; UserConfigParams::m_soccer_use_time_limit = timed; if (timed) @@ -466,18 +474,14 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name, } else if (name == "target-value-spinner") { - bool is_soccer = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER; + const bool is_soccer = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER; if (is_soccer) { - bool timed = m_target_type_spinner->getValue() == 0; + const bool timed = m_target_type_spinner->getValue() == 0; if (timed) - { UserConfigParams::m_soccer_time_limit = m_target_value_spinner->getValue(); - } else - { UserConfigParams::m_num_goals = m_target_value_spinner->getValue(); - } } else { diff --git a/src/states_screens/track_info_screen.hpp b/src/states_screens/track_info_screen.hpp index 775aec85d..add391075 100644 --- a/src/states_screens/track_info_screen.hpp +++ b/src/states_screens/track_info_screen.hpp @@ -55,10 +55,10 @@ class TrackInfoScreen : public GUIEngine::Screen, /** The label besides the target types spinner. */ GUIEngine::LabelWidget* m_target_type_label; - /** Spinner for number of laps. */ + /** Spinner for target value e.g. number of laps or goals to score. */ GUIEngine::SpinnerWidget* m_target_value_spinner; - /** The label besides the lap spinner. */ + /** The label besides the target value spinner. */ GUIEngine::LabelWidget* m_target_value_label; /** Spinner for number of AI karts. */