Allowed the music directory to be external. Renamed

getMusicFile to searchMusic and getTextureFile to
searchTexture. Removed m_root_dir from file_manager.
Added convenience function getTexture to irr_driver
which takes an asset type, so now less code is needed
to load textures (though that's proably not used
everywhere yet).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14736 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2013-12-18 22:29:08 +00:00
parent 0337ae19e0
commit c450c97472
33 changed files with 190 additions and 175 deletions

View File

@ -133,8 +133,7 @@ void MusicManager::loadMusicInformation()
void MusicManager::loadMusicFromOneDir(const std::string& dir)
{
std::set<std::string> files;
file_manager->listFiles(files, dir, /*is_full_path*/ true,
/*make_full_path*/ true);
file_manager->listFiles(files, dir, /*is_full_path*/ true);
for(std::set<std::string>::iterator i = files.begin();
i != files.end(); ++i)
{

View File

@ -19,6 +19,7 @@
#include "audio/dummy_sfx.hpp"
#include "audio/music_manager.hpp"
#include "audio/sfx_buffer.hpp"
#include "io/file_manager.hpp"
#include <stdexcept>
#include <algorithm>
@ -148,7 +149,7 @@ void SFXManager::loadSfx()
XMLNode* root = file_manager->createXMLTree(sfx_config_name);
if (!root || root->getName()!="sfx-config")
{
Log::error("SFXManager", "Could not read sounf effects XML file '%s'.",
Log::fatal("SFXManager", "Could not read sound effects XML file '%s'.",
sfx_config_name.c_str());
}

View File

@ -57,7 +57,7 @@ UnlockManager::UnlockManager()
// ----------------------------------------
std::set<std::string> result;
std::string challenge_dir = file_manager->getAsset(FileManager::CHALLENGE, "");
file_manager->listFiles(result, challenge_dir, /*full_path*/true);
file_manager->listFiles(result, challenge_dir);
for(std::set<std::string>::iterator i = result.begin();
i != result.end() ; i++)
{
@ -113,7 +113,7 @@ void UnlockManager::readAllChallengesInDirs(const std::vector<std::string>* all_
dir != all_dirs->end(); dir++)
{
std::set<std::string> all_files;
file_manager->listFiles(all_files, *dir, /*is_full_path*/ true);
file_manager->listFiles(all_files, *dir);
for(std::set<std::string>::iterator file = all_files.begin();
file != all_files.end(); file++)

View File

@ -266,8 +266,8 @@ void STKConfig::getAllData(const XMLNode * root)
std::string title_music;
music_node->get("title", &title_music);
assert(title_music.size() > 0);
m_title_music = MusicInformation::create(file_manager->getMusicFile(title_music));
title_music = file_manager->getAsset(FileManager::MUSIC, title_music);
m_title_music = MusicInformation::create(title_music);
if(!m_title_music)
Log::error("StkConfig", "Cannot load title music : %s", title_music.c_str());
}

View File

@ -444,8 +444,8 @@ void IrrDriver::initDevice()
sphere->drop();
m_lensflare = new scene::CLensFlareSceneNode(NULL, m_scene_manager, -1);
video::ITexture * const tex =
m_video_driver->getTexture((file_manager->getTextureFile("lensflare.png")).c_str());
video::ITexture * const tex = getTexture(FileManager::TEXTURE,
"lensflare.png" );
if (!tex) Log::fatal("irr_driver", "Cannot find lens flare texture");
m_lensflare->setMaterialTexture(0, tex);
m_lensflare->setAutomaticCulling(scene::EAC_OFF);
@ -1176,6 +1176,28 @@ void IrrDriver::unsetTextureErrorMessage()
m_texture_error_message = "";
} // unsetTextureErrorMessage
// ----------------------------------------------------------------------------
/** Loads a texture from a file and returns the texture object. This is just
* a convenient wrapper which loads the texture from a STK asset directory.
* It calls the file manager to get the full path, then calls the normal
* getTexture() function.s
* \param type The FileManager::AssetType of the texture.
* \param filename File name of the texture to load.
* \param is_premul If the alpha values needd to be multiplied for
* all pixels.
* \param is_prediv If the alpha value needs to be divided into
* each pixel.
*/
video::ITexture *IrrDriver::getTexture(FileManager::AssetType type,
const std::string &filename,
bool is_premul,
bool is_prediv,
bool complain_if_not_found)
{
const std::string path = file_manager->getAsset(type, filename);
return getTexture(path, is_premul, is_prediv, complain_if_not_found);
} // getTexture
// ----------------------------------------------------------------------------
/** Loads a texture from a file and returns the texture object.
* \param filename File name of the texture to load.

View File

@ -50,6 +50,7 @@ class ShadowImportanceProvider;
#include "graphics/rtts.hpp"
#include "graphics/shaders.hpp"
#include "graphics/wind.hpp"
#include "io/file_manager.hpp"
#include "utils/aligned_array.hpp"
#include "utils/no_copy.hpp"
#include "utils/ptr_vector.hpp"
@ -210,6 +211,11 @@ public:
void displayFPS();
bool OnEvent(const irr::SEvent &event);
void setAmbientLight(const video::SColor &light);
video::ITexture *getTexture(FileManager::AssetType type,
const std::string &filename,
bool is_premul=false,
bool is_prediv=false,
bool complain_if_not_found=true);
video::ITexture *getTexture(const std::string &filename,
bool is_premul=false,
bool is_prediv=false,

View File

@ -418,7 +418,7 @@ void Material::install(bool is_full_path, bool complain_if_not_found)
{
const std::string &full_path = is_full_path
? m_texname
: file_manager->getTextureFile(m_texname);
: file_manager->searchTexture(m_texname);
if (complain_if_not_found && full_path.size() == 0)
{
@ -838,7 +838,8 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
{
m->MaterialType = irr_driver->getShader(ES_CAUSTICS);
m->setTexture(1, irr_driver->getTexture(file_manager->getTextureFile("caustics.png")));
m->setTexture(1, irr_driver->getTexture(FileManager::SHADER,
"caustics.png"));
}
@ -879,8 +880,10 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
{
if (irr_driver->isGLSL())
{
m->setTexture(1, irr_driver->getTexture(file_manager->getTextureFile("waternormals.jpg")));
m->setTexture(2, irr_driver->getTexture(file_manager->getTextureFile("waternormals2.jpg")));
m->setTexture(1, irr_driver->getTexture(FileManager::TEXTURE,
"waternormals.jpg"));
m->setTexture(2, irr_driver->getTexture(FileManager::TEXTURE,
"waternormals2.jpg"));
((WaterShaderProvider *) irr_driver->getCallback(ES_WATER))->
setSpeed(m_water_shader_speed_1/100.0f, m_water_shader_speed_2/100.0f);

View File

@ -106,14 +106,7 @@ void Referee::init()
}
for(unsigned int i=0; i<3; i++)
{
std::string full_path = file_manager->getTextureFile(colors[i]);
if(full_path.size()==0)
{
Log::fatal("referee",
"Can't find texture '%s' for referee, aborting.",
colors[i].c_str());
}
m_st_traffic_lights[i] = irr_driver->getTexture(full_path);
m_st_traffic_lights[i] = irr_driver->getTexture(FileManager::MODEL, colors[i]);
}

View File

@ -803,7 +803,7 @@ void IrrDriver::renderDisplacement(video::SOverrideMaterial &overridemat,
overridemat.Material.MaterialType = m_shaders->getShader(ES_DISPLACE);
overridemat.Material.TextureLayer[0].Texture =
irr_driver->getTexture(file_manager->getTextureFile("displace.png"));
irr_driver->getTexture(FileManager::TEXTURE, "displace.png");
overridemat.Material.TextureLayer[0].BilinearFilter =
overridemat.Material.TextureLayer[0].TrilinearFilter = true;
overridemat.Material.TextureLayer[0].AnisotropicFilter = 0;

View File

@ -45,7 +45,7 @@ SunNode::SunNode(scene::ISceneManager* mgr, float r, float g, float b):
m.MaterialType = irr_driver->getShader(ES_SUNLIGHT);
m.setTexture(0, irr_driver->getRTT(RTT_NORMAL));
m.setTexture(1, irr_driver->getRTT(RTT_DEPTH));
m.setTexture(2, irr_driver->getTexture(file_manager->getTextureFile("cloudshadow.png")));
m.setTexture(2, irr_driver->getTexture(file_manager->getAsset(FileManager::TEXTURE,"cloudshadow.png")));
m.setFlag(EMF_BILINEAR_FILTER, false);
m.MaterialTypeParam = pack_textureBlendFunc(EBF_ONE, EBF_ONE);
m.BlendOperation = EBO_ADD;

View File

@ -98,9 +98,7 @@ namespace SkinConfig
// call last since it calculates coords considering all other
// parameters
std:: string full_path = file_manager->getAsset(FileManager::SKIN,
image);
new_param.setTexture( irr_driver->getTexture(full_path) );
new_param.setTexture( irr_driver->getTexture(FileManager::SKIN, image));
if (areas.size() > 0)
{
@ -1634,11 +1632,10 @@ void Skin::renderSections(PtrVector<Widget>* within_vector)
// there's about 40 empty pixels at the top of bar.png
ITexture* tex =
irr_driver->getTexture( file_manager->getAsset(FileManager::GUI,"bar.png") );
irr_driver->getTexture(FileManager::GUI,"bar.png");
if(!tex)
{
std::string file = file_manager->getAsset(FileManager::GUI,"main_help.png");
tex = irr_driver->getTexture(file);
tex = irr_driver->getTexture(FileManager::GUI, "main_help.png");
if(!tex)
Log::fatal("Skin",
"Can't find fallback texture 'main_help.png, aborting.");
@ -1652,7 +1649,7 @@ void Skin::renderSections(PtrVector<Widget>* within_vector)
else if (widget.isTopBar())
{
ITexture* tex =
irr_driver->getTexture( file_manager->getAsset(FileManager::GUI,"top_bar.png" ) );
irr_driver->getTexture(FileManager::GUI, "top_bar.png");
core::recti r1(0, 0,
(int)widget.m_w, (int)widget.m_h);
@ -1939,60 +1936,51 @@ void Skin::drawBadgeOn(const Widget* widget, const core::recti& rect)
{
if (widget->m_badges & LOCKED_BADGE)
{
video::ITexture* texture = irr_driver->getTexture(
file_manager->getTextureFile("gui_lock.png"),
"Can't find '%s'.",
file_manager->getTextureFile("gui_lock.png"));
video::ITexture* texture = irr_driver->getTexture(FileManager::GUI,
"gui_lock.png");
float max_icon_size = 0.5f; // Lock badge can be quite big
doDrawBadge(texture, rect, max_icon_size, true);
}
if (widget->m_badges & OK_BADGE)
{
video::ITexture* texture = irr_driver->getTexture(
file_manager->getTextureFile("green_check.png"),
"Can't find '%s'.",
file_manager->getTextureFile("green_check.png"));
video::ITexture* texture = irr_driver->getTexture(FileManager::GUI,
"green_check.png");
float max_icon_size = 0.35f;
doDrawBadge(texture, rect, max_icon_size, true);
}
if (widget->m_badges & BAD_BADGE)
{
video::ITexture* texture = irr_driver->getTexture(
file_manager->getTextureFile("red_mark.png"),
"Can't find red_mark.png");
video::ITexture* texture = irr_driver->getTexture(FileManager::GUI,
"red_mark.png");
float max_icon_size = 0.35f;
doDrawBadge(texture, rect, max_icon_size, false);
}
if (widget->m_badges & TROPHY_BADGE)
{
float max_icon_size = 0.43f;
video::ITexture* texture = irr_driver->getTexture(
file_manager->getTextureFile("cup_bronze.png"),
"Can't find cup_bronze.png.");
video::ITexture* texture = irr_driver->getTexture(FileManager::GUI,
"cup_bronze.png");
doDrawBadge(texture, rect, max_icon_size, false);
}
if (widget->m_badges & KEYBOARD_BADGE)
{
float max_icon_size = 0.43f;
video::ITexture* texture = irr_driver->getTexture(
file_manager->getAsset(FileManager::GUI,"keyboard.png"),
"Can't find 'keyboard.png'.");
video::ITexture* texture = irr_driver->getTexture(FileManager::GUI,
"keyboard.png");
doDrawBadge(texture, rect, max_icon_size, true);
}
if (widget->m_badges & GAMEPAD_BADGE)
{
float max_icon_size = 0.43f;
video::ITexture* texture = irr_driver->getTexture(
file_manager->getAsset(FileManager::GUI,"gamepad.png"),
"Can't find 'gamepad.png'.");
video::ITexture* texture = irr_driver->getTexture(FileManager::GUI,
"gamepad.png");
doDrawBadge(texture, rect, max_icon_size, true);
}
if (widget->m_badges & LOADING_BADGE)
{
float max_icon_size = 0.43f;
video::ITexture* texture = irr_driver->getTexture(
file_manager->getAsset(FileManager::GUI,"hourglass.png"),
"Can't find 'hourglass.png'.");
video::ITexture* texture = irr_driver->getTexture(FileManager::GUI,
"hourglass.png");
doDrawBadge(texture, rect, max_icon_size, true);
}
} // drawBadgeOn
@ -2227,8 +2215,7 @@ ITexture* Skin::getImage(const char* name)
}
else
{
return irr_driver->getTexture(
file_manager->getAsset(FileManager::GUI,"main_help.png"));
return irr_driver->getTexture(FileManager::GUI,"main_help.png");
}
} // getImage

View File

@ -107,8 +107,16 @@ namespace GUIEngine
* be resized to fit a different aspect ratio.
* \note May safely be called no matter if the widget is add()ed or not
*/
void setImage(const char* path_to_texture, IconPathType pathType=ICON_PATH_TYPE_NO_CHANGE);
void setImage(const char* path_to_texture,
IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE);
/** Convenience function taking std::string. */
void setImage(const std::string &path_to_texture,
IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE)
{
setImage(path_to_texture.c_str(), path_type);
}
/**
* Change the texture used for this icon.
* \pre At the moment, the new texture must have the same aspct ratio

View File

@ -182,7 +182,7 @@ ITexture* SpinnerWidget::getTexture()
{
assert(m_graphical);
std::string s = StringUtils::insertValues(m_properties[PROP_ICON], m_value);
std::string imagefile = file_manager->getTextureFile(s);
std::string imagefile = file_manager->searchTexture(s);
ITexture* texture = irr_driver->getTexture(imagefile);
return texture;
}
@ -323,7 +323,7 @@ void SpinnerWidget::setValue(const int new_value)
if (m_graphical)
{
std::string s = StringUtils::insertValues(m_properties[PROP_ICON], m_value);
std::string imagefile = file_manager->getTextureFile(s);
std::string imagefile = file_manager->searchTexture(s);
((IGUIImage*)(m_children[1].m_element))->setImage(irr_driver->getTexture(imagefile));
}
else if (m_labels.size() > 0 && m_children.size() > 0)

View File

@ -143,41 +143,42 @@ FileManager::FileManager(char *argv[])
// Also check for data dirs relative to the path of the executable.
// This is esp. useful for Visual Studio, since it's not necessary
// to define the working directory when debugging, it works automatically.
std::string root_dir;
if(m_file_system->existFile(argv[0]))
exe_path = m_file_system->getFileDir(argv[0]);
if(exe_path.size()==0 || exe_path[exe_path.size()-1]!='/')
exe_path += "/";
if ( getenv ( "SUPERTUXKART_DATADIR" ) != NULL )
m_root_dir = std::string(getenv("SUPERTUXKART_DATADIR"))+"/" ;
root_dir = std::string(getenv("SUPERTUXKART_DATADIR"))+"/" ;
#ifdef __APPLE__
else if( macSetBundlePathIfRelevant( m_root_dir ) ) { /* nothing to do */ }
else if( macSetBundlePathIfRelevant( root_dir ) ) { /* nothing to do */ }
#endif
else if(m_file_system->existFile("data"))
m_root_dir = "data/" ;
root_dir = "data/" ;
else if(m_file_system->existFile("../data"))
m_root_dir = "../data/" ;
root_dir = "../data/" ;
else if(m_file_system->existFile(exe_path+"data"))
m_root_dir = (exe_path+"data/").c_str();
root_dir = (exe_path+"data/").c_str();
else if(m_file_system->existFile(exe_path+"/../data"))
{
m_root_dir = exe_path.c_str();
m_root_dir += "/../data/";
root_dir = exe_path.c_str();
root_dir += "/../data/";
}
else
{
#ifdef SUPERTUXKART_DATADIR
m_root_dir = SUPERTUXKART_DATADIR;
if(m_root_dir.size()==0 || m_root_dir[m_root_dir.size()-1]!='/')
m_root_dir+='/';
root_dir = SUPERTUXKART_DATADIR;
if(root_dir.size()==0 || root_dir[root_dir.size()-1]!='/')
root_dir+='/';
#else
m_root_dir = "/usr/local/share/games/supertuxkart/";
root_dir = "/usr/local/share/games/supertuxkart/";
#endif
}
addRootDirs(m_root_dir);
if(m_file_system->existFile((m_root_dir+"../../data_supertuxkart").c_str()))
addRootDirs(m_root_dir+"../../data_supertuxkart");
addRootDirs(root_dir);
if( fileExists(root_dir+"../../data_supertuxkart"))
addRootDirs(root_dir+"../../data_supertuxkart");
if ( getenv ( "SUPERTUXKART_ROOT_PATH" ) != NULL )
addRootDirs(getenv("SUPERTUXKART_ROOT_PATH"));
@ -192,8 +193,9 @@ FileManager::FileManager(char *argv[])
// We can't use _() here, since translations will only be initalised
// after the filemanager (to get the path to the tranlsations from it)
Log::info("FileManager", "Data files will be fetched from: '%s'",
m_root_dir.c_str());
for(unsigned int i=0; i<m_root_dirs.size(); i++)
Log::info("FileManager", "Data files will be fetched from: '%s'",
m_root_dirs[i].c_str());
Log::info("FileManager", "User directory is '%s'.",
m_user_config_dir.c_str());
Log::info("FileManager", "Addons files will be stored in '%s'.",
@ -270,7 +272,7 @@ void FileManager::reInit()
pushModelSearchPath (m_subdir_name[MODEL]);
pushMusicSearchPath (m_root_dir+"music/" );
pushMusicSearchPath (m_subdir_name[MUSIC]);
// Add more paths from the STK_MUSIC_PATH environment variable
if(getenv("SUPERTUXKART_MUSIC_PATH")!=NULL)
@ -290,7 +292,7 @@ FileManager::~FileManager()
// (The 24h delay is useful when debugging a problem with a zip file)
std::set<std::string> allfiles;
std::string tmp=getAddonsFile("tmp");
listFiles(allfiles, tmp, /*fullpath*/true);
listFiles(allfiles, tmp);
for(std::set<std::string>::iterator i=allfiles.begin();
i!=allfiles.end(); i++)
{
@ -534,6 +536,13 @@ std::string FileManager::getAssetChecked(FileManager::AssetType type,
} // getAssetChecked
//-----------------------------------------------------------------------------
/** Returns the full path of a file of the given asset class. It is not
* checked if the file actually exists (use getAssetChecked() instead if
* checking is needed).
* \param type Type of the asset class.
* \param name Name of the file to search.
* \return Full path to the file.
*/
std::string FileManager::getAsset(FileManager::AssetType type,
const std::string &name) const
{
@ -561,21 +570,21 @@ std::string FileManager::getScreenshotDir() const
} // getScreenshotDir
//-----------------------------------------------------------------------------
/** Returns the full path of a texture file name by searching only in the main
* texture directory(data/texture), not all texture paths (e.g. kart or
* track directories). If the texture is not found, an error message is
* printed and the program aborted if abort_on_error is true, otherwise
* an empty string is returned.
/** Returns the full path of a texture file name by searching in all
* directories currently in the texture search path. The difference to
* a call getAsset(TEXTURE,...) is that the latter will only return
* textures from .../textures, while the searchTexture will also
* search e.g. in kart or track directories (depending on what is currently
* being loaded).
* \param file_name Name of the texture file to search.
* \return The full path for the texture, or "" if the texture was not found.
*/
std::string FileManager::getTextureFile(const std::string& file_name) const
std::string FileManager::searchTexture(const std::string& file_name) const
{
std::string path;
findFile(path, file_name, m_texture_search_path);
return path;
} // getTextureFile
} // searchTexture
//-----------------------------------------------------------------------------
/** Returns the list of all directories in which music files are searched.
@ -935,16 +944,17 @@ std::string FileManager::getUserConfigFile(const std::string &fname) const
* It throws an exception if the file is not found.
* \param file_name File name to search for.
*/
std::string FileManager::getMusicFile(const std::string& file_name) const
std::string FileManager::searchMusic(const std::string& file_name) const
{
std::string path;
bool success = findFile(path, file_name, m_music_search_path);
if(!success)
{
// If a music file is not found in any of the music search paths
// check all root dirs. This is used by stk_config loading the
// check all root dirs. This is used by stk_config to load the
// title music before any music search path is defined)
success = findFile(path, "music/"+file_name, m_root_dirs);
path = getAsset(MUSIC, file_name);
success = fileExists(path);
}
if (!success)
{
@ -953,7 +963,7 @@ std::string FileManager::getMusicFile(const std::string& file_name) const
+file_name+"'.");
}
return path;
} // getMusicFile
} // searchMusic
//-----------------------------------------------------------------------------
/** Returns true if the given name is a directory.
@ -976,26 +986,22 @@ bool FileManager::isDirectory(const std::string &path) const
* \param result A reference to a std::vector<std::string> which will
* hold all files in a directory. The vector will be cleared.
* \param dir The director for which to get the directory listing.
* \param is_full_path True if directory is already a full path,
* otherwise m_root_dir is used.
* \param make_full_path If set to true, all listed files will be full paths.
*/
void FileManager::listFiles(std::set<std::string>& result,
const std::string& dir, bool is_full_path,
const std::string& dir,
bool make_full_path) const
{
result.clear();
std::string path = is_full_path ? dir : m_root_dir+dir;
#ifndef ANDROID
if(!isDirectory(path))
if(!isDirectory(dir))
return;
#endif
io::path previous_cwd = m_file_system->getWorkingDirectory();
if(!m_file_system->changeWorkingDirectoryTo( path.c_str() ))
if(!m_file_system->changeWorkingDirectoryTo( dir.c_str() ))
{
Log::error("FileManager", "listFiles : Could not change CWD!\n");
return;
@ -1004,7 +1010,7 @@ void FileManager::listFiles(std::set<std::string>& result,
for(int n=0; n<(int)files->getFileCount(); n++)
{
result.insert(make_full_path ? path+"/"+ files->getFileName(n).c_str()
result.insert(make_full_path ? dir+"/"+ files->getFileName(n).c_str()
: files->getFileName(n).c_str() );
}

View File

@ -47,11 +47,10 @@ public:
/** The various asset types (and directories) STK might request.
* The last entry ASSET_COUNT specifies the number of entries. */
enum AssetType {ASSET_MIN,
TEXTURE=ASSET_MIN,
CHALLENGE, FONT, GFX,
GRANDPRIX, GUI, SKIN, MODEL, MUSIC,
TRANSLATION, SFX, SHADER,
ASSET_MAX = SHADER,
CHALLENGE=ASSET_MIN,
FONT, GFX, GRANDPRIX, GUI, MODEL, MUSIC,
SFX, SHADER, SKIN, TEXTURE, TRANSLATION,
ASSET_MAX = TRANSLATION,
ASSET_COUNT};
private:
@ -67,9 +66,6 @@ private:
/** Directory where addons are stored. */
std::string m_addons_dir;
/** Root data directory. */
std::string m_root_dir;
/** The list of all root directories. */
static std::vector<std::string> m_root_dirs;
@ -121,13 +117,12 @@ public:
bool abort_on_error=false) const;
std::string getAsset(AssetType type, const std::string &name) const;
std::string getAsset(const std::string &name) const;
std::string getMusicFile(const std::string& file_name) const;
std::string getTextureFile (const std::string& fname) const;
std::string searchMusic(const std::string& file_name) const;
std::string searchTexture(const std::string& fname) const;
std::string getUserConfigFile(const std::string& fname) const;
void listFiles (std::set<std::string>& result,
const std::string& dir,
bool is_full_path=false,
bool make_full_path=false) const;

View File

@ -167,7 +167,7 @@ void KartPropertiesManager::loadAllKarts(bool loading_icon)
// If not, check each subdir of this directory.
// --------------------------------------------
std::set<std::string> result;
file_manager->listFiles(result, *dir, /*is_full_path*/ true);
file_manager->listFiles(result, *dir);
for(std::set<std::string>::const_iterator subdir=result.begin();
subdir!=result.end(); subdir++)
{

View File

@ -1253,17 +1253,15 @@ void initRest()
track_manager->loadTrackList();
music_manager->addMusicToTracks();
GUIEngine::addLoadingIcon(
irr_driver->getTexture(file_manager->getTextureFile("notes.png")) );
GUIEngine::addLoadingIcon(irr_driver->getTexture(FileManager::GUI,
"notes.png" ) );
grand_prix_manager = new GrandPrixManager ();
// Consistency check for challenges, and enable all challenges
// that have all prerequisites fulfilled
grand_prix_manager->checkConsistency();
std::string file = file_manager->getTextureFile("cup_gold.png");
if(file.size()==0)
Log::fatal("main", "Can not find cup_gold.png, aborting.");
GUIEngine::addLoadingIcon( irr_driver->getTexture(file) );
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
"cup_gold.png" ) );
race_manager = new RaceManager ();
// default settings for Quickstart
@ -1395,15 +1393,13 @@ int main(int argc, char *argv[] )
input_manager->setMode(InputManager::MENU);
main_loop = new MainLoop();
material_manager -> loadMaterial ();
GUIEngine::addLoadingIcon( irr_driver->getTexture(
file_manager->getAsset(FileManager::GUI,"options_video.png")) );
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
"options_video.png"));
kart_properties_manager -> loadAllKarts ();
handleXmasMode();
unlock_manager = new UnlockManager();
std::string file = file_manager->getTextureFile("gui_lock.png");
if(file.size()==0)
Log::fatal("main", "Can not find gui_lock.png, aborting.");
GUIEngine::addLoadingIcon( irr_driver->getTexture(file));
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
"gui_lock.png" ) );
projectile_manager -> loadData ();
// Both item_manager and powerup_manager load models and therefore
@ -1425,15 +1421,15 @@ int main(int argc, char *argv[] )
powerup_manager -> loadAllPowerups ();
ItemManager::loadDefaultItemMeshes();
GUIEngine::addLoadingIcon( irr_driver->getTexture(
file_manager->getAsset(FileManager::GUI,"gift.png")) );
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
"gift.png") );
file_manager->popTextureSearchPath();
attachment_manager -> loadModels ();
GUIEngine::addLoadingIcon( irr_driver->getTexture(
file_manager->getAsset(FileManager::GUI,"banana.png")) );
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
"banana.png") );
//handleCmdLine() needs InitTuxkart() so it can't be called first
if(!handleCmdLine(argc, argv)) exit(0);

View File

@ -424,10 +424,10 @@ void SoccerWorld::initKartList()
}
//Loading the indicator textures
irr::video::ITexture *redTeamTexture = irr_driver->getTexture(
file_manager->getTextureFile("soccer_player_red.png"));
irr::video::ITexture *blueTeamTexture = irr_driver->getTexture(
file_manager->getTextureFile("soccer_player_blue.png"));
irr::video::ITexture *redTeamTexture =
irr_driver->getTexture(FileManager::GUI,"soccer_player_red.png");
irr::video::ITexture *blueTeamTexture =
irr_driver->getTexture(FileManager::GUI, "soccer_player_blue.png");
//Assigning indicators
for(unsigned int i=0; i<kart_amount; i++)
{

View File

@ -29,7 +29,7 @@ GrandPrixManager::GrandPrixManager()
// Findout which grand prixs are available and load them
std::set<std::string> result;
std::string gp_dir = file_manager->getAsset(FileManager::GRANDPRIX,"");
file_manager->listFiles(result, gp_dir,/*full_path*/true);
file_manager->listFiles(result, gp_dir);
for(std::set<std::string>::iterator i = result.begin();
i != result.end() ; i++)
{

View File

@ -97,21 +97,21 @@ SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
if (c->isSolved(RaceManager::DIFFICULTY_EASY))
{
IconButtonWidget* btn = getWidget<IconButtonWidget>("novice");
btn->setImage(file_manager->getTextureFile("cup_bronze.png").c_str(),
btn->setImage(file_manager->getAsset(FileManager::GUI, "cup_bronze.png"),
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}
if (c->isSolved(RaceManager::DIFFICULTY_MEDIUM))
{
IconButtonWidget* btn = getWidget<IconButtonWidget>("intermediate");
btn->setImage(file_manager->getTextureFile("cup_silver.png").c_str(),
btn->setImage(file_manager->getAsset(FileManager::GUI,"cup_silver.png"),
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}
if (c->isSolved(RaceManager::DIFFICULTY_HARD))
{
IconButtonWidget* btn = getWidget<IconButtonWidget>("expert");
btn->setImage(file_manager->getTextureFile("cup_gold.png").c_str(),
btn->setImage(file_manager->getAsset(FileManager::GUI,"cup_gold.png"),
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}

View File

@ -257,12 +257,12 @@ void FeatureUnlockedCutScene::init()
m_global_time = 0.0f;
std::vector<std::string> texture_names(6);
texture_names[0] = file_manager->getTextureFile("purplenebula.jpg");
texture_names[1] = file_manager->getTextureFile("purplenebula2.png");
texture_names[2] = file_manager->getTextureFile("purplenebula.jpg");
texture_names[3] = file_manager->getTextureFile("purplenebula2.png");
texture_names[4] = file_manager->getTextureFile("purplenebula.jpg");
texture_names[5] = file_manager->getTextureFile("purplenebula2.png");
texture_names[0] = file_manager->getAsset(FileManager::TEXTURE, "purplenebula.jpg");
texture_names[1] = file_manager->getAsset(FileManager::TEXTURE, "purplenebula2.png");
texture_names[2] = file_manager->getAsset(FileManager::TEXTURE, "purplenebula.jpg");
texture_names[3] = file_manager->getAsset(FileManager::TEXTURE, "purplenebula2.png");
texture_names[4] = file_manager->getAsset(FileManager::TEXTURE, "purplenebula.jpg");
texture_names[5] = file_manager->getAsset(FileManager::TEXTURE, "purplenebula2.png");
std::vector<video::ITexture*> textures;
for(unsigned int i=0; i<texture_names.size(); i++)
{

View File

@ -83,7 +83,8 @@ GrandPrixLose::GrandPrixLose() : Screen("grand_prix_lose.stkgui")
try
{
m_music = music_manager->getMusicInformation(file_manager->getMusicFile("lose_theme.music"));
std::string path = file_manager->getAsset(FileManager::MUSIC, "lose_theme.music");
m_music = music_manager->getMusicInformation(path);
}
catch (std::exception& e)
{
@ -112,8 +113,7 @@ void GrandPrixLose::init()
m_sky_angle = 0.0f;
m_global_time = 0.0f;
video::ITexture *t = irr_driver->getTexture(
file_manager->getTextureFile("clouds.png"));
video::ITexture *t = irr_driver->getTexture(FileManager::TEXTURE, "clouds.png");
m_sky = irr_driver->addSkyDome(t,
16 /* hori_res */, 16 /* vert_res */,
1.0f /* texture_percent */, 2.0f /* sphere_percent */);

View File

@ -64,7 +64,8 @@ GrandPrixWin::GrandPrixWin() : Screen("grand_prix_win.stkgui")
try
{
m_music = music_manager->getMusicInformation(file_manager->getMusicFile("win_theme.music"));
std::string path = file_manager->getAsset(FileManager::MUSIC,"win_theme.music");
m_music = music_manager->getMusicInformation(path);
}
catch (std::exception& e)
{
@ -117,7 +118,7 @@ void GrandPrixWin::init()
core::rect< s32 > iconarea(label_x_from - label_height, y_from,
label_x_from, y_to);
IGUIImage* img = GUIEngine::getGUIEnv()->addImage( iconarea );
img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) );
img->setImage( irr_driver->getTexture( FileManager::GUI, "cup_gold.png") );
img->setScaleImage(true);
img->setTabStop(false);
img->setUseAlphaChannel(true);
@ -125,7 +126,7 @@ void GrandPrixWin::init()
core::rect< s32 > icon2area(label_x_to, y_from,
label_x_to + label_height, y_to);
img = GUIEngine::getGUIEnv()->addImage( icon2area );
img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) );
img->setImage( irr_driver->getTexture( FileManager::GUI,"cup_gold.png") );
img->setScaleImage(true);
img->setTabStop(false);
img->setUseAlphaChannel(true);
@ -153,8 +154,8 @@ void GrandPrixWin::init()
m_sky_angle = 0.0f;
m_global_time = 0.0f;
video::ITexture *t = irr_driver->getTexture(
file_manager->getTextureFile("clouds.png"));
video::ITexture *t = irr_driver->getTexture(FileManager::TEXTURE,
"clouds.png ");
m_sky = irr_driver->addSkyDome(t,
16 /* hori_res */, 16 /* vert_res */,
1.0f /* texture_percent */,

View File

@ -144,8 +144,8 @@ void PlayerNameSpinner::markAsIncorrect()
m_incorrect = true;
irr::video::ITexture* texture = irr_driver->getTexture(
file_manager->getTextureFile("red_mark.png") );
irr::video::ITexture* texture = irr_driver->getTexture(FileManager::GUI,
"red_mark.png" );
const int mark_size = m_h;
const int mark_x = m_w - mark_size*2;
const int mark_y = 0;

View File

@ -71,7 +71,7 @@ void OptionsScreenUI::loadedFromFile()
std::set<std::string> skinFiles;
file_manager->listFiles(skinFiles /* out */, file_manager->getAsset(FileManager::SKIN,""),
true /* is full path */, true /* make full path */ );
true /* make full path */ );
for (std::set<std::string>::iterator it = skinFiles.begin(); it != skinFiles.end(); it++)
{

View File

@ -225,10 +225,10 @@ void RaceGUI::drawScores()
static video::SColor color = video::SColor(255,255,255,255);
//Draw kart icons above score(denoting teams)
irr::video::ITexture *red_team = irr_driver->getTexture(
file_manager->getTextureFile("soccer_ball_red.png"));
irr::video::ITexture *blue_team = irr_driver->getTexture(
file_manager->getTextureFile("soccer_ball_blue.png"));
irr::video::ITexture *red_team = irr_driver->getTexture(FileManager::GUI,
"soccer_ball_red.png");
irr::video::ITexture *blue_team = irr_driver->getTexture(FileManager::GUI,
"soccer_ball_blue.png");
irr::video::ITexture *team_icon;
int numLeader = 1;

View File

@ -69,9 +69,9 @@ RaceGUIOverworld::RaceGUIOverworld()
m_is_first_render_call = true;
m_close_to_a_challenge = false;
m_current_challenge = NULL;
m_trophy1 = irr_driver->getTexture( file_manager->getTextureFile("cup_bronze.png") );
m_trophy2 = irr_driver->getTexture( file_manager->getTextureFile("cup_silver.png") );
m_trophy3 = irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") );
m_trophy1 = irr_driver->getTexture(FileManager::GUI, "cup_bronze.png");
m_trophy2 = irr_driver->getTexture(FileManager::GUI, "cup_silver.png");
m_trophy3 = irr_driver->getTexture(FileManager::GUI, "cup_gold.png" );
const float scaling = irr_driver->getFrameSize().Height / 420.0f;
// Marker texture has to be power-of-two for (old) OpenGL compliance
@ -112,8 +112,8 @@ RaceGUIOverworld::RaceGUIOverworld()
gui::ScalableFont* font = GUIEngine::getFont();
m_trophy_points_width = font->getDimension(L"1000").Width;
m_lock = irr_driver->getTexture( file_manager->getTextureFile("gui_lock.png") );
m_open_challenge = irr_driver->getTexture( file_manager->getAsset(FileManager::GUI,"challenge.png") );
m_lock = irr_driver->getTexture(FileManager::GUI,"gui_lock.png");
m_open_challenge = irr_driver->getTexture(FileManager::GUI,"challenge.png");
m_icons[0] = m_lock;
m_icons[1] = m_open_challenge;

View File

@ -548,10 +548,9 @@ void RaceResultGUI::onUpdate(float dt, irr::video::IVideoDriver*)
{
try
{
music_manager->startMusic(
music_manager->getMusicInformation(
file_manager->getMusicFile("race_summary.music"))
);
std::string path = file_manager->getAsset(FileManager::MUSIC,
"race_summary.music");
music_manager->startMusic(music_manager->getMusicInformation(path));
}
catch (std::exception& e)
{
@ -914,10 +913,10 @@ void RaceResultGUI::displaySoccerResults()
//Draw team scores:
currY += rect.Height;
currX /= 2;
irr::video::ITexture* redTeamIcon = irr_driver->getTexture(
file_manager->getTextureFile("soccer_ball_red.png"));
irr::video::ITexture* blueTeamIcon = irr_driver->getTexture(
file_manager->getTextureFile("soccer_ball_blue.png"));
irr::video::ITexture* redTeamIcon = irr_driver->getTexture(FileManager::GUI,
"soccer_ball_red.png");
irr::video::ITexture* blueTeamIcon = irr_driver->getTexture(FileManager::GUI,
"soccer_ball_blue.png");
core::recti sourceRect(core::vector2di(0,0), redTeamIcon->getSize());
core::recti destRect(currX, currY, currX+redTeamIcon->getSize().Width/2,
@ -973,8 +972,8 @@ void RaceResultGUI::displaySoccerResults()
pos = core::rect<s32>(currX,currY,currX,currY);
font->draw(resultText,pos, color, true, false);
scorerIcon = soccerWorld->getKart(scorers.at(i))->
getKartProperties()->getIconMaterial()->getTexture();
scorerIcon = soccerWorld->getKart(scorers.at(i))
->getKartProperties()->getIconMaterial()->getTexture();
sourceRect = core::recti(core::vector2di(0,0), scorerIcon->getSize());
irr::u32 offsetX = GUIEngine::getFont()->getDimension(resultText.c_str()).Width/2;
destRect = core::recti(currX-offsetX-30, currY, currX-offsetX, currY+ 30);
@ -1005,7 +1004,7 @@ void RaceResultGUI::displaySoccerResults()
pos = core::rect<s32>(currX,currY,currX,currY);
font->draw(resultText,pos, color, true, false);
scorerIcon = soccerWorld->getKart(scorers.at(i))->
getKartProperties()->getIconMaterial()->getTexture();
getKartProperties()->getIconMaterial()->getTexture();
sourceRect = core::recti(core::vector2di(0,0), scorerIcon->getSize());
irr::u32 offsetX = GUIEngine::getFont()->getDimension(resultText.c_str()).Width/2;

View File

@ -35,7 +35,7 @@ StkFileSystem::open_directory(const std::string& pathname)
{
std::set<std::string> result;
file_manager->listFiles(result, pathname, /*is_full_path*/true);
file_manager->listFiles(result, pathname);
std::vector<std::string> files;
for(std::set<std::string>::iterator i=result.begin(); i!=result.end(); i++)
{

View File

@ -463,7 +463,7 @@ void Track::getMusicInformation(std::vector<std::string>& filenames,
{
try
{
std::string shared_name = file_manager->getMusicFile(filenames[i]);
std::string shared_name = file_manager->searchMusic(filenames[i]);
if(shared_name!="")
mi = music_manager->getMusicInformation(shared_name);
}

View File

@ -145,7 +145,7 @@ void TrackManager::loadTrackList()
// Then see if a subdir of this dir contains tracks
// ------------------------------------------------
std::set<std::string> dirs;
file_manager->listFiles(dirs, dir, /*is_full_path*/ true);
file_manager->listFiles(dirs, dir);
for(std::set<std::string>::iterator subdir = dirs.begin();
subdir != dirs.end(); subdir++)
{

View File

@ -457,7 +457,7 @@ TrackObjectPresentationBillboard::TrackObjectPresentationBillboard(const XMLNode
}
video::ITexture *texture =
irr_driver->getTexture(file_manager->getTextureFile(texture_name));
irr_driver->getTexture(file_manager->searchTexture(texture_name));
m_node = irr_driver->addBillboard(core::dimension2df(width, height),
texture);
Material *stk_material = material_manager->getMaterial(texture_name);

View File

@ -99,8 +99,7 @@ Translations::Translations() //: m_dictionary_manager("UTF-16")
{
std::set<std::string> flist;
file_manager->listFiles(flist,
file_manager->getAsset(FileManager::TRANSLATION,""),
/*is full path*/true);
file_manager->getAsset(FileManager::TRANSLATION,""));
// English is always there but won't be found on file system
g_language_list.push_back("en");