]> git.mxchange.org Git - flightgear.git/commitdiff
I wrote:
authordavid <david>
Sun, 17 Nov 2002 00:04:57 +0000 (00:04 +0000)
committerdavid <david>
Sun, 17 Nov 2002 00:04:57 +0000 (00:04 +0000)
 > Jim Wilson wrote:
 > > How hard would it be to have a property that toggles hotspot
 > > visibility?  It'd be nice to be able to turn it on and have yellow
 > > rectangles show up on the hotspots...
 >
 > That's not a bad idea.

It's actually an astoundingly good idea, and implementable over lunch
to boot. :)

Try the attached patch, which predicates the boxes on the
/sim/panel-hotspots property.  I mapped a toggle event on this to a
spare joystick button, and had fun. :)

[dpm: bound to Ctrl-C]

src/Cockpit/panel.cxx
src/Cockpit/panel.hxx

index 19a2672028b3fbdbda227ef6810907a74194cb89..bfdb5600cda50b5df116b90e914a9405d3820487 100644 (file)
@@ -436,6 +436,21 @@ FGPanel::draw()
     glPopMatrix();
   }
 
+  // Draw yellow "hotspots" if directed to.  This is a panel authoring
+  // feature; not intended to be high performance or to look good.
+  if(fgGetBool("/sim/panel-hotspots")) {
+    glPushAttrib(GL_ALL_ATTRIB_BITS);
+    glDisable(GL_DEPTH_TEST);
+    glDisable(GL_TEXTURE_2D);
+    glColor3f(1, 1, 0);
+    
+    for(int i=0; i<_instruments.size(); i++)
+      _instruments[i]->drawHotspots();
+
+    glPopAttrib();
+  }
+
+
   // restore some original state
   glPopAttrib();
   glPolygonOffset(0, 0);
@@ -650,6 +665,25 @@ FGPanelInstrument::~FGPanelInstrument ()
   }
 }
 
+void
+FGPanelInstrument::drawHotspots()
+{
+  for(int i=0; i<_actions.size(); i++) {
+    FGPanelAction* a = _actions[i];
+    float x1 = getXPos() + a->getX();
+    float x2 = x1 + a->getWidth();
+    float y1 = getYPos() + a->getY();
+    float y2 = y1 + a->getHeight();
+
+    glBegin(GL_LINE_LOOP);
+    glVertex2f(x1, y1);
+    glVertex2f(x1, y2);
+    glVertex2f(x2, y2);
+    glVertex2f(x2, y1);
+    glEnd();
+  }
+}
+
 void
 FGPanelInstrument::setPosition (int x, int y)
 {
index 0b41c2d259ccd1f2f03f364b20150246345255cf..4ef5fffc776f362403713b4ef68201a60517ca02 100644 (file)
@@ -370,6 +370,7 @@ public:
   virtual ~FGPanelInstrument ();
 
   virtual void draw () = 0;
+  virtual void drawHotspots();
 
   virtual void setPosition(int x, int y);
   virtual void setSize(int w, int h);