aboutsummaryrefslogtreecommitdiff
path: root/src/inventory.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2010-12-24 11:44:26 +0200
committerPerttu Ahola <celeron55@gmail.com>2010-12-24 11:44:26 +0200
commit705de63dcdfe78157234e1b65652d5c2f762dbd4 (patch)
tree6aeac4160d1034e7f8cf9daa4232a741c367774d /src/inventory.h
parent1611f00865031e5187bd9b51d2b2e9f8307af62e (diff)
downloadminetest-705de63dcdfe78157234e1b65652d5c2f762dbd4.tar.gz
minetest-705de63dcdfe78157234e1b65652d5c2f762dbd4.tar.bz2
minetest-705de63dcdfe78157234e1b65652d5c2f762dbd4.zip
ProgressBarTextureMod
Diffstat (limited to 'src/inventory.h')
-rw-r--r--src/inventory.h34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/inventory.h b/src/inventory.h
index e97db8ffb..fd2cd8778 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -226,17 +226,39 @@ public:
#ifndef SERVER
video::ITexture * getImage()
{
+ std::string basename;
if(m_toolname == "WPick")
- return g_irrlicht->getTexture("../data/tool_wpick.png");
- if(m_toolname == "STPick")
- return g_irrlicht->getTexture("../data/tool_stpick.png");
+ basename = "../data/tool_wpick.png";
+ else if(m_toolname == "STPick")
+ basename = "../data/tool_stpick.png";
// Default to cloud texture
- return g_irrlicht->getTexture(tile_texture_path_get(TILE_CLOUD));
+ 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()
{
- std::ostringstream os;
+ return "";
+
+ /*std::ostringstream os;
u16 f = 4;
u16 d = 65535/f;
u16 i;
@@ -244,7 +266,7 @@ public:
os<<'X';
for(; i<f; i++)
os<<'-';
- return os.str();
+ return os.str();*/
/*std::ostringstream os;
os<<m_toolname;