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