Absolutely frivolous, but very cute, change : show icons of what is being loaded during the loading screen (sorry, couldn't help but waste time on this =)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6054 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-09-18 23:09:02 +00:00
parent 979beb5a23
commit 37901f7f39
5 changed files with 96 additions and 14 deletions

View File

@ -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

View File

@ -1021,8 +1021,13 @@ namespace GUIEngine
} // render
// ------------------------------------------------------------------------
void renderLoading()
std::vector<irr::video::ITexture*> 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; n<icon_count; n++)
{
g_driver->draw2DImage(g_loading_icons[n],
core::rect<s32>(x, y, x+icon_size, y+icon_size),
core::rect<s32>(core::position2d<s32>(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

View File

@ -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);

View File

@ -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<std::string>::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

View File

@ -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);