]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel.cxx
Internal interface changes by David Megginson.
[flightgear.git] / src / Cockpit / panel.cxx
index cc4f10436679107f2f1319b778a4f728ac66c848..8cfc864a892987f6e092786feb9b1c1a00df9a39 100644 (file)
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/fgpath.hxx>
+
 #include <Main/globals.hxx>
-#include <Main/options.hxx>
+#include <Main/fg_props.hxx>
 #include <Objects/texload.h>
+#include <Time/light.hxx>
 
 #include "hud.hxx"
 #include "panel.hxx"
@@ -44,8 +46,8 @@
 bool
 fgPanelVisible ()
 {
-  return ((current_options.get_panel_status()) &&
-         (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_PILOT) &&
+  return ((globals->get_options()->get_panel_status()) &&
+         (globals->get_viewmgr()->get_current() == 0) &&
          (globals->get_current_view()->get_view_offset() == 0.0));
 }
 
@@ -63,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;
@@ -143,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++) {
@@ -162,11 +165,45 @@ 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 (!fgPanelVisible())
@@ -305,8 +342,8 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
   }
 
                                // Scale for the real window size.
-  x = int(((float)x / globals->get_current_view()->get_winWidth()) * _winw);
-  y = int(_winh - (((float)y / globals->get_current_view()->get_winHeight())
+  x = int(((float)x / globals->get_options()->get_xsize()) * _winw);
+  y = int(_winh - (((float)y / globals->get_options()->get_ysize())
                   * _winh));
 
                                // Adjust for offsets.