]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel.cxx
Use !strcmp for all property string-value comparisons.
[flightgear.git] / src / Cockpit / panel.cxx
index e3fcbe6782adb68358743ecd376062d0ededa186..7538e29b673b5307083e7a2f2df0d9761ff5ed03 100644 (file)
@@ -83,11 +83,16 @@ get_aspect_adjust (int xsize, int ysize)
 bool
 fgPanelVisible ()
 {
-    return (fgGetBool("/sim/virtual-cockpit") ||
-           ((current_panel != 0) &&
-            (current_panel->getVisibility()) &&
-            (globals->get_viewmgr()->get_current() == 0) &&
-            (globals->get_current_view()->get_view_offset() == 0.0)));
+     if(current_panel == 0)
+       return false;
+     if(current_panel->getVisibility() == 0)
+       return false;
+     if(globals->get_viewmgr()->get_current() != 0)
+       return false;
+     if(globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS != 0 &&
+        !fgGetBool("/sim/virtual-cockpit"))
+       return false;
+     return true;
 }
 
 
@@ -175,7 +180,6 @@ FGPanel::FGPanel ()
     _mouseInstrument(0),
     _width(WIN_W), _height(int(WIN_H * 0.5768 + 1)),
     _x_offset(0), _y_offset(0), _view_height(int(WIN_H * 0.4232)),
-    _bound(false),
     _jitter(0.0),
     _xsize_node(fgGetNode("/sim/startup/xsize", true)),
     _ysize_node(fgGetNode("/sim/startup/ysize", true))
@@ -189,8 +193,6 @@ FGPanel::FGPanel ()
  */
 FGPanel::~FGPanel ()
 {
-  if (_bound)
-    unbind();
   for (instrument_list_type::iterator it = _instruments.begin();
        it != _instruments.end();
        it++) {
@@ -247,15 +249,10 @@ FGPanel::init ()
 void
 FGPanel::bind ()
 {
-  fgTie("/sim/panel/visibility", &_visibility);
   fgSetArchivable("/sim/panel/visibility");
-  fgTie("/sim/panel/x-offset", &_x_offset);
   fgSetArchivable("/sim/panel/x-offset");
-  fgTie("/sim/panel/y-offset", &_y_offset);
   fgSetArchivable("/sim/panel/y-offset");
-  fgTie("/sim/panel/jitter", &_jitter);
   fgSetArchivable("/sim/panel/jitter");
-  _bound = true;
 }
 
 
@@ -265,10 +262,6 @@ FGPanel::bind ()
 void
 FGPanel::unbind ()
 {
-  fgUntie("/sim/panel/visibility");
-  fgUntie("/sim/panel/x-offset");
-  fgUntie("/sim/panel/y-offset");
-  _bound = false;
 }
 
 
@@ -278,6 +271,12 @@ FGPanel::unbind ()
 void
 FGPanel::update (int dt)
 {
+                               // TODO: cache the nodes
+    _visibility = fgGetBool("/sim/panel/visibility");
+    _x_offset = fgGetInt("/sim/panel/x-offset");
+    _y_offset = fgGetInt("/sim/panel/y-offset");
+    _jitter = fgGetFloat("/sim/panel/jitter");
+
                                // Do nothing if the panel isn't visible.
     if ( !fgPanelVisible() ) {
         return;
@@ -453,8 +452,8 @@ FGPanel::setupVirtualCockpit()
     // Generate a "look at" matrix using OpenGL (!) coordinate
     // conventions.
     float lookat[3];
-    float pitch = view->get_view_tilt();
-    float rot = view->get_view_offset();
+    float pitch = view->getPitchOffset_deg() * SGD_DEGREES_TO_RADIANS;
+    float rot = view->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS;
     lookat[0] = -sin(rot);
     lookat[1] = sin(pitch) / cos(pitch);
     lookat[2] = -cos(rot);
@@ -1077,7 +1076,7 @@ FGTextLayer::Chunk::Chunk (const string &text, const string &fmt)
   : _type(FGTextLayer::TEXT), _fmt(fmt)
 {
   _text = text;
-  if (_fmt == ""
+  if (_fmt.empty()
     _fmt = "%s";
 }
 
@@ -1085,7 +1084,7 @@ FGTextLayer::Chunk::Chunk (ChunkType type, const SGPropertyNode * node,
                           const string &fmt, float mult)
   : _type(type), _fmt(fmt), _mult(mult)
 {
-  if (_fmt == "") {
+  if (_fmt.empty()) {
     if (type == TEXT_VALUE)
       _fmt = "%s";
     else
@@ -1103,7 +1102,7 @@ FGTextLayer::Chunk::getValue () const
       sprintf(_buf, _fmt.c_str(), _text.c_str());
       return _buf;
     case TEXT_VALUE:
-      sprintf(_buf, _fmt.c_str(), _node->getStringValue().c_str());
+      sprintf(_buf, _fmt.c_str(), _node->getStringValue());
       break;
     case DOUBLE_VALUE:
       sprintf(_buf, _fmt.c_str(), _node->getFloatValue() * _mult);
@@ -1151,3 +1150,4 @@ FGSwitchLayer::draw ()
 // end of panel.cxx
 
 
+