xglViewport( 0, 0, iwidth, iheight );
- current_panel->update();
+ if (current_panel != 0)
+ current_panel->update();
}
////////////////////////////////////////////////////////////////////////
FGPanel * current_panel = NULL;
+static fntRenderer text_renderer;
+
FGPanel::FGPanel (int x, int y, int w, int h)
: _mouseDown(false),
{
}
-FGPanelTransformation::FGPanelTransformation (Type _type,
- const SGValue * _value,
- float _min, float _max,
- float _factor, float _offset)
- : type(_type), value(_value), min(_min), max(_max),
- factor(_factor), offset(_offset)
-{
-}
-
FGPanelTransformation::~FGPanelTransformation ()
{
}
}
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGWindowLayer.
-////////////////////////////////////////////////////////////////////////
-
-FGWindowLayer::FGWindowLayer (int w, int h)
- : FGTexturedLayer (w, h)
-{
-}
-
-FGWindowLayer::FGWindowLayer (const FGCroppedTexture &texture, int w, int h)
- : FGTexturedLayer(texture, w, h)
-{
-}
-
-FGWindowLayer::~FGWindowLayer ()
-{
-}
-
-void
-FGWindowLayer::draw ()
-{
- // doesn't do anything yet
- FGTexturedLayer::draw();
-}
-
-
\f
////////////////////////////////////////////////////////////////////////
// Implementation of FGTextLayer.
////////////////////////////////////////////////////////////////////////
-FGTextLayer::FGTextLayer (int w, int h, Chunk * chunk1, Chunk * chunk2,
- Chunk * chunk3)
+FGTextLayer::FGTextLayer (int w, int h)
: FGInstrumentLayer(w, h), _pointSize(14.0)
{
+ _then.stamp();
_color[0] = _color[1] = _color[2] = 0.0;
_color[3] = 1.0;
- if (chunk1)
- addChunk(chunk1);
- if (chunk2)
- addChunk(chunk2);
- if (chunk3)
- addChunk(chunk3);
}
FGTextLayer::~FGTextLayer ()
glPushMatrix();
glColor4fv(_color);
transform();
- _renderer.setFont(guiFntHandle);
- _renderer.setPointSize(_pointSize);
- _renderer.begin();
- _renderer.start3f(0, 0, 0);
-
- // Render each of the chunks.
- chunk_list::const_iterator it = _chunks.begin();
- chunk_list::const_iterator last = _chunks.end();
- for ( ; it != last; it++) {
- _renderer.puts((char *)((*it)->getValue()));
+ text_renderer.setFont(guiFntHandle);
+ text_renderer.setPointSize(_pointSize);
+ text_renderer.begin();
+ text_renderer.start3f(0, 0, 0);
+
+ _now.stamp();
+ if (_now - _then > 100000) {
+ recalc_value();
+ _then = _now;
}
+ text_renderer.puts((char *)(_value.c_str()));
- _renderer.end();
+ text_renderer.end();
glColor4f(1.0, 1.0, 1.0, 1.0); // FIXME
glPopMatrix();
}
void
FGTextLayer::setFont(fntFont * font)
{
- _renderer.setFont(font);
+ text_renderer.setFont(font);
+}
+
+
+void
+FGTextLayer::recalc_value () const
+{
+ _value = "";
+ chunk_list::const_iterator it = _chunks.begin();
+ chunk_list::const_iterator last = _chunks.end();
+ for ( ; it != last; it++) {
+ _value += (*it)->getValue();
+ }
}
#include <map>
#include <plib/fnt.h>
+#include <Time/timestamp.hxx>
+
FG_USING_STD(vector);
FG_USING_STD(map);
};
FGPanelTransformation ();
- FGPanelTransformation (Type type, const SGValue * value,
- float min, float max,
- float factor, float offset);
virtual ~FGPanelTransformation ();
Type type;
class FGLayeredInstrument : public FGPanelInstrument
{
public:
- typedef vector<FGInstrumentLayer *> layer_list;
FGLayeredInstrument (int x, int y, int w, int h);
virtual ~FGLayeredInstrument ();
virtual void addTransformation (FGPanelTransformation * transformation);
protected:
+ typedef vector<FGInstrumentLayer *> layer_list;
layer_list _layers;
};
};
-\f
-////////////////////////////////////////////////////////////////////////
-// A moving window on a texture.
-//
-// This layer automatically recrops a cropped texture based on
-// property values, creating a moving window over the texture.
-////////////////////////////////////////////////////////////////////////
-
-class FGWindowLayer : public FGTexturedLayer
-{
-public:
- FGWindowLayer (int w = -1, int h = -1);
- FGWindowLayer (const FGCroppedTexture &texture, int w = -1, int h = -1);
- virtual ~FGWindowLayer ();
-
- virtual void draw ();
-
- virtual const SGValue * getXValue () const { return _xValue; }
- virtual void setXValue (const SGValue * value) { _xValue = value; }
- virtual const SGValue * getYValue () const { return _yValue; }
- virtual void setYValue (const SGValue * value) { _yValue = value; }
-
-private:
- const SGValue * _xValue;
- const SGValue * _yValue;
-};
-
-
\f
////////////////////////////////////////////////////////////////////////
// A text layer of an instrument.
mutable char _buf[1024];
};
- FGTextLayer (int w = -1, int h = -1, Chunk * chunk1 = 0, Chunk * chunk2 = 0,
- Chunk * chunk3 = 0);
+ FGTextLayer (int w = -1, int h = -1);
virtual ~FGTextLayer ();
virtual void draw ();
virtual void setFont (fntFont * font);
private:
+
+ void recalc_value () const;
+
typedef vector<Chunk *> chunk_list;
chunk_list _chunks;
float _color[4];
float _pointSize;
- // FIXME: need only one globally
- mutable fntRenderer _renderer;
+
+ mutable string _value;
+ mutable FGTimeStamp _then;
+ mutable FGTimeStamp _now;
};
FG_USING_STD(string);
+\f
+////////////////////////////////////////////////////////////////////////
+// Default panel, instrument, and layer for when things go wrong...
+////////////////////////////////////////////////////////////////////////
+
+static FGCroppedTexture defaultTexture("Textures/default.rgb");
+
+
+/**
+ * Default layer: the default texture.
+ */
+class DefaultLayer : public FGTexturedLayer
+{
+public:
+ DefaultLayer () : FGTexturedLayer(defaultTexture)
+ {
+ }
+
+};
+
+/**
+ * Default instrument: a single default layer.
+ */
+class DefaultInstrument : public FGLayeredInstrument
+{
+public:
+ DefaultInstrument (int x, int y, int w, int h)
+ : FGLayeredInstrument(x, y, w, h)
+ {
+ addLayer(new DefaultLayer());
+ }
+};
+
+
+/**
+ * Default panel: the default texture.
+ */
+class DefaultPanel : public FGPanel
+{
+public:
+ DefaultPanel (int x, int y, int w, int h) : FGPanel(x, y, w, h)
+ {
+ setBackground(defaultTexture.getTexture());
+ }
+};
+
+
\f
////////////////////////////////////////////////////////////////////////
// Built-in layer for the magnetic compass ribbon layer.
readTexture (SGPropertyNode node)
{
FGCroppedTexture texture(node.getStringValue("path"),
- node.getFloatValue("x1"),
- node.getFloatValue("y1"),
- node.getFloatValue("x2", 1.0),
- node.getFloatValue("y2", 1.0));
+ node.getFloatValue("x1"),
+ node.getFloatValue("y1"),
+ node.getFloatValue("x2", 1.0),
+ node.getFloatValue("y2", 1.0));
FG_LOG(FG_INPUT, FG_INFO, "Read texture " << node.getName());
return texture;
}
if (real_w != -1) {
hscale = float(real_w) / float(w);
w = real_w;
- cerr << "hscale is " << hscale << endl;
}
if (real_h != -1) {
vscale = float(real_h) / float(h);
h = real_h;
- cerr << "vscale is " << hscale << endl;
}
FG_LOG(FG_INPUT, FG_INFO, "Reading instrument " << name);
hscale, vscale);
if (action == 0) {
delete instrument;
- return 0;
+ return new DefaultInstrument(x, y, w, h);
}
instrument->addAction(action);
}
hscale, vscale);
if (layer == 0) {
delete instrument;
- return 0;
+ return new DefaultInstrument(x, y, w, h);
}
instrument->addLayer(layer);
}
return 0;
}
- if (!readPropertyList(path.str(), &props2)) {
- delete panel;
- return 0;
- }
- FGPanelInstrument * instrument =
- readInstrument(SGPropertyNode("/", &props2), x, y, w, h);
+ FGPanelInstrument * instrument = 0;
+
+ if (readPropertyList(path.str(), &props2)) {
+ instrument = readInstrument(SGPropertyNode("/", &props2), x, y, w, h);
+ }
if (instrument == 0) {
- delete instrument;
- delete panel;
- return 0;
+ instrument = new DefaultInstrument(x, y, w, h);
}
panel->addInstrument(instrument);
}
FGPanel *
fgReadPanel (const string &relative_path)
{
+ FGPanel * panel = 0;
FGPath path(current_options.get_fg_root());
path.append(relative_path);
ifstream input(path.c_str());
if (!input.good()) {
FG_LOG(FG_INPUT, FG_ALERT,
"Cannot read panel configuration from " << path.str());
- return 0;
+ } else {
+ panel = fgReadPanel(input);
+ input.close();
}
- FGPanel * panel = fgReadPanel(input);
- input.close();
+ if (panel == 0)
+ panel = new DefaultPanel(0, 0, 1024, 768);
return panel;
}
continue;
switch (b.action) {
+ case button::ADJUST:
case button::TOGGLE:
// no op
+ flag = true;
break;
case button::SWITCH:
flag = b.value->setDoubleValue(0.0);
break;
- case button::ADJUST:
- // no op
- break;
default:
flag = false;
break;
current_properties.tieDouble("/controls/brakes/center",
getRightBrake, setCenterBrake);
- // Deprecated...
- current_properties.tieDouble("/controls/brake",
- getBrakes, setBrakes);
- current_properties.tieDouble("/controls/left-brake",
- getLeftBrake, setLeftBrake);
- current_properties.tieDouble("/controls/right-brake",
- getRightBrake, setRightBrake);
-
// Autopilot
current_properties.tieBool("/autopilot/locks/altitude",
getAPAltitudeLock, setAPAltitudeLock);
current_properties.tieDouble("/radios/adf/rotation",
getADFRotation, setADFRotation);
+ current_properties.tieDouble("/environment/visibility",
+ getVisibility, setVisibility);
+
FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
}