| 1 | /*! | 
|---|
| 2 |  * @file game_loader.h | 
|---|
| 3 |  *  loads campaigns, worlds and all other story_entities | 
|---|
| 4 | */ | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef _GAME_LOADER_H | 
|---|
| 7 | #define _GAME_LOADER_H | 
|---|
| 8 |  | 
|---|
| 9 | //#include "stdincl.h" | 
|---|
| 10 | #include "story_def.h" | 
|---|
| 11 | #include "comincl.h" | 
|---|
| 12 | #include "event_listener.h" | 
|---|
| 13 |  | 
|---|
| 14 |  | 
|---|
| 15 | //----------------------------------------------------------------------------- | 
|---|
| 16 | // Forward declarations | 
|---|
| 17 | //----------------------------------------------------------------------------- | 
|---|
| 18 | class Campaign; | 
|---|
| 19 | class World; | 
|---|
| 20 | class Factory; | 
|---|
| 21 | class TiXmlElement; | 
|---|
| 22 | class BaseObject; | 
|---|
| 23 | class Event; | 
|---|
| 24 | class EventHandler; | 
|---|
| 25 |  | 
|---|
| 26 | //! The GameLoader | 
|---|
| 27 | /** | 
|---|
| 28 |    The game loader loads all game date. this is performed in the following way: | 
|---|
| 29 |    1. Read the structure of campaings and worlds | 
|---|
| 30 |    2. Create the instances of the tree: here _ALL_ StoryEntities are created | 
|---|
| 31 |       also if they are not yet used. the worlds should load their data in | 
|---|
| 32 |       the StoryEntity::load() and StoryEntity::init() functions! NOWHERE ELSE! | 
|---|
| 33 |       Elsewhere, all the data will be allocated at the beginning... mess... | 
|---|
| 34 |    3. StoryEntities are load() and init() before they start | 
|---|
| 35 |    4. once the gamloader starts the game there will be a campaing starting a | 
|---|
| 36 |       world. this is done by callaing those StoryEntity::start() | 
|---|
| 37 | */ | 
|---|
| 38 | class GameLoader : public EventListener | 
|---|
| 39 | { | 
|---|
| 40 |  | 
|---|
| 41 |  public: | 
|---|
| 42 |   ~GameLoader (); | 
|---|
| 43 |  | 
|---|
| 44 |   static GameLoader* getInstance(); | 
|---|
| 45 |  | 
|---|
| 46 |   ErrorMessage init(); | 
|---|
| 47 |   ErrorMessage loadCampaign(const char* name); | 
|---|
| 48 |   ErrorMessage start(); | 
|---|
| 49 |   ErrorMessage stop(); | 
|---|
| 50 |   ErrorMessage pause(); | 
|---|
| 51 |   ErrorMessage resume(); | 
|---|
| 52 |   ErrorMessage destroy(); | 
|---|
| 53 |  | 
|---|
| 54 |   void nextLevel(); | 
|---|
| 55 |   void previousLevel(); | 
|---|
| 56 |  | 
|---|
| 57 |   /** \brief a world command to send to the GameLoader @param cmd the command */ | 
|---|
| 58 |   bool worldCommand(Command* cmd); | 
|---|
| 59 |   ErrorMessage loadDebugCampaign(Uint32 campaignID); | 
|---|
| 60 |  | 
|---|
| 61 |   void registerFactory( Factory* factory ); | 
|---|
| 62 |   BaseObject* fabricate(const TiXmlElement* data); | 
|---|
| 63 |  | 
|---|
| 64 |   void process(const Event &event); | 
|---|
| 65 |  | 
|---|
| 66 |  private: | 
|---|
| 67 |   GameLoader (); | 
|---|
| 68 |  | 
|---|
| 69 |   Campaign* fileToCampaign(const char* name); | 
|---|
| 70 |  | 
|---|
| 71 |  private: | 
|---|
| 72 |   static GameLoader*     singletonRef;         //!< The singleton-reference to this object | 
|---|
| 73 |  | 
|---|
| 74 |   Uint32                 startTime;            //!< start time of the campaign | 
|---|
| 75 |   bool                   isPaused;             //!< if the game is paused | 
|---|
| 76 |  | 
|---|
| 77 |   Campaign*              currentCampaign;      //!< reference to the current campaign playing | 
|---|
| 78 |  | 
|---|
| 79 |   EventHandler*          eventHandler;         //!< reference to the eventHandler | 
|---|
| 80 | }; | 
|---|
| 81 |  | 
|---|
| 82 | #endif /* _GAME_LOADER_H */ | 
|---|