1 // options.hxx -- class to handle command line options
3 // Written by Curtis Olson, started April 1998.
5 // Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
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.
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.
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.
22 // (Log is kept at end of this file)
30 # error This library requires C++
37 #include <Include/compiler.h>
50 #include "Include/fg_stl_config.h"
52 FG_USING_NAMESPACE(std);
54 #include "fg_serial.hxx"
57 typedef vector < string > str_container;
58 typedef str_container::iterator str_iterator;
59 typedef str_container::const_iterator const_str_iterator;
94 // The flight gear "root" directory
97 // Starting position and orientation
98 string airport_id; // ID of initial starting airport
99 double lon; // starting longitude in degrees (west = -)
100 double lat; // starting latitude in degrees (south = -)
101 double altitude; // starting altitude in meters
102 double heading; // heading (yaw) angle in degress (Psi)
103 double roll; // roll angle in degrees (Phi)
104 double pitch; // pitch angle in degrees (Theta)
107 bool game_mode; // Game mode enabled/disabled
108 bool splash_screen; // show splash screen
109 bool intro_music; // play introductory music
110 int mouse_pointer; // show mouse pointer
111 bool pause; // pause intially enabled/disabled
114 bool hud_status; // HUD on/off
115 bool panel_status; // Panel on/off
116 bool sound; // play sound effects
118 // Flight Model options
119 int flight_model; // Flight Model: FG_SLEW, FG_LARCSIM, etc.
122 fgFogKind fog; // Fog nicest/fastest/disabled
123 double fov; // Field of View
124 bool fullscreen; // Full screen mode enabled/disabled
125 int shading; // shading method, 0 = Flat, 1 = Smooth
126 bool skyblend; // Blend sky to haze (using polygons) or just clear
127 bool textures; // Textures enabled/disabled
128 bool wireframe; // Wireframe mode enabled/disabled
129 int xsize, ysize; // window size derived from geometry string
132 int tile_radius; // Square radius of rendered tiles (around center
134 int tile_diameter; // Diameter of rendered tiles. for instance
135 // if tile_diameter = 3 then a 3 x 3 grid of tiles will
136 // be drawn. Increase this to see terrain that is
140 int units; // feet or meters
144 int time_offset; // Offset true time by this many seconds
146 // Serial Ports, we currently support up to four channels
147 // fgSerialPortKind port_a_kind; // Port a kind
148 // fgSerialPortKind port_b_kind; // Port b kind
149 // fgSerialPortKind port_c_kind; // Port c kind
150 // fgSerialPortKind port_d_kind; // Port d kind
152 // Serial port configuration strings
153 str_container port_options_list;
160 // Parse a single option
161 int parse_option( const string& arg );
163 // Parse the command line options
164 int parse_command_line( int argc, char **argv );
166 // Parse the command line options
167 int parse_config_file( const string& path );
169 // Print usage message
173 inline string get_fg_root() const { return fg_root; }
174 inline string get_airport_id() const { return airport_id; }
175 inline double get_lon() const { return lon; }
176 inline double get_lat() const { return lat; }
177 inline double get_altitude() const { return altitude; }
178 inline double get_heading() const { return heading; }
179 inline double get_roll() const { return roll; }
180 inline double get_pitch() const { return pitch; }
181 inline bool get_game_mode() const { return game_mode; }
182 inline bool get_splash_screen() const { return splash_screen; }
183 inline bool get_intro_music() const { return intro_music; }
184 inline int get_mouse_pointer() const { return mouse_pointer; }
185 inline bool get_pause() const { return pause; }
186 inline bool get_hud_status() const { return hud_status; }
187 inline bool get_panel_status() const { return panel_status; }
188 inline bool get_sound() const { return sound; }
189 inline int get_flight_model() const { return flight_model; }
190 inline bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
191 inline fgFogKind get_fog() const { return fog; }
192 inline double get_fov() const { return fov; }
193 inline bool get_fullscreen() const { return fullscreen; }
194 inline int get_shading() const { return shading; }
195 inline bool get_skyblend() const { return skyblend; }
196 inline bool get_textures() const { return textures; }
197 inline bool get_wireframe() const { return wireframe; }
198 inline int get_xsize() const { return xsize; }
199 inline int get_ysize() const { return ysize; }
200 inline int get_tile_radius() const { return tile_radius; }
201 inline int get_tile_diameter() const { return tile_diameter; }
203 inline int get_units() const { return units; }
204 inline int get_tris_or_culled() const { return tris_or_culled; }
206 inline int get_time_offset() const { return time_offset; }
208 inline str_container get_port_options_list() const {
209 return port_options_list;
213 inline void set_hud_status( bool status ) { hud_status = status; }
214 inline void set_fov( double amount ) { fov = amount; }
215 inline void set_textures( bool status ) { textures = status; }
216 inline void cycle_fog( void ) {
217 if ( fog == FG_FOG_DISABLED ) {
218 fog = FG_FOG_FASTEST;
219 } else if ( fog == FG_FOG_FASTEST ) {
221 xglHint ( GL_FOG_HINT, GL_NICEST );
222 } else if ( fog == FG_FOG_NICEST ) {
223 fog = FG_FOG_DISABLED;
224 xglHint ( GL_FOG_HINT, GL_FASTEST );
227 inline void set_xsize( int x ) { xsize= x; }
228 inline void set_ysize( int y ) { xsize= y; }
232 double parse_time( const string& time_str );
233 double parse_degree( const string& degree_str );
234 int parse_time_offset( const string& time_str );
235 int parse_tile_radius( const string& arg );
236 int parse_flight_model( const string& fm );
237 double parse_fov( const string& arg );
238 bool parse_serial( const string& serial_str );
242 extern fgOPTIONS current_options;
245 #endif /* _OPTIONS_HXX */
249 // Revision 1.25 1999/01/19 20:57:06 curt
250 // MacOS portability changes contributed by "Robert Puyol" <puyol@abvent.fr>
252 // Revision 1.24 1998/11/25 01:34:01 curt
253 // Support for an arbitrary number of serial ports.
255 // Revision 1.23 1998/11/23 21:49:05 curt
256 // Borland portability tweaks.
258 // Revision 1.22 1998/11/20 01:02:38 curt
259 // Try to detect Mesa/Glide/Voodoo and chose the appropriate resolution.
261 // Revision 1.21 1998/11/16 14:00:04 curt
262 // Added pow() macro bug work around.
263 // Added support for starting FGFS at various resolutions.
264 // Added some initial serial port support.
265 // Specify default log levels in main().
267 // Revision 1.20 1998/11/02 23:04:05 curt
268 // HUD units now display in feet by default with meters being a command line
271 // Revision 1.19 1998/10/25 14:08:49 curt
272 // Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
274 // Revision 1.18 1998/09/17 18:35:31 curt
275 // Added F8 to toggle fog and F9 to toggle texturing.
277 // Revision 1.17 1998/09/08 21:40:10 curt
278 // Fixes by Charlie Hotchkiss.
280 // Revision 1.16 1998/08/27 17:02:08 curt
281 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
282 // - use strings for fg_root and airport_id and added methods to return
284 // - inlined all access methods,
285 // - made the parsing functions private methods,
286 // - deleted some unused functions.
287 // - propogated some of these changes out a bit further.
289 // Revision 1.15 1998/08/24 20:11:15 curt
290 // Added i/I to toggle full vs. minimal HUD.
291 // Added a --hud-tris vs --hud-culled option.
292 // Moved options accessor funtions to options.hxx.
294 // Revision 1.14 1998/08/20 15:10:35 curt
295 // Added GameGLUT support.
297 // Revision 1.13 1998/07/30 23:48:29 curt
298 // Output position & orientation when pausing.
299 // Eliminated libtool use.
300 // Added options to specify initial position and orientation.
301 // Changed default fov to 55 degrees.
302 // Added command line option to start in paused or unpaused state.
304 // Revision 1.12 1998/07/27 18:41:26 curt
305 // Added a pause command "p"
306 // Fixed some initialization order problems between pui and glut.
307 // Added an --enable/disable-sound option.
309 // Revision 1.11 1998/07/13 21:01:39 curt
310 // Wrote access functions for current fgOPTIONS.
312 // Revision 1.10 1998/07/06 21:34:20 curt
313 // Added an enable/disable splash screen option.
314 // Added an enable/disable intro music option.
315 // Added an enable/disable instrument panel option.
316 // Added an enable/disable mouse pointer option.
317 // Added using namespace std for compilers that support this.
319 // Revision 1.9 1998/06/27 16:54:34 curt
320 // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
321 // Don't change the view port when displaying the panel.
323 // Revision 1.8 1998/05/16 13:08:36 curt
324 // C++ - ified views.[ch]xx
325 // Shuffled some additional view parameters into the fgVIEW class.
326 // Changed tile-radius to tile-diameter because it is a much better
328 // Added a WORLD_TO_EYE transformation to views.cxx. This allows us
329 // to transform world space to eye space for view frustum culling.
331 // Revision 1.7 1998/05/13 18:29:59 curt
332 // Added a keyboard binding to dynamically adjust field of view.
333 // Added a command line option to specify fov.
334 // Adjusted terrain color.
335 // Root path info moved to fgOPTIONS.
336 // Added ability to parse options out of a config file.
338 // Revision 1.6 1998/05/06 03:16:26 curt
339 // Added an averaged global frame rate counter.
340 // Added an option to control tile radius.
342 // Revision 1.5 1998/05/03 00:47:32 curt
343 // Added an option to enable/disable full-screen mode.
345 // Revision 1.4 1998/04/30 12:34:19 curt
346 // Added command line rendering options:
347 // enable/disable fog/haze
348 // specify smooth/flat shading
349 // disable sky blending and just use a solid color
350 // enable wireframe drawing mode
352 // Revision 1.3 1998/04/28 01:20:23 curt
353 // Type-ified fgTIME and fgVIEW.
354 // Added a command line option to disable textures.
356 // Revision 1.2 1998/04/25 15:11:13 curt
357 // Added an command line option to set starting position based on airport ID.
359 // Revision 1.1 1998/04/24 00:49:21 curt
360 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
361 // Trying out some different option parsing code.
362 // Some code reorganization.