mirror of
https://github.com/minetest/minetest.git
synced 2024-11-24 00:23:46 +01:00
Clean InventoryItem interface a bit
This commit is contained in:
parent
7a29b14a20
commit
f68fa667c8
@ -451,7 +451,7 @@ void Camera::updateSettings()
|
|||||||
|
|
||||||
void Camera::wield(const InventoryItem* item, IGameDef *gamedef)
|
void Camera::wield(const InventoryItem* item, IGameDef *gamedef)
|
||||||
{
|
{
|
||||||
ITextureSource *tsrc = gamedef->tsrc();
|
//ITextureSource *tsrc = gamedef->tsrc();
|
||||||
INodeDefManager *ndef = gamedef->ndef();
|
INodeDefManager *ndef = gamedef->ndef();
|
||||||
|
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
@ -475,7 +475,7 @@ void Camera::wield(const InventoryItem* item, IGameDef *gamedef)
|
|||||||
// If that failed, make an extruded sprite.
|
// If that failed, make an extruded sprite.
|
||||||
if (!isCube)
|
if (!isCube)
|
||||||
{
|
{
|
||||||
m_wieldnode->setSprite(item->getImageRaw(tsrc));
|
m_wieldnode->setSprite(item->getImageRaw());
|
||||||
m_wieldnode->setScale(v3f(40));
|
m_wieldnode->setScale(v3f(40));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ void ItemCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc)
|
|||||||
<<std::endl;
|
<<std::endl;
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
texture = item->getImage(tsrc);
|
texture = item->getImage();
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ void drawInventoryItem(video::IVideoDriver *driver,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
video::ITexture *texture = NULL;
|
video::ITexture *texture = NULL;
|
||||||
texture = item->getImage(tsrc);
|
texture = item->getImage();
|
||||||
|
|
||||||
if(texture != NULL)
|
if(texture != NULL)
|
||||||
{
|
{
|
||||||
|
@ -179,7 +179,7 @@ MaterialItem::MaterialItem(IGameDef *gamedef, content_t content, u16 count):
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
video::ITexture * MaterialItem::getImage(ITextureSource *tsrc) const
|
video::ITexture * MaterialItem::getImage() const
|
||||||
{
|
{
|
||||||
return m_gamedef->getNodeDefManager()->get(m_nodename).inventory_texture;
|
return m_gamedef->getNodeDefManager()->get(m_nodename).inventory_texture;
|
||||||
}
|
}
|
||||||
@ -232,11 +232,10 @@ std::string ToolItem::getImageBasename() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
video::ITexture * ToolItem::getImage(ITextureSource *tsrc) const
|
video::ITexture * ToolItem::getImage() const
|
||||||
{
|
{
|
||||||
if(tsrc == NULL)
|
ITextureSource *tsrc = m_gamedef->tsrc();
|
||||||
return NULL;
|
|
||||||
|
|
||||||
std::string basename = getImageBasename();
|
std::string basename = getImageBasename();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -253,10 +252,9 @@ video::ITexture * ToolItem::getImage(ITextureSource *tsrc) const
|
|||||||
return tsrc->getTextureRaw(os.str());
|
return tsrc->getTextureRaw(os.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
video::ITexture * ToolItem::getImageRaw(ITextureSource *tsrc) const
|
video::ITexture * ToolItem::getImageRaw() const
|
||||||
{
|
{
|
||||||
if(tsrc == NULL)
|
ITextureSource *tsrc = m_gamedef->tsrc();
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return tsrc->getTextureRaw(getImageBasename());
|
return tsrc->getTextureRaw(getImageBasename());
|
||||||
}
|
}
|
||||||
@ -267,11 +265,10 @@ video::ITexture * ToolItem::getImageRaw(ITextureSource *tsrc) const
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
video::ITexture * CraftItem::getImage(ITextureSource *tsrc) const
|
video::ITexture * CraftItem::getImage() const
|
||||||
{
|
{
|
||||||
if(tsrc == NULL)
|
ITextureSource *tsrc = m_gamedef->tsrc();
|
||||||
return NULL;
|
|
||||||
|
|
||||||
std::string name = item_craft_get_image_name(m_subname, m_gamedef);
|
std::string name = item_craft_get_image_name(m_subname, m_gamedef);
|
||||||
|
|
||||||
// Get such a texture
|
// Get such a texture
|
||||||
|
@ -51,11 +51,11 @@ public:
|
|||||||
virtual std::string getImageBasename() const { return ""; }
|
virtual std::string getImageBasename() const { return ""; }
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
// Shall return an image of the item (or NULL)
|
// Shall return an image of the item (or NULL)
|
||||||
virtual video::ITexture * getImage(ITextureSource *tsrc) const
|
virtual video::ITexture * getImage() const
|
||||||
{ return NULL; }
|
{ return NULL; }
|
||||||
// Shall return an image of the item without embellishments (or NULL)
|
// Shall return an image of the item without embellishments (or NULL)
|
||||||
virtual video::ITexture * getImageRaw(ITextureSource *tsrc) const
|
virtual video::ITexture * getImageRaw() const
|
||||||
{ return getImage(tsrc); }
|
{ return getImage(); }
|
||||||
#endif
|
#endif
|
||||||
// Shall return a text to show in the GUI
|
// Shall return a text to show in the GUI
|
||||||
virtual std::string getText() { return ""; }
|
virtual std::string getText() { return ""; }
|
||||||
@ -161,7 +161,7 @@ public:
|
|||||||
return new MaterialItem(m_gamedef, m_nodename, m_count);
|
return new MaterialItem(m_gamedef, m_nodename, m_count);
|
||||||
}
|
}
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
video::ITexture * getImage(ITextureSource *tsrc) const;
|
video::ITexture * getImage() const;
|
||||||
#endif
|
#endif
|
||||||
std::string getText()
|
std::string getText()
|
||||||
{
|
{
|
||||||
@ -235,7 +235,7 @@ public:
|
|||||||
return new CraftItem(m_gamedef, m_subname, m_count);
|
return new CraftItem(m_gamedef, m_subname, m_count);
|
||||||
}
|
}
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
video::ITexture * getImage(ITextureSource *tsrc) const;
|
video::ITexture * getImage() const;
|
||||||
#endif
|
#endif
|
||||||
std::string getText()
|
std::string getText()
|
||||||
{
|
{
|
||||||
@ -316,8 +316,8 @@ public:
|
|||||||
|
|
||||||
std::string getImageBasename() const;
|
std::string getImageBasename() const;
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
video::ITexture * getImage(ITextureSource *tsrc) const;
|
video::ITexture * getImage() const;
|
||||||
video::ITexture * getImageRaw(ITextureSource *tsrc) const;
|
video::ITexture * getImageRaw() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string getText()
|
std::string getText()
|
||||||
|
Loading…
Reference in New Issue
Block a user