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