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.hxx>
16 #include <Scenery/scenery.hxx>
17 #include <Time/fg_timer.hxx>
18 #include <Weather/weather.h>
23 //======================= Top of instr_label class =========================
30 const char *label_format,
31 const char *pre_label_string,
32 const char *post_label_string,
35 fgLabelJust justification,
39 instr_item( x, y, width, height,
40 data_source, scale_data,options, working ),
41 pformat ( label_format ),
42 pre_str ( pre_label_string ),
43 post_str ( post_label_string ),
44 justify ( justification ),
45 fontSize ( font_size ),
50 // I put this in to make it easy to construct a class member using the current
54 instr_label :: ~instr_label()
59 instr_label :: instr_label( const instr_label & image) :
60 instr_item((const instr_item &)image),
61 pformat ( image.pformat ),
62 pre_str ( image.pre_str ),
63 post_str ( image.post_str ),
68 instr_label & instr_label ::operator = (const instr_label & rhs )
70 if( !(this == &rhs)) {
71 instr_item::operator = (rhs);
72 pformat = rhs.pformat;
73 fontSize = rhs.fontSize;
75 justify = rhs.justify;
76 pre_str = rhs.pre_str;
77 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 if( data_available() ) {
110 sprintf( label_buffer, format_buffer, get_value() );
113 sprintf( label_buffer, format_buffer );
117 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
118 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
119 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
120 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
122 lenstr = strlen( label_buffer );
124 posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8;
126 if( justify == CENTER_JUST ) {
127 posincr = - (lenstr << 2); // -lenstr*4;
130 if( justify == LEFT_JUST ) {
131 posincr = - (lenstr << 8); // 0;
135 if( fontSize == SMALL ) {
136 textString( scrn_rect.left + posincr, scrn_rect.top,
137 label_buffer, GLUT_BITMAP_8_BY_13);
140 if( fontSize == LARGE ) {
141 textString( scrn_rect.left + posincr, scrn_rect.top,
142 label_buffer, GLUT_BITMAP_9_BY_15);