home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / SMC_1.6_win32.exe / src / gui / hud.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-07-01  |  6.5 KB  |  262 lines

  1. /***************************************************************************
  2.  * hud.h  -  header for the corresponding cpp file
  3.  *
  4.  * Copyright (C) 2003 - 2008 Florian Richter
  5.  ***************************************************************************/
  6. /*
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 3 of the License, or
  10.    (at your option) any later version.
  11.    
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. */
  15.  
  16. #ifndef SMC_HUD_H
  17. #define SMC_HUD_H
  18.  
  19. #include "../objects/movingsprite.h"
  20. #include "../core/obj_manager.h"
  21.  
  22. /* *** *** *** *** *** *** *** cHudSprite *** *** *** *** *** *** *** *** *** *** */
  23.  
  24. class cHudSprite : public cSprite
  25. {
  26. public:
  27.     cHudSprite( GL_Surface *new_image = NULL, float x = 0, float y = 0, bool del_img = 0 );
  28.     virtual ~cHudSprite( void );
  29.     
  30.     // copy this sprite
  31.     virtual cHudSprite *Copy( void );
  32. };
  33.  
  34. typedef vector<cHudSprite *> HudSpriteList;
  35.  
  36. /* *** *** *** *** *** *** *** cHud_Manager *** *** *** *** *** *** *** *** *** *** */
  37.  
  38. class cHud_Manager : public cObject_Manager<cHudSprite>
  39. {
  40. public:
  41.     cHud_Manager( void );
  42.     virtual ~cHud_Manager( void );
  43.  
  44.     // Load the complete HUD
  45.     void Load( void );
  46.     // Unload the complete HUD
  47.     void Unload( void );
  48.  
  49.     // Update and reload text
  50.     void Update_Text( void );
  51.     // Update the objects
  52.     void Update( void );
  53.     // Draw the objects
  54.     void Draw( void );
  55.  
  56.     // is the HUD loaded
  57.     bool loaded;
  58. };
  59.  
  60. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  61.  
  62. // The HUD Manager
  63. extern cHud_Manager *pHud_Manager;
  64.  
  65. /* *** *** *** *** *** *** *** *** PointsText *** *** *** *** *** *** *** *** *** */
  66.  
  67. struct PointsText : public cHudSprite
  68. {
  69. public:
  70.     PointsText( void );
  71.     virtual ~PointsText( void );
  72.  
  73.     float vely;
  74.     unsigned int points;
  75. };
  76.  
  77. /* *** *** *** *** *** cMenuBackground *** *** *** *** *** *** *** *** *** *** *** *** */
  78.  
  79. class cMenuBackground : public cHudSprite
  80. {
  81. public:
  82.     cMenuBackground( float x = 0, float y = 0 );
  83.     virtual ~cMenuBackground( void );
  84.  
  85.     virtual void Draw( cSurfaceRequest *request = NULL );
  86.  
  87.     GL_Surface *maryo_head, *goldpiece;
  88.     SDL_Rect rect_maryo_head, rect_goldpiece;
  89. };
  90.  
  91. /* *** *** *** *** *** cStatusText *** *** *** *** *** *** *** *** *** *** *** *** */
  92.  
  93. class cStatusText : public cHudSprite
  94. {
  95. public:
  96.     cStatusText( float x = 0, float y = 0 );
  97.     virtual ~cStatusText( void );
  98.     
  99.     virtual void Draw( cSurfaceRequest *request = NULL );
  100. };
  101.  
  102. /* *** *** *** *** *** cPlayerPoints *** *** *** *** *** *** *** *** *** *** *** *** */
  103.  
  104. class cPlayerPoints : public cStatusText
  105. {
  106. public:
  107.     cPlayerPoints( float x = 0, float y = 0 );
  108.     virtual ~cPlayerPoints( void );
  109.  
  110.     void Set_Points( unsigned int points );
  111.     void Add_Points( unsigned int points, float x = 0, float y = 0, string strtext = "", Color color = static_cast<Uint8>(255), bool allow_multiplier = 0 );
  112.  
  113.     // removes all point texts
  114.     void Clear( void );
  115.  
  116.     virtual void Draw( cSurfaceRequest *request = NULL );
  117.  
  118.     typedef vector<PointsText *> PointsTextList;
  119.     PointsTextList pointsobjects;
  120. };
  121.  
  122. /* *** *** *** *** *** cGoldDisplay *** *** *** *** *** *** *** *** *** *** *** *** */
  123.  
  124. class cGoldDisplay : public cStatusText
  125. {
  126. public:
  127.     cGoldDisplay( float x = 0, float y = 0 );
  128.     virtual ~cGoldDisplay( void );
  129.  
  130.     void Set_Gold( int gold );
  131.     void Add_Gold( int gold );
  132.  
  133.     virtual void Draw( cSurfaceRequest *request = NULL );
  134. };
  135.  
  136. /* *** *** *** *** *** cLiveDisplay *** *** *** *** *** *** *** *** *** *** *** *** */
  137.  
  138. class cLiveDisplay : public cStatusText
  139. {
  140. public:
  141.     cLiveDisplay( float x = 0, float y = 0 );
  142.     virtual ~cLiveDisplay( void );
  143.  
  144.     void Set_Lives( int lives );
  145.     void Add_Lives( int lives );
  146.  
  147.     virtual void Draw( cSurfaceRequest *request = NULL );
  148. };
  149.  
  150. /* *** *** *** *** *** cTimeDisplay *** *** *** *** *** *** *** *** *** *** *** *** */
  151.  
  152. class cTimeDisplay : public cStatusText
  153. {
  154. public:
  155.     cTimeDisplay( float x = 0, float y = 0 );
  156.     virtual ~cTimeDisplay( void );
  157.  
  158.     // update
  159.     virtual void Update( void );
  160.     // draw
  161.     virtual void Draw( cSurfaceRequest *request = NULL );
  162.  
  163.     char text[50];
  164.     unsigned int old_seconds;
  165.     float counter;
  166. };
  167.  
  168. /* *** *** *** *** *** cItemBox *** *** *** *** *** *** *** *** *** *** *** *** */
  169.  
  170. class cItemBox : public cStatusText
  171. {
  172. public:
  173.     cItemBox( float x = 0, float y = 0 );
  174.     virtual ~cItemBox( void );
  175.  
  176.     // update
  177.     virtual void Update( void );
  178.     // draw
  179.     virtual void Draw( cSurfaceRequest *request = NULL );
  180.  
  181.     /* Set the item
  182.     * sound : if set the box sound is played
  183.     */
  184.     void Set_Item( SpriteType item_type, bool sound = 1 );
  185.     // Activates the itembox
  186.     void Request_Item( void );
  187.     // push the item back to the itembox
  188.     void Push_back( void );
  189.     
  190.     void Reset( void );
  191.  
  192.     /* The current Item
  193.      * uses the Item defines
  194.      */
  195.     SpriteType item_id;
  196.  
  197.     // alpha effect
  198.     float item_counter;
  199.     // alpha effect mod
  200.     bool item_counter_mod;
  201.  
  202.     // itembox color
  203.     Color box_color;
  204.  
  205.     // stored item
  206.     cMovingSprite *item;
  207. };
  208.  
  209. /* *** *** *** *** *** cDebugDisplay *** *** *** *** *** *** *** *** *** *** *** *** */
  210.  
  211. class cDebugDisplay : public cStatusText
  212. {
  213. public:
  214.     cDebugDisplay( float x = 0, float y = 0 );
  215.     virtual ~cDebugDisplay( void );
  216.  
  217.     // update
  218.     virtual void Update( void );
  219.     // draw
  220.     virtual void Draw( cSurfaceRequest *request = NULL );
  221.     // draw the frames per second info
  222.     void Draw_fps( void );
  223.     // draw the debug mode info
  224.     void Draw_Debug_Mode( void );
  225.     // draw the performance debug mode info
  226.     void Draw_Performance_Debug_Mode( void );
  227.  
  228.     // set the debug text to display
  229.     void Set_Text( string ntext, float display_time = speedfactor_fps * 2 );
  230.  
  231.     // display text
  232.     string text, text_old;
  233.     // text counter
  234.     float counter;
  235.  
  236.     // CEGUI debugtext
  237.     CEGUI::Window *window_debugtext, *text_debugtext;
  238.  
  239.     // last game mode
  240.     GameMode Game_Mode_last;
  241.     // last level text
  242.     string level_old;
  243.     // last object counters
  244.     int obj_counter, pass_counter, mass_counter, enemy_counter, active_counter;
  245.     // sprites
  246.     HudSpriteList sprites;
  247. };
  248.  
  249. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  250.  
  251. // The HUD
  252. extern cPlayerPoints *pointsdisplay;
  253. extern cDebugDisplay *debugdisplay;
  254. extern cGoldDisplay *golddisplay;
  255. extern cLiveDisplay *livedisplay;
  256. extern cTimeDisplay *timedisplay;
  257. extern cItemBox *Itembox;
  258.  
  259. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  260.  
  261. #endif
  262.