diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-11-16 14:44:01 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-11-29 19:13:47 +0200 |
commit | f68fa667c8723cc39f113502c53cc5c35eb32ab6 (patch) | |
tree | d1c8a3dd207a45dc2c1ff0f8703a62687d9875aa | |
parent | 7a29b14a20b16b97fd0d97d9f305fe0d53c160bf (diff) | |
download | minetest-f68fa667c8723cc39f113502c53cc5c35eb32ab6.tar.gz minetest-f68fa667c8723cc39f113502c53cc5c35eb32ab6.tar.bz2 minetest-f68fa667c8723cc39f113502c53cc5c35eb32ab6.zip |
Clean InventoryItem interface a bit
-rw-r--r-- | src/camera.cpp | 4 | ||||
-rw-r--r-- | src/content_cao.cpp | 2 | ||||
-rw-r--r-- | src/guiInventoryMenu.cpp | 2 | ||||
-rw-r--r-- | src/inventory.cpp | 21 | ||||
-rw-r--r-- | src/inventory.h | 14 |
5 files changed, 20 insertions, 23 deletions
diff --git a/src/camera.cpp b/src/camera.cpp index 74ecd6cec..938c7a5ce 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -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)); } diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 323836832..ca9e22811 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -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; } } diff --git a/src/guiInventoryMenu.cpp b/src/guiInventoryMenu.cpp index 4ed9c857c..9b73af3e0 100644 --- a/src/guiInventoryMenu.cpp +++ b/src/guiInventoryMenu.cpp @@ -39,7 +39,7 @@ void drawInventoryItem(video::IVideoDriver *driver, return; video::ITexture *texture = NULL; - texture = item->getImage(tsrc); + texture = item->getImage(); if(texture != NULL) { diff --git a/src/inventory.cpp b/src/inventory.cpp index b0b128418..5b99617b3 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -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 diff --git a/src/inventory.h b/src/inventory.h index 32e1cd93e..64fab921b 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -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() |