From 503723967f377b03365204fad83a0d948e7d3070 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Mon, 3 Jan 2011 10:45:31 +0000 Subject: [PATCH] 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 --- src/karts/kart_properties.cpp | 6 ++++-- src/karts/kart_properties.hpp | 6 +++--- src/karts/kart_properties_manager.cpp | 3 +-- src/states_screens/dialogs/race_over_dialog.cpp | 17 +++++++---------- .../dialogs/track_info_dialog.cpp | 3 +-- src/states_screens/kart_selection.cpp | 11 +++++------ src/states_screens/race_result_gui.cpp | 4 +++- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index fe37220d8..1079af2db 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -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); diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index 7649f4159..049cf08ad 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -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) diff --git a/src/karts/kart_properties_manager.cpp b/src/karts/kart_properties_manager.cpp index 8a9460e82..1c375b342 100644 --- a/src/karts/kart_properties_manager.cpp +++ b/src/karts/kart_properties_manager.cpp @@ -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() ) ); } diff --git a/src/states_screens/dialogs/race_over_dialog.cpp b/src/states_screens/dialogs/race_over_dialog.cpp index 7e7f3a64e..00c629b7c 100644 --- a/src/states_screens/dialogs/race_over_dialog.cpp +++ b/src/states_screens/dialogs/race_over_dialog.cpp @@ -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, diff --git a/src/states_screens/dialogs/track_info_dialog.cpp b/src/states_screens/dialogs/track_info_dialog.cpp index a46ecbaec..bec664743 100644 --- a/src/states_screens/dialogs/track_info_dialog.cpp +++ b/src/states_screens/dialogs/track_info_dialog.cpp @@ -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); } diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index ece84c426..8b7521f65 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -1629,17 +1629,16 @@ void KartSelectionScreen::setKartsFromCurrentGroup() for (int n=0; ngetKartById(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; ngetKartById(group[n]); - std::string icon_path = prop->getKartDir() + "/" + prop->getIconFile(); + const std::string &icon_path = prop->getAbsoluteIconFile(); if (unlock_manager->isLocked(prop->getIdent())) { diff --git a/src/states_screens/race_result_gui.cpp b/src/states_screens/race_result_gui.cpp index 1e86e94bf..370f9d325 100644 --- a/src/states_screens/race_result_gui.cpp +++ b/src/states_screens/race_result_gui.cpp @@ -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,