]> git.mxchange.org Git - flightgear.git/blob - Main/options.hxx
Fixes by Charlie Hotchkiss.
[flightgear.git] / Main / options.hxx
1 //
2 // options.hxx -- class to handle command line options
3 //
4 // Written by Curtis Olson, started April 1998.
5 //
6 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 // $Id$
23 // (Log is kept at end of this file)
24
25
26 #ifndef _OPTIONS_HXX
27 #define _OPTIONS_HXX
28
29
30 #ifndef __cplusplus
31 # error This library requires C++
32 #endif                                   
33
34 #ifdef HAVE_CONFIG_H
35 #  include <config.h>
36 #endif
37
38 #include <string>
39
40 #ifdef NEEDNAMESPACESTD
41 using namespace std;
42 #endif
43
44 class fgOPTIONS {
45 public:
46     enum
47     {
48         FG_OPTIONS_OK = 0,
49         FG_OPTIONS_HELP = 1,
50         FG_OPTIONS_ERROR = 2
51     };
52
53     enum fgFogKind
54     {
55         FG_FOG_DISABLED = 0,
56         FG_FOG_FASTEST  = 1,
57         FG_FOG_NICEST   = 2
58     };
59
60     static const int FG_RADIUS_MIN = 1;
61     static const int FG_RADIUS_MAX = 4;
62
63 private:
64
65     // The flight gear "root" directory
66     string fg_root;
67
68     // Starting position and orientation
69     string airport_id;  // ID of initial starting airport
70     double lon;         // starting longitude in degrees (west = -)
71     double lat;         // starting latitude in degrees (south = -)
72     double altitude;    // starting altitude in meters
73     double heading;     // heading (yaw) angle in degress (Psi)
74     double roll;        // roll angle in degrees (Phi)
75     double pitch;       // pitch angle in degrees (Theta)
76
77     // Miscellaneous
78     bool game_mode;     // Game mode enabled/disabled
79     bool splash_screen; // show splash screen
80     bool intro_music;   // play introductory music
81     int mouse_pointer;  // show mouse pointer
82     bool pause;         // pause intially enabled/disabled
83
84     // Features
85     bool hud_status;    // HUD on/off
86     bool panel_status;  // Panel on/off
87     bool sound;         // play sound effects
88
89     // Flight Model options
90     int flight_model;   // Flight Model:  FG_SLEW, FG_LARCSIM, etc.
91
92     // Rendering options
93     fgFogKind fog;      // Fog nicest/fastest/disabled
94     double fov;         // Field of View
95     bool fullscreen;    // Full screen mode enabled/disabled
96     int shading;        // shading method, 0 = Flat, 1 = Smooth
97     bool skyblend;      // Blend sky to haze (using polygons) or just clear
98     bool textures;      // Textures enabled/disabled
99     bool wireframe;     // Wireframe mode enabled/disabled
100
101     // Scenery options
102     int tile_radius;   // Square radius of rendered tiles (around center 
103                        // square.)
104     int tile_diameter; // Diameter of rendered tiles.  for instance
105                        // if tile_diameter = 3 then a 3 x 3 grid of tiles will 
106                        // be drawn.  Increase this to see terrain that is 
107                        // further away.
108
109     // HUD options
110     int tris_or_culled;
111
112     // Time options
113     int time_offset;   // Offset true time by this many seconds
114
115 public:
116
117     fgOPTIONS();
118     ~fgOPTIONS();
119
120     // Parse a single option
121     int parse_option( const string& arg );
122
123     // Parse the command line options
124     int parse_command_line( int argc, char **argv );
125
126     // Parse the command line options
127     int parse_config_file( const string& path );
128
129     // Print usage message
130     void usage ( void );
131
132     // Query functions
133     string get_fg_root() const { return fg_root; }
134     string get_airport_id() const { return airport_id; }
135     double get_lon() const { return lon; }
136     double get_lat() const { return lat; }
137     double get_altitude() const { return altitude; }
138     double get_heading() const { return heading; }
139     double get_roll() const { return roll; }
140     double get_pitch() const { return pitch; }
141     bool get_game_mode() const { return game_mode; }
142     bool get_splash_screen() const { return splash_screen; }
143     bool get_intro_music() const { return intro_music; }
144     int get_mouse_pointer() const { return mouse_pointer; }
145     bool get_pause() const { return pause; }
146     bool get_hud_status() const { return hud_status; }
147     bool get_panel_status() const { return panel_status; }
148     bool get_sound() const { return sound; }
149     int get_flight_model() const { return flight_model; }
150     bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
151     fgFogKind get_fog() const { return fog; }
152     double get_fov() const { return fov; }
153     bool get_fullscreen() const { return fullscreen; }
154     int get_shading() const { return shading; }
155     bool get_skyblend() const { return skyblend; }
156     bool get_textures() const { return textures; }
157     bool get_wireframe() const { return wireframe; }
158     int get_tile_radius() const { return tile_radius; }
159     int get_tile_diameter() const { return tile_diameter; }
160     int get_time_offset() const { return time_offset; }
161     int get_tris_or_culled() const { return tris_or_culled; }
162
163     // Update functions
164     void set_hud_status( bool status ) { hud_status = status; }
165     void set_fov( double amount ) { fov = amount; }
166
167 private:
168
169     double parse_time( const string& time_str );
170     double parse_degree( const string& degree_str );
171     int parse_time_offset( const string& time_str );
172     int parse_tile_radius( const string& arg );
173     int parse_flight_model( const string& fm );
174     double parse_fov( const string& arg );
175 };
176
177
178 extern fgOPTIONS current_options;
179
180
181 #endif /* _OPTIONS_HXX */
182
183
184 // $Log$
185 // Revision 1.17  1998/09/08 21:40:10  curt
186 // Fixes by Charlie Hotchkiss.
187 //
188 // Revision 1.16  1998/08/27 17:02:08  curt
189 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
190 // - use strings for fg_root and airport_id and added methods to return
191 //   them as strings,
192 // - inlined all access methods,
193 // - made the parsing functions private methods,
194 // - deleted some unused functions.
195 // - propogated some of these changes out a bit further.
196 //
197 // Revision 1.15  1998/08/24 20:11:15  curt
198 // Added i/I to toggle full vs. minimal HUD.
199 // Added a --hud-tris vs --hud-culled option.
200 // Moved options accessor funtions to options.hxx.
201 //
202 // Revision 1.14  1998/08/20 15:10:35  curt
203 // Added GameGLUT support.
204 //
205 // Revision 1.13  1998/07/30 23:48:29  curt
206 // Output position & orientation when pausing.
207 // Eliminated libtool use.
208 // Added options to specify initial position and orientation.
209 // Changed default fov to 55 degrees.
210 // Added command line option to start in paused or unpaused state.
211 //
212 // Revision 1.12  1998/07/27 18:41:26  curt
213 // Added a pause command "p"
214 // Fixed some initialization order problems between pui and glut.
215 // Added an --enable/disable-sound option.
216 //
217 // Revision 1.11  1998/07/13 21:01:39  curt
218 // Wrote access functions for current fgOPTIONS.
219 //
220 // Revision 1.10  1998/07/06 21:34:20  curt
221 // Added an enable/disable splash screen option.
222 // Added an enable/disable intro music option.
223 // Added an enable/disable instrument panel option.
224 // Added an enable/disable mouse pointer option.
225 // Added using namespace std for compilers that support this.
226 //
227 // Revision 1.9  1998/06/27 16:54:34  curt
228 // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
229 // Don't change the view port when displaying the panel.
230 //
231 // Revision 1.8  1998/05/16 13:08:36  curt
232 // C++ - ified views.[ch]xx
233 // Shuffled some additional view parameters into the fgVIEW class.
234 // Changed tile-radius to tile-diameter because it is a much better
235 //   name.
236 // Added a WORLD_TO_EYE transformation to views.cxx.  This allows us
237 //  to transform world space to eye space for view frustum culling.
238 //
239 // Revision 1.7  1998/05/13 18:29:59  curt
240 // Added a keyboard binding to dynamically adjust field of view.
241 // Added a command line option to specify fov.
242 // Adjusted terrain color.
243 // Root path info moved to fgOPTIONS.
244 // Added ability to parse options out of a config file.
245 //
246 // Revision 1.6  1998/05/06 03:16:26  curt
247 // Added an averaged global frame rate counter.
248 // Added an option to control tile radius.
249 //
250 // Revision 1.5  1998/05/03 00:47:32  curt
251 // Added an option to enable/disable full-screen mode.
252 //
253 // Revision 1.4  1998/04/30 12:34:19  curt
254 // Added command line rendering options:
255 //   enable/disable fog/haze
256 //   specify smooth/flat shading
257 //   disable sky blending and just use a solid color
258 //   enable wireframe drawing mode
259 //
260 // Revision 1.3  1998/04/28 01:20:23  curt
261 // Type-ified fgTIME and fgVIEW.
262 // Added a command line option to disable textures.
263 //
264 // Revision 1.2  1998/04/25 15:11:13  curt
265 // Added an command line option to set starting position based on airport ID.
266 //
267 // Revision 1.1  1998/04/24 00:49:21  curt
268 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
269 // Trying out some different option parsing code.
270 // Some code reorganization.
271 //
272 //