diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 2ecaca70e..5b16795c5 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -335,28 +335,44 @@ void IrrDriver::doApplyResSettings() m_video_driver = NULL; m_gui_env = NULL; m_scene_manager = NULL; + + + // ---- Reinit + // FIXME: this load sequence is (mostly) duplicated from main.cpp!! That's just error prone + // (we're sure to update main.cpp at some point and forget this one...) + initDevice(); - + + // Re-init GUI engine + GUIEngine::init(m_device, m_video_driver, StateManager::get()); + material_manager->reInit(); - + GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/options_video.png") ); + file_manager->pushTextureSearchPath(file_manager->getModelFile("")); const std::string materials_file = file_manager->getModelFile("materials.xml"); - if(materials_file!="") - material_manager->pushTempMaterial(materials_file); + if (materials_file != "") { - powerup_manager -> loadAllPowerups (); - item_manager -> loadDefaultItems(); + material_manager->pushTempMaterial(materials_file); } - if(materials_file!="") + + powerup_manager -> loadAllPowerups (); + item_manager -> loadDefaultItems(); + projectile_manager -> loadData(); + GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/gift.png") ); + + if (materials_file != "") + { material_manager->popTempMaterial(); + } + file_manager->popTextureSearchPath(); kart_properties_manager -> loadAllKarts(); - projectile_manager -> loadData(); + attachment_manager -> loadModels(); + GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/banana.png") ); - // Re-init GUI engine - GUIEngine::init(m_device, m_video_driver, StateManager::get()); GUIEngine::reshowCurrentScreen(); } // changeResolution diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp index 3470482e5..9644bef50 100644 --- a/src/guiengine/engine.cpp +++ b/src/guiengine/engine.cpp @@ -1021,8 +1021,13 @@ namespace GUIEngine } // render // ------------------------------------------------------------------------ - void renderLoading() + + std::vector g_loading_icons; + + void renderLoading(bool clearIcons) { + if (clearIcons) g_loading_icons.clear(); + g_skin->drawBgImage(); ITexture* loading = irr_driver->getTexture(file_manager->getGUIDir()+"/loading.png"); @@ -1055,9 +1060,49 @@ namespace GUIEngine SColor(255,255,255,255), true/* center h */, false /* center v */ ); + const int icon_count = g_loading_icons.size(); + const int icon_size = (int)(screen_w / 16.0f); + const int ICON_MARGIN = 6; + int x = ICON_MARGIN; + int y = screen_h - icon_size - ICON_MARGIN; + for (int n=0; ndraw2DImage(g_loading_icons[n], + core::rect(x, y, x+icon_size, y+icon_size), + core::rect(core::position2d(0, 0), g_loading_icons[n]->getSize()), + NULL, NULL, true + ); + + x += ICON_MARGIN + icon_size; + if (x + icon_size + ICON_MARGIN/2 > screen_w) + { + y = y - ICON_MARGIN - icon_size; + x = ICON_MARGIN; + } + } + } // renderLoading // ------------------------------------------------------------------------ + + void addLoadingIcon(irr::video::ITexture* icon) + { + if (icon != NULL) + { + g_loading_icons.push_back(icon); + + g_device->getVideoDriver()->beginScene(true, true, video::SColor(255,100,101,140)); + renderLoading(false); + g_device->getVideoDriver()->endScene(); + } + else + { + std::cerr << "WARNING: GUIEngine::addLoadingIcon given NULL icon\n"; + } + } // addLoadingIcon + + // ------------------------------------------------------------------------ + Widget* getWidget(const char* name) { // if a modal dialog is shown, search within it too diff --git a/src/guiengine/engine.hpp b/src/guiengine/engine.hpp index 056be430e..61612c6af 100644 --- a/src/guiengine/engine.hpp +++ b/src/guiengine/engine.hpp @@ -203,7 +203,10 @@ namespace GUIEngine void render(float dt); /** \brief renders a "loading" screen */ - void renderLoading(); + void renderLoading(bool clearIcons = true); + + /** \brief to spice up a bit the loading icon : add icons to the loading screen */ + void addLoadingIcon(irr::video::ITexture* icon); //void transmitEvent(Widget* widget, std::string& name, const int playerID); diff --git a/src/karts/kart_properties_manager.cpp b/src/karts/kart_properties_manager.cpp index de36ca171..1776fee27 100644 --- a/src/karts/kart_properties_manager.cpp +++ b/src/karts/kart_properties_manager.cpp @@ -27,6 +27,8 @@ #include "challenges/unlock_manager.hpp" #include "config/stk_config.hpp" #include "config/user_config.hpp" +#include "graphics/irr_driver.hpp" +#include "guiengine/engine.hpp" #include "io/file_manager.hpp" #include "karts/kart_properties.hpp" #include "utils/string_utils.hpp" @@ -119,7 +121,16 @@ void KartPropertiesManager::loadAllKarts() for(std::set::const_iterator subdir=result.begin(); subdir!=result.end(); subdir++) { - loadKart(*dir+"/"+*subdir); + const bool loaded = loadKart(*dir+"/"+*subdir); + + if (loaded) + { + GUIEngine::addLoadingIcon(irr_driver->getTexture( + *dir + "/"+*subdir + "/" + + m_karts_properties[m_karts_properties.size()-1]->getIconFile() + ) + ); + } } // for all files in the currently handled directory } // for i } // loadAllKarts diff --git a/src/main.cpp b/src/main.cpp index d49dffc7b..32d77edcf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -654,10 +654,12 @@ int main(int argc, char *argv[] ) main_loop = new MainLoop(); material_manager -> loadMaterial (); + GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/options_video.png") ); kart_properties_manager -> loadAllKarts (); unlock_manager = new UnlockManager(); + GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png")) ); projectile_manager -> loadData (); - + // Both item_manager and powerup_manager load models and therefore // textures from the model directory. To avoid reading the // materials.xml twice, we do this here once for both: @@ -671,10 +673,15 @@ int main(int argc, char *argv[] ) } if(materials_file!="") material_manager->popTempMaterial(); + + GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/gift.png") ); + file_manager->popTextureSearchPath(); attachment_manager -> loadModels (); + GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/banana.png") ); + //handleCmdLine() needs InitTuxkart() so it can't be called first if(!handleCmdLine(argc, argv)) exit(0);