]> git.mxchange.org Git - flightgear.git/blob - src/Main/globals.hxx
Move the texture loader to SimGear
[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 FGPanel;
76 class FGSoundMgr;
77 class FGTextureLoader;
78 class FGTileMgr;
79 class FGViewMgr;
80 class FGViewer;
81
82
83 /**
84  * Bucket for subsystem pointers representing the sim's state.
85  */
86 class FGGlobals
87 {
88
89 private:
90
91     FGSubsystemMgr * subsystem_mgr;
92
93     // Number of milliseconds elapsed since the start of the program.
94     double sim_time_sec;
95
96     // Root of FlightGear data tree
97     string fg_root;
98
99     // Root of FlightGear scenery tree
100     string fg_scenery;
101
102     // Fullscreen mode for old 3DFX cards.
103 #if defined(FX) && defined(XMESA)
104     bool fullscreen;
105 #endif
106
107     // An offset in seconds from the true time.  Allows us to adjust
108     // the effective time of day.
109     long int warp;
110
111     // How much to change the value of warp each iteration.  Allows us
112     // to make time progress faster than normal (or even run in reverse.)
113     long int warp_delta;
114
115     // Time structure
116     SGTime *time_params;
117
118     // Sky structures
119     SGEphemeris *ephem;
120
121     // Magnetic Variation
122     SGMagVar *mag;
123
124     // Current autopilot
125     FGAutopilot *autopilot;
126
127     // Global autopilot "route"
128     SGRoute *route;
129
130     // 2D panel
131     FGPanel *current_panel;
132
133     // sound manager
134     FGSoundMgr *soundmgr;
135
136     // environment information
137     FGEnvironmentMgr * environment_mgr;
138
139     // ATC manager
140     FGATCMgr *ATC_mgr;
141
142     // ATC Renderer
143     FGATCDisplay *ATC_display;
144
145     // AI manager
146     FGAIMgr *AI_mgr;
147
148     // control input state
149     FGControls *controls;
150
151     // viewer manager
152     FGViewMgr *viewmgr;
153
154     // properties
155     SGPropertyNode *props;
156     SGPropertyNode *initial_state;
157
158     // localization
159     SGPropertyNode *locale;
160
161     SGCommandMgr *commands;
162
163     FGModelLoader * model_loader;
164
165     FGTextureLoader * texture_loader;
166
167     FGAircraftModel *acmodel;
168
169     FGModelMgr * model_mgr;
170
171     // list of serial port-like configurations
172     string_list *channel_options_list;
173
174     // FlightGear scenery manager
175     FGScenery *scenery;
176
177     // Tile manager
178     FGTileMgr *tile_mgr;
179
180     FGIO* io;
181
182 #ifdef FG_MPLAYER_AS
183     //Mulitplayer managers
184     FGMultiplayTxMgr *multiplayer_tx_mgr;
185
186     FGMultiplayRxMgr *multiplayer_rx_mgr;
187 #endif
188
189 public:
190
191     FGGlobals();
192     virtual ~FGGlobals();
193
194     virtual FGSubsystemMgr * get_subsystem_mgr () const;
195
196     virtual FGSubsystem * get_subsystem (const char * name);
197
198     virtual void add_subsystem (const char * name,
199                                 FGSubsystem * subsystem,
200                                 FGSubsystemMgr::GroupType
201                                   type = FGSubsystemMgr::GENERAL,
202                                 double min_time_sec = 0);
203
204     inline double get_sim_time_sec () const { return sim_time_sec; }
205     inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
206     inline void set_sim_time_sec (double t) { sim_time_sec = t; }
207
208     inline const string &get_fg_root () const { return fg_root; }
209     inline void set_fg_root (const string &root) { fg_root = root; }
210
211     inline const string &get_fg_scenery () const { return fg_scenery; }
212     inline void set_fg_scenery (const string &scenery) {
213       fg_scenery = scenery;
214     }
215
216 #if defined(FX) && defined(XMESA)
217     inline bool get_fullscreen() const { return fullscreen; }
218     inline bool set_fullscreen( bool f ) { fullscreen = f; }
219 #endif
220
221     inline long int get_warp() const { return warp; }
222     inline void set_warp( long int w ) { warp = w; }
223     inline void inc_warp( long int w ) { warp += w; }
224
225     inline long int get_warp_delta() const { return warp_delta; }
226     inline void set_warp_delta( long int d ) { warp_delta = d; }
227     inline void inc_warp_delta( long int d ) { warp_delta += d; }
228
229     inline SGTime *get_time_params() const { return time_params; }
230     inline void set_time_params( SGTime *t ) { time_params = t; }
231
232     inline SGEphemeris *get_ephem() const { return ephem; }
233     inline void set_ephem( SGEphemeris *e ) { ephem = e; }
234
235     inline SGMagVar *get_mag() const { return mag; }
236     inline void set_mag( SGMagVar *m ) { mag = m; }
237
238     inline FGAutopilot *get_autopilot() const { return autopilot; }
239     inline void set_autopilot( FGAutopilot *ap) { autopilot = ap; }
240
241     inline SGRoute *get_route() const { return route; }
242     inline void set_route( SGRoute *r ) { route = r; }
243
244     inline FGEnvironmentMgr * get_environment_mgr() {
245       return environment_mgr;
246     }
247     inline void set_environment_mgr(FGEnvironmentMgr * mgr) {
248       environment_mgr = mgr;
249     }
250
251     inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
252     inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
253
254     inline FGATCDisplay *get_ATC_display() const { return ATC_display; }
255     inline void set_ATC_display( FGATCDisplay *d ) {ATC_display = d; }
256
257     inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
258     inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
259
260     inline FGPanel *get_current_panel() const { return current_panel; }
261     inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
262
263     inline FGSoundMgr *get_soundmgr() const { return soundmgr; }
264     inline void set_soundmgr( FGSoundMgr *sm ) { soundmgr = sm; }
265
266     inline FGControls *get_controls() const { return controls; }
267     inline void set_controls( FGControls *c ) { controls = c; }
268
269     inline FGViewMgr *get_viewmgr() const { return viewmgr; }
270     inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
271     FGViewer *get_current_view() const;
272
273     inline SGPropertyNode *get_props () { return props; }
274     inline void set_props( SGPropertyNode *n ) { props = n; }
275
276     inline SGPropertyNode *get_locale () { return locale; }
277     inline void set_locale( SGPropertyNode *n ) { locale = n; }
278
279     inline SGCommandMgr *get_commands () { return commands; }
280
281     inline FGModelLoader * get_model_loader () { return model_loader; }
282
283     inline void set_model_loader (FGModelLoader * loader) {
284         model_loader = loader;
285     }
286
287     inline FGTextureLoader * get_texture_loader () { return texture_loader; }
288
289     inline void set_texture_loader (FGTextureLoader * loader) {
290         texture_loader = loader;
291     }
292
293     inline FGAircraftModel *get_aircraft_model () { return acmodel; }
294
295     inline void set_aircraft_model (FGAircraftModel * model)
296     {
297         acmodel = model;
298     }
299
300     inline FGModelMgr *get_model_mgr () { return model_mgr; }
301
302     inline void set_model_mgr (FGModelMgr * mgr)
303     {
304       model_mgr = mgr;
305     }
306
307 #ifdef FG_MPLAYER_AS
308     inline FGMultiplayTxMgr *get_multiplayer_tx_mgr () { return multiplayer_tx_mgr; }
309
310     inline void set_multiplayer_tx_mgr (FGMultiplayTxMgr * mgr)
311     {
312       multiplayer_tx_mgr = mgr;
313     }
314
315     inline FGMultiplayRxMgr *get_multiplayer_rx_mgr () { return multiplayer_rx_mgr; }
316
317     inline void set_multiplayer_rx_mgr (FGMultiplayRxMgr * mgr)
318     {
319       multiplayer_rx_mgr = mgr;
320     }
321 #endif
322
323     inline string_list *get_channel_options_list () {
324         return channel_options_list;
325     }
326     inline void set_channel_options_list( string_list *l ) {
327         channel_options_list = l;
328     }
329
330     inline FGScenery * get_scenery () const { return scenery; }
331     inline void set_scenery ( FGScenery *s ) { scenery = s; }
332
333     inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
334     inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
335
336     FGIO* get_io() const { return io; }
337
338
339     /**
340      * Save the current state as the initial state.
341      */
342     void saveInitialState ();
343
344
345     /**
346      * Restore the saved initial state, if any.
347      */
348     void restoreInitialState ();
349
350 };
351
352
353 extern FGGlobals *globals;
354
355
356 #endif // _GLOBALS_HXX