From a3ba4a56959cc0314c2c5aa492f85a1de2cb0e72 Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 29 Aug 2009 19:07:00 +0000 Subject: [PATCH] Cleanup over previous commit git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3954 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- .../dialogs/track_info_dialog.cpp | 41 +++++++++---------- .../dialogs/track_info_dialog.hpp | 7 ++++ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/states_screens/dialogs/track_info_dialog.cpp b/src/states_screens/dialogs/track_info_dialog.cpp index 80e09e56b..c16d64f85 100644 --- a/src/states_screens/dialogs/track_info_dialog.cpp +++ b/src/states_screens/dialogs/track_info_dialog.cpp @@ -30,6 +30,9 @@ #include "tracks/track_manager.hpp" #include "utils/translation.hpp" +#include "irrlicht.h" + +using namespace irr::gui; using namespace GUIEngine; @@ -83,7 +86,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac a->setTabStop(false); // ---- High Scores & track info - //core::rect< s32 > area_left(0, y1, m_area.getWidth()/2, y2); + // TODO: update highscores display when number of laps changes const int hscores_y_from = y1; const int hscores_y_to = y1 + (y2 - y1)*2/3; @@ -106,8 +109,6 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac race_manager->getDifficulty(), trackIdent, race_manager->getNumLaps()); - - // TODO: update highscores display when number of laps changes const int amount = highscores->getNumberEntries(); std::string kart_name; @@ -115,39 +116,38 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac float time; char buffer[128]; - for (int n=0; n<3; n++) + + // fill highscore entries + for (int n=0; n icon_area(5, from_y + gap, 5 + icon_size, from_y + icon_size); - IGUIImage* kart_icon = GUIEngine::getGUIEnv()->addImage( icon_area, m_irrlicht_window ); - kart_icon->setImage(texture); - kart_icon->setScaleImage(true); - kart_icon->setTabStop(false); + m_kart_icons[n] = GUIEngine::getGUIEnv()->addImage( icon_area, m_irrlicht_window ); + m_kart_icons[n]->setImage(texture); + m_kart_icons[n]->setScaleImage(true); + m_kart_icons[n]->setTabStop(false); core::rect< s32 > entry_area(icon_size + 10, from_y, m_area.getWidth()/2, next_from_y); - + // Check if this entry is filled or still empty if (n < amount) { highscores->getEntry(n, kart_name, name, &time); - sprintf(buffer, "%s : %.2f s\n", name.c_str(), time); - - std::cout << buffer << std::endl; - + const KartProperties* prop = kart_properties_manager->getKart(kart_name); if (prop != NULL) { std::string icon_path = file_manager->getDataDir() ; icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile(); ITexture* kart_icon_texture = irr_driver->getTexture( icon_path ); - kart_icon->setImage(kart_icon_texture); + m_kart_icons[n]->setImage(kart_icon_texture); } } else @@ -157,18 +157,17 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trac } text = buffer; - GUIEngine::getGUIEnv()->addStaticText( text.c_str(), entry_area, false , true , // border, word warp - m_irrlicht_window); + m_highscore_entries[n] = GUIEngine::getGUIEnv()->addStaticText( text.c_str(), entry_area, + false , true , // border, word warp + m_irrlicht_window); } - //std::cout << "======================\n"; - Track* track = track_manager->getTrack(trackIdent); core::rect< s32 > creator_info_area(0, hscores_y_to, m_area.getWidth()/2, y2); - //I18N : when showing who is the author of track '%s' + //I18N : when showing who is the author of track '%s' (place %s where the name of the author should appear) sprintf(buffer, _("Track by %s"), track->getDesigner().c_str()); text = buffer; diff --git a/src/states_screens/dialogs/track_info_dialog.hpp b/src/states_screens/dialogs/track_info_dialog.hpp index ca936a9cc..c2a2fee6c 100644 --- a/src/states_screens/dialogs/track_info_dialog.hpp +++ b/src/states_screens/dialogs/track_info_dialog.hpp @@ -21,9 +21,16 @@ #include "guiengine/modaldialog.hpp" +static const int HIGHSCORE_COUNT = 3; + +namespace irr { namespace gui { class IGUIImage; class IGUIStaticText; } } + class TrackInfoDialog : public GUIEngine::ModalDialog { std::string m_track_ident; + + irr::gui::IGUIImage* m_kart_icons[HIGHSCORE_COUNT]; + irr::gui::IGUIStaticText* m_highscore_entries[HIGHSCORE_COUNT]; public: /** * Creates a modal dialog with given percentage of screen width and height