-class ToolItem : public InventoryItem
-{
-public:
- ToolItem(std::string toolname, u16 wear):
- InventoryItem(1)
- {
- 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()
- {
- std::string basename;
- if(m_toolname == "WPick")
- basename = "../data/tool_wpick.png";
- else if(m_toolname == "STPick")
- basename = "../data/tool_stpick.png";
- // Default to cloud texture
- else
- basename = tile_texture_path_get(TILE_CLOUD);
-
- /*
- Calculate some progress value with sane amount of
- maximum states
- */
- u32 maxprogress = 30;
- u32 toolprogress = (65535-m_wear)/(65535/maxprogress);
-
- // Make texture name for the new texture with a progress bar
- std::ostringstream os;
- os<<basename<<"-toolprogress-"<<toolprogress;
- std::string finalname = os.str();
-
- float value_f = (float)toolprogress / (float)maxprogress;
-
- // Get such a texture
- TextureMod *mod = new ProgressBarTextureMod(value_f);
- return g_irrlicht->getTexture(TextureSpec(finalname, basename, mod));
- }
-#endif
- std::string getText()
- {
- return "";
-
- /*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();*/
- }