-#include <Main/fg_props.hxx>
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include "hud.hxx"
node->getBoolValue("working", true),
node->getIntValue("digits")),
pformat(node->getStringValue("label_format")),
- pre_str(node->getStringValue("pre_label_string")),
- post_str(node->getStringValue("post_label_string")),
fontSize(fgGetInt("/sim/startup/xsize") > 1000 ? HUD_FONT_LARGE : HUD_FONT_SMALL), // FIXME
blink(node->getIntValue("blinking")),
lat(node->getBoolValue("latitude", false)),
lon(node->getBoolValue("longitude", false)),
- lbox(node->getBoolValue("label_box", false))
+ lbox(node->getBoolValue("label_box", false)),
+ lon_node(fgGetNode("/position/longitude-string", true)),
+ lat_node(fgGetNode("/position/latitude-string", true))
{
SG_LOG(SG_INPUT, SG_INFO, "Done reading instr_label instrument "
<< node->getStringValue("name", "[unnamed]"));
else if (just == 2)
justify = RIGHT_JUST;
- if (!strcmp(pre_str, "NULL"))
- pre_str = NULL;
- else if (!strcmp(pre_str, "blank"))
+ string pre_str(node->getStringValue("pre_label_string"));
+ if (pre_str== "NULL")
+ pre_str.clear();
+ else if (pre_str == "blank")
pre_str = " ";
const char *units = strcmp(fgGetString("/sim/startup/units"), "feet") ? " m" : " ft"; // FIXME
- if (!strcmp(post_str, "blank"))
+ string post_str(node->getStringValue("post_label_string"));
+ if (post_str== "NULL")
+ post_str.clear();
+ else if (post_str == "blank")
post_str = " ";
- else if (!strcmp(post_str, "NULL"))
- post_str = NULL;
- else if (!strcmp(post_str, "units"))
+ else if (post_str == "units")
post_str = units;
-
- if (pre_str != NULL) {
- if (post_str != NULL)
- sprintf(format_buffer, "%s%s%s", pre_str, pformat, post_str);
- else
- sprintf(format_buffer, "%s%s", pre_str, pformat);
-
- } else if (post_str != NULL) {
- sprintf(format_buffer, "%s%s", pformat, post_str);
- } else {
- strcpy(format_buffer, pformat); // FIXME
- }
+ format_buffer = pre_str + pformat;
+ format_buffer += post_str;
}
int lenstr;
RECT scrn_rect = get_location();
+ memset( label_buffer, 0, sizeof( label_buffer));
if (data_available()) {
if (lat)
- sprintf(label_buffer, format_buffer, coord_format_lat(get_value()));
+ snprintf(label_buffer, sizeof( label_buffer)-1, format_buffer.c_str(), lat_node->getStringValue());
else if (lon)
- sprintf(label_buffer, format_buffer, coord_format_lon(get_value()));
+ snprintf(label_buffer, sizeof( label_buffer)-1, format_buffer.c_str(), lon_node->getStringValue());
else {
if (lbox) {// Box for label
float x = scrn_rect.left;
glDisable(GL_LINE_STIPPLE);
glPopMatrix();
}
- sprintf(label_buffer, format_buffer, get_value() * data_scaling());
+ snprintf(label_buffer, sizeof(label_buffer)-1, format_buffer.c_str(), get_value() * data_scaling());
}
} else {
- sprintf(label_buffer, format_buffer);
+ snprintf(label_buffer, sizeof( label_buffer) -1, format_buffer.c_str());
}
lenstr = getStringWidth(label_buffer);
label_buffer, get_digits());
}
}
-
-