]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/hud_gaug.cxx
Merge branch 'torsten/metar'
[flightgear.git] / src / Cockpit / hud_gaug.cxx
index 51568fd30acd6237b882ef9dfb680ad62e04523a..7a4d5ce6fe52a65f373fb56e8539479b8a503672 100644 (file)
@@ -6,6 +6,7 @@
 #define textString(x, y, text, digit)  puDrawString(guiFnt, text, x, y)
 #endif
 
+FLTFNPTR get_func(const char *name);   // FIXME
 
 gauge_instr::gauge_instr(const SGPropertyNode *node) :
     instr_scale(
@@ -23,43 +24,12 @@ gauge_instr::gauge_instr(const SGPropertyNode *node) :
             node->getIntValue("minor_divs"),
             node->getIntValue("modulator"), // "rollover"
             0, /* hud.cxx: static int dp_shoing = 0; */    // FIXME
-            node->getBoolValue("working"))
+            node->getBoolValue("working", true))
 {
-    SG_LOG(SG_INPUT, SG_INFO, "Done reading gauge instrument "
+    SG_LOG(SG_INPUT, SG_BULK, "Done reading gauge instrument "
             << node->getStringValue("name", "[unnamed]"));
 
-    string loadfn = node->getStringValue("loadfn");            // FIXME
-    float (*load_fn)(void);
-    if (loadfn=="anzg") {
-        load_fn = get_anzg;
-    } else if (loadfn=="heading") {
-        load_fn = get_heading;
-    } else if (loadfn=="aoa") {
-        load_fn = get_aoa;
-    } else if (loadfn=="climb") {
-        load_fn = get_climb_rate;
-    } else if (loadfn=="altitude") {
-        load_fn = get_altitude;
-    } else if (loadfn=="agl") {
-        load_fn = get_agl;
-    } else if (loadfn=="speed") {
-        load_fn = get_speed;
-    } else if (loadfn=="view_direction") {
-        load_fn = get_view_direction;
-    } else if (loadfn=="aileronval") {
-        load_fn = get_aileronval;
-    } else if (loadfn=="elevatorval") {
-        load_fn = get_elevatorval;
-    } else if (loadfn=="elevatortrimval") {
-        load_fn = get_elev_trimval;
-    } else if (loadfn=="rudderval") {
-        load_fn = get_rudderval;
-    } else if (loadfn=="throttleval") {
-        load_fn = get_throttleval;
-    } else
-        load_fn = 0;
-
-    set_data_source(load_fn);
+    set_data_source(get_func(node->getStringValue("loadfn")));
 }
 
 
@@ -125,8 +95,8 @@ void gauge_instr::draw(void)
 
         if (!huds_noticks(options)) {    // If not no ticks...:)
             // Calculate x marker offsets
-            int last = (int)vmax + 1;    // FloatToInt(vmax)+1;
-            i = (int)vmin; //FloatToInt(vmin);
+            int last = (int)vmax + 1;    // float_to_int(vmax)+1;
+            i = (int)vmin; //float_to_int(vmin);
 
             for (; i < last; i++) {
                 // Calculate the location of this tick
@@ -165,7 +135,7 @@ void gauge_instr::draw(void)
                         if (!huds_notext(options)) {
                             disp_val = i;
                             sprintf(TextScale, "%d",
-                                    FloatToInt(disp_val * data_scaling()/*+.5*/));
+                                    float_to_int(disp_val * data_scaling()/*+.5*/));
 
                             lenstr = getStringWidth(TextScale);
 
@@ -173,12 +143,12 @@ void gauge_instr::draw(void)
                                 text_x = mid_scr.x -  lenstr/2 ;
 
                             } else if (huds_left(options)) {
-                                text_x = FloatToInt(marker_xs - lenstr);
+                                text_x = float_to_int(marker_xs - lenstr);
                             } else {
-                                text_x = FloatToInt(marker_xe - lenstr);
+                                text_x = float_to_int(marker_xe - lenstr);
                             }
                             // Now we know where to put the text.
-                            text_y = FloatToInt(marker_ys);
+                            text_y = float_to_int(marker_ys);
                             textString(text_x, text_y, TextScale, 0);
                         }
                     }
@@ -190,20 +160,20 @@ void gauge_instr::draw(void)
         // have been drawn, text_x and text_y may be recycled. This is used
         // with the marker start stops to produce a pointer for each side reading
 
-        text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
+        text_y = scrn_rect.top + float_to_int((cur_value - vmin) * factor() /*+.5f*/);
         //    text_x = marker_xs - scrn_rect.left;
 
         if (huds_right(options)) {
             glBegin(GL_LINE_STRIP);
             glVertex2f(scrn_rect.left, text_y + 5);
-            glVertex2f(FloatToInt(marker_xe), text_y);
+            glVertex2f(float_to_int(marker_xe), text_y);
             glVertex2f(scrn_rect.left, text_y - 5);
             glEnd();
         }
         if (huds_left(options)) {
             glBegin(GL_LINE_STRIP);
             glVertex2f(width, text_y + 5);
-            glVertex2f(FloatToInt(marker_xs), text_y);
+            glVertex2f(float_to_int(marker_xs), text_y);
             glVertex2f(width, text_y - 5);
             glEnd();
         }
@@ -248,8 +218,8 @@ void gauge_instr::draw(void)
         }
 
 
-        int last = (int)vmax + 1; //FloatToInt(vmax)+1;
-        i = (int)vmin; //FloatToInt(vmin);
+        int last = (int)vmax + 1; //float_to_int(vmax)+1;
+        i = (int)vmin; //float_to_int(vmin);
         for (; i <last ; i++) {
             condition = true;
             if (!modulo() && i < min_val())
@@ -289,7 +259,7 @@ void gauge_instr::draw(void)
                             disp_val = i;
                         }
                         sprintf(TextScale, "%d",
-                                FloatToInt(disp_val * data_scaling()/* +.5*/));
+                                float_to_int(disp_val * data_scaling()/* +.5*/));
                         lenstr = getStringWidth(TextScale);
 
                         // Draw major ticks and text only if far enough from the edge.