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 | class EventHandler; |
---|
26 | |
---|
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 | */ |
---|
39 | class GameLoader : public EventListener |
---|
40 | { |
---|
41 | |
---|
42 | public: |
---|
43 | ~GameLoader (); |
---|
44 | |
---|
45 | static GameLoader* getInstance(); |
---|
46 | |
---|
47 | ErrorMessage init(); |
---|
48 | ErrorMessage loadCampaign(const char* name); |
---|
49 | ErrorMessage loadNetworkCampaign(const char* fileName); |
---|
50 | ErrorMessage start(); |
---|
51 | void 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 process(const Event &event); |
---|
64 | |
---|
65 | private: |
---|
66 | GameLoader (); |
---|
67 | |
---|
68 | Campaign* fileToCampaign(const char* name); |
---|
69 | Campaign* fileToNetworkCampaign(const char* fileName); |
---|
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 */ |
---|