]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_commands.cxx
Centralized most view-management code in FGViewMgr. It's still a
[flightgear.git] / src / Main / fg_commands.cxx
index b6bf7f043d659c13eb98e065d0504dbdb08c6ae9..678a20a6b83861644c81370f5ec93f1e643d126f 100644 (file)
@@ -58,6 +58,8 @@ public:
     { return _wrap ? _wrap : &_dummy_0; }
   virtual const SGPropertyNode * getFactor () const 
     { return _factor ? _factor : &_dummy_1; }
+  virtual const SGPropertyNode * getSquared () const 
+    { return _squared ? _squared : &_dummy_1; }
   virtual const SGPropertyNode * getSetting () const 
     { return _setting ? _setting : &_dummy_0; }
   virtual const SGPropertyNode * getOffset () const
@@ -73,6 +75,7 @@ private:
   const SGPropertyNode * _max;
   const SGPropertyNode * _wrap;
   const SGPropertyNode * _factor;
+  const SGPropertyNode * _squared;
   const SGPropertyNode * _setting;
   const SGPropertyNode * _offset;
 };
@@ -90,6 +93,7 @@ PropertyCommandState::PropertyCommandState (const SGPropertyNode * arg)
     _max(arg->getNode("max")),
     _wrap(arg->getNode("wrap")),
     _factor(arg->getNode("factor")),
+    _squared(arg->getNode("squared")),
     _setting(arg->getNode("setting")),
     _offset(arg->getNode("offset"))
 {
@@ -164,9 +168,10 @@ static bool
 do_save (const SGPropertyNode * arg, SGCommandState ** state)
 {
   const string &file = arg->getStringValue("file", "fgfs.sav");
+  bool write_all = arg->getBoolValue("write-all", false);
   SG_LOG(SG_INPUT, SG_INFO, "Saving flight");
   ofstream output(file.c_str());
-  if (output.good() && fgSaveFlight(output)) {
+  if (output.good() && fgSaveFlight(output, write_all)) {
     output.close();
     SG_LOG(SG_INPUT, SG_INFO, "Saved flight to " << file);
     return true;
@@ -238,7 +243,7 @@ static bool
 do_view_cycle (const SGPropertyNode * arg, SGCommandState ** state)
 {
   globals->get_current_view()->set_view_offset(0.0);
-  globals->set_current_view(globals->get_viewmgr()->next_view());
+  globals->get_viewmgr()->next_view();
   if ( fgGetString("/sim/flight-model") == "ada" ) {
       globals->get_props()->setBoolValue( "/sim/hud/visibility", true );
       if ( globals->get_viewmgr()->get_current() == 1 ) {
@@ -267,24 +272,28 @@ do_screen_capture (const SGPropertyNode * arg, SGCommandState ** state)
 static bool
 do_tile_cache_reload (const SGPropertyNode * arg, SGCommandState ** state)
 {
-  bool freeze = globals->get_freeze();
-  SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache");
-  if ( !freeze ) 
-    globals->set_freeze( true );
-  BusyCursor(0);
-  if ( global_tile_mgr.init() ) {
-    // Load the local scenery data
-    global_tile_mgr.update(fgGetDouble("/position/longitude-deg"),
-                          fgGetDouble("/position/latitude-deg"));
-  } else {
-    SG_LOG( SG_GENERAL, SG_ALERT, 
-           "Error in Tile Manager initialization!" );
-    exit(-1);
-  }
-  BusyCursor(1);
-  if ( !freeze )
-    globals->set_freeze( false );
-  return true;
+    static const SGPropertyNode *master_freeze
+       = fgGetNode("/sim/freeze/master");
+    bool freeze = master_freeze->getBoolValue();
+    SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache");
+    if ( !freeze ) {
+       fgSetBool("/sim/freeze/master", true);
+    }
+    // BusyCursor(0);
+    if ( global_tile_mgr.init() ) {
+       // Load the local scenery data
+       global_tile_mgr.update(fgGetDouble("/position/longitude-deg"),
+                              fgGetDouble("/position/latitude-deg"));
+    } else {
+       SG_LOG( SG_GENERAL, SG_ALERT, 
+               "Error in Tile Manager initialization!" );
+       exit(-1);
+    }
+    // BusyCursor(1);
+    if ( !freeze ) {
+       fgSetBool("/sim/freeze/master", false);
+    }
+    return true;
 }
 
 
@@ -532,8 +541,14 @@ do_property_scale (const SGPropertyNode * arg, SGCommandState ** state)
     ((PropertyCommandState *)(*state))->getOffset()->getDoubleValue();
   double factor =
     ((PropertyCommandState *)(*state))->getFactor()->getDoubleValue();
+  bool squared =
+    ((PropertyCommandState *)(*state))->getSquared()->getBoolValue();
+
+  if (squared)
+    setting = (setting < 0 ? -1 : 1) * setting * setting;
+  double result = (setting + offset) * factor;
 
-  return prop->setDoubleValue((setting + offset) * factor);
+  return prop->setDoubleValue(result);
 }