Updates from David Megginson relating to the property manager.
This commit is contained in:
parent
9943166acd
commit
8d1295119f
6 changed files with 110 additions and 123 deletions
|
@ -524,5 +524,6 @@ void fgCockpitUpdate( void ) {
|
||||||
|
|
||||||
xglViewport( 0, 0, iwidth, iheight );
|
xglViewport( 0, 0, iwidth, iheight );
|
||||||
|
|
||||||
current_panel->update();
|
if (current_panel != 0)
|
||||||
|
current_panel->update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,8 @@ FGCroppedTexture::getTexture ()
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGPanel * current_panel = NULL;
|
FGPanel * current_panel = NULL;
|
||||||
|
static fntRenderer text_renderer;
|
||||||
|
|
||||||
|
|
||||||
FGPanel::FGPanel (int x, int y, int w, int h)
|
FGPanel::FGPanel (int x, int y, int w, int h)
|
||||||
: _mouseDown(false),
|
: _mouseDown(false),
|
||||||
|
@ -365,15 +367,6 @@ FGPanelTransformation::FGPanelTransformation ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ()
|
FGPanelTransformation::~FGPanelTransformation ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -628,50 +621,17 @@ FGTexturedLayer::draw ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGTextLayer.
|
// Implementation of FGTextLayer.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGTextLayer::FGTextLayer (int w, int h, Chunk * chunk1, Chunk * chunk2,
|
FGTextLayer::FGTextLayer (int w, int h)
|
||||||
Chunk * chunk3)
|
|
||||||
: FGInstrumentLayer(w, h), _pointSize(14.0)
|
: FGInstrumentLayer(w, h), _pointSize(14.0)
|
||||||
{
|
{
|
||||||
|
_then.stamp();
|
||||||
_color[0] = _color[1] = _color[2] = 0.0;
|
_color[0] = _color[1] = _color[2] = 0.0;
|
||||||
_color[3] = 1.0;
|
_color[3] = 1.0;
|
||||||
if (chunk1)
|
|
||||||
addChunk(chunk1);
|
|
||||||
if (chunk2)
|
|
||||||
addChunk(chunk2);
|
|
||||||
if (chunk3)
|
|
||||||
addChunk(chunk3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FGTextLayer::~FGTextLayer ()
|
FGTextLayer::~FGTextLayer ()
|
||||||
|
@ -689,19 +649,19 @@ FGTextLayer::draw ()
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glColor4fv(_color);
|
glColor4fv(_color);
|
||||||
transform();
|
transform();
|
||||||
_renderer.setFont(guiFntHandle);
|
text_renderer.setFont(guiFntHandle);
|
||||||
_renderer.setPointSize(_pointSize);
|
text_renderer.setPointSize(_pointSize);
|
||||||
_renderer.begin();
|
text_renderer.begin();
|
||||||
_renderer.start3f(0, 0, 0);
|
text_renderer.start3f(0, 0, 0);
|
||||||
|
|
||||||
// Render each of the chunks.
|
_now.stamp();
|
||||||
chunk_list::const_iterator it = _chunks.begin();
|
if (_now - _then > 100000) {
|
||||||
chunk_list::const_iterator last = _chunks.end();
|
recalc_value();
|
||||||
for ( ; it != last; it++) {
|
_then = _now;
|
||||||
_renderer.puts((char *)((*it)->getValue()));
|
|
||||||
}
|
}
|
||||||
|
text_renderer.puts((char *)(_value.c_str()));
|
||||||
|
|
||||||
_renderer.end();
|
text_renderer.end();
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0); // FIXME
|
glColor4f(1.0, 1.0, 1.0, 1.0); // FIXME
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
@ -730,7 +690,19 @@ FGTextLayer::setPointSize (float size)
|
||||||
void
|
void
|
||||||
FGTextLayer::setFont(fntFont * font)
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <plib/fnt.h>
|
#include <plib/fnt.h>
|
||||||
|
|
||||||
|
#include <Time/timestamp.hxx>
|
||||||
|
|
||||||
FG_USING_STD(vector);
|
FG_USING_STD(vector);
|
||||||
FG_USING_STD(map);
|
FG_USING_STD(map);
|
||||||
|
|
||||||
|
@ -343,9 +345,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
FGPanelTransformation ();
|
FGPanelTransformation ();
|
||||||
FGPanelTransformation (Type type, const SGValue * value,
|
|
||||||
float min, float max,
|
|
||||||
float factor, float offset);
|
|
||||||
virtual ~FGPanelTransformation ();
|
virtual ~FGPanelTransformation ();
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
|
@ -413,7 +412,6 @@ protected:
|
||||||
class FGLayeredInstrument : public FGPanelInstrument
|
class FGLayeredInstrument : public FGPanelInstrument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef vector<FGInstrumentLayer *> layer_list;
|
|
||||||
FGLayeredInstrument (int x, int y, int w, int h);
|
FGLayeredInstrument (int x, int y, int w, int h);
|
||||||
virtual ~FGLayeredInstrument ();
|
virtual ~FGLayeredInstrument ();
|
||||||
|
|
||||||
|
@ -427,6 +425,7 @@ public:
|
||||||
virtual void addTransformation (FGPanelTransformation * transformation);
|
virtual void addTransformation (FGPanelTransformation * transformation);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
typedef vector<FGInstrumentLayer *> layer_list;
|
||||||
layer_list _layers;
|
layer_list _layers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -460,34 +459,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// A text layer of an instrument.
|
// A text layer of an instrument.
|
||||||
|
@ -522,8 +493,7 @@ public:
|
||||||
mutable char _buf[1024];
|
mutable char _buf[1024];
|
||||||
};
|
};
|
||||||
|
|
||||||
FGTextLayer (int w = -1, int h = -1, Chunk * chunk1 = 0, Chunk * chunk2 = 0,
|
FGTextLayer (int w = -1, int h = -1);
|
||||||
Chunk * chunk3 = 0);
|
|
||||||
virtual ~FGTextLayer ();
|
virtual ~FGTextLayer ();
|
||||||
|
|
||||||
virtual void draw ();
|
virtual void draw ();
|
||||||
|
@ -535,13 +505,18 @@ public:
|
||||||
virtual void setFont (fntFont * font);
|
virtual void setFont (fntFont * font);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void recalc_value () const;
|
||||||
|
|
||||||
typedef vector<Chunk *> chunk_list;
|
typedef vector<Chunk *> chunk_list;
|
||||||
chunk_list _chunks;
|
chunk_list _chunks;
|
||||||
float _color[4];
|
float _color[4];
|
||||||
|
|
||||||
float _pointSize;
|
float _pointSize;
|
||||||
// FIXME: need only one globally
|
|
||||||
mutable fntRenderer _renderer;
|
mutable string _value;
|
||||||
|
mutable FGTimeStamp _then;
|
||||||
|
mutable FGTimeStamp _now;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,53 @@ FG_USING_STD(ifstream);
|
||||||
FG_USING_STD(string);
|
FG_USING_STD(string);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Built-in layer for the magnetic compass ribbon layer.
|
// Built-in layer for the magnetic compass ribbon layer.
|
||||||
|
@ -168,10 +215,10 @@ static FGCroppedTexture
|
||||||
readTexture (SGPropertyNode node)
|
readTexture (SGPropertyNode node)
|
||||||
{
|
{
|
||||||
FGCroppedTexture texture(node.getStringValue("path"),
|
FGCroppedTexture texture(node.getStringValue("path"),
|
||||||
node.getFloatValue("x1"),
|
node.getFloatValue("x1"),
|
||||||
node.getFloatValue("y1"),
|
node.getFloatValue("y1"),
|
||||||
node.getFloatValue("x2", 1.0),
|
node.getFloatValue("x2", 1.0),
|
||||||
node.getFloatValue("y2", 1.0));
|
node.getFloatValue("y2", 1.0));
|
||||||
FG_LOG(FG_INPUT, FG_INFO, "Read texture " << node.getName());
|
FG_LOG(FG_INPUT, FG_INFO, "Read texture " << node.getName());
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
@ -575,12 +622,10 @@ readInstrument (SGPropertyNode node, int x, int y, int real_w, int real_h)
|
||||||
if (real_w != -1) {
|
if (real_w != -1) {
|
||||||
hscale = float(real_w) / float(w);
|
hscale = float(real_w) / float(w);
|
||||||
w = real_w;
|
w = real_w;
|
||||||
cerr << "hscale is " << hscale << endl;
|
|
||||||
}
|
}
|
||||||
if (real_h != -1) {
|
if (real_h != -1) {
|
||||||
vscale = float(real_h) / float(h);
|
vscale = float(real_h) / float(h);
|
||||||
h = real_h;
|
h = real_h;
|
||||||
cerr << "vscale is " << hscale << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FG_LOG(FG_INPUT, FG_INFO, "Reading instrument " << name);
|
FG_LOG(FG_INPUT, FG_INFO, "Reading instrument " << name);
|
||||||
|
@ -598,7 +643,7 @@ readInstrument (SGPropertyNode node, int x, int y, int real_w, int real_h)
|
||||||
hscale, vscale);
|
hscale, vscale);
|
||||||
if (action == 0) {
|
if (action == 0) {
|
||||||
delete instrument;
|
delete instrument;
|
||||||
return 0;
|
return new DefaultInstrument(x, y, w, h);
|
||||||
}
|
}
|
||||||
instrument->addAction(action);
|
instrument->addAction(action);
|
||||||
}
|
}
|
||||||
|
@ -613,7 +658,7 @@ readInstrument (SGPropertyNode node, int x, int y, int real_w, int real_h)
|
||||||
hscale, vscale);
|
hscale, vscale);
|
||||||
if (layer == 0) {
|
if (layer == 0) {
|
||||||
delete instrument;
|
delete instrument;
|
||||||
return 0;
|
return new DefaultInstrument(x, y, w, h);
|
||||||
}
|
}
|
||||||
instrument->addLayer(layer);
|
instrument->addLayer(layer);
|
||||||
}
|
}
|
||||||
|
@ -693,17 +738,14 @@ fgReadPanel (istream &input)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!readPropertyList(path.str(), &props2)) {
|
|
||||||
delete panel;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FGPanelInstrument * instrument =
|
FGPanelInstrument * instrument = 0;
|
||||||
readInstrument(SGPropertyNode("/", &props2), x, y, w, h);
|
|
||||||
|
if (readPropertyList(path.str(), &props2)) {
|
||||||
|
instrument = readInstrument(SGPropertyNode("/", &props2), x, y, w, h);
|
||||||
|
}
|
||||||
if (instrument == 0) {
|
if (instrument == 0) {
|
||||||
delete instrument;
|
instrument = new DefaultInstrument(x, y, w, h);
|
||||||
delete panel;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
panel->addInstrument(instrument);
|
panel->addInstrument(instrument);
|
||||||
}
|
}
|
||||||
|
@ -726,16 +768,19 @@ fgReadPanel (istream &input)
|
||||||
FGPanel *
|
FGPanel *
|
||||||
fgReadPanel (const string &relative_path)
|
fgReadPanel (const string &relative_path)
|
||||||
{
|
{
|
||||||
|
FGPanel * panel = 0;
|
||||||
FGPath path(current_options.get_fg_root());
|
FGPath path(current_options.get_fg_root());
|
||||||
path.append(relative_path);
|
path.append(relative_path);
|
||||||
ifstream input(path.c_str());
|
ifstream input(path.c_str());
|
||||||
if (!input.good()) {
|
if (!input.good()) {
|
||||||
FG_LOG(FG_INPUT, FG_ALERT,
|
FG_LOG(FG_INPUT, FG_ALERT,
|
||||||
"Cannot read panel configuration from " << path.str());
|
"Cannot read panel configuration from " << path.str());
|
||||||
return 0;
|
} else {
|
||||||
|
panel = fgReadPanel(input);
|
||||||
|
input.close();
|
||||||
}
|
}
|
||||||
FGPanel * panel = fgReadPanel(input);
|
if (panel == 0)
|
||||||
input.close();
|
panel = new DefaultPanel(0, 0, 1024, 768);
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -446,15 +446,14 @@ fgJoystickRead()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch (b.action) {
|
switch (b.action) {
|
||||||
|
case button::ADJUST:
|
||||||
case button::TOGGLE:
|
case button::TOGGLE:
|
||||||
// no op
|
// no op
|
||||||
|
flag = true;
|
||||||
break;
|
break;
|
||||||
case button::SWITCH:
|
case button::SWITCH:
|
||||||
flag = b.value->setDoubleValue(0.0);
|
flag = b.value->setDoubleValue(0.0);
|
||||||
break;
|
break;
|
||||||
case button::ADJUST:
|
|
||||||
// no op
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
flag = false;
|
flag = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -163,14 +163,6 @@ FGBFI::init ()
|
||||||
current_properties.tieDouble("/controls/brakes/center",
|
current_properties.tieDouble("/controls/brakes/center",
|
||||||
getRightBrake, setCenterBrake);
|
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
|
// Autopilot
|
||||||
current_properties.tieBool("/autopilot/locks/altitude",
|
current_properties.tieBool("/autopilot/locks/altitude",
|
||||||
getAPAltitudeLock, setAPAltitudeLock);
|
getAPAltitudeLock, setAPAltitudeLock);
|
||||||
|
@ -231,6 +223,9 @@ FGBFI::init ()
|
||||||
current_properties.tieDouble("/radios/adf/rotation",
|
current_properties.tieDouble("/radios/adf/rotation",
|
||||||
getADFRotation, setADFRotation);
|
getADFRotation, setADFRotation);
|
||||||
|
|
||||||
|
current_properties.tieDouble("/environment/visibility",
|
||||||
|
getVisibility, setVisibility);
|
||||||
|
|
||||||
FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
|
FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue