00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "loading_screen.h"
00023 #include "../include/app.h"
00024 #include "../game/config.h"
00025 #include "../graphic/font.h"
00026 #include "../graphic/sprite.h"
00027
00028 LoadingScreen * LoadingScreen::singleton = NULL;
00029
00030 LoadingScreen::LoadingScreen()
00031 {
00032
00033 Config * config = Config::GetInstance();
00034 AppWormux * app = AppWormux::GetInstance();
00035
00036 loading_bg = new Sprite(Surface((
00037 config->GetDataDir() + PATH_SEPARATOR
00038 + "menu" + PATH_SEPARATOR
00039 + "img" + PATH_SEPARATOR
00040 + "loading.png").c_str()));
00041 loading_bg->cache.EnableLastFrameCache();
00042 loading_bg->ScaleSize(app->video.window.GetWidth(), app->video.window.GetHeight());
00043
00044
00045 res = resource_manager.LoadXMLProfile( "graphism.xml", false);
00046 }
00047
00048 LoadingScreen::~LoadingScreen()
00049 {
00050 delete loading_bg;
00051 resource_manager.UnLoadXMLProfile(res);
00052 }
00053
00054
00055 LoadingScreen * LoadingScreen::GetInstance()
00056 {
00057 if (singleton == NULL) {
00058 singleton = new LoadingScreen();
00059 }
00060 return singleton;
00061 }
00062
00063 void LoadingScreen::DrawBackground()
00064 {
00065 loading_bg->ScaleSize(AppWormux::GetInstance()->video.window.GetWidth(), AppWormux::GetInstance()->video.window.GetHeight());
00066 loading_bg->Blit( AppWormux::GetInstance()->video.window, 0, 0);
00067 AppWormux::GetInstance()->video.Flip();
00068 }
00069
00070 void LoadingScreen::StartLoading(uint nb, std::string resource,
00071 std::string label)
00072 {
00073 Surface image = resource_manager.LoadImage(res, "loading_screen/"+resource);
00074
00075 int slot_margin_x = (120/2 - image.GetWidth()/2);
00076 int x = (AppWormux::GetInstance()->video.window.GetWidth()/2)- (3*120) + nb*120;
00077 int y = (AppWormux::GetInstance()->video.window.GetHeight()/2)+40;
00078
00079 Rectanglei dest ( x+slot_margin_x,
00080 y,
00081 image.GetWidth(),
00082 image.GetHeight() );
00083 AppWormux::GetInstance()->video.window.Blit( image, dest.GetPosition());
00084
00085 Font::GetInstance(Font::FONT_NORMAL)->WriteCenter(Point2i(x+120/2, y+80), label, white_color);
00086
00087 AppWormux::GetInstance()->video.Flip();
00088 }
00089
00090
00091
00092