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 <Include/compiler.h>
45 #if defined(FX) && defined(XMESA)
46 extern bool global_fullscreen;
55 typedef vector < string > str_container;
56 typedef str_container::iterator str_iterator;
57 typedef str_container::const_iterator const_str_iterator;
92 FG_TIME_SYS_OFFSET = 1,
93 FG_TIME_GMT_OFFSET = 2,
94 FG_TIME_LAT_OFFSET = 3,
95 FG_TIME_SYS_ABSOLUTE = 4,
96 FG_TIME_GMT_ABSOLUTE = 5,
97 FG_TIME_LAT_ABSOLUTE = 6
109 FG_VIEW_FIRST_PERSON = 0,
115 FG_AUTO_COORD_NOT_SPECIFIED = 0,
116 FG_AUTO_COORD_DISABLED = 1,
117 FG_AUTO_COORD_ENABLED = 2
122 // The flight gear "root" directory
125 // Starting position and orientation
126 string airport_id; // ID of initial starting airport
127 double lon; // starting longitude in degrees (west = -)
128 double lat; // starting latitude in degrees (south = -)
129 double altitude; // starting altitude in meters
130 double heading; // heading (yaw) angle in degress (Psi)
131 double roll; // roll angle in degrees (Phi)
132 double pitch; // pitch angle in degrees (Theta)
133 double uBody; // Body axis X velocity (U)
134 double vBody; // Body axis Y velocity (V)
135 double wBody; // Body axis Z velocity (W)
138 bool game_mode; // Game mode enabled/disabled
139 bool splash_screen; // show splash screen
140 bool intro_music; // play introductory music
141 int mouse_pointer; // show mouse pointer
142 bool pause; // pause intially enabled/disabled
143 fgControlMode control_mode; // primary control mode
144 fgAutoCoordMode auto_coordination; // enable auto coordination
147 bool hud_status; // HUD on/off
148 bool panel_status; // Panel on/off
149 bool sound; // play sound effects
151 // Flight Model options
152 int flight_model; // Flight Model: FG_SLEW, FG_LARCSIM, etc.
153 int model_hz; // number of FDM iterations per second
154 int speed_up; // Sim mechanics run this much faster than normal speed
157 fgFogKind fog; // Fog nicest/fastest/disabled
158 double fov; // Field of View
159 bool fullscreen; // Full screen mode enabled/disabled
160 int shading; // shading method, 0 = Flat, 1 = Smooth
161 bool skyblend; // Blend sky to haze (using polygons) or just clear
162 bool textures; // Textures enabled/disabled
163 bool wireframe; // Wireframe mode enabled/disabled
164 int xsize, ysize; // window size derived from geometry string
165 fgViewMode view_mode; // view mode
168 int tile_radius; // Square radius of rendered tiles (around center
170 int tile_diameter; // Diameter of rendered tiles. for instance
171 // if tile_diameter = 3 then a 3 x 3 grid of tiles will
172 // be drawn. Increase this to see terrain that is
176 int units; // feet or meters
180 int time_offset; // Use this value to change time.
181 int time_offset_type; // Will be set to one of the FG_TIME_* enums,
182 // To deterine how time_offset should be used
184 // Serial Ports, we currently support up to four channels
185 // fgSerialPortKind port_a_kind; // Port a kind
186 // fgSerialPortKind port_b_kind; // Port b kind
187 // fgSerialPortKind port_c_kind; // Port c kind
188 // fgSerialPortKind port_d_kind; // Port d kind
190 // Serial port configuration strings
191 str_container port_options_list;
201 // Parse a single option
202 int parse_option( const string& arg );
204 // Parse the command line options
205 int parse_command_line( int argc, char **argv );
207 // Parse the command line options
208 int parse_config_file( const string& path );
210 // Print usage message
214 inline string get_fg_root() const { return fg_root; }
215 inline string get_airport_id() const { return airport_id; }
216 inline double get_lon() const { return lon; }
217 inline double get_lat() const { return lat; }
218 inline double get_altitude() const { return altitude; }
219 inline double get_heading() const { return heading; }
220 inline double get_roll() const { return roll; }
221 inline double get_pitch() const { return pitch; }
222 inline double get_uBody() const {return uBody;}
223 inline double get_vBody() const {return vBody;}
224 inline double get_wBody() const {return wBody;}
225 inline bool get_game_mode() const { return game_mode; }
226 inline bool get_splash_screen() const { return splash_screen; }
227 inline bool get_intro_music() const { return intro_music; }
228 inline int get_mouse_pointer() const { return mouse_pointer; }
229 inline bool get_pause() const { return pause; }
230 inline fgControlMode get_control_mode() const { return control_mode; }
231 inline void set_control_mode( fgControlMode mode ) { control_mode = mode; }
232 inline fgAutoCoordMode get_auto_coordination() const {
233 return auto_coordination;
235 inline void set_auto_coordination(fgAutoCoordMode m) {
236 auto_coordination = m;
238 inline bool get_hud_status() const { return hud_status; }
239 inline bool get_panel_status() const { return panel_status; }
240 inline bool get_sound() const { return sound; }
241 inline int get_flight_model() const { return flight_model; }
242 inline int get_model_hz() const { return model_hz; }
243 inline int get_speed_up() const { return speed_up; }
244 inline void set_speed_up( int speed ) { speed_up = speed; }
245 inline bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
246 inline fgFogKind get_fog() const { return fog; }
247 inline double get_fov() const { return fov; }
248 inline bool get_fullscreen() const { return fullscreen; }
249 inline int get_shading() const { return shading; }
250 inline bool get_skyblend() const { return skyblend; }
251 inline bool get_textures() const { return textures; }
252 inline bool get_wireframe() const { return wireframe; }
253 inline int get_xsize() const { return xsize; }
254 inline int get_ysize() const { return ysize; }
255 inline fgViewMode get_view_mode() const { return view_mode; }
256 inline int get_tile_radius() const { return tile_radius; }
257 inline int get_tile_diameter() const { return tile_diameter; }
259 inline int get_units() const { return units; }
260 inline int get_tris_or_culled() const { return tris_or_culled; }
262 inline int get_time_offset() const { return time_offset; }
263 inline int get_time_offset_type() const { return time_offset_type; };
265 inline str_container get_port_options_list() const {
266 return port_options_list;
268 inline string get_net_id() const { return net_id; }
271 inline void set_airport_id( const string id ) { airport_id = id; }
272 inline void set_hud_status( bool status ) { hud_status = status; }
273 inline void set_fov( double amount ) { fov = amount; }
274 inline void set_textures( bool status ) { textures = status; }
275 inline void cycle_fog( void ) {
276 if ( fog == FG_FOG_DISABLED ) {
277 fog = FG_FOG_FASTEST;
278 } else if ( fog == FG_FOG_FASTEST ) {
280 xglHint ( GL_FOG_HINT, GL_NICEST );
281 } else if ( fog == FG_FOG_NICEST ) {
282 fog = FG_FOG_DISABLED;
283 xglHint ( GL_FOG_HINT, GL_FASTEST );
287 inline void set_xsize( int x ) { xsize = x; }
288 inline void set_ysize( int y ) { ysize = y; }
289 inline void cycle_view_mode() {
290 if ( view_mode == FG_VIEW_FIRST_PERSON ) {
291 view_mode = FG_VIEW_FOLLOW;
292 } else if ( view_mode == FG_VIEW_FOLLOW ) {
293 view_mode = FG_VIEW_FIRST_PERSON;
297 inline void set_net_id( const string id ) { net_id = id; }
301 void parse_control( const string& mode );
302 double parse_time( const string& time_str );
303 long int parse_date( const string& date_str );
304 double parse_degree( const string& degree_str );
305 int parse_time_offset( const string& time_str );
306 int parse_tile_radius( const string& arg );
307 int parse_fdm( const string& fm );
308 double parse_fov( const string& arg );
309 bool parse_serial( const string& serial_str );
313 extern fgOPTIONS current_options;
316 #endif /* _OPTIONS_HXX */