diff options
author | Perttu Ahola <celeron55@gmail.com> | 2010-12-24 03:08:05 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2010-12-24 03:08:05 +0200 |
commit | f15670379da5529d38936d0a87a50b0dc72c6e8f (patch) | |
tree | 990b86539386bbe4122b530a6367c60f223e55d0 /src/inventory.h | |
parent | 10b06419ab454e8931a9b6502029bc298e8bce35 (diff) | |
download | minetest-f15670379da5529d38936d0a87a50b0dc72c6e8f.tar.gz minetest-f15670379da5529d38936d0a87a50b0dc72c6e8f.tar.bz2 minetest-f15670379da5529d38936d0a87a50b0dc72c6e8f.zip |
base stuff for item->object conversion
Diffstat (limited to 'src/inventory.h')
-rw-r--r-- | src/inventory.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/inventory.h b/src/inventory.h index ad3b297e8..e97db8ffb 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -196,6 +196,78 @@ private: std::string m_inventorystring; }; +class ToolItem : public InventoryItem +{ +public: + ToolItem(std::string toolname, u16 wear) + { + m_toolname = toolname; + m_wear = wear; + } + /* + Implementation interface + */ + virtual const char* getName() const + { + return "ToolItem"; + } + virtual void serialize(std::ostream &os) + { + os<<getName(); + os<<" "; + os<<m_toolname; + os<<" "; + os<<m_wear; + } + virtual InventoryItem* clone() + { + return new ToolItem(m_toolname, m_wear); + } +#ifndef SERVER + video::ITexture * getImage() + { + if(m_toolname == "WPick") + return g_irrlicht->getTexture("../data/tool_wpick.png"); + if(m_toolname == "STPick") + return g_irrlicht->getTexture("../data/tool_stpick.png"); + // Default to cloud texture + return g_irrlicht->getTexture(tile_texture_path_get(TILE_CLOUD)); + } +#endif + std::string getText() + { + std::ostringstream os; + u16 f = 4; + u16 d = 65535/f; + u16 i; + for(i=0; i<(65535-m_wear)/d; i++) + os<<'X'; + for(; i<f; i++) + os<<'-'; + return os.str(); + + /*std::ostringstream os; + os<<m_toolname; + os<<" "; + os<<(m_wear/655); + return os.str();*/ + } + /* + Special methods + */ + std::string getToolName() + { + return m_toolname; + } + u16 getWear() + { + return m_wear; + } +private: + std::string m_toolname; + u16 m_wear; +}; + class InventoryList { public: |