src/interface/loading_screen.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * Loading screen
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   // Get the background image
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   // Get profile from resource manager
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 // to manage singleton
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 

Generated on Mon Jan 1 13:10:58 2007 for Wormux by  doxygen 1.4.7