10 #include <Aircraft/aircraft.h>
11 #include <Debug/fg_debug.h>
12 #include <Include/fg_constants.h>
13 #include <Math/fg_random.h>
14 #include <Math/mat3.h>
15 #include <Math/polar3d.h>
16 #include <Scenery/scenery.hxx>
17 #include <Time/fg_timer.hxx>
18 #include <Weather/weather.h>
23 //======================= Top of instr_label class =========================
\r
30 const char *label_format,
31 const char *pre_label_string,
32 const char *post_label_string,
34 fgLabelJust justification,
38 instr_item( x, y, width, height,
39 data_source, options, working ),
40 pformat ( label_format ),
41 pre_str ( pre_label_string ),
42 post_str ( post_label_string ),
43 justify ( justification ),
44 fontSize ( font_size ),
49 // I put this in to make it easy to construct a class member using the current
53 instr_label :: ~instr_label()
58 instr_label :: instr_label( const instr_label & image) :
59 instr_item((const instr_item &)image),
60 pformat ( image.pformat ),
61 pre_str ( image.pre_str ),
62 post_str ( image.post_str ),
67 instr_label & instr_label ::operator = (const instr_label & rhs )
69 if( !(this == &rhs)) {
70 instr_item::operator = (rhs);
71 pformat = rhs.pformat;
72 fontSize = rhs.fontSize;
74 justify = rhs.justify;
75 pre_str = rhs.pre_str;
76 post_str = rhs.post_str;
83 // draw Draws a label anywhere in the HUD
87 draw( void ) // Required method in base class
89 char format_buffer[80];
90 char label_buffer[80];
93 RECT scrn_rect = get_location();
95 if( pre_str != NULL) {
96 if( post_str != NULL ) {
97 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
100 sprintf( format_buffer, "%s%s", pre_str, pformat );
104 if( post_str != NULL ) {
105 sprintf( format_buffer, "%s%s", pformat, post_str );
107 } // else do nothing if both pre and post strings are nulls. Interesting.
109 sprintf( label_buffer, format_buffer, get_value() );
111 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
112 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
113 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
114 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
116 lenstr = strlen( label_buffer );
118 posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8;
120 if( justify == CENTER_JUST ) {
121 posincr = - (lenstr << 2); // -lenstr*4;
124 if( justify == LEFT_JUST ) {
125 posincr = - (lenstr << 8); // 0;
129 if( fontSize == SMALL ) {
130 textString( scrn_rect.left + posincr, scrn_rect.top,
131 label_buffer, GLUT_BITMAP_8_BY_13);
134 if( fontSize == LARGE ) {
135 textString( scrn_rect.left + posincr, scrn_rect.top,
136 label_buffer, GLUT_BITMAP_9_BY_15);