]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/hud.cxx
Added static port system and a new altimeter model connected to it.
[flightgear.git] / src / Cockpit / hud.cxx
index 4b6933e7655a467013b4b6474aa906e7874bb9d4..4fba3ff43657ff4eaef35f6d02cf061e5584bfbf 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") {
@@ -452,7 +457,7 @@ readLabel(const SGPropertyNode * node)
 {
     instr_item *p;
 
-    int font_size = (fgGetInt("/sim/startup/xsize") > 1000) ? LARGE : SMALL;
+    int font_size = (fgGetInt("/sim/startup/xsize") > 1000) ? HUD_FONT_LARGE : HUD_FONT_SMALL;
 
     name               = node->getStringValue("name");
     x                   = node->getIntValue("x");
@@ -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");
@@ -806,19 +813,19 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
 }
 //$$$ End - added, Neetha, 28 Nov 2k  
 
-static int global_day_night_switch = DAY;
+static int global_day_night_switch = HUD_DAY;
 
 void HUD_masterswitch( bool incr )
 {
     if ( fgGetBool("/sim/hud/visibility") ) {
-       if ( global_day_night_switch == DAY ) {
-           global_day_night_switch = NIGHT;
+       if ( global_day_night_switch == HUD_DAY ) {
+           global_day_night_switch = HUD_NIGHT;
        } else {
            fgSetBool("/sim/hud/visibility", false);
        }
     } else {
         fgSetBool("/sim/hud/visibility", true);
-       global_day_night_switch = DAY;
+       global_day_night_switch = HUD_DAY;
     }  
 }
 
@@ -831,42 +838,42 @@ void HUD_brightkey( bool incr_bright )
        if( incr_bright ) {
            switch (brightness)
                {
-               case BRT_LIGHT:
-                   brightness = BRT_BLACK;
+               case HUD_BRT_LIGHT:
+                   brightness = HUD_BRT_BLACK;
                    break;
 
-               case BRT_MEDIUM:
-                   brightness = BRT_LIGHT;
+               case HUD_BRT_MEDIUM:
+                   brightness = HUD_BRT_LIGHT;
                    break;
 
-               case BRT_DARK:
-                   brightness = BRT_MEDIUM;
+               case HUD_BRT_DARK:
+                   brightness = HUD_BRT_MEDIUM;
                    break;
 
-               case BRT_BLACK:
-                   brightness = BRT_DARK;
+               case HUD_BRT_BLACK:
+                   brightness = HUD_BRT_DARK;
                    break;
 
                default:
-                   brightness = BRT_BLACK;
+                   brightness = HUD_BRT_BLACK;
                }
        } else {
            switch (brightness)
                {
-               case BRT_LIGHT:
-                   brightness = BRT_MEDIUM;
+               case HUD_BRT_LIGHT:
+                   brightness = HUD_BRT_MEDIUM;
                    break;
 
-               case BRT_MEDIUM:
-                   brightness = BRT_DARK;
+               case HUD_BRT_MEDIUM:
+                   brightness = HUD_BRT_DARK;
                    break;
 
-               case BRT_DARK:
-                   brightness = BRT_BLACK;
+               case HUD_BRT_DARK:
+                   brightness = HUD_BRT_BLACK;
                    break;
 
-               case BRT_BLACK:
-                   brightness = BRT_LIGHT;
+               case HUD_BRT_BLACK:
+                   brightness = HUD_BRT_LIGHT;
                    break;
 
                default:
@@ -1093,22 +1100,22 @@ void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
         glLineWidth(1.0);
     }
 
-    if( day_night_sw == DAY) {
+    if( day_night_sw == HUD_DAY) {
         switch (brightness)
             {
-            case BRT_LIGHT:
+            case HUD_BRT_LIGHT:
                 set_hud_color (0.1f, 0.9f, 0.1f);
                 break;
 
-            case BRT_MEDIUM:
+            case HUD_BRT_MEDIUM:
                 set_hud_color (0.1f, 0.7f, 0.0f);
                 break;
 
-            case BRT_DARK:
+            case HUD_BRT_DARK:
                 set_hud_color (0.0f, 0.6f, 0.0f);
                 break;
 
-            case BRT_BLACK:
+            case HUD_BRT_BLACK:
                 set_hud_color( 0.0f, 0.0f, 0.0f);
                 break;
 
@@ -1116,22 +1123,22 @@ void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
                 set_hud_color (0.1f, 0.9f, 0.1f);
             }
     } else {
-        if( day_night_sw == NIGHT) {
+        if( day_night_sw == HUD_NIGHT) {
             switch (brightness)
                 {
-                case BRT_LIGHT:
+                case HUD_BRT_LIGHT:
                     set_hud_color (0.9f, 0.1f, 0.1f);
                     break;
 
-                case BRT_MEDIUM:
+                case HUD_BRT_MEDIUM:
                     set_hud_color (0.7f, 0.0f, 0.1f);
                     break;
 
-                case BRT_DARK:
+                case HUD_BRT_DARK:
                     set_hud_color (0.6f, 0.0f, 0.0f);
                     break;
 
-                case BRT_BLACK:
+                case HUD_BRT_BLACK:
                     set_hud_color( 0.0f, 0.0f, 0.0f);
                     break;
 
@@ -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;