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

  1. /***************************************************************************
  2.  * level.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_LEVEL_H
  17. #define SMC_LEVEL_H
  18.  
  19. #include "../core/globals.h"
  20. #include "../level/global_effect.h"
  21. #include "../level/level_background.h"
  22. #include "../core/file_parser.h"
  23. #include "../level/level_manager.h"
  24. #include "../objects/level_entry.h"
  25. #include "../audio/random_sound.h"
  26.  
  27.  
  28. /* *** *** *** *** *** cLevel *** *** *** *** *** *** *** *** *** *** *** *** */
  29.  
  30. class cLevel : public cFile_parser, public CEGUI::XMLHandler
  31. {
  32. public:
  33.     cLevel( void );
  34.     virtual ~cLevel( void );
  35.  
  36.     /* Create a new level
  37.      * returns true if successful
  38.     */
  39.     bool New( string filename );
  40.     /* Load a Level
  41.      * if delayed is given the level will be loaded on the next update
  42.     */
  43.     bool Load( string filename, bool delayed = 0 );
  44.     /* Unload the current Level
  45.      * if delayed is given unloads the on the next update
  46.     */
  47.     void Unload( bool delayed = 0 );
  48.     // Save the Level
  49.     void Save( void );
  50.     // Delete and Unload Level
  51.     void Delete( void );
  52.  
  53.     // update level changes
  54.     void Update( void );
  55.  
  56.     // Draw Layer 1 ( Backgrounds, Level Objects and Animations )
  57.     void Draw_Layer1( LevelDrawType type = LVL_DRAW );
  58.     // Draw Layer 2 ( Global Effects )
  59.     void Draw_Layer2( LevelDrawType type = LVL_DRAW );
  60.  
  61.     // Function : Process_Input
  62.     // static input handler
  63.     void Process_Input( void );
  64.     /* handle key down event
  65.      * returns true processed
  66.     */
  67.     bool Key_Down( SDLKey key );
  68.     /* handle key up event
  69.      * returns true if processed
  70.     */
  71.     bool Key_Up( SDLKey key );
  72.     /* handle mouse button down event
  73.      * returns true if processed
  74.     */
  75.     bool Mouse_Down( Uint8 button );
  76.     /* handle mouse button up event
  77.      * returns true if processed
  78.     */
  79.     bool Mouse_Up( Uint8 button );
  80.     /* handle joystick button down event
  81.      * returns true if processed
  82.     */
  83.     bool Joy_Button_Down( Uint8 button );
  84.     /* handle joystick button up event
  85.      * returns true if processed
  86.     */
  87.     bool Joy_Button_Up( Uint8 button );
  88.  
  89.     /* Return the current Music filename with the given options
  90.      * if with_dir is set to 0 the whole directory is cut
  91.      * if set to 1 the music directory is cut out
  92.      * if set to 1 the full directory will be returned
  93.     */
  94.     string Get_Musicfile( int with_dir = 2, bool with_end = 1 );
  95.     // Set the Music filename
  96.     void Set_Musicfile( string filename );
  97.     /* Set a new Level filename name and automatically re-save the level
  98.      * delete_old : if set delete the old level name
  99.     */
  100.     void Set_Levelfile( string filename, bool delete_old = 1 );
  101.     /* Return the level path if level is valid else empty
  102.      * check_only_user_dir : only check user directory for the level
  103.     */
  104.     bool Get_Path( string &filename, bool check_only_user_dir = 0 );
  105.     // Set the Level Author
  106.     void Set_Author( string name );
  107.     // Set the Level Version
  108.     void Set_Version( string level_version );
  109.  
  110.     // Get entry with the given name
  111.     cLevel_Entry *Get_Entry( string name );
  112.  
  113.     // Return true if a level is loaded
  114.     bool Is_Loaded( void );
  115.  
  116.     // music filename
  117.     string musicfile;
  118.     // valid music to play
  119.     bool valid_music;
  120.  
  121.     // level filename
  122.     string levelfile;
  123.     // if a new level should be loaded this is the next level filename
  124.     string next_levelfile;
  125.  
  126.     // unload the level on the next update
  127.     bool delayed_unload;
  128.  
  129.     // level engine version
  130.     float engine_version;
  131.     // last save time
  132.     time_t last_saved;
  133.     // level author
  134.     string author;
  135.     // level version
  136.     string version;
  137.  
  138.     // background manager
  139.     cBackground_Manager *background_manager;
  140.     // global effect
  141.     cGlobal_effect *pGlobal_effect;
  142.     // sprite manager
  143.     cSprite_Manager *pSprite_Manager;
  144.  
  145. private:
  146.     // Handles the old txt level format command
  147.     virtual bool HandleMessage( string *parts, unsigned int count, unsigned int line );
  148.     bool Read_Color_Data( string *parts, unsigned int count, unsigned int line, Color &read_color );
  149.  
  150.     // XML element start
  151.     virtual void elementStart( const CEGUI::String &element, const CEGUI::XMLAttributes &attributes );
  152.     // XML element end
  153.     virtual void elementEnd( const CEGUI::String &element );
  154.  
  155.     // XML element Item Tag list
  156.     CEGUI::XMLAttributes xml_attributes;
  157. };
  158.  
  159. // Return the Level Object if element name is available else NULL
  160. cSprite *Get_Level_Object( const CEGUI::String &xml_element, CEGUI::XMLAttributes &attributes, float engine_version = level_engine_version );
  161.  
  162. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  163.  
  164. // The Level
  165. extern cLevel *pActive_Level;
  166.  
  167. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  168.  
  169. #endif
  170.