From 705de63dcdfe78157234e1b65652d5c2f762dbd4 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 24 Dec 2010 11:44:26 +0200 Subject: [PATCH] ProgressBarTextureMod --- data/tool_stpick.png | Bin 992 -> 990 bytes data/tool_wpick.png | Bin 1014 -> 989 bytes src/inventory.h | 34 +++++++++++++++++++----- src/irrlichtwrapper.cpp | 56 ++++++++++++++++++++++------------------ src/irrlichtwrapper.h | 14 ++++++++++ src/main.cpp | 32 ++++++++++++++++++++--- src/map.cpp | 4 ++- src/mapblockobject.h | 2 +- src/server.cpp | 2 +- 9 files changed, 107 insertions(+), 37 deletions(-) diff --git a/data/tool_stpick.png b/data/tool_stpick.png index 531599f44965e8600a807f3777cdf0124f841aa3..9ca3a5e03524a653dfebbb28e6ba63d25443fc07 100644 GIT binary patch delta 183 zcmV;o07(Df2i^y;Fav*?Nkl>AWy4Yh)&03uRPu+DTA zKDO1>O|XmoEF#wcwlHSK*ZxKkf#>{C7ogR$2NHUUE)ycsl+rIx)#ZNE79@O^_m@fU lyT|0xSO|_lVvI0s@&PR{VL_Hs+t^RMA`T5NtA&{ n62-x4C5HvI1OSBk&VzabWwU8Tp)bR|00000NkvXXu0mjfA81xZ diff --git a/data/tool_wpick.png b/data/tool_wpick.png index ee7b8222e0d143a3f430cc7c54c33bd79626390b..3592495154f62365e3adf6b6941dec31c793772d 100644 GIT binary patch delta 182 zcmeyyewTfN0dxHfPZ!4!i_^&o3j_>=R&O}q|JdHB{?Ib%9u{7QYb7sFIk(k*-)AiJ zlxc=r%&ZBF+-7I<@BdFsNJvmvF|!c}IA=dw?myqi00@rUTJ=Z$B*TnnARUKz5*1XZ zT+A&Adi2Ntgs9JpZOY6uygNQ}#ksP?20d8*@xEuL@OoXn3SPxioj-UKQ><4qdQVd9 inIfU2t9#aAqc_8whUiPqJiQ(aK;Y@>=d#Wzp$PyQEKWWE delta 207 zcmV;=05JdE2lfZBFav+FNklhAgetTexture("../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<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(; igetVideoDriver(); - - core::dimension2d dim(size.X, size.Y); + core::position2d pos_base(0, 0); + core::dimension2d dim = original->getOriginalSize(); - video::IImage *baseimage = driver->createImage( - base, - core::position2d(pos_base.X, pos_base.Y), - dim); + video::IImage *baseimage = driver->createImage(original, pos_base, dim); assert(baseimage); - - video::IImage *otherimage = driver->createImage( - other, - core::position2d(pos_other.X, pos_other.Y), - dim); - assert(sourceimage); - otherimage->copyToWithAlpha(baseimage, v2s32(0,0), - core::rect(v2s32(0,0), dim), - video::SColor(255,255,255,255), - core::rect(v2s32(0,0), dim)); - otherimage->drop(); + core::dimension2d size = baseimage->getDimension(); - video::ITexture *newtexture = driver->addTexture(name, baseimage); + u32 barheight = 1; + u32 barpad_x = 1; + u32 barpad_y = 1; + u32 barwidth = size.Width - barpad_x*2; + v2u32 barpos(barpad_x, size.Height - barheight - barpad_y); + + u32 barvalue_i = round((float)barwidth * value); + + video::SColor active(255,255,0,0); + video::SColor inactive(255,0,0,0); + for(u32 x0=0; x0setPixel(x,y, *c); + } + } + + video::ITexture *newtexture = driver->addTexture(newname, baseimage); baseimage->drop(); return newtexture; } -#endif diff --git a/src/irrlichtwrapper.h b/src/irrlichtwrapper.h index 981e3377f..ce54b70c0 100644 --- a/src/irrlichtwrapper.h +++ b/src/irrlichtwrapper.h @@ -97,6 +97,20 @@ struct CrackTextureMod: public TextureMod u16 progression; }; +struct ProgressBarTextureMod: public TextureMod +{ + // value is from 0.0 to 1.0 + ProgressBarTextureMod(float a_value) + { + value = a_value; + } + + virtual video::ITexture * make(video::ITexture *original, + const char *newname, video::IVideoDriver* driver); + + float value; +}; + /* A class for specifying a requested texture */ diff --git a/src/main.cpp b/src/main.cpp index ac91b9d3d..df335ad39 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -177,7 +177,8 @@ TODO: Check if the usage of Client::isFetchingBlocks() in Doing now: ====================================================================== -TODO: Tool capability table +TODO: Tool capability table: Which materials, at what speed, how much + wearing TODO: Transferring of the table from server to client ====================================================================== @@ -2122,9 +2123,21 @@ int main(int argc, char *argv[]) } } } + else if(n.d == CONTENT_TORCH) + { + dig_time_complete = 0.0; + } - dig_index = (u16)((float)CRACK_ANIMATION_LENGTH - * dig_time/dig_time_complete); + if(dig_time_complete >= 0.001) + { + dig_index = (u16)((float)CRACK_ANIMATION_LENGTH + * dig_time/dig_time_complete); + } + // This is for torches + else + { + dig_index = CRACK_ANIMATION_LENGTH; + } if(dig_index < CRACK_ANIMATION_LENGTH) { @@ -2142,6 +2155,19 @@ int main(int argc, char *argv[]) nodig_delay_counter = dig_time_complete / (float)CRACK_ANIMATION_LENGTH; + + // We don't want a corresponding delay to + // very time consuming nodes + if(nodig_delay_counter > 0.5) + { + nodig_delay_counter = 0.5; + } + // We want a slight delay to very little + // time consuming nodes + if(nodig_delay_counter < 0.15) + { + nodig_delay_counter = 0.15; + } } dig_time += dtime; diff --git a/src/map.cpp b/src/map.cpp index acaf8436a..fe94d6e97 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1991,7 +1991,9 @@ MapBlock * ServerMap::emergeBlock( coal_rareness = 1; if(rand()%coal_rareness == 0) { - for(s16 i=0; i= 360.) m_yaw -= 360.; diff --git a/src/server.cpp b/src/server.cpp index db4e04228..35f1f8a27 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1785,7 +1785,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) /* 3: Digging completed */ - if(action == 3) + else if(action == 3) { // Mandatory parameter; actually used for nothing core::map modified_blocks; -- 2.25.1