]> git.mxchange.org Git - flightgear.git/commitdiff
Stefan Seifert: implement persistent dialog options, so changes in rendering, static...
authorehofman <ehofman>
Sat, 17 Dec 2005 15:34:37 +0000 (15:34 +0000)
committerehofman <ehofman>
Sat, 17 Dec 2005 15:34:37 +0000 (15:34 +0000)
src/Main/fg_commands.cxx
src/Main/fg_init.cxx
src/Main/fg_props.cxx
src/Main/fg_props.hxx

index 21a5b7d2a8f04e20fa4d7a1cc80ee053629ac959..a23b5355e998cf379df684fbfc4f5a3758464078 100644 (file)
@@ -189,9 +189,26 @@ do_nasal (const SGPropertyNode * arg)
 static bool
 do_exit (const SGPropertyNode * arg)
 {
-  SG_LOG(SG_INPUT, SG_INFO, "Program exit requested.");
-  fgExit(arg->getIntValue("status", 0));
-  return true;
+    SG_LOG(SG_INPUT, SG_INFO, "Program exit requested.");
+
+    char* envp = ::getenv( "HOME" );
+    if ( envp != NULL ) {
+        SGPath config( globals->get_fg_root() );
+        config.set( envp );
+        config.append( ".fgfs" );
+        config.append( "preferences.xml" );
+        config.create_dir( 0700 );
+        SG_LOG(SG_IO, SG_INFO, "Saving user preferences");
+        try {
+            writeProperties(config.str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
+        } catch (const sg_exception &e) {
+            guiErrorMessage("Error saving preferences: ", e);
+        }
+
+        SG_LOG(SG_INPUT, SG_BULK, "Finished Saving user preferences");
+    }
+    fgExit(arg->getIntValue("status", 0));
+    return true;
 }
 
 
index 14660cd459dd93bb2010ece96d1ab126911e5de9..e1bb2e56588147861b1dc3b8c9a0fdaeebdba3fb 100644 (file)
@@ -607,6 +607,18 @@ bool fgInitConfig ( int argc, char **argv ) {
         SG_LOG( SG_INPUT, SG_ALERT, "No default aircraft specified" );
     }
 
+
+    char* envp = ::getenv( "HOME" );
+    if ( envp != NULL ) {
+        SGPath config( globals->get_fg_root() );
+        config.set( envp );
+        config.append( ".fgfs" );
+        config.append( "preferences.xml" );
+        SG_LOG(SG_INPUT, SG_INFO, "Reading user preferences");
+        fgLoadProps(config.str().c_str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
+        SG_LOG(SG_INPUT, SG_BULK, "Finished Reading user preferences");
+    }
+
     // parse options after loading aircraft to ensure any user
     // overrides of defaults are honored.
     do_options(argc, argv);
index 4e3c9a3d471dfb255c0df1a959eedd79e051ca32..9c32d1d11276e50819644d97c634a47bd349ed4b 100644 (file)
@@ -585,7 +585,7 @@ fgLoadFlight (istream &input)
 
 
 bool
-fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root)
+fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root, int default_mode)
 {
     string fullpath;
     if (in_fg_root) {
@@ -597,7 +597,7 @@ fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root)
     }
 
     try {
-        readProperties(fullpath, props);
+        readProperties(fullpath, props, default_mode);
     } catch (const sg_exception &e) {
         guiErrorMessage("Error reading properties: ", e);
         return false;
index 8a53147c7395e18e9ffea06fcad40bab01de81bc..a6faf0b1e5d422918ecc53bfda772b487531739a 100644 (file)
@@ -69,7 +69,7 @@ extern bool fgLoadFlight (istream &input);
  *         otherwise.
  */
 extern bool fgLoadProps (const char * path, SGPropertyNode * props,
-                         bool in_fg_root = true);
+                         bool in_fg_root = true, int default_mode = 0);
 
 
 \f