Fixed more hard coded paths. Icon path in KartProperties now

stores the absolute path (and getKartIconFile is now called
getAbsoluteKartIconFile).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7223 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-01-03 10:45:31 +00:00
parent 76ee2036d8
commit 503723967f
7 changed files with 24 additions and 26 deletions

View File

@ -158,12 +158,14 @@ void KartProperties::load(const std::string &filename, const std::string &node)
// addShared makes sure that these textures/material infos stay in memory
material_manager->addSharedMaterial(materials_file);
m_icon_file = m_root+"/"+m_icon_file;
// Make permanent is important, since otherwise icons can get deleted
// (e.g. when freeing temp. materials from a track, the last icon
// would get deleted, too.
m_icon_material = material_manager->getMaterial(m_icon_file,
/*is_full+path*/false,
/*is_full+path*/true,
/*make_permanent*/true);
if(m_minimap_icon_file!="")
m_minimap_icon = irr_driver->getTexture(m_minimap_icon_file);

View File

@ -52,7 +52,7 @@ private:
/** Base directory for this kart. */
std::string m_root;
/** The icon texture to use. */
/** The absolute path of the icon texture to use. */
Material *m_icon_material;
/** The minimap icon file. */
@ -313,8 +313,8 @@ public:
/** Returns the shadow texture to use. */
video::ITexture *getShadowTexture() const {return m_shadow_texture; }
/** Returns the icon file of this kart. */
const std::string& getIconFile () const {return m_icon_file; }
/** Returns the absolute path of the icon file of this kart. */
const std::string& getAbsoluteIconFile() const { return m_icon_file; }
/** Returns custom sound effects for this kart. */
const int getCustomSfxId (SFXManager::CustomSFX type)

View File

@ -126,8 +126,7 @@ void KartPropertiesManager::loadAllKarts(bool loading_icon)
if (loaded && loading_icon)
{
GUIEngine::addLoadingIcon(irr_driver->getTexture(
*dir + "/"+*subdir + "/" +
m_karts_properties[m_karts_properties.size()-1]->getIconFile()
m_karts_properties[m_karts_properties.size()-1]->getAbsoluteIconFile()
)
);
}

View File

@ -179,10 +179,9 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
time_string.c_str());
}
const KartProperties* prop = current_kart->getKartProperties();
std::string icon_path = file_manager->getDataDir() ;
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
const KartProperties* prop = current_kart->getKartProperties();
const std::string &icon_path = prop->getAbsoluteIconFile();
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
const int entry_width = (show_highscores? m_area.getWidth()*2/3 : m_area.getWidth());
@ -277,8 +276,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
const Kart *current_kart = world->getKart(i);
const KartProperties* prop = current_kart->getKartProperties();
std::string icon_path = file_manager->getDataDir() ;
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
const std::string &icon_path = prop->getAbsoluteIconFile();
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
@ -661,10 +659,9 @@ void RaceOverDialog::renderThreeStrikesGraph(const int x, const int y, const int
{
const Kart* current_kart = world->getKart(k);
const KartProperties* prop = current_kart->getKartProperties();
std::string icon_path = file_manager->getDataDir() ;
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
const KartProperties* prop = current_kart->getKartProperties();
const std::string& icon_path = prop->getAbsoluteIconFile();
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
/*
draw2DImage (const video::ITexture *texture, const core::rect< s32 > &destRect,

View File

@ -250,8 +250,7 @@ void TrackInfoDialog::updateHighScores()
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();
const std::string &icon_path = prop->getAbsoluteIconFile();
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
m_kart_icons[n]->setImage(kart_icon_texture);
}

View File

@ -1629,17 +1629,16 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
for (int n=0; n<kart_amount; n++)
{
const KartProperties* prop = kart_properties_manager->getKartById(n);
std::string icon_path = prop->getKartDir()+"/"+ prop->getIconFile();
if (unlock_manager->isLocked(prop->getIdent()))
{
w->addItem( _("Locked : solve active challenges to gain access to more!"),
"locked", icon_path, LOCKED_BADGE);
w->addItem(
_("Locked : solve active challenges to gain access to more!"),
"locked", prop->getAbsoluteIconFile(), LOCKED_BADGE);
}
else
{
w->addItem(prop->getName().c_str(), prop->getIdent(),
icon_path, 0,
prop->getAbsoluteIconFile(), 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
usableKartCount++;
}
@ -1659,7 +1658,7 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
for (int n=0; n<kart_amount; n++)
{
const KartProperties* prop = kart_properties_manager->getKartById(group[n]);
std::string icon_path = prop->getKartDir() + "/" + prop->getIconFile();
const std::string &icon_path = prop->getAbsoluteIconFile();
if (unlock_manager->isLocked(prop->getIdent()))
{

View File

@ -604,8 +604,10 @@ void RaceResultGUI::displayOneEntry(unsigned int x, unsigned int y,
irr_driver->getVideoDriver()->draw2DImage(ri->m_kart_icon, dest_rect,
source_rect, NULL, NULL,
true);
current_x += m_width_icon + m_width_column_space;
}
current_x += m_width_icon + m_width_column_space;
// Draw the name
// -------------
core::recti pos_name(current_x, y,