#include <Main/globals.hxx>
#include <Main/viewmgr.hxx>
+#include <Main/viewer.hxx>
#include "HUD.hxx"
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)),
_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);
HUD::~HUD()
{
+ _path->removeChangeListener(this);
_visibility->removeChangeListener(this);
_3DenabledN->removeChangeListener(this);
_antialiasing->removeChangeListener(this);
void HUD::init()
{
+ const char* fontName = 0;
_font_cache = globals->get_fontcache();
+ if (!_font) {
+ fontName = fgGetString("/sim/hud/font/name", "Helvetica.txf");
+ _font = _font_cache->getTexFont(fontName);
+ }
if (!_font)
- _font = _font_cache->getTexFont(fgGetString("/sim/hud/font/name", "Helvetica.txf"));
- if (!_font)
- throw sg_throwable(string("/sim/hud/font/name is not a texture font"));
+ throw sg_io_exception("/sim/hud/font/name is not a texture font",
+ sg_location(fontName));
_font_size = fgGetFloat("/sim/hud/font/size", 8);
_font_renderer->setFont(_font);
_font_renderer->setPointSize(_font_size);
_text_list.setFont(_font_renderer);
- load(fgGetString("/sim/hud/path[1]", "Huds/default.xml"));
+ _path->fireValueChanged();
}
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)
_cl = clamp(_alpha_clamp->getFloatValue());
_units = strcmp(_unitsN->getStringValue(), "feet") ? METER : FEET;
+ _listener_active = false;
}