diff --git a/data/gui/track_info.stkgui b/data/gui/track_info.stkgui index dcb8db333..7037750ff 100644 --- a/data/gui/track_info.stkgui +++ b/data/gui/track_info.stkgui @@ -10,13 +10,13 @@ - -
- - - -
+
+ + + +
+
-
diff --git a/data/gui/track_info_dialog.stkgui b/data/gui/track_info_dialog.stkgui deleted file mode 100644 index 1cd67f681..000000000 --- a/data/gui/track_info_dialog.stkgui +++ /dev/null @@ -1,73 +0,0 @@ - - -
-
-
- - -
-
diff --git a/sources.cmake b/sources.cmake index ba4868d71..f484b15d5 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,4 +1,4 @@ -# Modify this file to change the last-modified date when you add/remove a file. +# Modify this file to change the last-modified date when you add/remove a file. # This will then trigger a new cmake run automatically. file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") diff --git a/src/race/race_manager.hpp b/src/race/race_manager.hpp index 379fd3ed0..2a0f4b3cf 100644 --- a/src/race/race_manager.hpp +++ b/src/race/race_manager.hpp @@ -185,12 +185,13 @@ public: case MINOR_MODE_SOCCER: return _("Soccer"); default: assert(false); return NULL; } - } + } // getNameOf // ------------------------------------------------------------------------ - static bool hasAI(const MinorRaceModeType mode) + /** Returns if the currently set minor game mode can be used by the AI. */ + bool hasAI() { - switch (mode) + switch (m_minor_mode) { case MINOR_MODE_NORMAL_RACE: return true; case MINOR_MODE_TIME_TRIAL: return true; @@ -200,7 +201,7 @@ public: case MINOR_MODE_SOCCER: return false; default: assert(false); return false; } - } + } // hasAI // ------------------------------------------------------------------------ diff --git a/src/states_screens/arenas_screen.cpp b/src/states_screens/arenas_screen.cpp index f556629ac..fd4ead99e 100644 --- a/src/states_screens/arenas_screen.cpp +++ b/src/states_screens/arenas_screen.cpp @@ -25,7 +25,7 @@ #include "io/file_manager.hpp" #include "states_screens/state_manager.hpp" #include "states_screens/arenas_screen.hpp" -#include "states_screens/dialogs/track_info_dialog.hpp" +#include "states_screens/track_info_screen.hpp" #include "tracks/track.hpp" #include "tracks/track_manager.hpp" #include "utils/random_generator.hpp" @@ -163,13 +163,11 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const RandomGenerator random; const int randomID = random.get(curr_group.size()); - Track* clickedTrack = track_manager->getTrack( curr_group[randomID] ); - if (clickedTrack != NULL) + Track* clicked_track = track_manager->getTrack( curr_group[randomID] ); + if (clicked_track != NULL) { - ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() ); - - new TrackInfoDialog(selection, clickedTrack->getIdent(), clickedTrack->getName(), - screenshot, 0.8f, 0.7f); + TrackInfoScreen::getInstance()->setTrack(clicked_track); + StateManager::get()->pushScreen(TrackInfoScreen::getInstance()); } } @@ -182,13 +180,11 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const } else { - Track* clickedTrack = track_manager->getTrack(selection); - if (clickedTrack != NULL) + Track* clicked_track = track_manager->getTrack(selection); + if (clicked_track != NULL) { - ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() ); - - new TrackInfoDialog(selection, clickedTrack->getIdent(), clickedTrack->getName(), - screenshot, 0.8f, 0.7f); + TrackInfoScreen::getInstance()->setTrack(clicked_track); + StateManager::get()->pushScreen(TrackInfoScreen::getInstance()); } // clickedTrack != NULL } // if random_track diff --git a/src/states_screens/dialogs/track_info_dialog.cpp b/src/states_screens/dialogs/track_info_dialog.cpp deleted file mode 100644 index e7d7025f2..000000000 --- a/src/states_screens/dialogs/track_info_dialog.cpp +++ /dev/null @@ -1,285 +0,0 @@ -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2009-2013 Marianne Gagnon -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "states_screens/dialogs/track_info_dialog.hpp" - -#include "challenges/unlock_manager.hpp" -#include "config/player_manager.hpp" -#include "config/user_config.hpp" -#include "graphics/irr_driver.hpp" -#include "guiengine/engine.hpp" -#include "guiengine/screen.hpp" -#include "guiengine/widgets/button_widget.hpp" -#include "guiengine/widgets/icon_button_widget.hpp" -#include "guiengine/widgets/label_widget.hpp" -#include "guiengine/widgets/spinner_widget.hpp" -#include "io/file_manager.hpp" -#include "karts/kart_properties.hpp" -#include "karts/kart_properties_manager.hpp" -#include "race/highscores.hpp" -#include "race/highscore_manager.hpp" -#include "race/race_manager.hpp" -#include "states_screens/state_manager.hpp" -#include "states_screens/tracks_screen.hpp" -#include "tracks/track.hpp" -#include "tracks/track_manager.hpp" -#include "utils/string_utils.hpp" -#include "utils/translation.hpp" - -#include -#include -#include - -using namespace irr::gui; -using namespace irr::video; -using namespace irr::core; -using namespace GUIEngine; - -// ------------------------------------------------------------------------------------------------------ - -TrackInfoDialog::TrackInfoDialog(const std::string& ribbonItem, const std::string& trackIdent, - const irr::core::stringw& trackName, ITexture* screenshot, - const float w, const float h) : ModalDialog(w, h) -{ - loadFromFile("track_info_dialog.stkgui"); - - const bool has_laps = race_manager->modeHasLaps(); - const bool has_highscores = race_manager->modeHasHighscores(); - - m_track_ident = trackIdent; - m_ribbon_item = ribbonItem; - - getWidget("name")->setText(trackName.c_str(), false); - - Track* track = track_manager->getTrack(trackIdent); - //I18N: when showing who is the author of track '%s' (place %s where the name of the author should appear) - getWidget("author")->setText( _("Track by %s", track->getDesigner().c_str()), false ); - - - // ---- Track screenshot - Widget* screenshot_div = getWidget("screenshot_div"); - IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO, - false /* tab stop */, false /* focusable */); - // images are saved squared, but must be stretched to 4: - screenshotWidget->setCustomAspectRatio(4.0f / 3.0f); - - screenshotWidget->m_x = screenshot_div->m_x; - screenshotWidget->m_y = screenshot_div->m_y; - screenshotWidget->m_w = screenshot_div->m_w; - screenshotWidget->m_h = screenshot_div->m_h; - - // temporary icon, will replace it just after (but it will be shown if the given icon is not found) - screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png"; - screenshotWidget->setParent(m_irrlicht_window); - screenshotWidget->add(); - - if (screenshot != NULL) - screenshotWidget->setImage(screenshot); - m_widgets.push_back(screenshotWidget); - - - // ---- Lap count m_spinner - if (has_laps) - { - m_spinner = getWidget("lapcountspinner"); - if (UserConfigParams::m_artist_debug_mode) - m_spinner->setMin(0); - - m_spinner->setValue(track->getActualNumberOfLap()); - race_manager->setNumLaps(m_spinner->getValue()); - } - else - { - getWidget("lapcountspinner")->setVisible(false); - m_spinner = NULL; - } - - - // Reverse track - const bool reverse_available = track->reverseAvailable() && - race_manager->getMinorMode() != RaceManager::MINOR_MODE_EASTER_EGG; - if (reverse_available) - { - m_checkbox = getWidget("reverse"); - m_checkbox->setState(race_manager->getReverseTrack()); - } - else - { - getWidget("reverse")->setVisible(false); - getWidget("reverse-text")->setVisible(false); - m_checkbox = NULL; - race_manager->setReverseTrack(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_entries[0] = getWidget("highscore1"); - m_highscore_entries[1] = getWidget("highscore2"); - m_highscore_entries[2] = getWidget("highscore3"); - - updateHighScores(); - } - else - { - getWidget("iconscore1")->setVisible(false); - getWidget("iconscore2")->setVisible(false); - getWidget("iconscore3")->setVisible(false); - - getWidget("highscores")->setVisible(false); - getWidget("highscore1")->setVisible(false); - getWidget("highscore2")->setVisible(false); - getWidget("highscore3")->setVisible(false); - } - - getWidget("start")->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); - -} // TrackInfoDialog - -// ------------------------------------------------------------------------------------------------------ - -TrackInfoDialog::~TrackInfoDialog() -{ - // Place focus back on selected track, in case the dialog was cancelled and we're back to - // the track selection screen after - GUIEngine::Screen* curr_screen = GUIEngine::getCurrentScreen(); - if (curr_screen->getName() == "tracks.stkgui") - { - ((TracksScreen*)curr_screen)->setFocusOnTrack(m_ribbon_item); - } - -} // ~TrackInfoDialog - -// ------------------------------------------------------------------------------------------------------ - -void TrackInfoDialog::updateHighScores() -{ - std::string game_mode_ident = RaceManager::getIdentOf( race_manager->getMinorMode() ); - const Highscores::HighscoreType type = "HST_" + game_mode_ident; - - Highscores* highscores = - highscore_manager->getHighscores(type, - race_manager->getNumberOfKarts(), - race_manager->getDifficulty(), - m_track_ident, - race_manager->getNumLaps(), - race_manager->getReverseTrack() ); - const int amount = highscores->getNumberEntries(); - - std::string kart_name; - core::stringw name; - float time; - - // fill highscore entries - for (int n=0; ngetEntry(n, kart_name, name, &time); - - std::string time_string = StringUtils::timeToString(time); - - const KartProperties* prop = kart_properties_manager->getKart(kart_name); - if (prop != NULL) - { - const std::string &icon_path = prop->getAbsoluteIconFile(); - ITexture* kart_icon_texture = irr_driver->getTexture( icon_path ); - m_kart_icons[n]->setImage(kart_icon_texture); - } - line = name + "\t" + core::stringw(time_string.c_str()); - } - else - { - //I18N: for empty highscores entries - line = _("(Empty)"); - - ITexture* no_kart_texture = irr_driver->getTexture( - file_manager->getAsset(FileManager::GUI, - "random_kart.png") ); - m_kart_icons[n]->setImage(no_kart_texture); - - } - - m_highscore_entries[n]->setText( line.c_str(), false ); - - } -} // updateHighScores - -// ------------------------------------------------------------------------------------------------------ - -void TrackInfoDialog::onEnterPressedInternal() -{ - - // Create a copy of member variables we still need, since they will - // not be accessible after dismiss: - const int num_laps = (m_spinner == NULL ? -1 : m_spinner->getValue()); - const bool reverse_track = m_checkbox == NULL ? false - : m_checkbox->getState(); - track_manager->getTrack(m_track_ident)->setActualNumberOfLaps(num_laps); - race_manager->setReverseTrack(reverse_track); - std::string track_ident = m_track_ident; - // Disable accidentally unlocking of a challenge - PlayerManager::getCurrentPlayer()->setCurrentChallenge(""); - - ModalDialog::dismiss(); - race_manager->startSingleRace(track_ident, num_laps, false); -} // onEnterPressedInternal - -// ------------------------------------------------------------------------------------------------------ - -GUIEngine::EventPropagation TrackInfoDialog::processEvent(const std::string& eventSource) -{ - if (eventSource == "start" ) - { - onEnterPressedInternal(); - return GUIEngine::EVENT_BLOCK; - } - else if (eventSource == "closePopup") - { - ModalDialog::dismiss(); - return GUIEngine::EVENT_BLOCK; - } - else if (eventSource == "reverse") - { - race_manager->setReverseTrack(m_checkbox->getState()); - // Makes sure the highscores get swapped when clicking the 'reverse' - // checkbox. - if (race_manager->modeHasHighscores()) - { - updateHighScores(); - } - } - else if (eventSource == "lapcountspinner") - { - assert(m_spinner != NULL); - const int num_laps = m_spinner->getValue(); - race_manager->setNumLaps(num_laps); - UserConfigParams::m_num_laps = num_laps; - updateHighScores(); - } - - return GUIEngine::EVENT_LET; -} // processEvent - -// ------------------------------------------------------------------------------------------------------ diff --git a/src/states_screens/dialogs/track_info_dialog.hpp b/src/states_screens/dialogs/track_info_dialog.hpp deleted file mode 100644 index 3367ac5c2..000000000 --- a/src/states_screens/dialogs/track_info_dialog.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2009-2013 Marianne Gagnon -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef HEADER_TRACKINFO_DIALOG_HPP -#define HEADER_TRACKINFO_DIALOG_HPP - -#include "guiengine/modaldialog.hpp" -#include "guiengine/widgets/check_box_widget.hpp" - -static const int HIGHSCORE_COUNT = 3; - -namespace GUIEngine -{ - class SpinnerWidget; - class IconButtonWidget; - class LabelWidget; -} - -/** - * \brief Dialog that shows the information about a given track - * \ingroup states_screens - */ -class TrackInfoDialog : public GUIEngine::ModalDialog -{ - std::string m_track_ident; - std::string m_ribbon_item; - - // When there is no need to tab through / click on images/labels, we can add directly - // irrlicht labels (more complicated uses require the use of our widget set) - GUIEngine::SpinnerWidget* m_spinner; - GUIEngine::CheckBoxWidget* m_checkbox; - GUIEngine::IconButtonWidget* m_kart_icons[HIGHSCORE_COUNT]; - GUIEngine::LabelWidget* m_highscore_entries[HIGHSCORE_COUNT]; - - void updateHighScores(); - -public: - /** - * \brief Creates a track info modal dialog with given percentage of screen width and height - * \param ribbonItem identifier name of the ribbon item that was clicked in the track selection - * screen to get there (often will be 'trackIdent' but may also be the random item) - * \param trackIdent identifier name of the track to show information about - * \param trackName human-readable, possibly translated, name of the track to show information about - * \param screenshot screenshot of the track to show information about - */ - TrackInfoDialog(const std::string& ribbonItem, const std::string& trackIdent, - const irr::core::stringw& trackName, irr::video::ITexture* screenshot, - const float percentWidth, const float percentHeight); - virtual ~TrackInfoDialog(); - - void onEnterPressedInternal(); - GUIEngine::EventPropagation processEvent(const std::string& eventSource); -}; - -#endif diff --git a/src/states_screens/easter_egg_screen.cpp b/src/states_screens/easter_egg_screen.cpp index 474615e32..bf0790cde 100644 --- a/src/states_screens/easter_egg_screen.cpp +++ b/src/states_screens/easter_egg_screen.cpp @@ -26,7 +26,7 @@ #include "guiengine/widgets/icon_button_widget.hpp" #include "io/file_manager.hpp" #include "states_screens/state_manager.hpp" -#include "states_screens/dialogs/track_info_dialog.hpp" +#include "states_screens/track_info_screen.hpp" #include "tracks/track.hpp" #include "tracks/track_manager.hpp" #include "utils/translation.hpp" @@ -80,19 +80,13 @@ void EasterEggScreen::eventCallback(Widget* widget, const std::string& name, con std::string track = m_random_track_list.front(); m_random_track_list.pop_front(); m_random_track_list.push_back(track); - Track* clickedTrack = track_manager->getTrack( track ); + Track* clicked_track = track_manager->getTrack( track ); - if (clickedTrack != NULL) + if (clicked_track != NULL) { - ITexture* screenshot = - irr_driver->getTexture( clickedTrack->getScreenshotFile(), - "While loading screenshot for track '%s':", - clickedTrack->getFilename() ); - - new TrackInfoDialog(selection, clickedTrack->getIdent(), - translations->fribidize(clickedTrack->getName()), - screenshot, 0.8f, 0.7f); + TrackInfoScreen::getInstance()->setTrack(clicked_track); + StateManager::get()->pushScreen(TrackInfoScreen::getInstance()); } } @@ -100,22 +94,13 @@ void EasterEggScreen::eventCallback(Widget* widget, const std::string& name, con { unlock_manager->playLockSound(); } - else if (selection == RibbonWidget::NO_ITEM_ID) + else if (selection != RibbonWidget::NO_ITEM_ID) { - } - else - { - Track* clickedTrack = track_manager->getTrack(selection); - if (clickedTrack != NULL) + Track* clicked_track = track_manager->getTrack(selection); + if (clicked_track != NULL) { - ITexture* screenshot = - irr_driver->getTexture( clickedTrack->getScreenshotFile(), - "While loading screenshot for track '%s'", - clickedTrack->getFilename()); - - new TrackInfoDialog(selection, clickedTrack->getIdent(), - translations->fribidize(clickedTrack->getName()), - screenshot, 0.8f, 0.7f); + TrackInfoScreen::getInstance()->setTrack(clicked_track); + StateManager::get()->pushScreen(TrackInfoScreen::getInstance()); } } } diff --git a/src/states_screens/grand_prix_editor_screen.cpp b/src/states_screens/grand_prix_editor_screen.cpp index 64bb9449f..1552835c1 100644 --- a/src/states_screens/grand_prix_editor_screen.cpp +++ b/src/states_screens/grand_prix_editor_screen.cpp @@ -29,7 +29,6 @@ #include "states_screens/edit_gp_screen.hpp" #include "states_screens/dialogs/enter_gp_name_dialog.hpp" #include "states_screens/dialogs/gp_info_dialog.hpp" -#include "states_screens/dialogs/track_info_dialog.hpp" #include "tracks/track.hpp" #include "tracks/track_manager.hpp" #include "utils/translation.hpp" diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index 180eab769..4390fa7d8 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -333,18 +333,10 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, #endif if (selection == "new") { -#undef XX -#ifdef XX - Track *track = track_manager->getTrack("olivermath"); - TrackInfoScreen *tis = TrackInfoScreen::getInstance(); - tis->setTrack(track); - StateManager::get()->pushScreen(tis); -#else KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance(); //FIXME : that was for tests s->setMultiplayer(false); s->setFromOverworld(false); StateManager::get()->pushScreen( s ); -#endif } else if (selection == "multiplayer") { diff --git a/src/states_screens/track_info_screen.cpp b/src/states_screens/track_info_screen.cpp index 569477ca2..ba3d916bc 100644 --- a/src/states_screens/track_info_screen.cpp +++ b/src/states_screens/track_info_screen.cpp @@ -54,15 +54,22 @@ using namespace GUIEngine; DEFINE_SCREEN_SINGLETON( TrackInfoScreen ); -// ------------------------------------------------------------------------------------------------------ - -//TrackInfoScreen::TrackInfoScreen(const std::string& ribbonItem, const std::string& trackIdent, -// const irr::core::stringw& trackName, ITexture* screenshot) +// ---------------------------------------------------------------------------- +/** Constructor, which loads the corresponding track_info.stkgui file. */ TrackInfoScreen::TrackInfoScreen() : Screen("track_info.stkgui") { } // TrackInfoScreen +// ---------------------------------------------------------------------------- +/* Saves some often used pointers. */ +void TrackInfoScreen::loadedFromFile() +{ + m_lap_spinner = getWidget("lap-spinner"); + m_ai_kart_spinner = getWidget("ai-spinner"); + m_reverse = getWidget("reverse"); +} // loadedFromFile + // ---------------------------------------------------------------------------- void TrackInfoScreen::setTrack(const Track *track) { @@ -75,9 +82,6 @@ void TrackInfoScreen::setTrack(const Track *track) */ void TrackInfoScreen::init() { - RaceManager::MinorRaceModeType minor = race_manager->getMinorMode(); - - const bool has_AI = race_manager->hasAI(minor); const bool has_laps = race_manager->modeHasLaps(); const bool has_highscores = race_manager->modeHasHighscores(); @@ -115,29 +119,23 @@ void TrackInfoScreen::init() // Lap count m_lap_spinner // ----------------------- + m_lap_spinner->setVisible(has_laps); + getWidget("lap-text")->setVisible(has_laps); if (has_laps) { - m_lap_spinner = getWidget("lapcountspinner"); - m_lap_spinner->setVisible(true); - getWidget("lap-text")->setVisible(true); if (UserConfigParams::m_artist_debug_mode) m_lap_spinner->setMin(0); - m_lap_spinner->setValue(m_track->getActualNumberOfLap()); race_manager->setNumLaps(m_lap_spinner->getValue()); } - else - { - getWidget("lapcountspinner")->setVisible(false); - getWidget("lap-text")->setVisible(false); - m_lap_spinner = NULL; - } // Number of AIs // ------------- + const bool has_AI = race_manager->hasAI(); + m_ai_kart_spinner->setVisible(has_AI); + getWidget("ai-text")->setVisible(has_AI); if (has_AI) { - m_ai_kart_spinner = getWidget("kartcountspinner"); m_ai_kart_spinner->setActivated(); // Avoid negative numbers (which can happen if e.g. the number of karts @@ -145,30 +143,27 @@ void TrackInfoScreen::init() int num_ai = UserConfigParams::m_num_karts - race_manager->getNumLocalPlayers(); if (num_ai < 0) num_ai = 0; m_ai_kart_spinner->setValue(num_ai); - m_ai_kart_spinner->setMax(stk_config->m_max_karts - race_manager->getNumLocalPlayers()); race_manager->setNumKarts(num_ai + race_manager->getNumLocalPlayers()); - } - else - { - getWidget("kartcountspinner")->setVisible(false); - m_ai_kart_spinner = NULL; - } + m_ai_kart_spinner->setMax(stk_config->m_max_karts - race_manager->getNumLocalPlayers()); + // A ftl reace needs at least three karts to make any sense + if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER) + { + m_ai_kart_spinner->setMin(3-race_manager->getNumLocalPlayers()); + } + else + m_ai_kart_spinner->setMin(0); + + } // has_AI // Reverse track // ------------- const bool reverse_available = m_track->reverseAvailable() && race_manager->getMinorMode() != RaceManager::MINOR_MODE_EASTER_EGG; + m_reverse->setVisible(reverse_available); + getWidget("reverse-text")->setVisible(reverse_available); if (reverse_available) { - m_checkbox = getWidget("reverse"); - m_checkbox->setState(race_manager->getReverseTrack()); - } - else - { - getWidget("reverse")->setVisible(false); - getWidget("reverse-text")->setVisible(false); - m_checkbox = NULL; - race_manager->setReverseTrack(false); + m_reverse->setState(race_manager->getReverseTrack()); } // ---- High Scores @@ -196,9 +191,7 @@ void TrackInfoScreen::init() getWidget("highscore3")->setVisible(false); } - //FIXME getWidget("start")->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); - -} // TrackInfoScreen +} // init // ---------------------------------------------------------------------------- @@ -271,9 +264,10 @@ void TrackInfoScreen::onEnterPressedInternal() // Create a copy of member variables we still need, since they will // not be accessible after dismiss: - const int num_laps = (m_lap_spinner == NULL ? -1 : m_lap_spinner->getValue()); - const bool reverse_track = m_checkbox == NULL ? false - : m_checkbox->getState(); + const int num_laps = race_manager->modeHasLaps() ? m_lap_spinner->getValue() + : -1; + const bool reverse_track = m_reverse == NULL ? false + : m_reverse->getState(); //FIXME m_track->setActualNumberOfLaps(num_laps); race_manager->setReverseTrack(reverse_track); @@ -302,7 +296,7 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name, } else if (name == "reverse") { - race_manager->setReverseTrack(m_checkbox->getState()); + race_manager->setReverseTrack(m_reverse->getState()); // Makes sure the highscores get swapped when clicking the 'reverse' // checkbox. if (race_manager->modeHasHighscores()) @@ -310,20 +304,20 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name, updateHighScores(); } } - else if (name == "lapcountspinner") + else if (name == "lap-spinner") { - assert(m_lap_spinner != NULL); + assert(race_manager->modeHasLaps()); const int num_laps = m_lap_spinner->getValue(); race_manager->setNumLaps(num_laps); UserConfigParams::m_num_laps = num_laps; updateHighScores(); } - else if (name=="kartcountspinner") + else if (name=="ai-spinner") { SpinnerWidget* w = dynamic_cast(widget); - race_manager->setNumKarts( race_manager->getNumLocalPlayers() + w->getValue() ); - UserConfigParams::m_num_karts = race_manager->getNumLocalPlayers() + w->getValue(); - + const int num_ai = m_ai_kart_spinner->getValue(); + race_manager->setNumKarts( race_manager->getNumLocalPlayers() + num_ai ); + UserConfigParams::m_num_karts = race_manager->getNumLocalPlayers() + num_ai; } } // eventCallback diff --git a/src/states_screens/track_info_screen.hpp b/src/states_screens/track_info_screen.hpp index 64335d583..5594f3cbf 100644 --- a/src/states_screens/track_info_screen.hpp +++ b/src/states_screens/track_info_screen.hpp @@ -55,9 +55,13 @@ class TrackInfoScreen : public GUIEngine::Screen, /** Spinner for number of AI karts. */ GUIEngine::SpinnerWidget* m_ai_kart_spinner; - /** */ - GUIEngine::CheckBoxWidget* m_checkbox; + /** Check box for reverse mode. */ + GUIEngine::CheckBoxWidget* m_reverse; + + /** 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(); @@ -75,7 +79,7 @@ public: virtual ~TrackInfoScreen(); virtual void init(); - virtual void loadedFromFile() {} + virtual void loadedFromFile(); virtual void eventCallback(GUIEngine::Widget *,const std::string &name , const int player_id); void onEnterPressedInternal();