]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel.cxx
Continued FGViewer cleanups. FGViewer is now a base class so that we can
[flightgear.git] / src / Cockpit / panel.cxx
index 16168f8c80d7a0d1443072dcb1e87297de08caf0..95de80c6ce5f61d976364a23cdded723f09a3342 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 <Objects/texload.h>
+#include <Time/light.hxx>
 
 #include "hud.hxx"
 #include "panel.hxx"
 
 
+bool
+fgPanelVisible ()
+{
+  return ((globals->get_options()->get_panel_status()) &&
+         (globals->get_options()->get_view_mode() == FGOptions::FG_VIEW_PILOT) &&
+         (globals->get_current_view()->get_view_offset() == 0.0));
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGTextureManager.
@@ -54,7 +63,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 +134,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());
 }
 
 
@@ -160,7 +169,7 @@ void
 FGPanel::update () const
 {
                                // Do nothing if the panel isn't visible.
-  if (!_visibility)
+  if (!fgPanelVisible())
     return;
 
                                // If the mouse is down, do something
@@ -296,8 +305,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;