More consistent progress bar from 0-100 on startup

master
sapier 2014-08-23 12:16:46 +02:00
parent 35149a10e3
commit 0db73bd83e
2 changed files with 26 additions and 14 deletions

View File

@ -2703,17 +2703,27 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)
assert(m_nodedef_received); assert(m_nodedef_received);
assert(mediaReceived()); assert(mediaReceived());
wchar_t* text = wgettext("Loading textures...");
// Rebuild inherited images and recreate textures // Rebuild inherited images and recreate textures
infostream<<"- Rebuilding images and textures"<<std::endl; infostream<<"- Rebuilding images and textures"<<std::endl;
draw_load_screen(text,device, guienv, 0, 70);
m_tsrc->rebuildImagesAndTextures(); m_tsrc->rebuildImagesAndTextures();
delete[] text;
// Rebuild shaders // Rebuild shaders
infostream<<"- Rebuilding shaders"<<std::endl; infostream<<"- Rebuilding shaders"<<std::endl;
text = wgettext("Rebuilding shaders...");
draw_load_screen(text, device, guienv, 0, 75);
m_shsrc->rebuildShaders(); m_shsrc->rebuildShaders();
delete[] text;
// Update node aliases // Update node aliases
infostream<<"- Updating node aliases"<<std::endl; infostream<<"- Updating node aliases"<<std::endl;
text = wgettext("Initializing nodes...");
draw_load_screen(text, device, guienv, 0, 80);
m_nodedef->updateAliases(m_itemdef); m_nodedef->updateAliases(m_itemdef);
delete[] text;
// Update node textures and assign shaders to each tile // Update node textures and assign shaders to each tile
infostream<<"- Updating node textures"<<std::endl; infostream<<"- Updating node textures"<<std::endl;
@ -2723,21 +2733,21 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)
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..."); text = wgettext("Item textures...");
draw_load_screen(text, device, guienv, 0, 0); draw_load_screen(text, device, guienv, 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 size = names.size();
size_t count = 0; size_t count = 0;
int percent = 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++; count++;
percent = count*100/size; percent = (count * 100 / size * 0.2) + 80;
if (count%50 == 0) // only update every 50 item draw_load_screen(text, device, guienv, 0, percent);
draw_load_screen(text, device, guienv, 0, percent);
} }
delete[] text; delete[] text;
} }
@ -2748,7 +2758,10 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)
m_state = LC_Ready; m_state = LC_Ready;
sendReady(); sendReady();
text = wgettext("Done!");
draw_load_screen(text, device, guienv, 0, 100);
infostream<<"Client::afterContentReceived() done"<<std::endl; infostream<<"Client::afterContentReceived() done"<<std::endl;
delete[] text;
} }
float Client::getRTT(void) float Client::getRTT(void)

View File

@ -1325,7 +1325,6 @@ struct FpsControl {
* many functions that do require objects of thse types do not modify them * many functions that do require objects of thse types do not modify them
* (so they can be passed as a const qualified parameter) * (so they can be passed as a const qualified parameter)
*/ */
struct CameraOrientation { struct CameraOrientation {
f32 camera_yaw; // "right/left" f32 camera_yaw; // "right/left"
f32 camera_pitch; // "up/down" f32 camera_pitch; // "up/down"
@ -1898,7 +1897,7 @@ bool Game::initSound()
bool Game::createSingleplayerServer(const std::string map_dir, bool Game::createSingleplayerServer(const std::string map_dir,
const SubgameSpec &gamespec, u16 port, std::string *address) const SubgameSpec &gamespec, u16 port, std::string *address)
{ {
showOverlayMessage("Creating server...", 0, 25); showOverlayMessage("Creating server...", 0, 5);
std::string bind_str = g_settings->get("bind_address"); std::string bind_str = g_settings->get("bind_address");
Address bind_addr(0, 0, 0, 0, port); Address bind_addr(0, 0, 0, 0, port);
@ -1936,7 +1935,7 @@ bool Game::createClient(const std::string &playername,
const std::string &password, std::string *address, u16 port, const std::string &password, std::string *address, u16 port,
std::wstring *error_message) std::wstring *error_message)
{ {
showOverlayMessage("Creating client...", 0, 50); showOverlayMessage("Creating client...", 0, 10);
draw_control = new MapDrawControl; draw_control = new MapDrawControl;
if (!draw_control) if (!draw_control)
@ -2105,7 +2104,7 @@ bool Game::connectToServer(const std::string &playername,
const std::string &password, std::string *address, u16 port, const std::string &password, std::string *address, u16 port,
bool *connect_ok, bool *aborted) bool *connect_ok, bool *aborted)
{ {
showOverlayMessage("Resolving address...", 0, 75); showOverlayMessage("Resolving address...", 0, 15);
Address connect_address(0, 0, 0, 0, port); Address connect_address(0, 0, 0, 0, port);
@ -2196,7 +2195,7 @@ bool Game::connectToServer(const std::string &playername,
} }
// Update status // Update status
showOverlayMessage("Connecting to server...", dtime, 100); showOverlayMessage("Connecting to server...", dtime, 20);
} }
} catch (con::PeerNotFoundException &e) { } catch (con::PeerNotFoundException &e) {
// TODO: Should something be done here? At least an info/error // TODO: Should something be done here? At least an info/error
@ -2251,16 +2250,16 @@ bool Game::getServerContent(bool *aborted)
} }
// Display status // Display status
int progress = 0; int progress = 25;
if (!client->itemdefReceived()) { if (!client->itemdefReceived()) {
wchar_t *text = wgettext("Item definitions..."); wchar_t *text = wgettext("Item definitions...");
progress = 0; progress = 25;
draw_load_screen(text, device, guienv, dtime, progress); draw_load_screen(text, device, guienv, dtime, progress);
delete[] text; delete[] text;
} else if (!client->nodedefReceived()) { } else if (!client->nodedefReceived()) {
wchar_t *text = wgettext("Node definitions..."); wchar_t *text = wgettext("Node definitions...");
progress = 25; progress = 30;
draw_load_screen(text, device, guienv, dtime, progress); draw_load_screen(text, device, guienv, dtime, progress);
delete[] text; delete[] text;
} else { } else {
@ -2281,7 +2280,7 @@ bool Game::getServerContent(bool *aborted)
message << " ( " << cur << cur_unit << " )"; message << " ( " << cur << cur_unit << " )";
} }
progress = 50 + client->mediaReceiveProgress() * 50 + 0.5; progress = 30 + client->mediaReceiveProgress() * 35 + 0.5;
draw_load_screen(narrow_to_wide(message.str().c_str()), device, draw_load_screen(narrow_to_wide(message.str().c_str()), device,
guienv, dtime, progress); guienv, dtime, progress);
} }