private:
int Code;
int cockpitStatus;
- SGValue * hud_status;
+ SGPropertyNode * hud_status;
public:
fg_Cockpit () : Code(1), cockpitStatus(0) {};
////////////////////////////////////////////////////////////////////////
FGAdjustAction::FGAdjustAction (int button, int x, int y, int w, int h,
- SGValue * value, float increment,
+ SGPropertyNode * node, float increment,
float min, float max, bool wrap)
: FGPanelAction(button, x, y, w, h),
- _value(value), _increment(increment), _min(min), _max(max), _wrap(wrap)
+ _node(node), _increment(increment), _min(min), _max(max), _wrap(wrap)
{
}
void
FGAdjustAction::doAction ()
{
- float val = _value->getFloatValue();
+ float val = _node->getFloatValue();
val += _increment;
if (val < _min) {
val = (_wrap ? _max : _min);
} else if (val > _max) {
val = (_wrap ? _min : _max);
}
- _value->setDoubleValue(val);
+ _node->setDoubleValue(val);
}
////////////////////////////////////////////////////////////////////////
FGSwapAction::FGSwapAction (int button, int x, int y, int w, int h,
- SGValue * value1, SGValue * value2)
- : FGPanelAction(button, x, y, w, h), _value1(value1), _value2(value2)
+ SGPropertyNode * node1, SGPropertyNode * node2)
+ : FGPanelAction(button, x, y, w, h), _node1(node1), _node2(node2)
{
}
void
FGSwapAction::doAction ()
{
- float val = _value1->getFloatValue();
- _value1->setDoubleValue(_value2->getFloatValue());
- _value2->setDoubleValue(val);
+ float val = _node1->getFloatValue();
+ _node1->setDoubleValue(_node2->getFloatValue());
+ _node2->setDoubleValue(val);
}
////////////////////////////////////////////////////////////////////////
FGToggleAction::FGToggleAction (int button, int x, int y, int w, int h,
- SGValue * value)
- : FGPanelAction(button, x, y, w, h), _value(value)
+ SGPropertyNode * node)
+ : FGPanelAction(button, x, y, w, h), _node(node)
{
}
void
FGToggleAction::doAction ()
{
- _value->setBoolValue(!(_value->getBoolValue()));
+ _node->setBoolValue(!(_node->getBoolValue()));
}
transformation_list::const_iterator last = _transformations.end();
while (it != last) {
FGPanelTransformation *t = *it;
- float val = (t->value == 0 ? 0.0 : t->value->getFloatValue());
+ float val = (t->node == 0 ? 0.0 : t->node->getFloatValue());
if (val < t->min) {
val = t->min;
} else if (val > t->max) {
_fmt = "%s";
}
-FGTextLayer::Chunk::Chunk (ChunkType type, const SGValue * value,
+FGTextLayer::Chunk::Chunk (ChunkType type, const SGPropertyNode * node,
const string &fmt, float mult)
: _type(type), _fmt(fmt), _mult(mult)
{
else
_fmt = "%.2f";
}
- _value = value;
+ _node = node;
}
const char *
sprintf(_buf, _fmt.c_str(), _text.c_str());
return _buf;
case TEXT_VALUE:
- sprintf(_buf, _fmt.c_str(), _value->getStringValue().c_str());
+ sprintf(_buf, _fmt.c_str(), _node->getStringValue().c_str());
break;
case DOUBLE_VALUE:
- sprintf(_buf, _fmt.c_str(), _value->getFloatValue() * _mult);
+ sprintf(_buf, _fmt.c_str(), _node->getFloatValue() * _mult);
break;
}
return _buf;
// Implementation of FGSwitchLayer.
////////////////////////////////////////////////////////////////////////
-FGSwitchLayer::FGSwitchLayer (int w, int h, const SGValue * value,
+FGSwitchLayer::FGSwitchLayer (int w, int h, const SGPropertyNode * node,
FGInstrumentLayer * layer1,
FGInstrumentLayer * layer2)
- : FGInstrumentLayer(w, h), _value(value), _layer1(layer1), _layer2(layer2)
+ : FGInstrumentLayer(w, h), _node(node), _layer1(layer1), _layer2(layer2)
{
}
FGSwitchLayer::draw ()
{
transform();
- if (_value->getBoolValue()) {
+ if (_node->getBoolValue()) {
_layer1->draw();
} else {
_layer2->draw();
{
public:
FGAdjustAction (int button, int x, int y, int w, int h,
- SGValue * value, float increment,
+ SGPropertyNode * node, float increment,
float min, float max, bool wrap=false);
virtual ~FGAdjustAction ();
virtual void doAction ();
private:
- SGValue * _value;
+ SGPropertyNode * _node;
float _increment;
float _min;
float _max;
{
public:
FGSwapAction (int button, int x, int y, int w, int h,
- SGValue * value1, SGValue * value2);
+ SGPropertyNode * node1, SGPropertyNode * node2);
virtual ~FGSwapAction ();
virtual void doAction ();
private:
- SGValue * _value1;
- SGValue * _value2;
+ SGPropertyNode * _node1;
+ SGPropertyNode * _node2;
};
{
public:
FGToggleAction (int button, int x, int y, int w, int h,
- SGValue * value);
+ SGPropertyNode * node);
virtual ~FGToggleAction ();
virtual void doAction ();
private:
- SGValue * _value;
+ SGPropertyNode * _node;
};
virtual ~FGPanelTransformation ();
Type type;
- const SGValue * value;
+ const SGPropertyNode * node;
float min;
float max;
float factor;
class Chunk {
public:
Chunk (const string &text, const string &fmt = "%s");
- Chunk (ChunkType type, const SGValue * value,
+ Chunk (ChunkType type, const SGPropertyNode * node,
const string &fmt = "", float mult = 1.0);
const char * getValue () const;
private:
ChunkType _type;
string _text;
- const SGValue * _value;
+ const SGPropertyNode * _node;
string _fmt;
float _mult;
mutable char _buf[1024];
{
public:
// Transfer pointers!!
- FGSwitchLayer (int w, int h, const SGValue * value,
+ FGSwitchLayer (int w, int h, const SGPropertyNode * node,
FGInstrumentLayer * layer1,
FGInstrumentLayer * layer2);
virtual ~FGSwitchLayer ();
virtual void draw ();
private:
- const SGValue * _value;
+ const SGPropertyNode * _node;
FGInstrumentLayer * _layer1, * _layer2;
};
* Read an action from the instrument's property list.
*
* The action will be performed when the user clicks a mouse button
- * within the specified region of the instrument. Actions always
- * work by modifying the value of a property (see the SGValue class).
+ * within the specified region of the instrument. Actions always work
+ * by modifying the value of a property (see the SGPropertyNode
+ * class).
*
* The following action types are defined:
*
// Adjust a property value
if (type == "adjust") {
string propName = node->getStringValue("property");
- SGValue * value = fgGetValue(propName, true);
+ SGPropertyNode * target = fgGetNode(propName, true);
float increment = node->getFloatValue("increment", 1.0);
float min = node->getFloatValue("min", 0.0);
float max = node->getFloatValue("max", 0.0);
if (min == max)
SG_LOG(SG_COCKPIT, SG_ALERT, "Action " << node->getName()
<< " has same min and max value");
- action = new FGAdjustAction(button, x, y, w, h, value,
+ action = new FGAdjustAction(button, x, y, w, h, target,
increment, min, max, wrap);
}
else if (type == "swap") {
string propName1 = node->getStringValue("property1");
string propName2 = node->getStringValue("property2");
- SGValue * value1 = fgGetValue(propName1, true);
- SGValue * value2 = fgGetValue(propName2, true);
- action = new FGSwapAction(button, x, y, w, h, value1, value2);
+ SGPropertyNode * target1 = fgGetNode(propName1, true);
+ SGPropertyNode * target2 = fgGetNode(propName2, true);
+ action = new FGSwapAction(button, x, y, w, h, target1, target2);
}
// Toggle a boolean value
else if (type == "toggle") {
string propName = node->getStringValue("property");
- SGValue * value = fgGetValue(propName, true);
- action = new FGToggleAction(button, x, y, w, h, value);
+ SGPropertyNode * target = fgGetNode(propName, true);
+ action = new FGToggleAction(button, x, y, w, h, target);
}
// Unrecognized type
string name = node->getName();
string type = node->getStringValue("type");
string propName = node->getStringValue("property", "");
- SGValue * value = 0;
+ SGPropertyNode * target = 0;
if (type == "") {
SG_LOG( SG_COCKPIT, SG_ALERT,
}
if (propName != (string)"") {
- value = fgGetValue(propName, true);
+ target = fgGetNode(propName, true);
}
- t->value = value;
+ t->node = target;
t->min = node->getFloatValue("min", -9999999);
t->max = node->getFloatValue("max", 99999999);
t->factor = node->getFloatValue("scale", 1.0);
// The value of a string property.
else if (type == "text-value") {
- SGValue * value =
- fgGetValue(node->getStringValue("property"), true);
- chunk = new FGTextLayer::Chunk(FGTextLayer::TEXT_VALUE, value, format);
+ SGPropertyNode * target =
+ fgGetNode(node->getStringValue("property"), true);
+ chunk = new FGTextLayer::Chunk(FGTextLayer::TEXT_VALUE, target, format);
}
// The value of a float property.
else if (type == "number-value") {
string propName = node->getStringValue("property");
float scale = node->getFloatValue("scale", 1.0);
- SGValue * value = fgGetValue(propName, true);
- chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, value,
+ SGPropertyNode * target = fgGetNode(propName, true);
+ chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target,
format, scale);
}
// A switch instrument layer.
else if (type == "switch") {
- SGValue * value =
- fgGetValue(node->getStringValue("property"), true);
+ SGPropertyNode * target =
+ fgGetNode(node->getStringValue("property"), true);
FGInstrumentLayer * layer1 =
readLayer(node->getNode("layer1"), w_scale, h_scale);
FGInstrumentLayer * layer2 =
readLayer(node->getNode("layer2"), w_scale, h_scale);
- layer = new FGSwitchLayer(w, h, value, layer1, layer2);
+ layer = new FGSwitchLayer(w, h, target, layer1, layer2);
}
// A built-in instrument layer.
//
// Grab the panel's initial offsets, default to 0, 0.
//
- if (!fgHasValue("/sim/panel/x-offset"))
+ if (!fgHasNode("/sim/panel/x-offset"))
fgSetInt("/sim/panel/x-offset", root->getIntValue("x-offset", 0));
- if (!fgHasValue("/sim/panel/y-offset"))
+ if (!fgHasNode("/sim/panel/y-offset"))
fgSetInt("/sim/panel/y-offset", root->getIntValue("y-offset", 0));
//