]> git.mxchange.org Git - flightgear.git/blob - Main/options.hxx
Borland portability tweaks.
[flightgear.git] / Main / options.hxx
1 // options.hxx -- class to handle command line options
2 //
3 // Written by Curtis Olson, started April 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
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 // (Log is kept at end of this file)
23
24
25 #ifndef _OPTIONS_HXX
26 #define _OPTIONS_HXX
27
28
29 #ifndef __cplusplus
30 # error This library requires C++
31 #endif                                   
32
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
36
37 #ifdef HAVE_WINDOWS_H
38 #  include <windows.h>
39 #endif
40
41 #include <GL/glut.h>
42 #include <XGL/xgl.h>
43
44 #include <string>
45 #include <Include/compiler.h>
46 FG_USING_STD(string);
47
48 #include "fg_serial.hxx"
49
50
51 class fgOPTIONS {
52
53 public:
54
55     enum
56     {
57         FG_OPTIONS_OK = 0,
58         FG_OPTIONS_HELP = 1,
59         FG_OPTIONS_ERROR = 2
60     };
61
62     enum
63     {
64         FG_UNITS_FEET = 0,
65         FG_UNITS_METERS = 1
66     };
67
68     enum fgFogKind
69     {
70         FG_FOG_DISABLED = 0,
71         FG_FOG_FASTEST  = 1,
72         FG_FOG_NICEST   = 2
73     };
74
75     enum
76     {
77         FG_RADIUS_MIN = 1,
78         FG_RADIUS_MAX = 4
79     };
80
81 private:
82
83     // The flight gear "root" directory
84     string fg_root;
85
86     // Starting position and orientation
87     string airport_id;  // ID of initial starting airport
88     double lon;         // starting longitude in degrees (west = -)
89     double lat;         // starting latitude in degrees (south = -)
90     double altitude;    // starting altitude in meters
91     double heading;     // heading (yaw) angle in degress (Psi)
92     double roll;        // roll angle in degrees (Phi)
93     double pitch;       // pitch angle in degrees (Theta)
94
95     // Miscellaneous
96     bool game_mode;     // Game mode enabled/disabled
97     bool splash_screen; // show splash screen
98     bool intro_music;   // play introductory music
99     int mouse_pointer;  // show mouse pointer
100     bool pause;         // pause intially enabled/disabled
101
102     // Features
103     bool hud_status;    // HUD on/off
104     bool panel_status;  // Panel on/off
105     bool sound;         // play sound effects
106
107     // Flight Model options
108     int flight_model;   // Flight Model:  FG_SLEW, FG_LARCSIM, etc.
109
110     // Rendering options
111     fgFogKind fog;      // Fog nicest/fastest/disabled
112     double fov;         // Field of View
113     bool fullscreen;    // Full screen mode enabled/disabled
114     int shading;        // shading method, 0 = Flat, 1 = Smooth
115     bool skyblend;      // Blend sky to haze (using polygons) or just clear
116     bool textures;      // Textures enabled/disabled
117     bool wireframe;     // Wireframe mode enabled/disabled
118     int xsize, ysize;   // window size derived from geometry string
119
120     // Scenery options
121     int tile_radius;   // Square radius of rendered tiles (around center 
122                        // square.)
123     int tile_diameter; // Diameter of rendered tiles.  for instance
124                        // if tile_diameter = 3 then a 3 x 3 grid of tiles will 
125                        // be drawn.  Increase this to see terrain that is 
126                        // further away.
127
128     // HUD options
129     int units;         // feet or meters
130     int tris_or_culled;
131
132     // Time options
133     int time_offset;   // Offset true time by this many seconds
134
135     // Serial Ports, we currently support up to four channels
136     // fgSerialPortKind port_a_kind;  // Port a kind
137     // fgSerialPortKind port_b_kind;  // Port b kind
138     // fgSerialPortKind port_c_kind;  // Port c kind
139     // fgSerialPortKind port_d_kind;  // Port d kind
140
141     // Serial port configuration strings
142     string port_a_config;
143     string port_b_config;
144     string port_c_config;
145     string port_d_config;
146     
147 public:
148
149     fgOPTIONS();
150     ~fgOPTIONS();
151
152     // Parse a single option
153     int parse_option( const string& arg );
154
155     // Parse the command line options
156     int parse_command_line( int argc, char **argv );
157
158     // Parse the command line options
159     int parse_config_file( const string& path );
160
161     // Print usage message
162     void usage ( void );
163
164     // Query functions
165     inline string get_fg_root() const { return fg_root; }
166     inline string get_airport_id() const { return airport_id; }
167     inline double get_lon() const { return lon; }
168     inline double get_lat() const { return lat; }
169     inline double get_altitude() const { return altitude; }
170     inline double get_heading() const { return heading; }
171     inline double get_roll() const { return roll; }
172     inline double get_pitch() const { return pitch; }
173     inline bool get_game_mode() const { return game_mode; }
174     inline bool get_splash_screen() const { return splash_screen; }
175     inline bool get_intro_music() const { return intro_music; }
176     inline int get_mouse_pointer() const { return mouse_pointer; }
177     inline bool get_pause() const { return pause; }
178     inline bool get_hud_status() const { return hud_status; }
179     inline bool get_panel_status() const { return panel_status; }
180     inline bool get_sound() const { return sound; }
181     inline int get_flight_model() const { return flight_model; }
182     inline bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
183     inline fgFogKind get_fog() const { return fog; }
184     inline double get_fov() const { return fov; }
185     inline bool get_fullscreen() const { return fullscreen; }
186     inline int get_shading() const { return shading; }
187     inline bool get_skyblend() const { return skyblend; }
188     inline bool get_textures() const { return textures; }
189     inline bool get_wireframe() const { return wireframe; }
190     inline int get_xsize() const { return xsize; }
191     inline int get_ysize() const { return ysize; }
192     inline int get_tile_radius() const { return tile_radius; }
193     inline int get_tile_diameter() const { return tile_diameter; }
194
195     inline int get_units() const { return units; }
196     inline int get_tris_or_culled() const { return tris_or_culled; }
197
198     inline int get_time_offset() const { return time_offset; }
199
200     // inline fgSerialPortKind get_port_a_kind() const { return port_a_kind; }
201     // inline fgSerialPortKind get_port_b_kind() const { return port_b_kind; }
202     // inline fgSerialPortKind get_port_c_kind() const { return port_c_kind; }
203     // inline fgSerialPortKind get_port_d_kind() const { return port_d_kind; }
204
205     inline string get_port_a_config() const { return port_a_config; }
206     inline string get_port_b_config() const { return port_b_config; }
207     inline string get_port_c_config() const { return port_c_config; }
208     inline string get_port_d_config() const { return port_d_config; }
209
210     // Update functions
211     inline void set_hud_status( bool status ) { hud_status = status; }
212     inline void set_fov( double amount ) { fov = amount; }
213     inline void set_textures( bool status ) { textures = status; }
214     inline void cycle_fog( void ) { 
215         if ( fog == FG_FOG_DISABLED ) {
216             fog = FG_FOG_FASTEST;
217         } else if ( fog == FG_FOG_FASTEST ) {
218             fog = FG_FOG_NICEST;
219             xglHint ( GL_FOG_HINT, GL_NICEST );
220         } else if ( fog == FG_FOG_NICEST ) {
221             fog = FG_FOG_DISABLED;
222             xglHint ( GL_FOG_HINT, GL_FASTEST );
223         }
224     }
225     inline void set_xsize( int x ) { xsize= x; }
226     inline void set_ysize( int y ) { xsize= y; }
227
228 private:
229
230     double parse_time( const string& time_str );
231     double parse_degree( const string& degree_str );
232     int parse_time_offset( const string& time_str );
233     int parse_tile_radius( const string& arg );
234     int parse_flight_model( const string& fm );
235     double parse_fov( const string& arg );
236     bool parse_serial( const string& serial_str );
237 };
238
239
240 extern fgOPTIONS current_options;
241
242
243 #endif /* _OPTIONS_HXX */
244
245
246 // $Log$
247 // Revision 1.23  1998/11/23 21:49:05  curt
248 // Borland portability tweaks.
249 //
250 // Revision 1.22  1998/11/20 01:02:38  curt
251 // Try to detect Mesa/Glide/Voodoo and chose the appropriate resolution.
252 //
253 // Revision 1.21  1998/11/16 14:00:04  curt
254 // Added pow() macro bug work around.
255 // Added support for starting FGFS at various resolutions.
256 // Added some initial serial port support.
257 // Specify default log levels in main().
258 //
259 // Revision 1.20  1998/11/02 23:04:05  curt
260 // HUD units now display in feet by default with meters being a command line
261 // option.
262 //
263 // Revision 1.19  1998/10/25 14:08:49  curt
264 // Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
265 //
266 // Revision 1.18  1998/09/17 18:35:31  curt
267 // Added F8 to toggle fog and F9 to toggle texturing.
268 //
269 // Revision 1.17  1998/09/08 21:40:10  curt
270 // Fixes by Charlie Hotchkiss.
271 //
272 // Revision 1.16  1998/08/27 17:02:08  curt
273 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
274 // - use strings for fg_root and airport_id and added methods to return
275 //   them as strings,
276 // - inlined all access methods,
277 // - made the parsing functions private methods,
278 // - deleted some unused functions.
279 // - propogated some of these changes out a bit further.
280 //
281 // Revision 1.15  1998/08/24 20:11:15  curt
282 // Added i/I to toggle full vs. minimal HUD.
283 // Added a --hud-tris vs --hud-culled option.
284 // Moved options accessor funtions to options.hxx.
285 //
286 // Revision 1.14  1998/08/20 15:10:35  curt
287 // Added GameGLUT support.
288 //
289 // Revision 1.13  1998/07/30 23:48:29  curt
290 // Output position & orientation when pausing.
291 // Eliminated libtool use.
292 // Added options to specify initial position and orientation.
293 // Changed default fov to 55 degrees.
294 // Added command line option to start in paused or unpaused state.
295 //
296 // Revision 1.12  1998/07/27 18:41:26  curt
297 // Added a pause command "p"
298 // Fixed some initialization order problems between pui and glut.
299 // Added an --enable/disable-sound option.
300 //
301 // Revision 1.11  1998/07/13 21:01:39  curt
302 // Wrote access functions for current fgOPTIONS.
303 //
304 // Revision 1.10  1998/07/06 21:34:20  curt
305 // Added an enable/disable splash screen option.
306 // Added an enable/disable intro music option.
307 // Added an enable/disable instrument panel option.
308 // Added an enable/disable mouse pointer option.
309 // Added using namespace std for compilers that support this.
310 //
311 // Revision 1.9  1998/06/27 16:54:34  curt
312 // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
313 // Don't change the view port when displaying the panel.
314 //
315 // Revision 1.8  1998/05/16 13:08:36  curt
316 // C++ - ified views.[ch]xx
317 // Shuffled some additional view parameters into the fgVIEW class.
318 // Changed tile-radius to tile-diameter because it is a much better
319 //   name.
320 // Added a WORLD_TO_EYE transformation to views.cxx.  This allows us
321 //  to transform world space to eye space for view frustum culling.
322 //
323 // Revision 1.7  1998/05/13 18:29:59  curt
324 // Added a keyboard binding to dynamically adjust field of view.
325 // Added a command line option to specify fov.
326 // Adjusted terrain color.
327 // Root path info moved to fgOPTIONS.
328 // Added ability to parse options out of a config file.
329 //
330 // Revision 1.6  1998/05/06 03:16:26  curt
331 // Added an averaged global frame rate counter.
332 // Added an option to control tile radius.
333 //
334 // Revision 1.5  1998/05/03 00:47:32  curt
335 // Added an option to enable/disable full-screen mode.
336 //
337 // Revision 1.4  1998/04/30 12:34:19  curt
338 // Added command line rendering options:
339 //   enable/disable fog/haze
340 //   specify smooth/flat shading
341 //   disable sky blending and just use a solid color
342 //   enable wireframe drawing mode
343 //
344 // Revision 1.3  1998/04/28 01:20:23  curt
345 // Type-ified fgTIME and fgVIEW.
346 // Added a command line option to disable textures.
347 //
348 // Revision 1.2  1998/04/25 15:11:13  curt
349 // Added an command line option to set starting position based on airport ID.
350 //
351 // Revision 1.1  1998/04/24 00:49:21  curt
352 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
353 // Trying out some different option parsing code.
354 // Some code reorganization.
355 //
356 //