// HUD_label.cxx -- HUD Label // // Written by Michele America, started September 1997. // // Copyright (C) 1997 Michele F. America [micheleamerica#geocities:com] // Copyright (C) 2006 Melchior FRANZ [mfranz#aon:at] // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #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); string halign = n->getStringValue("halign", "center"); if (halign == "left") _halign = LEFT; else if (halign == "right") _halign = RIGHT; else _halign = HCENTER; _halign |= VCENTER; string pre = n->getStringValue("prefix", ""); string post = n->getStringValue("postfix", ""); 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