Make HUD loading lazy upon first show.
This commit is contained in:
parent
2999675234
commit
e06b3df11e
2 changed files with 28 additions and 11 deletions
|
@ -66,6 +66,7 @@ HUD::HUD() :
|
||||||
_alpha_clamp(fgGetNode("/sim/hud/color/alpha-clamp", true)),
|
_alpha_clamp(fgGetNode("/sim/hud/color/alpha-clamp", true)),
|
||||||
_brightness(fgGetNode("/sim/hud/color/brightness", true)),
|
_brightness(fgGetNode("/sim/hud/color/brightness", true)),
|
||||||
_visible(false),
|
_visible(false),
|
||||||
|
_loaded(false),
|
||||||
_antialiased(false),
|
_antialiased(false),
|
||||||
_transparent(false),
|
_transparent(false),
|
||||||
_a(0.67), // FIXME better names
|
_a(0.67), // FIXME better names
|
||||||
|
@ -115,7 +116,8 @@ void HUD::init()
|
||||||
_font_renderer->setFont(_font);
|
_font_renderer->setFont(_font);
|
||||||
_font_renderer->setPointSize(_font_size);
|
_font_renderer->setPointSize(_font_size);
|
||||||
_text_list.setFont(_font_renderer);
|
_text_list.setFont(_font_renderer);
|
||||||
|
_loaded = false;
|
||||||
|
|
||||||
currentColorChanged();
|
currentColorChanged();
|
||||||
_currentPath->fireValueChanged();
|
_currentPath->fireValueChanged();
|
||||||
}
|
}
|
||||||
|
@ -134,6 +136,8 @@ void HUD::deinit()
|
||||||
|
|
||||||
delete _clip_box;
|
delete _clip_box;
|
||||||
_clip_box = NULL;
|
_clip_box = NULL;
|
||||||
|
|
||||||
|
_loaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::reinit()
|
void HUD::reinit()
|
||||||
|
@ -427,16 +431,28 @@ void HUD::valueChanged(SGPropertyNode *node)
|
||||||
if (_listener_active)
|
if (_listener_active)
|
||||||
return;
|
return;
|
||||||
_listener_active = true;
|
_listener_active = true;
|
||||||
if (!strcmp(node->getName(), "current-path")) {
|
|
||||||
int pathIndex = _currentPath->getIntValue();
|
bool loadNow = false;
|
||||||
SGPropertyNode* pathNode = fgGetNode("/sim/hud/path", pathIndex);
|
_visible = _visibility->getBoolValue();
|
||||||
std::string path("Huds/default.xml");
|
if (_visible && !_loaded) {
|
||||||
if (pathNode && pathNode->hasValue()) {
|
loadNow = true;
|
||||||
path = pathNode->getStringValue();
|
}
|
||||||
SG_LOG(SG_INSTR, SG_INFO, "will load Hud from " << path);
|
|
||||||
}
|
if (!strcmp(node->getName(), "current-path") && _visible) {
|
||||||
|
loadNow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadNow) {
|
||||||
|
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());
|
_loaded = true;
|
||||||
|
load(path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(node->getName(), "current-color")) {
|
if (!strcmp(node->getName(), "current-color")) {
|
||||||
|
@ -446,7 +462,7 @@ void HUD::valueChanged(SGPropertyNode *node)
|
||||||
_scr_width = _scr_widthN->getIntValue();
|
_scr_width = _scr_widthN->getIntValue();
|
||||||
_scr_height = _scr_heightN->getIntValue();
|
_scr_height = _scr_heightN->getIntValue();
|
||||||
|
|
||||||
_visible = _visibility->getBoolValue();
|
|
||||||
_3Denabled = _3DenabledN->getBoolValue();
|
_3Denabled = _3DenabledN->getBoolValue();
|
||||||
_transparent = _transparency->getBoolValue();
|
_transparent = _transparency->getBoolValue();
|
||||||
_antialiased = _antialiasing->getBoolValue();
|
_antialiased = _antialiasing->getBoolValue();
|
||||||
|
|
|
@ -228,6 +228,7 @@ private:
|
||||||
SGPropertyNode_ptr _alpha_clamp;
|
SGPropertyNode_ptr _alpha_clamp;
|
||||||
SGPropertyNode_ptr _brightness;
|
SGPropertyNode_ptr _brightness;
|
||||||
bool _visible;
|
bool _visible;
|
||||||
|
bool _loaded;
|
||||||
bool _3Denabled;
|
bool _3Denabled;
|
||||||
bool _antialiased;
|
bool _antialiased;
|
||||||
bool _transparent;
|
bool _transparent;
|
||||||
|
|
Loading…
Add table
Reference in a new issue