-
- FGOptions();
- ~FGOptions();
-
- // Parse a single option
- int parse_option( const string& arg );
-
- // Scan the command line options for an fg_root definition and set
- // just that.
- int scan_command_line_for_root( int argc, char **argv );
-
- // Scan the config file for an fg_root definition and set just
- // that.
- int scan_config_file_for_root( const string& path );
-
- // Parse the command line options
- int parse_command_line( int argc, char **argv );
-
- // Parse the command line options
- int parse_config_file( const string& path );
-
- // Print usage message
- void usage ( void );
-
- // Query functions
- inline string get_fg_root() const { return fg_root; }
- inline string get_fg_scenery() const { return fg_scenery; }
- inline string get_airport_id() const { return airport_id; }
- inline double get_lon() const { return lon; }
- inline double get_lat() const { return lat; }
- inline double get_altitude() const { return altitude; }
- inline double get_heading() const { return heading; }
- inline double get_roll() const { return roll; }
- inline double get_pitch() const { return pitch; }
- inline double get_uBody() const {return uBody;}
- inline double get_vBody() const {return vBody;}
- inline double get_wBody() const {return wBody;}
- inline double get_vc() const {return vkcas;}
- inline double get_mach() const {return mach;}
-
- inline bool get_game_mode() const { return game_mode; }
- inline bool get_splash_screen() const { return splash_screen; }
- inline bool get_intro_music() const { return intro_music; }
- inline int get_mouse_pointer() const { return mouse_pointer; }
- inline bool get_anti_alias_hud() const { return anti_alias_hud; }
- inline fgControlMode get_control_mode() const { return control_mode; }
- inline void set_control_mode( fgControlMode mode ) { control_mode = mode; }
- inline fgAutoCoordMode get_auto_coordination() const {
- return auto_coordination;
- }
- inline void set_auto_coordination(fgAutoCoordMode m) {
- auto_coordination = m;
- }
- inline bool get_hud_status() const { return hud_status; }
- inline bool get_panel_status() const { return panel_status; }
- inline bool get_sound() const { return sound; }
- inline int get_flight_model() const { return flight_model; }
- inline string get_aircraft() const { return aircraft; }
- inline int get_model_hz() const { return model_hz; }
- inline int get_speed_up() const { return speed_up; }
- inline void set_speed_up( int speed ) { speed_up = speed; }
- inline int get_trim_mode(void) { return trim; }
-
- inline bool fog_enabled() const { return fog != FG_FOG_DISABLED; }
- inline fgFogKind get_fog() const { return fog; }
- inline bool get_clouds() const { return clouds; }
- inline double get_clouds_asl() const { return clouds_asl; }
- inline double get_fov() const { return fov; }
- inline bool get_fullscreen() const { return fullscreen; }
- inline int get_shading() const { return shading; }
- inline bool get_skyblend() const { return skyblend; }
- inline bool get_textures() const { return textures; }
- inline bool get_wireframe() const { return wireframe; }
- inline int get_xsize() const { return xsize; }
- inline int get_ysize() const { return ysize; }
- inline int get_xmin() const { return xmin; }
- inline int get_ymin() const { return ymin; }
- inline int get_xmax() const { return xmax; }
- inline int get_ymax() const { return ymax; }
- inline int get_bpp() const { return bpp; }
- inline fgViewMode get_view_mode() const { return view_mode; }
- inline double get_default_view_offset() const {
- return default_view_offset;
- }
-
-
- inline int get_tile_radius() const { return tile_radius; }
- inline int get_tile_diameter() const { return tile_diameter; }
-
- inline int get_units() const { return units; }
- inline int get_tris_or_culled() const { return tris_or_culled; }
-
- inline int get_time_offset() const { return time_offset; }
- inline fgTimingOffsetType get_time_offset_type() const {
- return time_offset_type;
- };
-
- inline string_list get_channel_options_list() const {
- return channel_options_list;
- }
-
- inline bool get_network_olk() const { return network_olk; }
- inline string get_net_id() const { return net_id; }
-
- // Update functions
- inline void set_fg_root (const string value) { fg_root = value; }
- inline void set_fg_scenery (const string value) { fg_scenery = value; }
- inline void set_airport_id( const string id ) { airport_id = id; }
- inline void set_lon (double value) { lon = value; }
- inline void set_lat (double value) { lat = value; }
- inline void set_altitude (double value) { altitude = value; }
- inline void set_heading (double value) { heading = value; }
- inline void set_roll (double value) { roll = value; }
- inline void set_pitch (double value) { pitch = value; }
- inline void set_uBody (double value) { uBody = value; }
- inline void set_vBody (double value) { vBody = value; }
- inline void set_wBody (double value) { wBody = value; }
- inline void set_vc (double value) { vkcas = value; }
- inline void set_mach(double value) { mach = value; }
- inline void set_game_mode (bool value) { game_mode = value; }
- inline void set_splash_screen (bool value) { splash_screen = value; }
- inline void set_intro_music (bool value) { intro_music = value; }
- inline void set_mouse_pointer (int value) { mouse_pointer = value; }
- inline void set_anti_alias_hud (bool value) { anti_alias_hud = value; }
- inline void set_hud_status( bool status ) { hud_status = status; }
- inline void set_sound (bool value) { sound = value; }
- inline void set_flight_model (int value) { flight_model = value; }
- inline void set_aircraft (const string &ac) { aircraft = ac; }
- inline void set_model_hz (int value) { model_hz = value; }
- inline void set_trim_mode(int value) { trim = value; }
- inline void set_fog (fgFogKind value) { fog = value; }
- inline void set_clouds( bool value ) { clouds = value; }
- inline void set_clouds_asl( double value ) { clouds_asl = value; }
- inline void set_fov( double amount ) { fov = amount; }
- inline void set_fullscreen (bool value) { fullscreen = value; }
- inline void set_shading (int value) { shading = value; }
- inline void set_skyblend (bool value) { skyblend = value; }
- inline void set_textures( bool status ) { textures = status; }
- inline void set_wireframe (bool status) { wireframe = status; }
- inline void cycle_fog( void ) {
- if ( fog == FG_FOG_DISABLED ) {
- fog = FG_FOG_FASTEST;
- } else if ( fog == FG_FOG_FASTEST ) {
- fog = FG_FOG_NICEST;
- xglHint ( GL_FOG_HINT, GL_NICEST );
- } else if ( fog == FG_FOG_NICEST ) {
- fog = FG_FOG_DISABLED;
- xglHint ( GL_FOG_HINT, GL_FASTEST );
- }
- }
- void toggle_panel();
- inline void set_xsize( int x ) { xsize = x; }
- inline void set_ysize( int y ) { ysize = y; }
- inline void set_view_mode (fgViewMode value) { view_mode = value; }
- inline void set_tile_radius (int value) { tile_radius = value; }
- inline void set_tile_diameter (int value) { tile_diameter = value; }
- inline void set_units (int value) { units = value; }
- inline void set_tris_or_culled (int value) { tris_or_culled = value; }
- inline void set_time_offset (int value) { time_offset = value; }
- inline void set_time_offset_type (fgTimingOffsetType value) {
- time_offset_type = value;
- }
- inline void cycle_view_mode() {
- if ( view_mode == FG_VIEW_PILOT ) {
- view_mode = FG_VIEW_FOLLOW;
- } else if ( view_mode == FG_VIEW_FOLLOW ) {
- view_mode = FG_VIEW_PILOT;
- }
- }
-
- inline void set_network_olk( bool net ) { network_olk = net; }
- inline void set_net_id( const string id ) { net_id = id; }
-
+ static Options* sharedInstance();
+
+ ~Options();
+
+ /**
+ * pass command line arguments, read default config files
+ */
+ void init(int argc, char* argv[], const SGPath& appDataPath);
+
+ /**
+ * parse a config file (eg, .fgfsrc)
+ */
+ void readConfig(const SGPath& path);
+
+ /**
+ * read the value for an option, if it has been set
+ */
+ std::string valueForOption(const std::string& key, const std::string& defValue = std::string()) const;
+
+ /**
+ * return all values for a multi-valued option
+ */
+ string_list valuesForOption(const std::string& key) const;
+
+ /**
+ * check if a particular option has been set (so far)
+ */
+ bool isOptionSet(const std::string& key) const;
+
+
+ /**
+ * set an option value, assuming it is not already set (or multiple values
+ * are permitted)
+ * This can be used to inject option values, eg based upon environment variables
+ */
+ int addOption(const std::string& key, const std::string& value);
+
+ /**
+ * set an option, overwriting any existing value which might be set
+ */
+ int setOption(const std::string& key, const std::string& value);
+
+ void clearOption(const std::string& key);
+
+ /**
+ * apply option values to the simulation state
+ * (set properties, etc).
+ */
+ OptionResult processOptions();
+
+ /**
+ * process command line options relating to scenery / aircraft / data paths
+ */
+ void initPaths();
+
+ /**
+ * init the aircraft options
+ */
+ void initAircraft();
+
+ /**
+ * should defualt configuration files be loaded and processed or not?
+ * There's many configuration files we have historically read by default
+ * on startup - preferences.xml, fgfs.rc in various places and so on.
+ * --no-default-config allows this behaviour to be changed, so only
+ * expicitly listed files are read - this is useful for testing. Expose
+ * the value of the option here.
+ */
+ bool shouldLoadDefaultConfig() const;
+
+ /**
+ * check if the arguments array contains a particular string (with a '--' or
+ * '-' prefix).
+ * Used by early startup code before Options object is created
+ */
+ static bool checkForArg(int argc, char* argv[], const char* arg);
+
+ std::string platformDefaultRoot() const;