]> 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 4b72ce0f2cb767f68d339e3fd2cbedf5d301ae12..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
@@ -202,9 +211,9 @@ FGPanel::update () const
   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   glBegin(GL_POLYGON);
   glTexCoord2f(0.0, 0.0); glVertex3f(_winx, _winy, 0);
-  glTexCoord2f(10.0, 0.0); glVertex3f(_winx + _width, _winy, 0);
-  glTexCoord2f(10.0, 5.0); glVertex3f(_winx + _width, _winy + _height, 0);
-  glTexCoord2f(0.0, 5.0); glVertex3f(_winx, _winy + _height, 0);
+  glTexCoord2f(1.0, 0.0); glVertex3f(_winx + _width, _winy, 0);
+  glTexCoord2f(1.0, 1.0); glVertex3f(_winx + _width, _winy + _height, 0);
+  glTexCoord2f(0.0, 1.0); glVertex3f(_winx, _winy + _height, 0);
   glEnd();
 
                                // Draw the instruments.
@@ -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;