]> git.mxchange.org Git - flightgear.git/blob - src/Main/options.hxx
Borland C++ tweaks.
[flightgear.git] / src / 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
23
24 #ifndef _OPTIONS_HXX
25 #define _OPTIONS_HXX
26
27
28 #ifndef __cplusplus
29 # error This library requires C++
30 #endif                                   
31
32 #ifdef HAVE_CONFIG_H
33 #  include <config.h>
34 #endif
35
36 #include <Include/compiler.h>
37
38 #ifdef HAVE_WINDOWS_H
39 #  include <windows.h>
40 #endif
41
42 #include <GL/glut.h>
43 #include <XGL/xgl.h>
44
45 #if defined(FX) && defined(XMESA)
46 extern bool global_fullscreen;
47 #endif
48
49 #include STL_STRING
50 #include <vector>
51
52 FG_USING_STD(vector);
53 FG_USING_STD(string);
54
55 typedef vector < string > str_container;
56 typedef str_container::iterator str_iterator;
57 typedef str_container::const_iterator const_str_iterator;
58
59
60 class fgOPTIONS {
61
62 public:
63
64     enum
65     {
66         FG_OPTIONS_OK = 0,
67         FG_OPTIONS_HELP = 1,
68         FG_OPTIONS_ERROR = 2
69     };
70
71     enum
72     {
73         FG_UNITS_FEET = 0,
74         FG_UNITS_METERS = 1
75     };
76
77     enum fgFogKind
78     {
79         FG_FOG_DISABLED = 0,
80         FG_FOG_FASTEST  = 1,
81         FG_FOG_NICEST   = 2
82     };
83
84     enum
85     {
86         FG_RADIUS_MIN = 1,
87         FG_RADIUS_MAX = 4
88     };
89
90 private:
91
92     // The flight gear "root" directory
93     string fg_root;
94
95     // Starting position and orientation
96     string airport_id;  // ID of initial starting airport
97     double lon;         // starting longitude in degrees (west = -)
98     double lat;         // starting latitude in degrees (south = -)
99     double altitude;    // starting altitude in meters
100     double heading;     // heading (yaw) angle in degress (Psi)
101     double roll;        // roll angle in degrees (Phi)
102     double pitch;       // pitch angle in degrees (Theta)
103
104     // Miscellaneous
105     bool game_mode;     // Game mode enabled/disabled
106     bool splash_screen; // show splash screen
107     bool intro_music;   // play introductory music
108     int mouse_pointer;  // show mouse pointer
109     bool pause;         // pause intially enabled/disabled
110
111     // Features
112     bool hud_status;    // HUD on/off
113     bool panel_status;  // Panel on/off
114     bool sound;         // play sound effects
115
116     // Flight Model options
117     int flight_model;   // Flight Model:  FG_SLEW, FG_LARCSIM, etc.
118
119     // Rendering options
120     fgFogKind fog;      // Fog nicest/fastest/disabled
121     double fov;         // Field of View
122     bool fullscreen;    // Full screen mode enabled/disabled
123     int shading;        // shading method, 0 = Flat, 1 = Smooth
124     bool skyblend;      // Blend sky to haze (using polygons) or just clear
125     bool textures;      // Textures enabled/disabled
126     bool wireframe;     // Wireframe mode enabled/disabled
127     int xsize, ysize;   // window size derived from geometry string
128
129     // Scenery options
130     int tile_radius;   // Square radius of rendered tiles (around center 
131                        // square.)
132     int tile_diameter; // Diameter of rendered tiles.  for instance
133                        // if tile_diameter = 3 then a 3 x 3 grid of tiles will 
134                        // be drawn.  Increase this to see terrain that is 
135                        // further away.
136
137     // HUD options
138     int units;         // feet or meters
139     int tris_or_culled;
140
141     // Time options
142     int time_offset;   // Offset true time by this many seconds
143     long int start_gst;     // Specify a greenwich sidereal time (gst)
144     long int start_lst;     // Specify a local sidereal time (lst)
145
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
151
152     // Serial port configuration strings
153     str_container port_options_list;
154     
155 public:
156
157     fgOPTIONS();
158     ~fgOPTIONS();
159
160     // Parse a single option
161     int parse_option( const string& arg );
162
163     // Parse the command line options
164     int parse_command_line( int argc, char **argv );
165
166     // Parse the command line options
167     int parse_config_file( const string& path );
168
169     // Print usage message
170     void usage ( void );
171
172     // Query functions
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; }
202
203     inline int get_units() const { return units; }
204     inline int get_tris_or_culled() const { return tris_or_culled; }
205
206     inline int get_time_offset() const { return time_offset; }
207     inline long int get_start_gst() const { return start_gst; };
208     inline long int get_start_lst() const { return start_lst; }
209
210     inline str_container get_port_options_list() const { 
211         return port_options_list;
212     }
213
214     // Update functions
215     inline void set_airport_id( const string id ) { airport_id = id; }
216     inline void set_hud_status( bool status ) { hud_status = status; }
217     inline void set_fov( double amount ) { fov = amount; }
218     inline void set_textures( bool status ) { textures = status; }
219     inline void cycle_fog( void ) { 
220         if ( fog == FG_FOG_DISABLED ) {
221             fog = FG_FOG_FASTEST;
222         } else if ( fog == FG_FOG_FASTEST ) {
223             fog = FG_FOG_NICEST;
224             xglHint ( GL_FOG_HINT, GL_NICEST );
225         } else if ( fog == FG_FOG_NICEST ) {
226             fog = FG_FOG_DISABLED;
227             xglHint ( GL_FOG_HINT, GL_FASTEST );
228         }
229     }
230     void toggle_panel();
231     inline void set_xsize( int x ) { xsize= x; }
232     inline void set_ysize( int y ) { xsize= y; }
233
234 private:
235
236     double parse_time( const string& time_str );
237     long int parse_date( const string& date_str );
238     double parse_degree( const string& degree_str );
239     int parse_time_offset( const string& time_str );
240     int parse_tile_radius( const string& arg );
241     int parse_fdm( const string& fm );
242     double parse_fov( const string& arg );
243     bool parse_serial( const string& serial_str );
244 };
245
246
247 extern fgOPTIONS current_options;
248
249
250 #endif /* _OPTIONS_HXX */
251
252