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
This commit is contained in:
auria 2009-08-29 19:07:00 +00:00
parent 432da8b070
commit a3ba4a5695
2 changed files with 27 additions and 21 deletions

View File

@ -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<HIGHSCORE_COUNT; n++)
{
const int from_y = hscores_y_from + (hscores_y_to - hscores_y_from)*(n+1)/4;
const int next_from_y = hscores_y_from + (hscores_y_to - hscores_y_from)*(n+2)/4;
const int from_y = hscores_y_from + (hscores_y_to - hscores_y_from)*(n+1)/(HIGHSCORE_COUNT+1);
const int next_from_y = hscores_y_from + (hscores_y_to - hscores_y_from)*(n+2)/(HIGHSCORE_COUNT+1);
const int gap = 3;
const int icon_size = next_from_y - from_y - gap*2;
core::rect< s32 > 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;

View File

@ -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