]> git.mxchange.org Git - flightgear.git/blobdiff - utils/fgviewer/fgviewer.cxx
Merge branch 'next' of git://gitorious.org/fg/flightgear into next
[flightgear.git] / utils / fgviewer / fgviewer.cxx
index 42f2104ca4c5678c8a5bf8ac72848fb90a2784e0..c7a6599941d607b97da317da2af8de12a0d2ad14 100644 (file)
@@ -12,6 +12,7 @@
 #include <osgGA/TerrainManipulator>
 
 #include <simgear/props/props.hxx>
+#include <simgear/props/props_io.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/material/matlib.hxx>
 #include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
@@ -57,14 +58,14 @@ main(int argc, char** argv)
     osgGA::KeySwitchMatrixManipulator* keyswitchManipulator;
     keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
     
-    osgGA::MatrixManipulator* mm = new osgGA::TrackballManipulator;
-    keyswitchManipulator->addMatrixManipulator('1', "Trackball", mm);
-    mm = new osgGA::FlightManipulator;
-    keyswitchManipulator->addMatrixManipulator('2', "Flight", mm);
-    mm = new osgGA::DriveManipulator;
-    keyswitchManipulator->addMatrixManipulator('3', "Drive", mm);
-    mm = new osgGA::TerrainManipulator;
-    keyswitchManipulator->addMatrixManipulator('4', "Terrain", mm);
+    keyswitchManipulator->addMatrixManipulator('1', "Trackball",
+                                               new osgGA::TrackballManipulator);
+    keyswitchManipulator->addMatrixManipulator('2', "Flight",
+                                               new osgGA::FlightManipulator);
+    keyswitchManipulator->addMatrixManipulator('3', "Drive",
+                                               new osgGA::DriveManipulator);
+    keyswitchManipulator->addMatrixManipulator('4', "Terrain",
+                                               new osgGA::TerrainManipulator);
     
     viewer.setCameraManipulator(keyswitchManipulator);
 
@@ -109,7 +110,17 @@ main(int argc, char** argv)
     }
 
     SGSharedPtr<SGPropertyNode> props = new SGPropertyNode;
-    props->getNode("sim/startup/season", true)->setStringValue("summer");
+    try {
+        SGPath preferencesFile = fg_root;
+        preferencesFile.append("preferences.xml");
+        readProperties(preferencesFile.str(), props);
+    } catch (...) {
+        // In case of an error, at least make summer :)
+        props->getNode("sim/startup/season", true)->setStringValue("summer");
+
+        std::cerr << "Problems loading FlightGear preferences.\n"
+                  << "Probably FG_ROOT is not properly set." << std::endl;
+    }
     SGMaterialLib* ml = new SGMaterialLib;
     SGPath mpath(fg_root);
     mpath.append("materials.xml");