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++
45 #include <Include/compiler.h>
48 #include "fg_serial.hxx"
83 // The flight gear "root" directory
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)
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
103 bool hud_status; // HUD on/off
104 bool panel_status; // Panel on/off
105 bool sound; // play sound effects
107 // Flight Model options
108 int flight_model; // Flight Model: FG_SLEW, FG_LARCSIM, etc.
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
121 int tile_radius; // Square radius of rendered tiles (around center
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
129 int units; // feet or meters
133 int time_offset; // Offset true time by this many seconds
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
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;
152 // Parse a single option
153 int parse_option( const string& arg );
155 // Parse the command line options
156 int parse_command_line( int argc, char **argv );
158 // Parse the command line options
159 int parse_config_file( const string& path );
161 // Print usage message
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; }
195 inline int get_units() const { return units; }
196 inline int get_tris_or_culled() const { return tris_or_culled; }
198 inline int get_time_offset() const { return time_offset; }
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; }
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; }
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 ) {
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 );
225 inline void set_xsize( int x ) { xsize= x; }
226 inline void set_ysize( int y ) { xsize= y; }
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 );
240 extern fgOPTIONS current_options;
243 #endif /* _OPTIONS_HXX */
247 // Revision 1.23 1998/11/23 21:49:05 curt
248 // Borland portability tweaks.
250 // Revision 1.22 1998/11/20 01:02:38 curt
251 // Try to detect Mesa/Glide/Voodoo and chose the appropriate resolution.
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().
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
263 // Revision 1.19 1998/10/25 14:08:49 curt
264 // Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
266 // Revision 1.18 1998/09/17 18:35:31 curt
267 // Added F8 to toggle fog and F9 to toggle texturing.
269 // Revision 1.17 1998/09/08 21:40:10 curt
270 // Fixes by Charlie Hotchkiss.
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
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.
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.
286 // Revision 1.14 1998/08/20 15:10:35 curt
287 // Added GameGLUT support.
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.
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.
301 // Revision 1.11 1998/07/13 21:01:39 curt
302 // Wrote access functions for current fgOPTIONS.
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.
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.
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
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.
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.
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.
334 // Revision 1.5 1998/05/03 00:47:32 curt
335 // Added an option to enable/disable full-screen mode.
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
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.
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.
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.