]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel.cxx
Internal interface changes by David Megginson.
[flightgear.git] / src / Cockpit / panel.cxx
index 16168f8c80d7a0d1443072dcb1e87297de08caf0..8cfc864a892987f6e092786feb9b1c1a00df9a39 100644 (file)
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/fgpath.hxx>
-#include <Main/options.hxx>
-#include <Main/views.hxx>
+
+#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 #include <Objects/texload.h>
+#include <Time/light.hxx>
 
 #include "hud.hxx"
 #include "panel.hxx"
 
 
+bool
+fgPanelVisible ()
+{
+  return ((globals->get_options()->get_panel_status()) &&
+         (globals->get_viewmgr()->get_current() == 0) &&
+         (globals->get_current_view()->get_view_offset() == 0.0));
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGTextureManager.
@@ -54,7 +65,7 @@ FGTextureManager::createTexture (const string &relativePath)
   ssgTexture * texture = _textureMap[relativePath];
   if (texture == 0) {
     cerr << "Texture " << relativePath << " does not yet exist" << endl;
-    FGPath tpath(current_options.get_fg_root());
+    FGPath tpath(globals->get_options()->get_fg_root());
     tpath.append(relativePath);
     texture = new ssgTexture((char *)tpath.c_str(), false, false);
     _textureMap[relativePath] = texture;
@@ -125,7 +136,7 @@ FGPanel::FGPanel (int window_x, int window_y, int window_w, int window_h)
     _width(_winw), _height(int(_winh * 0.5768 + 1)),
     _x_offset(0), _y_offset(0), _view_height(int(_winh * 0.4232))
 {
-  setVisibility(current_options.get_panel_status());
+  setVisibility(fgPanelVisible());
 }
 
 
@@ -134,6 +145,7 @@ FGPanel::FGPanel (int window_x, int window_y, int window_w, int window_h)
  */
 FGPanel::~FGPanel ()
 {
+  unbind();
   for (instrument_list_type::iterator it = _instruments.begin();
        it != _instruments.end();
        it++) {
@@ -153,14 +165,48 @@ FGPanel::addInstrument (FGPanelInstrument * instrument)
 }
 
 
+/**
+ * Initialize the panel.
+ */
+void
+FGPanel::init ()
+{
+  // NO-OP
+}
+
+
+/**
+ * Bind panel properties.
+ */
+void
+FGPanel::bind ()
+{
+  fgTie("/sim/panel/visibility", &_visibility);
+  fgTie("/sim/panel/x-offset", &_x_offset);
+  fgTie("/sim/panel/y-offset", &_y_offset);
+}
+
+
+/**
+ * Unbind panel properties.
+ */
+void
+FGPanel::unbind ()
+{
+  fgUntie("/sim/panel/visibility");
+  fgUntie("/sim/panel/x-offset");
+  fgUntie("/sim/panel/y-offset");
+}
+
+
 /**
  * Update the panel.
  */
 void
-FGPanel::update () const
+FGPanel::update ()
 {
                                // Do nothing if the panel isn't visible.
-  if (!_visibility)
+  if (!fgPanelVisible())
     return;
 
                                // If the mouse is down, do something
@@ -296,8 +342,9 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
   }
 
                                // Scale for the real window size.
-  x = int(((float)x / current_view.get_winWidth()) * _winw);
-  y = int(_winh - (((float)y / current_view.get_winHeight()) * _winh));
+  x = int(((float)x / globals->get_options()->get_xsize()) * _winw);
+  y = int(_winh - (((float)y / globals->get_options()->get_ysize())
+                  * _winh));
 
                                // Adjust for offsets.
   x -= _x_offset;