Fixed incorrect overloaded getTexture function (char * where handled
as bool, not std::string), avoided more crashes on missing textures, adde better warnings. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14505 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
195daa8794
commit
5a7fb84267
@ -1081,6 +1081,9 @@ void IrrDriver::removeCameraSceneNode(scene::ICameraSceneNode *camera)
|
||||
void IrrDriver::setTextureErrorMessage(const std::string &error,
|
||||
const std::string &detail)
|
||||
{
|
||||
if(detail=="")
|
||||
m_texture_error_message = error;
|
||||
else
|
||||
m_texture_error_message = StringUtils::insertValues(error, detail);
|
||||
} // setTextureErrorMessage
|
||||
|
||||
@ -1121,7 +1124,7 @@ video::ITexture *IrrDriver::getTexture(const std::string &filename,
|
||||
// PNGs are non premul, but some are used for premul tasks, so convert
|
||||
// http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Premultiplied%20alpha]]
|
||||
// FIXME check param, not name
|
||||
if(is_premul &&
|
||||
if(img && is_premul &&
|
||||
StringUtils::hasSuffix(filename.c_str(), ".png") &&
|
||||
(img->getColorFormat() == video::ECF_A8R8G8B8) &&
|
||||
img->lock())
|
||||
@ -1144,7 +1147,7 @@ video::ITexture *IrrDriver::getTexture(const std::string &filename,
|
||||
} // if png and ColorFOrmat and lock
|
||||
// Other formats can be premul, but the tasks can be non premul
|
||||
// So divide to get the separate RGBA (only possible if alpha!=0)
|
||||
else if(is_prediv &&
|
||||
else if(img && is_prediv &&
|
||||
(img->getColorFormat() == video::ECF_A8R8G8B8) &&
|
||||
img->lock())
|
||||
{
|
||||
@ -1173,6 +1176,7 @@ video::ITexture *IrrDriver::getTexture(const std::string &filename,
|
||||
|
||||
if (complain_if_not_found && out == NULL)
|
||||
{
|
||||
|
||||
if(m_texture_error_message.size()>0)
|
||||
{
|
||||
Log::error("irr_driver", m_texture_error_message.c_str());
|
||||
|
@ -228,6 +228,26 @@ public:
|
||||
return tex;
|
||||
} // getTexture
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Convenience function that loads a texture with default parameters
|
||||
* but includes an error message.
|
||||
* \param filename File name of the texture to load.
|
||||
* \param error Error message, potentially with a '%' which will be replaced
|
||||
* with detail.
|
||||
* \param detail String to replace a '%' in the error message.
|
||||
*/
|
||||
video::ITexture* getTexture(const std::string &filename,
|
||||
char *error_message,
|
||||
char *detail=NULL)
|
||||
{
|
||||
if(!detail)
|
||||
return getTexture(filename, std::string(error_message),
|
||||
std::string(""));
|
||||
|
||||
return getTexture(filename, std::string(error_message),
|
||||
std::string(detail));
|
||||
} // getTexture
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the currently defined texture error message, which is used
|
||||
* by event_handler.cpp to print additional info about irrlicht
|
||||
|
@ -1261,6 +1261,11 @@ namespace GUIEngine
|
||||
ITexture* loading =
|
||||
irr_driver->getTexture(file_manager->getGUIDir()+"loading.png");
|
||||
|
||||
if(!loading)
|
||||
{
|
||||
Log::fatal("Engine", "Can not find loading.png texture, aborting.");
|
||||
exit(-1);
|
||||
}
|
||||
const int texture_w = loading->getSize().Width;
|
||||
const int texture_h = loading->getSize().Height;
|
||||
|
||||
|
@ -1627,6 +1627,14 @@ void Skin::renderSections(PtrVector<Widget>* within_vector)
|
||||
ITexture* tex =
|
||||
irr_driver->getTexture( file_manager->getGUIDir()
|
||||
+ "bar.png" );
|
||||
if(!tex)
|
||||
{
|
||||
std::string file = file_manager->getGUIDir() + "main_help.png";
|
||||
tex = irr_driver->getTexture(file);
|
||||
if(!tex)
|
||||
Log::fatal("Skin",
|
||||
"Can't find fallback texture 'main_help.png, aborting.");
|
||||
}
|
||||
core::recti r1(0, (int)(widget.m_y - 40*y_size),
|
||||
framesize.Width, framesize.Height);
|
||||
core::recti r2(core::dimension2di(0,0), tex->getSize());
|
||||
@ -1892,6 +1900,9 @@ void Skin::process3DPane(IGUIElement *element, const core::recti &rect,
|
||||
void doDrawBadge(ITexture* texture, const core::recti& rect,
|
||||
float max_icon_size, bool badge_at_left)
|
||||
{
|
||||
// In case of a problem
|
||||
if(!texture) return;
|
||||
|
||||
const core::dimension2d<u32>& texture_size = texture->getSize();
|
||||
const float aspectRatio = (float)texture_size.Width
|
||||
/ (float)texture_size.Height;
|
||||
@ -1922,6 +1933,8 @@ 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"));
|
||||
float max_icon_size = 0.5f; // Lock badge can be quite big
|
||||
doDrawBadge(texture, rect, max_icon_size, true);
|
||||
@ -1929,6 +1942,8 @@ void Skin::drawBadgeOn(const Widget* widget, const core::recti& rect)
|
||||
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"));
|
||||
float max_icon_size = 0.35f;
|
||||
doDrawBadge(texture, rect, max_icon_size, true);
|
||||
@ -1936,7 +1951,8 @@ void Skin::drawBadgeOn(const Widget* widget, const core::recti& rect)
|
||||
if (widget->m_badges & BAD_BADGE)
|
||||
{
|
||||
video::ITexture* texture = irr_driver->getTexture(
|
||||
file_manager->getTextureFile("red_mark.png"));
|
||||
file_manager->getTextureFile("red_mark.png"),
|
||||
"Can't find red_mark.png");
|
||||
float max_icon_size = 0.35f;
|
||||
doDrawBadge(texture, rect, max_icon_size, false);
|
||||
}
|
||||
@ -1944,13 +1960,16 @@ void Skin::drawBadgeOn(const Widget* widget, const core::recti& rect)
|
||||
{
|
||||
float max_icon_size = 0.43f;
|
||||
video::ITexture* texture = irr_driver->getTexture(
|
||||
file_manager->getTextureFile("cup_bronze.png"));
|
||||
file_manager->getTextureFile("cup_bronze.png"),
|
||||
"Can't find 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->getGUIDir() + "keyboard.png",
|
||||
"Can't find '%s'.",
|
||||
file_manager->getGUIDir() + "keyboard.png");
|
||||
doDrawBadge(texture, rect, max_icon_size, true);
|
||||
}
|
||||
@ -1958,6 +1977,8 @@ void Skin::drawBadgeOn(const Widget* widget, const core::recti& rect)
|
||||
{
|
||||
float max_icon_size = 0.43f;
|
||||
video::ITexture* texture = irr_driver->getTexture(
|
||||
file_manager->getGUIDir() + "gamepad.png",
|
||||
"Can't find '%s'.",
|
||||
file_manager->getGUIDir() + "gamepad.png");
|
||||
doDrawBadge(texture, rect, max_icon_size, true);
|
||||
}
|
||||
@ -1965,6 +1986,8 @@ void Skin::drawBadgeOn(const Widget* widget, const core::recti& rect)
|
||||
{
|
||||
float max_icon_size = 0.43f;
|
||||
video::ITexture* texture = irr_driver->getTexture(
|
||||
file_manager->getGUIDir() + "hourglass.png",
|
||||
"Can't find '%s'.",
|
||||
file_manager->getGUIDir() + "hourglass.png");
|
||||
doDrawBadge(texture, rect, max_icon_size, true);
|
||||
}
|
||||
|
@ -72,8 +72,11 @@ void IconButtonWidget::add()
|
||||
Log::error("icon_button",
|
||||
"add() : error, cannot find texture '%s'.",
|
||||
m_properties[PROP_ICON].c_str());
|
||||
std::string file = file_manager->getDataDir() + "gui/main_help.png";
|
||||
std::string file = file_manager->getGUIDir() + "main_help.png";
|
||||
m_texture = irr_driver->getTexture(file);
|
||||
if(!m_texture)
|
||||
Log::fatal("IconButtonWidget",
|
||||
"Can't find fallback texture 'gui/main_help.png, aborting.");
|
||||
}
|
||||
m_texture_w = m_texture->getSize().Width;
|
||||
m_texture_h = m_texture->getSize().Height;
|
||||
|
@ -298,6 +298,15 @@ void RibbonWidget::add()
|
||||
+ m_children[i].m_properties[PROP_ICON];
|
||||
video::ITexture* image =
|
||||
irr_driver->getTexture((filename).c_str());
|
||||
if(!image)
|
||||
{
|
||||
std::string file = file_manager->getGUIDir() + "main_help.png";
|
||||
image = irr_driver->getTexture(file);
|
||||
if(!image)
|
||||
Log::fatal("RibbonWidget",
|
||||
"Can't find fallback texture 'gui/main_help.png, aborting.");
|
||||
}
|
||||
|
||||
float image_h = (float)image->getSize().Height;
|
||||
float image_w = image_h*imageRatio;
|
||||
|
||||
|
13
src/main.cpp
13
src/main.cpp
@ -1217,8 +1217,10 @@ void initRest()
|
||||
// Consistency check for challenges, and enable all challenges
|
||||
// that have all prerequisites fulfilled
|
||||
grand_prix_manager->checkConsistency();
|
||||
GUIEngine::addLoadingIcon( irr_driver->getTexture(
|
||||
file_manager->getTextureFile("cup_gold.png")) );
|
||||
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) );
|
||||
|
||||
race_manager = new RaceManager ();
|
||||
// default settings for Quickstart
|
||||
@ -1334,9 +1336,10 @@ int main(int argc, char *argv[] )
|
||||
kart_properties_manager -> loadAllKarts ();
|
||||
handleXmasMode();
|
||||
unlock_manager = new UnlockManager();
|
||||
//m_tutorial_manager = new TutorialManager();
|
||||
GUIEngine::addLoadingIcon( irr_driver->getTexture(
|
||||
file_manager->getTextureFile("gui_lock.png")) );
|
||||
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));
|
||||
projectile_manager -> loadData ();
|
||||
|
||||
// Both item_manager and powerup_manager load models and therefore
|
||||
|
@ -76,19 +76,29 @@ RaceGUIBase::RaceGUIBase()
|
||||
m_music_icon = material_manager->getMaterial("notes.png",
|
||||
/*full path*/false,
|
||||
/*permanent*/true);
|
||||
if(!m_music_icon->getTexture())
|
||||
Log::fatal("RaceGuiBase", "Can't find 'notes.png' texture, aborting.");
|
||||
|
||||
m_plunger_face = material_manager->getMaterial("plungerface.png",
|
||||
/*full path*/false,
|
||||
/*permanent*/true);
|
||||
if(!m_plunger_face->getTexture())
|
||||
Log::fatal("RaceGuiBase",
|
||||
"Can't find 'plungerface.png' texture, aborting.");
|
||||
|
||||
//read frame picture for icons in the mini map.
|
||||
m_icons_frame = material_manager->getMaterial("icons-frame.png",
|
||||
/*full_path*/false,
|
||||
/*permanent*/true);
|
||||
if(!m_icons_frame->getTexture())
|
||||
Log::fatal("RaceGuiBase",
|
||||
"Can't find 'icons-frame.png' texture, aborting.");
|
||||
|
||||
const std::string &guid = file_manager->getGUIDir();
|
||||
m_gauge_full = irr_driver->getTexture(guid+"gauge_full.png" );
|
||||
m_gauge_full_bright = irr_driver->getTexture(guid+"gauge_full_bright.png" );
|
||||
m_gauge_empty = irr_driver->getTexture(guid+"gauge_empty.png");
|
||||
m_gauge_goal = irr_driver->getTexture(guid+"gauge_goal.png" );
|
||||
|
||||
m_dist_show_overlap = 2;
|
||||
m_icons_inertia = 2;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user