]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/hud.cxx
Property patches from Frederic Bouvier:
[flightgear.git] / src / Cockpit / hud.cxx
index 74c2d08fffd3fb3b7d9240d3e548d0bf3dd13e79..9d5f5272b64a44ba18be81017bf4208771119248 100644 (file)
 
 #include <GL/glut.h>
 #include <stdlib.h>
+#include <stdio.h>             // char related functions
+#include <string.h>            // strcmp()
 #include STL_STRING
 #include STL_FSTREAM
 
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/props.hxx>
+#include <simgear/misc/sg_path.hxx>
 //#include <simgear/math/fg_random.h>
 //#include <simgear/math/polar3d.hxx>
 
@@ -390,6 +393,8 @@ readCard(const SGPropertyNode * node)
         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") {
@@ -643,10 +648,12 @@ readTBI(const SGPropertyNode * node)
 
 int readInstrument(const SGPropertyNode * node)
 {
+    static const SGPropertyNode *startup_units_node
+        = fgGetNode("/sim/startup/units");
 
     instr_item *HIptr;
     
-    if ( fgGetString("/sim/startup/units") == "feet" ) {
+    if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
         strcpy(units, " ft");
     } else {
         strcpy(units, " m");
@@ -931,7 +938,7 @@ void fgHUDalphaInit( void ) {
     char *s;
 
     int labelX = (DialogWidth / 2) -
-        (puGetStringWidth( puGetDefaultLabelFont(), Label ) / 2);
+        ( puGetDefaultLabelFont().getStringWidth( Label ) / 2);
        
     int nSliders = 1;
     int slider_x = 10;
@@ -946,8 +953,8 @@ void fgHUDalphaInit( void ) {
     puGetDefaultFonts ( &HUDalphaLegendFont, &HUDalphaLabelFont );
        
     HUDalphaDialog = new puDialogBox ( DialogX, DialogY ); {
-        int horiz_slider_height = puGetStringHeight (HUDalphaLabelFont) +
-            puGetStringDescender (HUDalphaLabelFont) +
+        int horiz_slider_height = HUDalphaLabelFont.getStringHeight() +
+            HUDalphaLabelFont.getStringDescender() +
             PUSTR_TGAP + PUSTR_BGAP + 5;
 
         /* puFrame *
@@ -1033,8 +1040,8 @@ static void set_hud_color(float r, float g, float b) {
 void fgUpdateHUD( void ) {
        
     static const float normal_aspect = float(640) / float(480);
-    // note: win_ratio is Y/X
-    float current_aspect = 1.0f/globals->get_current_view()->get_win_ratio();
+    // note: aspect_ratio is Y/X
+    float current_aspect = 1.0f/globals->get_current_view()->get_aspect_ratio();
     if( current_aspect > normal_aspect ) {
         float aspect_adjust = current_aspect / normal_aspect;
         float adjust = 320.0f*aspect_adjust - 320.0f;
@@ -1180,31 +1187,31 @@ void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
     // char scratch[128];
     // HUD_TextList.add( fgText( "AUTOPILOT", 20, apY) );
     // apY -= 15;
-    if( current_autopilot->get_HeadingEnabled() ) {
+    if( globals->get_autopilot()->get_HeadingEnabled() ) {
         HUD_TextList.add( fgText( 40, apY, 
-                                  current_autopilot->get_TargetHeadingStr()) );
+                                  globals->get_autopilot()->get_TargetHeadingStr()) );
         apY -= 15;
     }
-    if( current_autopilot->get_AltitudeEnabled() ) {
+    if( globals->get_autopilot()->get_AltitudeEnabled() ) {
         HUD_TextList.add( fgText( 40, apY, 
-                                  current_autopilot->get_TargetAltitudeStr()) );
+                                  globals->get_autopilot()->get_TargetAltitudeStr()) );
         apY -= 15;
     }
-    if( current_autopilot->get_HeadingMode() == 
+    if( globals->get_autopilot()->get_HeadingMode() == 
         FGAutopilot::FG_HEADING_WAYPOINT )
     {
         char *wpstr;
-        wpstr = current_autopilot->get_TargetWP1Str();
+        wpstr = globals->get_autopilot()->get_TargetWP1Str();
         if ( strlen( wpstr ) ) {
             HUD_TextList.add( fgText( 40, apY, wpstr ) );
             apY -= 15;
         }
-        wpstr = current_autopilot->get_TargetWP2Str();
+        wpstr = globals->get_autopilot()->get_TargetWP2Str();
         if ( strlen( wpstr ) ) {
             HUD_TextList.add( fgText( 40, apY, wpstr ) );
             apY -= 15;
         }
-        wpstr = current_autopilot->get_TargetWP3Str();
+        wpstr = globals->get_autopilot()->get_TargetWP3Str();
         if ( strlen( wpstr ) ) {
             HUD_TextList.add( fgText( 40, apY, wpstr ) );
                 apY -= 15;