00001 /* $Id: loadscreen.hpp 24573 2008-03-12 16:24:55Z soliton $ */ 00002 /* 00003 Copyright (C) 2005 - 2008 by Joeri Melis <joeri_melis@hotmail.com> 00004 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License version 2 00008 or at your option any later version. 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY. 00011 00012 See the COPYING file for more details. 00013 */ 00014 00015 //! @file loadscreen.hpp 00016 //! 00017 00018 #ifndef JM_LOADSCREEN_HPP 00019 #define JM_LOADSCREEN_HPP 00020 00021 #include "SDL.h" 00022 #include "SDL_image.h" 00023 00024 #include "global.hpp" 00025 00026 //#include "font.hpp" 00027 #include "video.hpp" 00028 00029 #include <iostream> 00030 #include <string> 00031 00032 class loadscreen { 00033 public: 00034 // Preferred constructor 00035 explicit loadscreen(CVideo &screen, const int &percent = 0); 00036 // Keep default copy constructor 00037 // Keep default copy assignment 00038 // Destructor, dumps the counter values to stderr 00039 ~loadscreen() 00040 { 00041 std::cerr << "loadscreen: filesystem counter = " << filesystem_counter << std::endl; 00042 std::cerr << "loadscreen: binarywml counter = " << binarywml_counter << std::endl; 00043 std::cerr << "loadscreen: setconfig counter = " << setconfig_counter << std::endl; 00044 std::cerr << "loadscreen: parser counter = " << parser_counter << std::endl; 00045 if (logo_surface_) { 00046 SDL_FreeSurface (logo_surface_); 00047 } 00048 } 00049 00050 //! Function to display a load progress bar. 00051 void set_progress(const int percentage=0, const std::string &text="", const bool commit=true); 00052 //! Function to increment the progress bar. 00053 void increment_progress(const int percentage=1, const std::string &text="", const bool commit=true); 00054 //! Function to draw a blank screen. 00055 void clear_screen(const bool commit=true); 00056 00057 // Counters 00058 int filesystem_counter; 00059 int binarywml_counter; 00060 int setconfig_counter; 00061 int parser_counter; 00062 00063 //! A global loadscreen instance that can be used to avoid 00064 //! passing it on to functions that are many levels deep. 00065 static loadscreen *global_loadscreen; 00066 00067 struct global_loadscreen_manager { 00068 explicit global_loadscreen_manager(CVideo& screen); 00069 ~global_loadscreen_manager(); 00070 00071 bool owns; 00072 }; 00073 private: 00074 // Prohibit default constructor 00075 loadscreen(); 00076 00077 // Data members 00078 CVideo &screen_; 00079 SDL_Rect textarea_; 00080 SDL_Surface *logo_surface_; 00081 bool logo_drawn_; 00082 int pby_offset_; 00083 int prcnt_; 00084 }; 00085 00086 // Global accessible functions that centralize the loadscreen related work. 00087 void increment_filesystem_progress(); 00088 void increment_binary_wml_progress(); 00089 void increment_set_config_progress(); 00090 void increment_parser_progress(); 00091 00092 #endif
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |