]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/options.cxx
Canvas: Allow using canvases as PUI widgets.
[flightgear.git] / src / Main / options.cxx
index 4ed3f3252f91b40ad1e79a8d1a57357198d4f233..77bbd78c01ffb9ab8ba32ea88c6344316badb9cb 100644 (file)
 #include "fg_props.hxx"
 #include "options.hxx"
 #include "util.hxx"
-#include "viewmgr.hxx"
 #include "main.hxx"
-#include <Main/viewer.hxx>
+#include "locale.hxx"
+#include <Viewer/viewer.hxx>
+#include <Viewer/viewmgr.hxx>
 #include <Environment/presets.hxx>
 
 #include <osg/Version>
@@ -732,7 +733,7 @@ fgOptMach( const char *arg )
 static int
 fgOptRoc( const char *arg )
 {
-    fgSetDouble("/velocities/vertical-speed-fps", atof(arg)/60);
+    fgSetDouble("/sim/presets/vertical-speed-fps", atof(arg)/60);
     return FG_OPTIONS_OK;
 }
 
@@ -1155,7 +1156,7 @@ fgOptScenario( const char *arg )
     }
     SGPropertyNode_ptr scenario = ai_node->getNode( "scenario", index + 1, true );
     scenario->setStringValue( arg );
-    ai_node->setBoolValue( "enabled", true );
+    ai_node->setBoolValue( "scenarios-enabled", true );
     return FG_OPTIONS_OK;
 }
 
@@ -1164,7 +1165,7 @@ fgOptNoScenarios( const char *arg )
 {
     SGPropertyNode_ptr ai_node = fgGetNode( "/sim/ai", true );
     ai_node->removeChildren("scenario",false);
-    ai_node->setBoolValue( "enabled", false );
+    ai_node->setBoolValue( "scenarios-enabled", false );
     return FG_OPTIONS_OK;
 }
 
@@ -1321,8 +1322,9 @@ struct OptionDesc {
     } fgOptionArray[] = {
 
     {"language",                     true,  OPTION_IGNORE, "", false, "", 0 },
-    {"disable-rembrandt",            false, OPTION_BOOL,   "/sim/rendering/rembrandt", false, "", 0 },
-    {"enable-rembrandt",             false, OPTION_BOOL,   "/sim/rendering/rembrandt", true, "", 0 },
+    {"disable-rembrandt",            false, OPTION_BOOL,   "/sim/rendering/rembrandt/enabled", false, "", 0 },
+    {"enable-rembrandt",             false, OPTION_BOOL,   "/sim/rendering/rembrandt/enabled", true, "", 0 },
+    {"renderer",                     true,  OPTION_STRING, "/sim/rendering/rembrandt/renderer", false, "", 0 },
     {"disable-game-mode",            false, OPTION_BOOL,   "/sim/startup/game-mode", false, "", 0 },
     {"enable-game-mode",             false, OPTION_BOOL,   "/sim/startup/game-mode", true, "", 0 },
     {"disable-splash-screen",        false, OPTION_BOOL,   "/sim/startup/splash-screen", false, "", 0 },
@@ -1333,6 +1335,10 @@ struct OptionDesc {
     {"enable-mouse-pointer",         false, OPTION_STRING, "/sim/startup/mouse-pointer", false, "enabled", 0 },
     {"disable-random-objects",       false, OPTION_BOOL,   "/sim/rendering/random-objects", false, "", 0 },
     {"enable-random-objects",        false, OPTION_BOOL,   "/sim/rendering/random-objects", true, "", 0 },
+    {"disable-random-vegetation",    false, OPTION_BOOL,   "/sim/rendering/random-vegetation", false, "", 0 },
+    {"enable-random-vegetation",     false, OPTION_BOOL,   "/sim/rendering/random-vegetation", true, "", 0 },
+    {"disable-random-buildings",     false, OPTION_BOOL,   "/sim/rendering/random-buildings", false, "", 0 },
+    {"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 },
@@ -1422,6 +1428,7 @@ struct OptionDesc {
     {"enable-fullscreen",            false, OPTION_BOOL,   "/sim/startup/fullscreen", true, "", 0 },
     {"disable-save-on-exit",         false, OPTION_BOOL,   "/sim/startup/save-on-exit", false, "", 0 },
     {"enable-save-on-exit",          false, OPTION_BOOL,   "/sim/startup/save-on-exit", true, "", 0 },
+    {"restore-defaults",             false, OPTION_BOOL,   "/sim/startup/restore-defaults", true, "", 0 },
     {"shading-flat",                 false, OPTION_BOOL,   "/sim/rendering/shading", false, "", 0 },
     {"shading-smooth",               false, OPTION_BOOL,   "/sim/rendering/shading", true, "", 0 },
     {"disable-skyblend",             false, OPTION_BOOL,   "/sim/rendering/skyblend", false, "", 0 },
@@ -1732,6 +1739,10 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
   } // of arguments iteration
   p->insertGroupMarker(); // command line is one group
   
+  // establish log-level before anything else - otherwise it is not possible
+  // to show extra (debug/info/warning) messages for the start-up phase.
+  fgOptLogLevel(valueForOption("log-level", "alert").c_str());
+
 // then config files
   SGPath config;
   
@@ -1971,11 +1982,10 @@ string_list Options::valuesForOption(const std::string& key) const
 
 void Options::processOptions()
 {
-  // establish locale before showing help
-  if (isOptionSet("language")) {
-      globals->set_locale( fgInitLocale( valueForOption("language").c_str() ) );
-  }
-    
+  // establish locale before showing help (this selects the default locale,
+  // when no explicit option was set)
+  globals->get_locale()->selectLanguage(valueForOption("language").c_str());
+
   // now FG_ROOT is setup, process various command line options that bail us
   // out quickly, but rely on aircraft / root settings
   if (p->showHelp) {
@@ -2064,12 +2074,12 @@ void Options::showUsage() const
 {
   fgOptLogLevel( "alert" );
   
-  SGPropertyNode *locale = globals->get_locale();
+  FGLocale *locale = globals->get_locale();
   SGPropertyNode options_root;
   
   SG_LOG( SG_GENERAL, SG_ALERT, "" ); // To popup the console on Windows
   cout << endl;
-  
+
   try {
     fgLoadProps("options.xml", &options_root);
   } catch (const sg_exception &) {
@@ -2080,17 +2090,23 @@ void Options::showUsage() const
     
     exit(-1);
   }
-  
+
   SGPropertyNode *options = options_root.getNode("options");
   if (!options) {
     SG_LOG( SG_GENERAL, SG_ALERT,
            "Error reading options.xml: <options> directive not found." );
     exit(-1);
   }
-  
-  SGPropertyNode *usage = locale->getNode(options->getStringValue("usage"));
+
+  if (!locale->loadResource("options"))
+  {
+      cout << "Unable to read the language resource." << endl;
+      exit(-1);
+  }
+
+  const char* usage = locale->getLocalizedString(options->getStringValue("usage"), "options");
   if (usage) {
-    cout << usage->getStringValue() << endl;
+    cout << usage << endl;
   }
   
   vector<SGPropertyNode_ptr>section = options->getChildren("section");
@@ -2131,21 +2147,17 @@ void Options::showUsage() const
           msg += tmp + '\n';
           msg.append(32, ' ');
         }
-        // There may be more than one <description> tag assosiated
+        // There may be more than one <description> tag associated
         // with one option
         
         vector<SGPropertyNode_ptr> desc;
         desc = option[k]->getChildren("description");
         if (desc.size() > 0) {
           for ( unsigned int l = 0; l < desc.size(); l++) {
-            
-            // There may be more than one translation line.
-            
             string t = desc[l]->getStringValue();
-            SGPropertyNode *n = locale->getNode("strings");
-            vector<SGPropertyNode_ptr>trans_desc =
-            n->getChildren(t.substr(8).c_str());
-            
+
+            // There may be more than one translation line.
+            vector<SGPropertyNode_ptr>trans_desc = locale->getLocalizedStrings(t.c_str(),"options");
             for ( unsigned int m = 0; m < trans_desc.size(); m++ ) {
               string t_str = trans_desc[m]->getStringValue();
               
@@ -2171,19 +2183,18 @@ void Options::showUsage() const
       }
     }
     
-    SGPropertyNode *name;
-    name = locale->getNode(section[j]->getStringValue("name"));
-    
+    const char* name = locale->getLocalizedString(section[j]->getStringValue("name"),"options");
     if (!msg.empty() && name) {
-      cout << endl << name->getStringValue() << ":" << endl;
+      cout << endl << name << ":" << endl;
       cout << msg;
       msg.erase();
     }
   }
   
   if ( !p->verbose ) {
-    cout << endl;
-    cout << "For a complete list of options use --help --verbose" << endl;
+    const char* verbose_help = locale->getLocalizedString(options->getStringValue("verbose-help"),"options");
+    if (verbose_help)
+        cout << endl << verbose_help << endl;
   }
 #ifdef _MSC_VER
   std::cout << "Hit a key to continue..." << std::endl;