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.
29 # error This library requires C++
36 #include <simgear/compiler.h>
43 #include <simgear/xgl/xgl.h>
45 #if defined(FX) && defined(XMESA)
46 extern bool global_fullscreen;
49 #include <simgear/math/fg_types.hxx>
50 #include <simgear/timing/sg_time.hxx>
58 #define NEW_DEFAULT_MODEL_HZ 120
100 FG_VIEW_PILOT = 0, // Pilot perspective
101 FG_VIEW_FOLLOW = 1, // Following in the "foot steps" so to speak
102 FG_VIEW_CHASE = 2, // Chase
103 FG_VIEW_CIRCLING = 3, // Circling
104 FG_VIEW_SATELLITE = 4, // From high above
105 FG_VIEW_ANCHOR = 5, // Drop an anchor and watch from there
106 FG_VIEW_TOWER = 6, // From nearest tower?
107 FG_VIEW_SPOTTER = 7 // Fron a ground spotter
112 FG_AUTO_COORD_NOT_SPECIFIED = 0,
113 FG_AUTO_COORD_DISABLED = 1,
114 FG_AUTO_COORD_ENABLED = 2
117 enum fgTimingOffsetType {
118 FG_TIME_SYS_OFFSET = 0,
119 FG_TIME_GMT_OFFSET = 1,
120 FG_TIME_LAT_OFFSET = 2,
121 FG_TIME_SYS_ABSOLUTE = 3,
122 FG_TIME_GMT_ABSOLUTE = 4,
123 FG_TIME_LAT_ABSOLUTE = 5
128 // The flight gear "root" directory
131 // Starting position and orientation
132 string airport_id; // ID of initial starting airport
133 double lon; // starting longitude in degrees (west = -)
134 double lat; // starting latitude in degrees (south = -)
135 double altitude; // starting altitude in meters
136 double heading; // heading (yaw) angle in degress (Psi)
137 double roll; // roll angle in degrees (Phi)
138 double pitch; // pitch angle in degrees (Theta)
139 double uBody; // Body axis X velocity (U)
140 double vBody; // Body axis Y velocity (V)
141 double wBody; // Body axis Z velocity (W)
142 double vkcas; // Calibrated airspeed, knots
143 double mach; // Mach number
146 bool game_mode; // Game mode enabled/disabled
147 bool splash_screen; // show splash screen
148 bool intro_music; // play introductory music
149 int mouse_pointer; // show mouse pointer
150 fgControlMode control_mode; // primary control mode
151 fgAutoCoordMode auto_coordination; // enable auto coordination
154 bool hud_status; // HUD on/off
155 bool panel_status; // Panel on/off
156 bool sound; // play sound effects
159 // Flight Model options
160 int flight_model; // Core flight model code: jsb, larcsim, magic, etc.
161 string aircraft; // Aircraft to model
162 int model_hz; // number of FDM iterations per second
163 int speed_up; // Sim mechanics run this much faster than normal speed
164 int trim; // use the FDM trimming routine during init
165 // <0 --notrim set, 0 no trim, >0 trim
166 // default behavior is to enable trimming for jsbsim
167 // disable for all other fdm's
170 fgFogKind fog; // Fog nicest/fastest/disabled
171 bool clouds; // Enable clouds
172 double clouds_asl; // Cloud layer height above sea level
173 double fov; // Field of View
174 bool fullscreen; // Full screen mode enabled/disabled
175 int shading; // shading method, 0 = Flat, 1 = Smooth
176 bool skyblend; // Blend sky to haze (using polygons) or just clear
177 bool textures; // Textures enabled/disabled
178 bool wireframe; // Wireframe mode enabled/disabled
179 int xsize, ysize; // window size derived from geometry string
180 int bpp; // bits per pixel
181 fgViewMode view_mode; // view mode
184 int tile_radius; // Square radius of rendered tiles (around center
186 int tile_diameter; // Diameter of rendered tiles. for instance
187 // if tile_diameter = 3 then a 3 x 3 grid of tiles will
188 // be drawn. Increase this to see terrain that is
192 int units; // feet or meters
196 int time_offset; // Use this value to change time.
197 fgTimingOffsetType time_offset_type; // Will be set to one of the
198 // FG_TIME_* enums, to deterine how
199 // time_offset should be used
201 // Serial port configuration strings
202 string_list channel_options_list;
213 // Parse a single option
214 int parse_option( const string& arg );
216 // Parse the command line options
217 int parse_command_line( int argc, char **argv );
219 // Parse the command line options
220 int parse_config_file( const string& path );
222 // Print usage message
226 inline string get_fg_root() const { return fg_root; }
227 inline string get_airport_id() const { return airport_id; }
228 inline double get_lon() const { return lon; }
229 inline double get_lat() const { return lat; }
230 inline double get_altitude() const { return altitude; }
231 inline double get_heading() const { return heading; }
232 inline double get_roll() const { return roll; }
233 inline double get_pitch() const { return pitch; }
234 inline double get_uBody() const {return uBody;}
235 inline double get_vBody() const {return vBody;}
236 inline double get_wBody() const {return wBody;}
237 inline double get_vc() const {return vkcas;}
238 inline double get_mach() const {return mach;}
240 inline bool get_game_mode() const { return game_mode; }
241 inline bool get_splash_screen() const { return splash_screen; }
242 inline bool get_intro_music() const { return intro_music; }
243 inline int get_mouse_pointer() const { return mouse_pointer; }
244 inline bool get_anti_alias_hud() const { return anti_alias_hud; }
245 inline fgControlMode get_control_mode() const { return control_mode; }
246 inline void set_control_mode( fgControlMode mode ) { control_mode = mode; }
247 inline fgAutoCoordMode get_auto_coordination() const {
248 return auto_coordination;
250 inline void set_auto_coordination(fgAutoCoordMode m) {
251 auto_coordination = m;
253 inline bool get_hud_status() const { return hud_status; }
254 inline bool get_panel_status() const { return panel_status; }
255 inline bool get_sound() const { return sound; }
256 inline int get_flight_model() const { return flight_model; }
257 inline string get_aircraft() const { return aircraft; }
258 inline int get_model_hz() const { return model_hz; }
259 inline int get_speed_up() const { return speed_up; }
260 inline void set_speed_up( int speed ) { speed_up = speed; }
261 inline int get_trim_mode(void) { return trim; }
263 inline bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
264 inline fgFogKind get_fog() const { return fog; }
265 inline bool get_clouds() const { return clouds; }
266 inline double get_clouds_asl() const { return clouds_asl; }
267 inline double get_fov() const { return fov; }
268 inline bool get_fullscreen() const { return fullscreen; }
269 inline int get_shading() const { return shading; }
270 inline bool get_skyblend() const { return skyblend; }
271 inline bool get_textures() const { return textures; }
272 inline bool get_wireframe() const { return wireframe; }
273 inline int get_xsize() const { return xsize; }
274 inline int get_ysize() const { return ysize; }
275 inline int get_bpp() const { return bpp; }
276 inline fgViewMode get_view_mode() const { return view_mode; }
277 inline int get_tile_radius() const { return tile_radius; }
278 inline int get_tile_diameter() const { return tile_diameter; }
280 inline int get_units() const { return units; }
281 inline int get_tris_or_culled() const { return tris_or_culled; }
283 inline int get_time_offset() const { return time_offset; }
284 inline fgTimingOffsetType get_time_offset_type() const {
285 return time_offset_type;
288 inline string_list get_channel_options_list() const {
289 return channel_options_list;
292 inline bool get_network_olk() const { return network_olk; }
293 inline string get_net_id() const { return net_id; }
296 inline void set_fg_root (const string value) { fg_root = value; }
297 inline void set_airport_id( const string id ) { airport_id = id; }
298 inline void set_lon (double value) { lon = value; }
299 inline void set_lat (double value) { lat = value; }
300 inline void set_altitude (double value) { altitude = value; }
301 inline void set_heading (double value) { heading = value; }
302 inline void set_roll (double value) { roll = value; }
303 inline void set_pitch (double value) { pitch = value; }
304 inline void set_uBody (double value) { uBody = value; }
305 inline void set_vBody (double value) { vBody = value; }
306 inline void set_wBody (double value) { wBody = value; }
307 inline void set_vc (double value) { vkcas = value; }
308 inline void set_mach(double value) { mach = value; }
309 inline void set_game_mode (bool value) { game_mode = value; }
310 inline void set_splash_screen (bool value) { splash_screen = value; }
311 inline void set_intro_music (bool value) { intro_music = value; }
312 inline void set_mouse_pointer (int value) { mouse_pointer = value; }
313 inline void set_anti_alias_hud (bool value) { anti_alias_hud = value; }
314 inline void set_hud_status( bool status ) { hud_status = status; }
315 inline void set_sound (bool value) { sound = value; }
316 inline void set_flight_model (int value) { flight_model = value; }
317 inline void set_aircraft (const string &ac) { aircraft = ac; }
318 inline void set_model_hz (int value) { model_hz = value; }
319 inline void set_trim_mode(int value) { trim = value; }
320 inline void set_fog (fgFogKind value) { fog = value; }
321 inline void set_clouds( bool value ) { clouds = value; }
322 inline void set_clouds_asl( double value ) { clouds_asl = value; }
323 inline void set_fov( double amount ) { fov = amount; }
324 inline void set_fullscreen (bool value) { fullscreen = value; }
325 inline void set_shading (int value) { shading = value; }
326 inline void set_skyblend (bool value) { skyblend = value; }
327 inline void set_textures( bool status ) { textures = status; }
328 inline void set_wireframe (bool status) { wireframe = status; }
329 inline void cycle_fog( void ) {
330 if ( fog == FG_FOG_DISABLED ) {
331 fog = FG_FOG_FASTEST;
332 } else if ( fog == FG_FOG_FASTEST ) {
334 xglHint ( GL_FOG_HINT, GL_NICEST );
335 } else if ( fog == FG_FOG_NICEST ) {
336 fog = FG_FOG_DISABLED;
337 xglHint ( GL_FOG_HINT, GL_FASTEST );
341 inline void set_xsize( int x ) { xsize = x; }
342 inline void set_ysize( int y ) { ysize = y; }
343 inline void set_view_mode (fgViewMode value) { view_mode = value; }
344 inline void set_tile_radius (int value) { tile_radius = value; }
345 inline void set_tile_diameter (int value) { tile_diameter = value; }
346 inline void set_units (int value) { units = value; }
347 inline void set_tris_or_culled (int value) { tris_or_culled = value; }
348 inline void set_time_offset (int value) { time_offset = value; }
349 inline void set_time_offset_type (fgTimingOffsetType value) {
350 time_offset_type = value;
352 inline void cycle_view_mode() {
353 if ( view_mode == FG_VIEW_PILOT ) {
354 view_mode = FG_VIEW_FOLLOW;
355 } else if ( view_mode == FG_VIEW_FOLLOW ) {
356 view_mode = FG_VIEW_PILOT;
360 inline void set_network_olk( bool net ) { network_olk = net; }
361 inline void set_net_id( const string id ) { net_id = id; }
365 void parse_control( const string& mode );
366 double parse_time( const string& time_str );
367 long int parse_date( const string& date_str );
368 double parse_degree( const string& degree_str );
369 int parse_time_offset( const string& time_str );
370 int parse_tile_radius( const string& arg );
371 int parse_fdm( const string& fm );
372 double parse_fov( const string& arg );
373 bool parse_channel( const string& type, const string& channel_str );
377 extern fgOPTIONS current_options;
380 #endif /* _OPTIONS_HXX */