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

  1. /***************************************************************************
  2.  * overworld.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_OVERWORLD_H
  17. #define SMC_OVERWORLD_H
  18.  
  19. #include "../overworld/world_manager.h"
  20. #include "../overworld/world_waypoint.h"
  21. #include "../overworld/world_layer.h"
  22. #include "../overworld/world_player.h"
  23. #include "../gui/hud.h"
  24. #include "../audio/random_sound.h"
  25.  
  26. /* *** *** *** *** *** *** *** *** cOverworld_description *** *** *** *** *** *** *** *** *** */
  27.  
  28. class cOverworld_description : public CEGUI::XMLHandler
  29. {
  30. public:
  31.     cOverworld_description( void );
  32.     virtual ~cOverworld_description( void );
  33.  
  34.     // Load
  35.     void Load( void );
  36.  
  37.     // Save
  38.     void Save( void );
  39.  
  40.     // returns the full path
  41.     string Get_Full_Path( void );
  42.  
  43.     // directory name
  44.     string path;
  45.     // world name
  46.     string name;
  47.     // is visible on selection
  48.     bool visible;
  49.     // from user directory
  50.     bool user;
  51.  
  52.     // world comment
  53.     string comment;
  54. private:
  55.     // XML element start
  56.     virtual void elementStart( const CEGUI::String &element, const CEGUI::XMLAttributes &attributes );
  57.     // XML element end
  58.     virtual void elementEnd( const CEGUI::String &element );
  59.     // handle world description
  60.     void handle_world( const CEGUI::XMLAttributes& attributes );
  61.  
  62.     // XML element Property list
  63.     CEGUI::XMLAttributes xml_attributes;
  64. };
  65.  
  66. /* *** *** *** *** *** *** *** *** cOverworld *** *** *** *** *** *** *** *** *** */
  67.  
  68. typedef vector<cWaypoint *> WaypointList;
  69.  
  70. class cOverworld : public CEGUI::XMLHandler
  71. {
  72. public:
  73.     cOverworld( void );
  74.     virtual ~cOverworld( void );
  75.  
  76.     /* Enter
  77.     * if delayed is set this overworld will be entered on the next game update
  78.     */
  79.     void Enter( bool delayed = 0 );
  80.  
  81.     /* handle key down event
  82.      * returns true if processed
  83.     */
  84.     bool Key_Down( SDLKey key );
  85.     /* handle key up event
  86.      * returns true if processed
  87.     */
  88.     bool Key_Up( SDLKey key );
  89.     /* handle mouse button down event
  90.      * returns true if processed
  91.     */
  92.     bool Mouse_Down( Uint8 button );
  93.     /* handle mouse button up event
  94.      * returns true if processed
  95.     */
  96.     bool Mouse_Up( Uint8 button );
  97.     /* handle joystick button down event
  98.      * returns true if processed
  99.     */
  100.     bool Joy_Button_Down( Uint8 button );
  101.     /* handle joystick button up event
  102.      * returns true if processed
  103.     */
  104.     bool Joy_Button_Up( Uint8 button );
  105.  
  106.     // Load
  107.     bool Load( void );
  108.     // Unload
  109.     void Unload( void );
  110.     // Save
  111.     void Save( void );
  112.  
  113.     // Draw
  114.     void Draw( void );
  115.     // Draws the HUD
  116.     void Draw_HUD( void );
  117.  
  118.     // Update
  119.     void Update( void );
  120.     // Updates the Camera
  121.     void Update_Camera( void );
  122.  
  123.     // Add Map Object
  124.     void Add_Map_Object( cSprite *object );
  125.  
  126.     /* Sets the current Waypoint progress
  127.      * if force is set already accessible waypoints will be unset
  128.     */
  129.     void Set_Progress( unsigned int normal_level, bool force = 1 );
  130.  
  131.     /* Returns a pointer to the Waypoint
  132.      * if not found returns NULL
  133.     */
  134.     cWaypoint *Get_Waypoint( string name );
  135.     cWaypoint *Get_Waypoint( unsigned int num );
  136.     /* Returns the Waypoint array number if the level name matches
  137.      * if not found returns -1
  138.     */
  139.     int Get_Level_Waypoint_Num( string level_name );
  140.     /* Returns the Waypoint array number if the destination name matches
  141.      * if not found returns -1
  142.     */
  143.     int Get_Waypoint_Num( string world_name );
  144.  
  145.     /* Check if the rect collides with a Waypoint
  146.      * if no collision found returns -1
  147.     */
  148.     int Get_Waypoint_Collision( GL_rect *rect_2 );
  149.     // returns the last accessible Waypoint
  150.     int Get_Last_Valid_Waypoint( void );
  151.     // update the Waypoint text
  152.     void Update_Waypoint_text( void );
  153.  
  154.     // Enable the next Level and walk into the forward direction
  155.     bool Goto_Next_Level( void );
  156.     // Resets the Waypoint access to the default
  157.     void Reset_Waypoints( void );
  158.  
  159.     // description
  160.     cOverworld_description *description;
  161.  
  162.     // Map objects
  163.     cSprite_Manager *sprite_manager;
  164.     // Waypoints
  165.     WaypointList waypoints;
  166.  
  167.     // current Layer for collision checking
  168.     cLayer *pLayer;
  169.     // Background Color
  170.     Color background_color;
  171.     // music filename
  172.     string musicfile;
  173.     // HUD world name
  174.     cHudSprite *hud_world_name;
  175.     // HUD current level name
  176.     cHudSprite *hud_level_name;
  177.  
  178.     // goto next level on overworld enter
  179.     bool next_level;
  180.  
  181.     // Settings
  182.     unsigned int player_start_waypoint;
  183.     Moving_state player_moving_state;
  184.  
  185. private:
  186.     // XML element start
  187.     virtual void elementStart( const CEGUI::String &element, const CEGUI::XMLAttributes &attributes );
  188.     // XML element end
  189.     virtual void elementEnd( const CEGUI::String &element );
  190.  
  191.     // XML element Property list
  192.     CEGUI::XMLAttributes xml_attributes;
  193. };
  194.  
  195. // Returns a World Object if element name is available else NULL
  196. cSprite *Get_World_Object( const CEGUI::String &element, CEGUI::XMLAttributes &attributes );
  197.  
  198. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  199.  
  200. // The Overworld
  201. extern cOverworld *pActive_Overworld;
  202.  
  203. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  204.  
  205. #endif
  206.