1
0
Fork 0

Clean InventoryItem interface a bit

mutilcraft-mt53
Perttu Ahola 2011-11-16 14:44:01 +02:00
parent 7a29b14a20
commit f68fa667c8
5 changed files with 20 additions and 23 deletions

View File

@ -451,7 +451,7 @@ void Camera::updateSettings()
void Camera::wield(const InventoryItem* item, IGameDef *gamedef)
{
ITextureSource *tsrc = gamedef->tsrc();
//ITextureSource *tsrc = gamedef->tsrc();
INodeDefManager *ndef = gamedef->ndef();
if (item != NULL)
@ -475,7 +475,7 @@ void Camera::wield(const InventoryItem* item, IGameDef *gamedef)
// If that failed, make an extruded sprite.
if (!isCube)
{
m_wieldnode->setSprite(item->getImageRaw(tsrc));
m_wieldnode->setSprite(item->getImageRaw());
m_wieldnode->setScale(v3f(40));
}

View File

@ -224,7 +224,7 @@ void ItemCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc)
<<std::endl;
if(item)
{
texture = item->getImage(tsrc);
texture = item->getImage();
delete item;
}
}

View File

@ -39,7 +39,7 @@ void drawInventoryItem(video::IVideoDriver *driver,
return;
video::ITexture *texture = NULL;
texture = item->getImage(tsrc);
texture = item->getImage();
if(texture != NULL)
{

View File

@ -179,7 +179,7 @@ MaterialItem::MaterialItem(IGameDef *gamedef, content_t content, u16 count):
}
#ifndef SERVER
video::ITexture * MaterialItem::getImage(ITextureSource *tsrc) const
video::ITexture * MaterialItem::getImage() const
{
return m_gamedef->getNodeDefManager()->get(m_nodename).inventory_texture;
}
@ -232,11 +232,10 @@ std::string ToolItem::getImageBasename() const
}
#ifndef SERVER
video::ITexture * ToolItem::getImage(ITextureSource *tsrc) const
video::ITexture * ToolItem::getImage() const
{
if(tsrc == NULL)
return NULL;
ITextureSource *tsrc = m_gamedef->tsrc();
std::string basename = getImageBasename();
/*
@ -253,10 +252,9 @@ video::ITexture * ToolItem::getImage(ITextureSource *tsrc) const
return tsrc->getTextureRaw(os.str());
}
video::ITexture * ToolItem::getImageRaw(ITextureSource *tsrc) const
video::ITexture * ToolItem::getImageRaw() const
{
if(tsrc == NULL)
return NULL;
ITextureSource *tsrc = m_gamedef->tsrc();
return tsrc->getTextureRaw(getImageBasename());
}
@ -267,11 +265,10 @@ video::ITexture * ToolItem::getImageRaw(ITextureSource *tsrc) const
*/
#ifndef SERVER
video::ITexture * CraftItem::getImage(ITextureSource *tsrc) const
video::ITexture * CraftItem::getImage() const
{
if(tsrc == NULL)
return NULL;
ITextureSource *tsrc = m_gamedef->tsrc();
std::string name = item_craft_get_image_name(m_subname, m_gamedef);
// Get such a texture

View File

@ -51,11 +51,11 @@ public:
virtual std::string getImageBasename() const { return ""; }
#ifndef SERVER
// Shall return an image of the item (or NULL)
virtual video::ITexture * getImage(ITextureSource *tsrc) const
virtual video::ITexture * getImage() const
{ return NULL; }
// Shall return an image of the item without embellishments (or NULL)
virtual video::ITexture * getImageRaw(ITextureSource *tsrc) const
{ return getImage(tsrc); }
virtual video::ITexture * getImageRaw() const
{ return getImage(); }
#endif
// Shall return a text to show in the GUI
virtual std::string getText() { return ""; }
@ -161,7 +161,7 @@ public:
return new MaterialItem(m_gamedef, m_nodename, m_count);
}
#ifndef SERVER
video::ITexture * getImage(ITextureSource *tsrc) const;
video::ITexture * getImage() const;
#endif
std::string getText()
{
@ -235,7 +235,7 @@ public:
return new CraftItem(m_gamedef, m_subname, m_count);
}
#ifndef SERVER
video::ITexture * getImage(ITextureSource *tsrc) const;
video::ITexture * getImage() const;
#endif
std::string getText()
{
@ -316,8 +316,8 @@ public:
std::string getImageBasename() const;
#ifndef SERVER
video::ITexture * getImage(ITextureSource *tsrc) const;
video::ITexture * getImageRaw(ITextureSource *tsrc) const;
video::ITexture * getImage() const;
video::ITexture * getImageRaw() const;
#endif
std::string getText()