forked from Mirrorlandia_minetest/minetest
Add progress bar to item visuals preloading
This commit is contained in:
parent
efc9329033
commit
bda62bd3bf
@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "mapblock.h"
|
#include "mapblock.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "profiler.h"
|
#include "profiler.h"
|
||||||
|
#include "gettext.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "nodemetadata.h"
|
#include "nodemetadata.h"
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
@ -2804,7 +2805,10 @@ ClientEvent Client::getClientEvent()
|
|||||||
return m_client_event_queue.pop_front();
|
return m_client_event_queue.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::afterContentReceived()
|
void draw_load_screen(const std::wstring &text,
|
||||||
|
IrrlichtDevice* device, gui::IGUIFont* font,
|
||||||
|
float dtime=0 ,int percent=0, bool clouds=true);
|
||||||
|
void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)
|
||||||
{
|
{
|
||||||
infostream<<"Client::afterContentReceived() started"<<std::endl;
|
infostream<<"Client::afterContentReceived() started"<<std::endl;
|
||||||
assert(m_itemdef_received);
|
assert(m_itemdef_received);
|
||||||
@ -2839,13 +2843,23 @@ void Client::afterContentReceived()
|
|||||||
if(g_settings->getBool("preload_item_visuals"))
|
if(g_settings->getBool("preload_item_visuals"))
|
||||||
{
|
{
|
||||||
verbosestream<<"Updating item textures and meshes"<<std::endl;
|
verbosestream<<"Updating item textures and meshes"<<std::endl;
|
||||||
|
wchar_t* text = wgettext("Item textures...");
|
||||||
|
draw_load_screen(text,device,font,0,0);
|
||||||
std::set<std::string> names = m_itemdef->getAll();
|
std::set<std::string> names = m_itemdef->getAll();
|
||||||
|
size_t size = names.size();
|
||||||
|
size_t count = 0;
|
||||||
|
int percent = 0;
|
||||||
for(std::set<std::string>::const_iterator
|
for(std::set<std::string>::const_iterator
|
||||||
i = names.begin(); i != names.end(); ++i){
|
i = names.begin(); i != names.end(); ++i){
|
||||||
// Asking for these caches the result
|
// Asking for these caches the result
|
||||||
m_itemdef->getInventoryTexture(*i, this);
|
m_itemdef->getInventoryTexture(*i, this);
|
||||||
m_itemdef->getWieldMesh(*i, this);
|
m_itemdef->getWieldMesh(*i, this);
|
||||||
|
count++;
|
||||||
|
percent = count*100/size;
|
||||||
|
if (count%50 == 0) // only update every 50 item
|
||||||
|
draw_load_screen(text,device,font,0,percent);
|
||||||
}
|
}
|
||||||
|
delete[] text;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start mesh update thread after setting up content definitions
|
// Start mesh update thread after setting up content definitions
|
||||||
|
@ -385,7 +385,7 @@ public:
|
|||||||
bool nodedefReceived()
|
bool nodedefReceived()
|
||||||
{ return m_nodedef_received; }
|
{ return m_nodedef_received; }
|
||||||
|
|
||||||
void afterContentReceived();
|
void afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font);
|
||||||
|
|
||||||
float getRTT(void);
|
float getRTT(void);
|
||||||
|
|
||||||
|
@ -1232,7 +1232,7 @@ void the_game(
|
|||||||
After all content has been received:
|
After all content has been received:
|
||||||
Update cached textures, meshes and materials
|
Update cached textures, meshes and materials
|
||||||
*/
|
*/
|
||||||
client.afterContentReceived();
|
client.afterContentReceived(device,font);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Create the camera node
|
Create the camera node
|
||||||
|
Loading…
Reference in New Issue
Block a user