From: mfranz Date: Wed, 11 Mar 2009 19:10:12 +0000 (+0000) Subject: allow to change/reload HUD by setting path in /sim/path/path[1] X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d3b2b9f1e3e924ac884a9ebe9fa029992e55ae87;p=flightgear.git allow to change/reload HUD by setting path in /sim/path/path[1] --- diff --git a/src/Instrumentation/HUD/HUD.cxx b/src/Instrumentation/HUD/HUD.cxx index 4f480b47e..d199c3b30 100644 --- a/src/Instrumentation/HUD/HUD.cxx +++ b/src/Instrumentation/HUD/HUD.cxx @@ -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; } diff --git a/src/Instrumentation/HUD/HUD.hxx b/src/Instrumentation/HUD/HUD.hxx index c1a0e21a0..4801ef947 100644 --- a/src/Instrumentation/HUD/HUD.hxx +++ b/src/Instrumentation/HUD/HUD.hxx @@ -215,6 +215,7 @@ private: deque _items; deque _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;