Fixed crashes in track info screen
This commit is contained in:
Marc Coll Carrillo 2014-10-04 12:15:11 +02:00
parent f520e38cd5
commit ee49604856
2 changed files with 28 additions and 29 deletions

View File

@ -70,6 +70,16 @@ void TrackInfoScreen::loadedFromFile()
m_ai_kart_spinner = getWidget<SpinnerWidget>("ai-spinner");
m_reverse = getWidget<CheckBoxWidget>("reverse");
m_reverse->setState(false);
m_highscore_label = getWidget<LabelWidget>("highscores");
m_kart_icons[0] = getWidget<IconButtonWidget>("iconscore1");
m_kart_icons[1] = getWidget<IconButtonWidget>("iconscore2");
m_kart_icons[2] = getWidget<IconButtonWidget>("iconscore3");
m_highscore_entries[0] = getWidget<LabelWidget>("highscore1");
m_highscore_entries[1] = getWidget<LabelWidget>("highscore2");
m_highscore_entries[2] = getWidget<LabelWidget>("highscore3");
} // loadedFromFile
// ----------------------------------------------------------------------------
@ -181,29 +191,15 @@ void TrackInfoScreen::init()
m_reverse->setState(false);
// ---- High Scores
if (has_highscores)
{
m_kart_icons[0] = getWidget<IconButtonWidget>("iconscore1");
m_kart_icons[1] = getWidget<IconButtonWidget>("iconscore2");
m_kart_icons[2] = getWidget<IconButtonWidget>("iconscore3");
m_highscore_label->setVisible(has_highscores);
m_highscore_entries[0] = getWidget<LabelWidget>("highscore1");
m_highscore_entries[1] = getWidget<LabelWidget>("highscore2");
m_highscore_entries[2] = getWidget<LabelWidget>("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<IconButtonWidget>("iconscore1")->setVisible(false);
getWidget<IconButtonWidget>("iconscore2")->setVisible(false);
getWidget<IconButtonWidget>("iconscore3")->setVisible(false);
getWidget<LabelWidget>("highscores")->setVisible(false);
getWidget<LabelWidget>("highscore1")->setVisible(false);
getWidget<LabelWidget>("highscore2")->setVisible(false);
getWidget<LabelWidget>("highscore3")->setVisible(false);
}
m_highscore_entries[0]->setVisible(has_highscores);
m_highscore_entries[1]->setVisible(has_highscores);
m_highscore_entries[2]->setVisible(has_highscores);
RibbonWidget* bt_start = getWidget<GUIEngine::RibbonWidget>("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;
@ -318,11 +317,8 @@ 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();
}
}
else if (name == "lap-spinner")
{
assert(race_manager->modeHasLaps());

View File

@ -58,6 +58,9 @@ 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];