return FG_OPTIONS_OK;
}
+static int
+fgOptTerrasyncDir( const char *arg )
+{
+ globals->append_fg_scenery(arg, true);
+ fgSetString("/sim/terrasync/scenery-dir", arg);
+ return FG_OPTIONS_OK;
+}
+
static int
fgOptFov( const char *arg )
{
return FG_OPTIONS_OK;
}
+static int
+fgOptMetar( const char *arg )
+{
+ // The given METAR string cannot be effective without disabling
+ // real weather fetching.
+ fgSetBool("/environment/realwx/enabled", false);
+ // The user-supplied METAR string
+ fgSetString("/environment/metar/data", arg);
+
+ return FG_OPTIONS_OK;
+}
+
static int
fgOptRandomWind( const char *arg )
{
{"enable-random-buildings", false, OPTION_BOOL, "/sim/rendering/random-buildings", true, "", 0 },
{"disable-real-weather-fetch", false, OPTION_BOOL, "/environment/realwx/enabled", false, "", 0 },
{"enable-real-weather-fetch", false, OPTION_BOOL, "/environment/realwx/enabled", true, "", 0 },
- {"metar", true, OPTION_STRING, "/environment/metar/data", false, "", 0 },
+ {"metar", true, OPTION_FUNC, "", false, "", fgOptMetar },
{"disable-ai-models", false, OPTION_BOOL, "/sim/ai/enabled", false, "", 0 },
{"enable-ai-models", false, OPTION_BOOL, "/sim/ai/enabled", true, "", 0 },
{"disable-ai-traffic", false, OPTION_BOOL, "/sim/traffic-manager/enabled", false, "", 0 },
{"materials-file", true, OPTION_STRING, "/sim/rendering/materials-file", false, "", 0 },
{"disable-terrasync", false, OPTION_BOOL, "/sim/terrasync/enabled", false, "", 0 },
{"enable-terrasync", false, OPTION_BOOL, "/sim/terrasync/enabled", true, "", 0 },
- {"terrasync-dir", true, OPTION_STRING, "/sim/terrasync/scenery-dir", false, "", 0 },
+ {"terrasync-dir", true, OPTION_FUNC, "", false, "", fgOptTerrasyncDir },
{"download-dir", true, OPTION_STRING, "/sim/paths/download-dir", false, "", 0 },
{"geometry", true, OPTION_FUNC, "", false, "", fgOptGeometry },
{"bpp", true, OPTION_FUNC, "", false, "", fgOptBpp },
return it; // not found
}
+
+ OptionValueVec::iterator findValue(const string& key)
+ {
+ OptionValueVec::iterator it = values.begin();
+ for (; it != values.end(); ++it) {
+ if (!it->desc) {
+ continue; // ignore markers
+ }
+
+ if (it->desc->option == key) {
+ return it;
+ }
+ } // of set values iteration
+
+ return it; // not found
+ }
OptionDesc* findOption(const string& key) const
{
p->values.push_back(OptionValue(desc, value));
return FG_OPTIONS_OK;
}
-
+
+int Options::setOption(const string &key, const string &value)
+{
+ OptionDesc* desc = p->findOption(key);
+ if (!desc) {
+ flightgear::modalMessageBox("Unknown option", "Unknown command-line option: " + key);
+ return FG_OPTIONS_ERROR;
+ }
+
+ if (!(desc->type & OPTION_MULTI)) {
+ OptionValueVec::iterator it = p->findValue(key);
+ if (it != p->values.end()) {
+ // remove existing valye
+ p->values.erase(it);
+ }
+ }
+
+ p->values.push_back(OptionValue(desc, value));
+ return FG_OPTIONS_OK;
+}
+
+void Options::clearOption(const std::string& key)
+{
+ OptionValueVec::iterator it = p->findValue(key);
+ for (; it != p->values.end(); it = p->findValue(key)) {
+ p->values.erase(it);
+ }
+}
+
bool Options::isOptionSet(const string &key) const
{
OptionValueVec::const_iterator it = p->findValue(key);