1
0
Fork 0

allow to change/reload HUD by setting path in /sim/path/path[1]

This commit is contained in:
mfranz 2009-03-11 19:10:12 +00:00 committed by Tim Moore
parent f07e8a7e94
commit d3b2b9f1e3
2 changed files with 14 additions and 1 deletions

View file

@ -46,6 +46,7 @@ static float clamp(float f)
HUD::HUD() :
_path(fgGetNode("/sim/hud/path[1]", "Huds/default.xml")),
_current(fgGetNode("/sim/hud/current-color", true)),
_visibility(fgGetNode("/sim/hud/visibility[1]", true)),
_3DenabledN(fgGetNode("/sim/hud/enable3d[1]", true)),
@ -72,10 +73,12 @@ HUD::HUD() :
_font(0),
_font_size(0.0),
_style(0),
_listener_active(false),
_clip_box(0)
{
SG_LOG(SG_COCKPIT, SG_INFO, "Initializing HUD Instrument");
_path->addChangeListener(this);
_visibility->addChangeListener(this);
_3DenabledN->addChangeListener(this);
_antialiasing->addChangeListener(this);
@ -95,6 +98,7 @@ HUD::HUD() :
HUD::~HUD()
{
_path->removeChangeListener(this);
_visibility->removeChangeListener(this);
_3DenabledN->removeChangeListener(this);
_antialiasing->removeChangeListener(this);
@ -134,7 +138,7 @@ void HUD::init()
_font_renderer->setPointSize(_font_size);
_text_list.setFont(_font_renderer);
load(fgGetString("/sim/hud/path[1]", "Huds/default.xml"));
_path->fireValueChanged();
}
@ -411,6 +415,12 @@ int HUD::load(const char *file, float x, float y, int level, const string& inden
void HUD::valueChanged(SGPropertyNode *node)
{
if (_listener_active)
return;
_listener_active = true;
if (!strcmp(node->getName(), "path"))
load(fgGetString("/sim/hud/path[1]", "Huds/default.xml"));
if (!strcmp(node->getName(), "current-color")) {
int i = node->getIntValue();
if (i < 0)
@ -450,6 +460,7 @@ void HUD::valueChanged(SGPropertyNode *node)
_cl = clamp(_alpha_clamp->getFloatValue());
_units = strcmp(_unitsN->getStringValue(), "feet") ? METER : FEET;
_listener_active = false;
}

View file

@ -215,6 +215,7 @@ private:
deque<Item *> _items;
deque<Item *> _ladders;
SGPropertyNode_ptr _path;
SGPropertyNode_ptr _current;
SGPropertyNode_ptr _visibility;
SGPropertyNode_ptr _3DenabledN;
@ -240,6 +241,7 @@ private:
fntTexFont *_font;
float _font_size;
int _style;
bool _listener_active;
ClipBox *_clip_box;
TextList _text_list;