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