Display warning when a track uses a deprecated texture

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12319 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2013-01-01 19:01:39 +00:00
parent 00418fce4b
commit baeaac3189
4 changed files with 26 additions and 12 deletions

View File

@@ -315,8 +315,10 @@ public:
* \param node Node containing the parameters for this material.
* \param index Index in material_manager.
*/
Material::Material(const XMLNode *node, int index)
Material::Material(const XMLNode *node, int index, bool deprecated)
{
m_deprecated = deprecated;
node->get("name", &m_texname);
if (m_texname=="")
{
@@ -556,6 +558,8 @@ Material::Material(const XMLNode *node, int index)
Material::Material(const std::string& fname, int index, bool is_full_path,
bool complain_if_not_found)
{
m_deprecated = false;
m_texname = fname;
init(index);
install(is_full_path, complain_if_not_found);
@@ -853,6 +857,13 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
// !!======== This method is only called for materials that can be found in
// materials.xml, if you want to set flags for all surfaces, see
// 'MaterialManager::setAllMaterialFlags'
if (m_deprecated)
{
fprintf(stderr, "WARNING: track uses deprecated texture <%s>\n", m_texname.c_str());
}
int modes = 0;
if (m_alpha_testing)

View File

@@ -227,13 +227,15 @@ private:
/** Only used if bubble effect is enabled */
std::map<scene::IMeshBuffer*, BubbleEffectProvider*> m_bubble_provider;
bool m_deprecated;
void init (unsigned int index);
void install (bool is_full_path=false, bool complain_if_not_found=true);
void initCustomSFX(const XMLNode *sfx);
void initParticlesEffect(const XMLNode *node);
public:
Material(const XMLNode *node, int index);
Material(const XMLNode *node, int index, bool deprecated);
Material(const std::string& fname, int index,
bool is_full_path=false,
bool complain_if_not_found=true);

View File

@@ -175,14 +175,14 @@ void MaterialManager::loadMaterial()
std::string deprecated = file_manager->getTextureDir()
+ "deprecated/materials.xml";
if(file_manager->fileExists(deprecated))
addSharedMaterial(deprecated);
addSharedMaterial(deprecated, true);
// Save index of shared textures
m_shared_material_index = (int)m_materials.size();
} // MaterialManager
//-----------------------------------------------------------------------------
void MaterialManager::addSharedMaterial(const std::string& filename)
void MaterialManager::addSharedMaterial(const std::string& filename, bool deprecated)
{
// Use temp material for reading, but then set the shared
// material index later, so that these materials are not popped
@@ -192,7 +192,7 @@ void MaterialManager::addSharedMaterial(const std::string& filename)
msg<<"FATAL: File '"<<filename<<"' not found\n";
throw std::runtime_error(msg.str());
}
if(!pushTempMaterial(filename))
if(!pushTempMaterial(filename, deprecated))
{
std::ostringstream msg;
msg <<"FATAL: Parsing error in '"<<filename<<"'\n";
@@ -202,7 +202,7 @@ void MaterialManager::addSharedMaterial(const std::string& filename)
} // addSharedMaterial
//-----------------------------------------------------------------------------
bool MaterialManager::pushTempMaterial(const std::string& filename)
bool MaterialManager::pushTempMaterial(const std::string& filename, bool deprecated)
{
XMLNode *root = file_manager->createXMLTree(filename);
if(!root || root->getName()!="materials")
@@ -210,14 +210,15 @@ bool MaterialManager::pushTempMaterial(const std::string& filename)
if(root) delete root;
return true;
}
const bool success = pushTempMaterial(root, filename);
const bool success = pushTempMaterial(root, filename, deprecated);
delete root;
return success;
} // pushTempMaterial
//-----------------------------------------------------------------------------
bool MaterialManager::pushTempMaterial(const XMLNode *root,
const std::string& filename)
const std::string& filename,
bool deprecated)
{
for(unsigned int i=0; i<root->getNumNodes(); i++)
{
@@ -230,7 +231,7 @@ bool MaterialManager::pushTempMaterial(const XMLNode *root,
}
try
{
m_materials.push_back(new Material(node, m_materials.size()));
m_materials.push_back(new Material(node, m_materials.size(), deprecated));
}
catch(std::exception& e)
{

View File

@@ -66,9 +66,9 @@ public:
bool is_full_path=false,
bool make_permanent=false,
bool complain_if_not_found=true);
void addSharedMaterial(const std::string& filename);
bool pushTempMaterial (const std::string& filename);
bool pushTempMaterial (const XMLNode *root, const std::string& filename);
void addSharedMaterial(const std::string& filename, bool deprecated = false);
bool pushTempMaterial (const std::string& filename, bool deprecated = false);
bool pushTempMaterial (const XMLNode *root, const std::string& filename, bool deprecated = false);
void popTempMaterial ();
void makeMaterialsPermanent();
bool hasMaterial(const std::string& fname);