1
0
Fork 0

Updates from David Megginson relating to the property manager.

This commit is contained in:
curt 2000-09-30 03:35:38 +00:00
parent 9943166acd
commit 8d1295119f
6 changed files with 110 additions and 123 deletions

View file

@ -524,5 +524,6 @@ void fgCockpitUpdate( void ) {
xglViewport( 0, 0, iwidth, iheight );
current_panel->update();
if (current_panel != 0)
current_panel->update();
}

View file

@ -112,6 +112,8 @@ FGCroppedTexture::getTexture ()
////////////////////////////////////////////////////////////////////////
FGPanel * current_panel = NULL;
static fntRenderer text_renderer;
FGPanel::FGPanel (int x, int y, int w, int h)
: _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 ()
{
}
@ -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.
////////////////////////////////////////////////////////////////////////
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 ()
@ -689,19 +649,19 @@ FGTextLayer::draw ()
glPushMatrix();
glColor4fv(_color);
transform();
_renderer.setFont(guiFntHandle);
_renderer.setPointSize(_pointSize);
_renderer.begin();
_renderer.start3f(0, 0, 0);
text_renderer.setFont(guiFntHandle);
text_renderer.setPointSize(_pointSize);
text_renderer.begin();
text_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()));
_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();
}
@ -730,7 +690,19 @@ FGTextLayer::setPointSize (float size)
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();
}
}

View file

@ -45,6 +45,8 @@
#include <map>
#include <plib/fnt.h>
#include <Time/timestamp.hxx>
FG_USING_STD(vector);
FG_USING_STD(map);
@ -343,9 +345,6 @@ public:
};
FGPanelTransformation ();
FGPanelTransformation (Type type, const SGValue * value,
float min, float max,
float factor, float offset);
virtual ~FGPanelTransformation ();
Type type;
@ -413,7 +412,6 @@ protected:
class FGLayeredInstrument : public FGPanelInstrument
{
public:
typedef vector<FGInstrumentLayer *> layer_list;
FGLayeredInstrument (int x, int y, int w, int h);
virtual ~FGLayeredInstrument ();
@ -427,6 +425,7 @@ public:
virtual void addTransformation (FGPanelTransformation * transformation);
protected:
typedef vector<FGInstrumentLayer *> layer_list;
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.
@ -522,8 +493,7 @@ public:
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 ();
@ -535,13 +505,18 @@ public:
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;
};

View file

@ -46,6 +46,53 @@ FG_USING_STD(ifstream);
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.
@ -168,10 +215,10 @@ static FGCroppedTexture
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;
}
@ -575,12 +622,10 @@ readInstrument (SGPropertyNode node, int x, int y, int real_w, int real_h)
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);
@ -598,7 +643,7 @@ readInstrument (SGPropertyNode node, int x, int y, int real_w, int real_h)
hscale, vscale);
if (action == 0) {
delete instrument;
return 0;
return new DefaultInstrument(x, y, w, h);
}
instrument->addAction(action);
}
@ -613,7 +658,7 @@ readInstrument (SGPropertyNode node, int x, int y, int real_w, int real_h)
hscale, vscale);
if (layer == 0) {
delete instrument;
return 0;
return new DefaultInstrument(x, y, w, h);
}
instrument->addLayer(layer);
}
@ -693,17 +738,14 @@ fgReadPanel (istream &input)
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);
}
@ -726,16 +768,19 @@ fgReadPanel (istream &input)
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;
}

View file

@ -446,15 +446,14 @@ fgJoystickRead()
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;

View file

@ -163,14 +163,6 @@ FGBFI::init ()
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);
@ -231,6 +223,9 @@ FGBFI::init ()
current_properties.tieDouble("/radios/adf/rotation",
getADFRotation, setADFRotation);
current_properties.tieDouble("/environment/visibility",
getVisibility, setVisibility);
FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
}