1
0
Fork 0

Add hud-cycling back - issue #337

This commit is contained in:
James Turner 2011-12-11 14:12:17 +00:00
parent d47342a5a4
commit 7c79e16d8d
2 changed files with 24 additions and 43 deletions

View file

@ -53,8 +53,8 @@ static float clamp(float f)
HUD::HUD() : HUD::HUD() :
_path(fgGetNode("/sim/hud/path[1]", "Huds/default.xml")), _currentPath(fgGetNode("/sim/hud/current-path", true)),
_current(fgGetNode("/sim/hud/current-color", true)), _currentColor(fgGetNode("/sim/hud/current-color", true)),
_visibility(fgGetNode("/sim/hud/visibility[1]", true)), _visibility(fgGetNode("/sim/hud/visibility[1]", true)),
_3DenabledN(fgGetNode("/sim/hud/enable3d[1]", true)), _3DenabledN(fgGetNode("/sim/hud/enable3d[1]", true)),
_antialiasing(fgGetNode("/sim/hud/color/antialiased", true)), _antialiasing(fgGetNode("/sim/hud/color/antialiased", true)),
@ -85,43 +85,16 @@ HUD::HUD() :
{ {
SG_LOG(SG_COCKPIT, SG_INFO, "Initializing HUD Instrument"); SG_LOG(SG_COCKPIT, SG_INFO, "Initializing HUD Instrument");
_path->addChangeListener(this); SGPropertyNode* hud = fgGetNode("/sim/hud");
_visibility->addChangeListener(this); hud->addChangeListener(this);
_3DenabledN->addChangeListener(this);
_antialiasing->addChangeListener(this);
_transparency->addChangeListener(this);
_red->addChangeListener(this);
_green->addChangeListener(this);
_blue->addChangeListener(this);
_alpha->addChangeListener(this);
_alpha_clamp->addChangeListener(this);
_brightness->addChangeListener(this);
_current->addChangeListener(this);
_scr_widthN->addChangeListener(this);
_scr_heightN->addChangeListener(this);
_unitsN->addChangeListener(this, true);
} }
HUD::~HUD() HUD::~HUD()
{ {
_path->removeChangeListener(this); SGPropertyNode* hud = fgGetNode("/sim/hud");
_visibility->removeChangeListener(this); hud->removeChangeListener(this);
_3DenabledN->removeChangeListener(this);
_antialiasing->removeChangeListener(this);
_transparency->removeChangeListener(this);
_red->removeChangeListener(this);
_green->removeChangeListener(this);
_blue->removeChangeListener(this);
_alpha->removeChangeListener(this);
_alpha_clamp->removeChangeListener(this);
_brightness->removeChangeListener(this);
_current->removeChangeListener(this);
_scr_widthN->removeChangeListener(this);
_scr_heightN->removeChangeListener(this);
_unitsN->removeChangeListener(this);
delete _font_renderer;
deinit(); deinit();
} }
@ -144,8 +117,7 @@ void HUD::init()
_text_list.setFont(_font_renderer); _text_list.setFont(_font_renderer);
currentColorChanged(); currentColorChanged();
_currentPath->fireValueChanged();
_path->fireValueChanged();
} }
void HUD::deinit() void HUD::deinit()
@ -167,7 +139,7 @@ void HUD::deinit()
void HUD::reinit() void HUD::reinit()
{ {
deinit(); deinit();
_path->fireValueChanged(); _currentPath->fireValueChanged();
} }
void HUD::update(double dt) void HUD::update(double dt)
@ -455,9 +427,18 @@ void HUD::valueChanged(SGPropertyNode *node)
if (_listener_active) if (_listener_active)
return; return;
_listener_active = true; _listener_active = true;
if (!strcmp(node->getName(), "path")) if (!strcmp(node->getName(), "current-path")) {
load(fgGetString("/sim/hud/path[1]", "Huds/default.xml")); int pathIndex = _currentPath->getIntValue();
SGPropertyNode* pathNode = fgGetNode("/sim/hud/path", pathIndex);
std::string path("Huds/default.xml");
if (pathNode && pathNode->hasValue()) {
path = pathNode->getStringValue();
SG_LOG(SG_INSTR, SG_INFO, "will load Hud from " << path);
}
load(path.c_str());
}
if (!strcmp(node->getName(), "current-color")) { if (!strcmp(node->getName(), "current-color")) {
currentColorChanged(); currentColorChanged();
} }
@ -483,7 +464,7 @@ void HUD::valueChanged(SGPropertyNode *node)
void HUD::currentColorChanged() void HUD::currentColorChanged()
{ {
SGPropertyNode *n = fgGetNode("/sim/hud/palette", true); SGPropertyNode *n = fgGetNode("/sim/hud/palette", true);
int index = _current->getIntValue(); int index = _currentColor->getIntValue();
if (index < 0) { if (index < 0) {
index = 0; index = 0;
} }

View file

@ -218,8 +218,8 @@ private:
deque<Item *> _items; deque<Item *> _items;
deque<Item *> _ladders; deque<Item *> _ladders;
SGPropertyNode_ptr _path; SGPropertyNode_ptr _currentPath;
SGPropertyNode_ptr _current; SGPropertyNode_ptr _currentColor;
SGPropertyNode_ptr _visibility; SGPropertyNode_ptr _visibility;
SGPropertyNode_ptr _3DenabledN; SGPropertyNode_ptr _3DenabledN;
SGPropertyNode_ptr _antialiasing; SGPropertyNode_ptr _antialiasing;