]> git.mxchange.org Git - flightgear.git/blob - src/Main/globals.hxx
Don't start paused for in air starts.
[flightgear.git] / src / Main / globals.hxx
1 // globals.hxx -- Global state that needs to be shared among the sim modules
2 //
3 // Written by Curtis Olson, started July 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _GLOBALS_HXX
25 #define _GLOBALS_HXX
26
27 #include <simgear/compiler.h>
28
29 #include <vector>
30 #include STL_STRING
31
32 #include "fgfs.hxx"
33
34
35 SG_USING_STD( vector );
36 SG_USING_STD( string );
37
38 typedef vector<string> string_list;
39
40
41 // Forward declarations
42
43 // This file is included, directly or indirectly, almost everywhere in
44 // FlightGear, so if any of its dependencies changes, most of the sim
45 // has to be recompiled.  Using these forward declarations helps us to
46 // avoid including a lot of header files (and thus, a lot of
47 // dependencies).  Since Most of the methods simply set or return
48 // pointers, we don't need to know anything about the class details
49 // anyway.
50
51 class SGEphemeris;
52
53 class SGCommandMgr;
54 class SGMagVar;
55 class SGPropertyNode;
56 class SGRoute;
57 class SGTime;
58
59 class FGAIMgr;
60 class FGATCMgr;
61 class FGATCDisplay;
62 class FGAircraftModel;
63 class FGAutopilot;
64 class FGControls;
65 class FGEnvironment;
66 class FGEnvironmentMgr;
67 class FGIO;
68 class FGModelLoader;
69 class FGModelMgr;
70 class FGScenery;
71 #ifdef FG_MPLAYER_AS
72 class FGMultiplayRxMgr;
73 class FGMultiplayTxMgr;
74 #endif
75 class FGSoundMgr;
76 class FGTextureLoader;
77 class FGTileMgr;
78 class FGViewMgr;
79 class FGViewer;
80
81
82 /**
83  * Bucket for subsystem pointers representing the sim's state.
84  */
85 class FGGlobals
86 {
87
88 private:
89
90     FGSubsystemMgr * subsystem_mgr;
91
92     // Number of milliseconds elapsed since the start of the program.
93     double sim_time_sec;
94
95     // Root of FlightGear data tree
96     string fg_root;
97
98     // Root of FlightGear scenery tree
99     string fg_scenery;
100
101     // Fullscreen mode for old 3DFX cards.
102 #if defined(FX) && defined(XMESA)
103     bool fullscreen;
104 #endif
105
106     // An offset in seconds from the true time.  Allows us to adjust
107     // the effective time of day.
108     long int warp;
109
110     // How much to change the value of warp each iteration.  Allows us
111     // to make time progress faster than normal (or even run in reverse.)
112     long int warp_delta;
113
114     // Time structure
115     SGTime *time_params;
116
117     // Sky structures
118     SGEphemeris *ephem;
119
120     // Magnetic Variation
121     SGMagVar *mag;
122
123     // Current autopilot
124     FGAutopilot *autopilot;
125
126     // Global autopilot "route"
127     SGRoute *route;
128
129     // sound manager
130     FGSoundMgr *soundmgr;
131
132     // environment information
133     FGEnvironmentMgr * environment_mgr;
134
135     // ATC manager
136     FGATCMgr *ATC_mgr;
137
138     // ATC Renderer
139     FGATCDisplay *ATC_display;
140
141     // AI manager
142     FGAIMgr *AI_mgr;
143
144     // control input state
145     FGControls *controls;
146
147     // viewer manager
148     FGViewMgr *viewmgr;
149
150     // properties
151     SGPropertyNode *props;
152     SGPropertyNode *initial_state;
153
154     // localization
155     SGPropertyNode *locale;
156
157     SGCommandMgr *commands;
158
159     FGModelLoader * model_loader;
160
161     FGTextureLoader * texture_loader;
162
163     FGAircraftModel *acmodel;
164
165     FGModelMgr * model_mgr;
166
167     // list of serial port-like configurations
168     string_list *channel_options_list;
169
170     // FlightGear scenery manager
171     FGScenery *scenery;
172
173     // Tile manager
174     FGTileMgr *tile_mgr;
175
176     FGIO* io;
177
178 #ifdef FG_MPLAYER_AS
179     //Mulitplayer managers
180     FGMultiplayTxMgr *multiplayer_tx_mgr;
181
182     FGMultiplayRxMgr *multiplayer_rx_mgr;
183 #endif
184
185 public:
186
187     FGGlobals();
188     virtual ~FGGlobals();
189
190     virtual FGSubsystemMgr * get_subsystem_mgr () const;
191
192     virtual FGSubsystem * get_subsystem (const char * name);
193
194     virtual void add_subsystem (const char * name,
195                                 FGSubsystem * subsystem,
196                                 FGSubsystemMgr::GroupType
197                                   type = FGSubsystemMgr::GENERAL,
198                                 double min_time_sec = 0);
199
200     inline double get_sim_time_sec () const { return sim_time_sec; }
201     inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
202     inline void set_sim_time_sec (double t) { sim_time_sec = t; }
203
204     inline const string &get_fg_root () const { return fg_root; }
205     inline void set_fg_root (const string &root) { fg_root = root; }
206
207     inline const string &get_fg_scenery () const { return fg_scenery; }
208     inline void set_fg_scenery (const string &scenery) {
209       fg_scenery = scenery;
210     }
211
212 #if defined(FX) && defined(XMESA)
213     inline bool get_fullscreen() const { return fullscreen; }
214     inline bool set_fullscreen( bool f ) { fullscreen = f; }
215 #endif
216
217     inline long int get_warp() const { return warp; }
218     inline void set_warp( long int w ) { warp = w; }
219     inline void inc_warp( long int w ) { warp += w; }
220
221     inline long int get_warp_delta() const { return warp_delta; }
222     inline void set_warp_delta( long int d ) { warp_delta = d; }
223     inline void inc_warp_delta( long int d ) { warp_delta += d; }
224
225     inline SGTime *get_time_params() const { return time_params; }
226     inline void set_time_params( SGTime *t ) { time_params = t; }
227
228     inline SGEphemeris *get_ephem() const { return ephem; }
229     inline void set_ephem( SGEphemeris *e ) { ephem = e; }
230
231     inline SGMagVar *get_mag() const { return mag; }
232     inline void set_mag( SGMagVar *m ) { mag = m; }
233
234     inline FGAutopilot *get_autopilot() const { return autopilot; }
235     inline void set_autopilot( FGAutopilot *ap) { autopilot = ap; }
236
237     inline SGRoute *get_route() const { return route; }
238     inline void set_route( SGRoute *r ) { route = r; }
239
240     inline FGEnvironmentMgr * get_environment_mgr() {
241       return environment_mgr;
242     }
243     inline void set_environment_mgr(FGEnvironmentMgr * mgr) {
244       environment_mgr = mgr;
245     }
246
247     inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
248     inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
249
250     inline FGATCDisplay *get_ATC_display() const { return ATC_display; }
251     inline void set_ATC_display( FGATCDisplay *d ) {ATC_display = d; }
252
253     inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
254     inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
255
256     inline FGSoundMgr *get_soundmgr() const { return soundmgr; }
257     inline void set_soundmgr( FGSoundMgr *sm ) { soundmgr = sm; }
258
259     inline FGControls *get_controls() const { return controls; }
260     inline void set_controls( FGControls *c ) { controls = c; }
261
262     inline FGViewMgr *get_viewmgr() const { return viewmgr; }
263     inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
264     FGViewer *get_current_view() const;
265
266     inline SGPropertyNode *get_props () { return props; }
267     inline void set_props( SGPropertyNode *n ) { props = n; }
268
269     inline SGPropertyNode *get_locale () { return locale; }
270     inline void set_locale( SGPropertyNode *n ) { locale = n; }
271
272     inline SGCommandMgr *get_commands () { return commands; }
273
274     inline FGModelLoader * get_model_loader () { return model_loader; }
275
276     inline void set_model_loader (FGModelLoader * loader) {
277         model_loader = loader;
278     }
279
280     inline FGTextureLoader * get_texture_loader () { return texture_loader; }
281
282     inline void set_texture_loader (FGTextureLoader * loader) {
283         texture_loader = loader;
284     }
285
286     inline FGAircraftModel *get_aircraft_model () { return acmodel; }
287
288     inline void set_aircraft_model (FGAircraftModel * model)
289     {
290         acmodel = model;
291     }
292
293     inline FGModelMgr *get_model_mgr () { return model_mgr; }
294
295     inline void set_model_mgr (FGModelMgr * mgr)
296     {
297       model_mgr = mgr;
298     }
299
300 #ifdef FG_MPLAYER_AS
301     inline FGMultiplayTxMgr *get_multiplayer_tx_mgr () { return multiplayer_tx_mgr; }
302
303     inline void set_multiplayer_tx_mgr (FGMultiplayTxMgr * mgr)
304     {
305       multiplayer_tx_mgr = mgr;
306     }
307
308     inline FGMultiplayRxMgr *get_multiplayer_rx_mgr () { return multiplayer_rx_mgr; }
309
310     inline void set_multiplayer_rx_mgr (FGMultiplayRxMgr * mgr)
311     {
312       multiplayer_rx_mgr = mgr;
313     }
314 #endif
315
316     inline string_list *get_channel_options_list () {
317         return channel_options_list;
318     }
319     inline void set_channel_options_list( string_list *l ) {
320         channel_options_list = l;
321     }
322
323     inline FGScenery * get_scenery () const { return scenery; }
324     inline void set_scenery ( FGScenery *s ) { scenery = s; }
325
326     inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
327     inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
328
329     FGIO* get_io() const { return io; }
330
331
332     /**
333      * Save the current state as the initial state.
334      */
335     void saveInitialState ();
336
337
338     /**
339      * Restore the saved initial state, if any.
340      */
341     void restoreInitialState ();
342
343 };
344
345
346 extern FGGlobals *globals;
347
348
349 #endif // _GLOBALS_HXX