/* * SPDX-FileName: HUD_label.cxx * SPDX-FileComment: HUD Label * SPDX-FileCopyrightText: Copyright (C) 1997 Michele F. America [micheleamerica#geocities:com] * SPDX-FileContributor: Copyright (C) 2006 Melchior FRANZ [mfranz#aon:at] * SPDX-License-Identifier: GPL-2.0-or-later */ #ifdef HAVE_CONFIG_H # include #endif #include "HUD.hxx" #include "HUD_private.hxx" #include
HUD::Label::Label(HUD *hud, const SGPropertyNode *n, float x, float y) : Item(hud, n, x, y), _input(n->getNode("input", false)), _box(n->getBoolValue("box", false)), _pointer_width(n->getFloatValue("pointer-width", 7.0)), _pointer_length(n->getFloatValue("pointer-length", 5.0)), _blink_condition(0), _blink_interval(n->getFloatValue("blinking/interval", -1.0f)), _blink_target(0.0), _blink_state(true) { const SGPropertyNode *node = n->getNode("blinking/condition"); if (node) _blink_condition = sgReadCondition(globals->get_props(), node); std::string halign = n->getStringValue("halign", "center"); if (halign == "left") _halign = LEFT; else if (halign == "right") _halign = RIGHT; else _halign = HCENTER; _halign |= VCENTER; std::string pre = n->getStringValue("prefix", ""); std::string post = n->getStringValue("postfix", ""); std::string fmt = n->getStringValue("format", ""); if (!pre.empty()) _format = pre; if (!fmt.empty()) _format += fmt; else _format += "%s"; if (!post.empty()) _format += post; _mode = check_format(_format.c_str()); if (_mode == INVALID) { SG_LOG(SG_INPUT, SG_ALERT, "HUD: invalid format '" << _format.c_str() << "' in