diff --git a/src/states_screens/track_info_screen.cpp b/src/states_screens/track_info_screen.cpp index fd089f376..b54c100ba 100644 --- a/src/states_screens/track_info_screen.cpp +++ b/src/states_screens/track_info_screen.cpp @@ -70,6 +70,16 @@ void TrackInfoScreen::loadedFromFile() m_ai_kart_spinner = getWidget("ai-spinner"); m_reverse = getWidget("reverse"); m_reverse->setState(false); + + m_highscore_label = getWidget("highscores"); + + m_kart_icons[0] = getWidget("iconscore1"); + m_kart_icons[1] = getWidget("iconscore2"); + m_kart_icons[2] = getWidget("iconscore3"); + + m_highscore_entries[0] = getWidget("highscore1"); + m_highscore_entries[1] = getWidget("highscore2"); + m_highscore_entries[2] = getWidget("highscore3"); } // loadedFromFile // ---------------------------------------------------------------------------- @@ -181,30 +191,16 @@ void TrackInfoScreen::init() m_reverse->setState(false); // ---- High Scores - if (has_highscores) - { - m_kart_icons[0] = getWidget("iconscore1"); - m_kart_icons[1] = getWidget("iconscore2"); - m_kart_icons[2] = getWidget("iconscore3"); + m_highscore_label->setVisible(has_highscores); - m_highscore_entries[0] = getWidget("highscore1"); - m_highscore_entries[1] = getWidget("highscore2"); - m_highscore_entries[2] = getWidget("highscore3"); + m_kart_icons[0]->setVisible(has_highscores); + m_kart_icons[1]->setVisible(has_highscores); + m_kart_icons[2]->setVisible(has_highscores); - updateHighScores(); - } - else - { - getWidget("iconscore1")->setVisible(false); - getWidget("iconscore2")->setVisible(false); - getWidget("iconscore3")->setVisible(false); + m_highscore_entries[0]->setVisible(has_highscores); + m_highscore_entries[1]->setVisible(has_highscores); + m_highscore_entries[2]->setVisible(has_highscores); - getWidget("highscores")->setVisible(false); - getWidget("highscore1")->setVisible(false); - getWidget("highscore2")->setVisible(false); - getWidget("highscore3")->setVisible(false); - } - RibbonWidget* bt_start = getWidget("buttons"); bt_start->setFocusForPlayer(PLAYER_ID_GAME_MASTER); @@ -220,6 +216,9 @@ TrackInfoScreen::~TrackInfoScreen() void TrackInfoScreen::updateHighScores() { + if (!race_manager->modeHasHighscores()) + return; + std::string game_mode_ident = RaceManager::getIdentOf( race_manager->getMinorMode() ); const Highscores::HighscoreType type = "HST_" + game_mode_ident; @@ -281,7 +280,7 @@ void TrackInfoScreen::onEnterPressedInternal() // Create a copy of member variables we still need, since they will // not be accessible after dismiss: - const int num_laps = race_manager->modeHasLaps() ? m_lap_spinner->getValue() + const int num_laps = race_manager->modeHasLaps() ? m_lap_spinner->getValue() : -1; const bool reverse_track = m_reverse == NULL ? false : m_reverse->getState(); @@ -318,10 +317,7 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name, race_manager->setReverseTrack(m_reverse->getState()); // Makes sure the highscores get swapped when clicking the 'reverse' // checkbox. - if (race_manager->modeHasHighscores()) - { - updateHighScores(); - } + updateHighScores(); } else if (name == "lap-spinner") { diff --git a/src/states_screens/track_info_screen.hpp b/src/states_screens/track_info_screen.hpp index 4034bd5de..e84173d6a 100644 --- a/src/states_screens/track_info_screen.hpp +++ b/src/states_screens/track_info_screen.hpp @@ -58,18 +58,21 @@ class TrackInfoScreen : public GUIEngine::Screen, /** Check box for reverse mode. */ GUIEngine::CheckBoxWidget* m_reverse; + /** The label of the highscore list. */ + GUIEngine::LabelWidget* m_highscore_label; + /** The icons for the highscore list. */ GUIEngine::IconButtonWidget* m_kart_icons[HIGHSCORE_COUNT]; /** The actual highscore text values shown. */ GUIEngine::LabelWidget* m_highscore_entries[HIGHSCORE_COUNT]; - + void updateHighScores(); - + public: TrackInfoScreen(); virtual ~TrackInfoScreen(); - + virtual void init(); virtual void loadedFromFile(); virtual void eventCallback(GUIEngine::Widget *,const std::string &name ,