Skip to content

Commit bda62bd

Browse files
Zeg9PilzAdam
authored andcommittedMay 13, 2013
Add progress bar to item visuals preloading
1 parent efc9329 commit bda62bd

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
 

‎src/client.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2929
#include "mapblock.h"
3030
#include "settings.h"
3131
#include "profiler.h"
32+
#include "gettext.h"
3233
#include "log.h"
3334
#include "nodemetadata.h"
3435
#include "nodedef.h"
@@ -2804,7 +2805,10 @@ ClientEvent Client::getClientEvent()
28042805
return m_client_event_queue.pop_front();
28052806
}
28062807

2807-
void Client::afterContentReceived()
2808+
void draw_load_screen(const std::wstring &text,
2809+
IrrlichtDevice* device, gui::IGUIFont* font,
2810+
float dtime=0 ,int percent=0, bool clouds=true);
2811+
void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)
28082812
{
28092813
infostream<<"Client::afterContentReceived() started"<<std::endl;
28102814
assert(m_itemdef_received);
@@ -2839,13 +2843,23 @@ void Client::afterContentReceived()
28392843
if(g_settings->getBool("preload_item_visuals"))
28402844
{
28412845
verbosestream<<"Updating item textures and meshes"<<std::endl;
2846+
wchar_t* text = wgettext("Item textures...");
2847+
draw_load_screen(text,device,font,0,0);
28422848
std::set<std::string> names = m_itemdef->getAll();
2849+
size_t size = names.size();
2850+
size_t count = 0;
2851+
int percent = 0;
28432852
for(std::set<std::string>::const_iterator
28442853
i = names.begin(); i != names.end(); ++i){
28452854
// Asking for these caches the result
28462855
m_itemdef->getInventoryTexture(*i, this);
28472856
m_itemdef->getWieldMesh(*i, this);
2857+
count++;
2858+
percent = count*100/size;
2859+
if (count%50 == 0) // only update every 50 item
2860+
draw_load_screen(text,device,font,0,percent);
28482861
}
2862+
delete[] text;
28492863
}
28502864

28512865
// Start mesh update thread after setting up content definitions

‎src/client.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
385385
bool nodedefReceived()
386386
{ return m_nodedef_received; }
387387

388-
void afterContentReceived();
388+
void afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font);
389389

390390
float getRTT(void);
391391

‎src/game.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ void the_game(
12321232
After all content has been received:
12331233
Update cached textures, meshes and materials
12341234
*/
1235-
client.afterContentReceived();
1235+
client.afterContentReceived(device,font);
12361236

12371237
/*
12381238
Create the camera node

0 commit comments

Comments
 (0)
Please sign in to comment.