From 0db73bd83effa7dbc0f28862c8157e0283d24e44 Mon Sep 17 00:00:00 2001 From: sapier Date: Sat, 23 Aug 2014 12:16:46 +0200 Subject: [PATCH] More consistent progress bar from 0-100 on startup --- src/client.cpp | 23 ++++++++++++++++++----- src/game.cpp | 17 ++++++++--------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index b401eb804..cfa8704b3 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2703,17 +2703,27 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font) assert(m_nodedef_received); assert(mediaReceived()); + wchar_t* text = wgettext("Loading textures..."); + // Rebuild inherited images and recreate textures infostream<<"- Rebuilding images and textures"<rebuildImagesAndTextures(); + delete[] text; // Rebuild shaders infostream<<"- Rebuilding shaders"<rebuildShaders(); + delete[] text; // Update node aliases infostream<<"- Updating node aliases"<updateAliases(m_itemdef); + delete[] text; // Update node textures and assign shaders to each tile infostream<<"- Updating node textures"<getBool("preload_item_visuals")) { verbosestream<<"Updating item textures and meshes"< names = m_itemdef->getAll(); size_t size = names.size(); size_t count = 0; int percent = 0; for(std::set::const_iterator - i = names.begin(); i != names.end(); ++i){ + i = names.begin(); i != names.end(); ++i) + { // Asking for these caches the result m_itemdef->getInventoryTexture(*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, guienv, 0, percent); + percent = (count * 100 / size * 0.2) + 80; + draw_load_screen(text, device, guienv, 0, percent); } delete[] text; } @@ -2748,7 +2758,10 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font) m_state = LC_Ready; sendReady(); + text = wgettext("Done!"); + draw_load_screen(text, device, guienv, 0, 100); infostream<<"Client::afterContentReceived() done"<get("bind_address"); 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, std::wstring *error_message) { - showOverlayMessage("Creating client...", 0, 50); + showOverlayMessage("Creating client...", 0, 10); draw_control = new MapDrawControl; if (!draw_control) @@ -2105,7 +2104,7 @@ bool Game::connectToServer(const std::string &playername, const std::string &password, std::string *address, u16 port, bool *connect_ok, bool *aborted) { - showOverlayMessage("Resolving address...", 0, 75); + showOverlayMessage("Resolving address...", 0, 15); Address connect_address(0, 0, 0, 0, port); @@ -2196,7 +2195,7 @@ bool Game::connectToServer(const std::string &playername, } // Update status - showOverlayMessage("Connecting to server...", dtime, 100); + showOverlayMessage("Connecting to server...", dtime, 20); } } catch (con::PeerNotFoundException &e) { // TODO: Should something be done here? At least an info/error @@ -2251,16 +2250,16 @@ bool Game::getServerContent(bool *aborted) } // Display status - int progress = 0; + int progress = 25; if (!client->itemdefReceived()) { wchar_t *text = wgettext("Item definitions..."); - progress = 0; + progress = 25; draw_load_screen(text, device, guienv, dtime, progress); delete[] text; } else if (!client->nodedefReceived()) { wchar_t *text = wgettext("Node definitions..."); - progress = 25; + progress = 30; draw_load_screen(text, device, guienv, dtime, progress); delete[] text; } else { @@ -2281,7 +2280,7 @@ bool Game::getServerContent(bool *aborted) 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, guienv, dtime, progress); } -- 2.25.1