| 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 | #include "error.h" | 
|---|
| 15 |  | 
|---|
| 16 | //----------------------------------------------------------------------------- | 
|---|
| 17 | // Forward declarations | 
|---|
| 18 | //----------------------------------------------------------------------------- | 
|---|
| 19 | class Campaign; | 
|---|
| 20 | class World; | 
|---|
| 21 | class Factory; | 
|---|
| 22 | class TiXmlElement; | 
|---|
| 23 | class BaseObject; | 
|---|
| 24 | class Event; | 
|---|
| 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 | public: | 
|---|
| 41 | virtual ~GameLoader (); | 
|---|
| 42 | /**  this class is a singleton class @returns an instance of itself  */ | 
|---|
| 43 | static GameLoader* getInstance() { if(singletonRef == NULL) singletonRef = new GameLoader(); return singletonRef; } | 
|---|
| 44 |  | 
|---|
| 45 | ErrorMessage loadCampaign(const std::string& name); | 
|---|
| 46 | ErrorMessage loadDebugCampaign(Uint32 campaignID); | 
|---|
| 47 | ErrorMessage loadNetworkCampaign(const std::string& fileName); | 
|---|
| 48 |  | 
|---|
| 49 | ErrorMessage init(); | 
|---|
| 50 | ErrorMessage start(); | 
|---|
| 51 | void stop(); | 
|---|
| 52 | ErrorMessage pause(); | 
|---|
| 53 | ErrorMessage resume(); | 
|---|
| 54 |  | 
|---|
| 55 | void switchToNextLevel(); | 
|---|
| 56 |  | 
|---|
| 57 | void process(const Event &event); | 
|---|
| 58 |  | 
|---|
| 59 |  | 
|---|
| 60 | private: | 
|---|
| 61 | GameLoader (); | 
|---|
| 62 |  | 
|---|
| 63 | Campaign* fileToCampaign(const std::string& name); | 
|---|
| 64 |  | 
|---|
| 65 |  | 
|---|
| 66 | private: | 
|---|
| 67 | static GameLoader*     singletonRef;         //!< The singleton-reference to this object | 
|---|
| 68 |  | 
|---|
| 69 | Uint32                 startTime;            //!< start time of the campaign | 
|---|
| 70 | bool                   isPaused;             //!< if the game is paused | 
|---|
| 71 | bool                   bRun;                 //!< true if stop | 
|---|
| 72 |  | 
|---|
| 73 | Campaign*              currentCampaign;      //!< reference to the current campaign playing | 
|---|
| 74 | }; | 
|---|
| 75 |  | 
|---|
| 76 | #endif /* _GAME_LOADER_H */ | 
|---|