Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/util/loading/game_loader.h @ 5974

Last change on this file since 5974 was 5974, checked in by patrick, 18 years ago

network: cleaned up the game_loader

File size: 2.3 KB
Line 
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//-----------------------------------------------------------------------------
19class Campaign;
20class World;
21class Factory;
22class TiXmlElement;
23class BaseObject;
24class Event;
25class 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*/
39class GameLoader : public EventListener
40{
41
42
43 public:
44  ~GameLoader ();
45
46  /**  this class is a singleton class @returns an instance of itself  */
47  static GameLoader* getInstance() { if(singletonRef == NULL) singletonRef = new GameLoader();  return singletonRef; }
48
49  void registerFactory( Factory* factory );
50  BaseObject* fabricate(const TiXmlElement* data);
51
52  ErrorMessage init();
53  ErrorMessage start();
54  void stop();
55  ErrorMessage pause();
56  ErrorMessage resume();
57  ErrorMessage destroy();
58
59  ErrorMessage loadDebugCampaign(Uint32 campaignID);
60  ErrorMessage loadCampaign(const char* name);
61  ErrorMessage loadNetworkCampaign(const char* name);
62
63  void process(const Event &event);
64
65  void nextLevel();
66  void previousLevel();
67
68
69 private:
70  GameLoader ();
71
72  Campaign* fileToCampaign(const char* name);
73
74
75 private:
76  static GameLoader*     singletonRef;         //!< The singleton-reference to this object
77  Campaign*              currentCampaign;      //!< reference to the current campaign playing
78
79  bool                   isPaused;             //!< if the game is paused
80};
81
82#endif /* _GAME_LOADER_H */
Note: See TracBrowser for help on using the repository browser.