1 #include <Main/fg_props.hxx>
5 #ifdef USE_HUD_TextList
6 #define textString(x, y, text, digit) TextString(text, x , y ,digit)
8 #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
12 extern float get_aux1(), get_aux2(), get_aux3(), get_aux4(), get_aux5(), get_aux6();
13 extern float get_aux7(), get_aux8(), get_aux9(), get_aux10(), get_aux11(), get_aux12();
14 extern float get_aux13(), get_aux14(), get_aux15(), get_aux16(), get_aux17(), get_aux18();
15 extern float get_Ax(), get_speed(), get_mach(), get_altitude(), get_agl(), get_frame_rate();
16 extern float get_heading(), get_fov(), get_vfc_tris_culled(), get_vfc_tris_drawn(), get_aoa();
17 extern float get_latitude(), get_anzg(), get_longitude(), get_throttleval();
19 instr_label::instr_label(const SGPropertyNode *node) :
21 node->getIntValue("x"),
22 node->getIntValue("y"),
23 node->getIntValue("width"),
24 node->getIntValue("height"),
25 NULL /* node->getStringValue("data_source") */, // FIXME
26 node->getFloatValue("scale_data"),
27 node->getIntValue("options"),
28 node->getBoolValue("working"),
29 node->getIntValue("digits")),
30 pformat(node->getStringValue("label_format")),
31 pre_str(node->getStringValue("pre_label_string")),
32 post_str(node->getStringValue("post_label_string")),
33 fontSize(fgGetInt("/sim/startup/xsize") > 1000 ? HUD_FONT_LARGE : HUD_FONT_SMALL), // FIXME
34 blink(node->getIntValue("blinking")),
35 lat(node->getBoolValue("latitude", false)),
36 lon(node->getBoolValue("longitude", false)),
37 lbox(node->getBoolValue("label_box", false))
39 SG_LOG(SG_INPUT, SG_INFO, "Done reading instr_label instrument "
40 << node->getStringValue("name", "[none]"));
42 string loadfn = node->getStringValue("data_source"); // FIXME
43 float (*load_fn)(void);
47 else if (loadfn == "aux2")
49 else if (loadfn == "aux3")
51 else if (loadfn == "aux4")
53 else if (loadfn == "aux5")
55 else if (loadfn == "aux6")
57 else if (loadfn == "aux7")
59 else if (loadfn == "aux8")
61 else if (loadfn == "aux9")
63 else if (loadfn == "aux10")
65 else if (loadfn == "aux11")
67 else if (loadfn == "aux12")
69 else if (loadfn == "aux13")
71 else if (loadfn == "aux14")
73 else if (loadfn == "aux15")
75 else if (loadfn == "aux16")
77 else if (loadfn == "aux17")
79 else if (loadfn == "aux18")
85 else if (loadfn == "speed")
87 else if (loadfn == "mach")
89 else if (loadfn == "altitude")
90 load_fn = get_altitude;
91 else if (loadfn == "agl")
93 else if (loadfn == "framerate")
94 load_fn = get_frame_rate;
95 else if (loadfn == "heading")
96 load_fn = get_heading;
97 else if (loadfn == "fov")
99 else if (loadfn == "vfc_tris_culled")
100 load_fn = get_vfc_tris_culled;
101 else if (loadfn == "vfc_tris_drawn")
102 load_fn = get_vfc_tris_drawn;
103 else if (loadfn == "aoa")
105 else if (loadfn == "latitude")
106 load_fn = get_latitude;
107 else if (loadfn == "anzg")
109 else if (loadfn == "longitude")
110 load_fn = get_longitude;
111 else if (loadfn =="throttleval")
112 load_fn = get_throttleval;
116 set_data_source(load_fn);
118 int just = node->getIntValue("justification");
122 justify = CENTER_JUST;
124 justify = RIGHT_JUST;
126 if (!strcmp(pre_str, "NULL"))
128 else if (!strcmp(pre_str, "blank"))
131 const char *units = strcmp(fgGetString("/sim/startup/units"), "feet") ? " m" : " ft"; // FIXME
133 if (!strcmp(post_str, "blank"))
135 else if (!strcmp(post_str, "NULL"))
137 else if (!strcmp(post_str, "units"))
141 if (pre_str != NULL) {
142 if (post_str != NULL)
143 sprintf(format_buffer, "%s%s%s", pre_str, pformat, post_str);
145 sprintf(format_buffer, "%s%s", pre_str, pformat);
147 } else if (post_str != NULL) {
148 sprintf(format_buffer, "%s%s", pformat, post_str);
150 strcpy(format_buffer, pformat); // FIXME
155 instr_label::~instr_label()
160 void instr_label::draw(void)
162 char label_buffer[80];
165 RECT scrn_rect = get_location();
167 if (data_available()) {
169 sprintf(label_buffer, format_buffer, coord_format_lat(get_value()));
171 sprintf(label_buffer, format_buffer, coord_format_lon(get_value()));
173 if (lbox) {// Box for label
174 float x = scrn_rect.left;
175 float y = scrn_rect.top;
176 float w = scrn_rect.right;
177 float h = HUD_TextSize;
183 glVertex2f(x - 2.0, y - 2.0);
184 glVertex2f(x + w + 2.0, y - 2.0);
185 glVertex2f(x + w + 2.0, y + h + 2.0);
186 glVertex2f(x - 2.0, y + h + 2.0);
189 glEnable(GL_LINE_STIPPLE);
190 glLineStipple(1, 0xAAAA);
193 glVertex2f(x + w + 2.0, y - 2.0);
194 glVertex2f(x + w + 2.0, y + h + 2.0);
195 glVertex2f(x - 2.0, y + h + 2.0);
196 glVertex2f(x - 2.0, y - 2.0);
199 glDisable(GL_LINE_STIPPLE);
202 sprintf(label_buffer, format_buffer, get_value() * data_scaling());
206 sprintf(label_buffer, format_buffer);
209 lenstr = getStringWidth(label_buffer);
212 fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer);
213 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n");
214 fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer);
215 fgPrintf( SG_COCKPIT, SG_DEBUG, "\n");
217 lenstr = strlen(label_buffer);
219 if (justify == RIGHT_JUST)
220 posincr = scrn_rect.right - lenstr;
221 else if (justify == CENTER_JUST)
222 posincr = get_span() - (lenstr / 2); // -lenstr*4;
223 else // justify == LEFT_JUST
226 if (fontSize == HUD_FONT_SMALL) {
227 textString(scrn_rect.left + posincr, scrn_rect.top,
228 label_buffer, get_digits());
230 } else if (fontSize == HUD_FONT_LARGE) {
231 textString(scrn_rect.left + posincr, scrn_rect.top,
232 label_buffer, get_digits());