]> git.mxchange.org Git - flightgear.git/commitdiff
Eric Hofman:
authorcurt <curt>
Thu, 10 Oct 2002 15:02:50 +0000 (15:02 +0000)
committercurt <curt>
Thu, 10 Oct 2002 15:02:50 +0000 (15:02 +0000)
Now the options can be localized as well. This adds a slight problem for
the --language options, but not that much (worst case, the strings are
loaded twice consuming some more memory). I tried to be as accurate as
posiible when copying the options texts, but there might be some
mostakes left.

Thanks
src/Main/fg_init.cxx
src/Main/main.cxx
src/Main/options.cxx
src/Objects/matlib.cxx

diff --git a/Thanks b/Thanks
index 7c3c76db117ca25e8a50d8ea74ee6d772c55d176..7185ba3f2c9e5c65497e4bdb23d7daefe15d3442 100644 (file)
--- a/Thanks
+++ b/Thanks
@@ -172,6 +172,7 @@ Erik Hofman <erik@ehofman.com>
   Major overhaul and parameterization of the sound module, to allow
   aircraft-specific sound configuration at runtime.
   Irix port.
+  Localization support.
 
 
 Charlie Hotchkiss <clhotch@pacbell.net> 
@@ -233,6 +234,7 @@ David Megginson <david@megginson.com>
   3D model animation module
   initial take of sound-effects module
   Random ground cover objects
+  Vacuum and pitot systems.
 
 
 Eric Mitchell <mitchell@mars.ark.com>
@@ -278,6 +280,8 @@ Curt Olson <curt@flightgear.org>
   He has his hands in many of the areas, but is primarily responsible
   for the scenery subsystem, as well as much of the infrastructure in
   the sim.
+  Electrical system.
+  Runway lighting.
 
 
 Brian Paul
@@ -466,6 +470,11 @@ Jean-Claude Wippler <jcw@equi4.com>
   http://www.equi4.com/metakit
 
 
+John Wojnaroski <castle@mminternet.com>
+  Open Glass Cockpit project
+  3d clouds
+
+
 WoodSoup Project  http://www.woodsoup.org
   [ FlightGear no longer uses woodsoup services, but we appreciate
   the support provided to our project during the time they hosted us. ]
index 029356efd187eae02e6e70a587e66440ddb5f86e..8314d7bbdce987ac655ecc3383e3be92c32954c7 100644 (file)
@@ -228,80 +228,6 @@ string fgBasePackageVersion() {
 }
 
 
-// Read in configuration (file and command line)
-bool fgInitConfig ( int argc, char **argv ) {
-
-                                // First, set some sane default values
-    fgSetDefaults();
-
-    // Read global preferences from $FG_ROOT/preferences.xml
-    SGPath props_path(globals->get_fg_root());
-    props_path.append("preferences.xml");
-    SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
-    readProperties(props_path.str(), globals->get_props());
-    SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
-
-    // Read the default aircraft config file.
-    string aircraft = fgGetString("/sim/aircraft", "");
-    if (aircraft.size() > 0) {
-      SGPath aircraft_path(globals->get_fg_root());
-      aircraft_path.append("Aircraft");
-      aircraft_path.append(aircraft);
-      aircraft_path.concat("-set.xml");
-      SG_LOG(SG_INPUT, SG_INFO, "Reading default aircraft: " << aircraft
-             << " from " << aircraft_path.str());
-      try {
-        readProperties(aircraft_path.str(), globals->get_props());
-      } catch (const sg_exception &e) {
-        string message = "Error reading default aircraft: ";
-        message += e.getFormattedMessage();
-        SG_LOG(SG_INPUT, SG_ALERT, message);
-        exit(2);
-      }
-    } else {
-      SG_LOG(SG_INPUT, SG_ALERT, "No default aircraft specified");
-    }
-
-    // Attempt to locate and parse the various config files in order
-    // from least precidence to greatest precidence
-
-    // Check for $fg_root/system.fgfsrc
-    SGPath config( globals->get_fg_root() );
-    config.append( "system.fgfsrc" );
-    fgParseOptions(config.str());
-
-#if defined( unix ) || defined( __CYGWIN__ )
-    char name[256];
-    // Check for $fg_root/system.fgfsrc.hostname
-    gethostname( name, 256 );
-    config.concat( "." );
-    config.concat( name );
-    fgParseOptions(config.str());
-#endif
-
-    // Check for ~/.fgfsrc
-    char* envp = ::getenv( "HOME" );
-    if ( envp != NULL ) {
-        config.set( envp );
-        config.append( ".fgfsrc" );
-        fgParseOptions(config.str());
-    }
-
-#if defined( unix ) || defined( __CYGWIN__ )
-    // Check for ~/.fgfsrc.hostname
-    gethostname( name, 256 );
-    config.concat( "." );
-    config.concat( name );
-    fgParseOptions(config.str());
-#endif
-
-    // Parse remaining command line options
-    // These will override anything specified in a config file
-    fgParseArgs(argc, argv);
-
-    return true;
-}
-
 // Initialize the localization
 SGPropertyNode *fgInitLocale(const char *language) {
    SGPropertyNode *c_node = NULL, *d_node = NULL;
@@ -312,7 +238,7 @@ SGPropertyNode *fgInitLocale(const char *language) {
    // localization not defined
    if (!intl)
       return NULL;
+
    //
    // Select the proper language from the list
    //
@@ -364,7 +290,6 @@ SGPropertyNode *fgInitLocale(const char *language) {
       return NULL;
    }
 
-
    //
    // Load the language specific strings
    //
@@ -393,6 +318,109 @@ SGPropertyNode *fgInitLocale(const char *language) {
 }
 
 
+
+// Initialize the localization routines
+bool fgDetectLanguage() {
+    char *language = ::getenv("LANG");
+
+    if (language == NULL) {
+        SG_LOG(SG_GENERAL, SG_INFO, "Unable to detect the language" );
+        language = "C";
+    }
+
+    SGPropertyNode *locale = fgInitLocale(language);
+    if (!locale) {
+       cerr << "No internationalization settings specified in preferences.xml"
+            << endl;
+
+       return false;
+    }
+
+    globals->set_locale( locale );
+
+    return true;
+}
+
+
+// Read in configuration (file and command line)
+bool fgInitConfig ( int argc, char **argv ) {
+
+                                // First, set some sane default values
+    fgSetDefaults();
+
+    // Read global preferences from $FG_ROOT/preferences.xml
+    SGPath props_path(globals->get_fg_root());
+    props_path.append("preferences.xml");
+    SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
+    readProperties(props_path.str(), globals->get_props());
+    SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
+
+    // Detect the required language as early as possible
+    if (fgDetectLanguage() != true)
+       return false;
+
+    // Read the default aircraft config file.
+    string aircraft = fgGetString("/sim/aircraft", "");
+    if (aircraft.size() > 0) {
+      SGPath aircraft_path(globals->get_fg_root());
+      aircraft_path.append("Aircraft");
+      aircraft_path.append(aircraft);
+      aircraft_path.concat("-set.xml");
+      SG_LOG(SG_INPUT, SG_INFO, "Reading default aircraft: " << aircraft
+             << " from " << aircraft_path.str());
+      try {
+        readProperties(aircraft_path.str(), globals->get_props());
+      } catch (const sg_exception &e) {
+        string message = "Error reading default aircraft: ";
+        message += e.getFormattedMessage();
+        SG_LOG(SG_INPUT, SG_ALERT, message);
+        exit(2);
+      }
+    } else {
+      SG_LOG(SG_INPUT, SG_ALERT, "No default aircraft specified");
+    }
+
+    // Attempt to locate and parse the various config files in order
+    // from least precidence to greatest precidence
+
+    // Check for $fg_root/system.fgfsrc
+    SGPath config( globals->get_fg_root() );
+    config.append( "system.fgfsrc" );
+    fgParseOptions(config.str());
+
+#if defined( unix ) || defined( __CYGWIN__ )
+    char name[256];
+    // Check for $fg_root/system.fgfsrc.hostname
+    gethostname( name, 256 );
+    config.concat( "." );
+    config.concat( name );
+    fgParseOptions(config.str());
+#endif
+
+    // Check for ~/.fgfsrc
+    char* envp = ::getenv( "HOME" );
+    if ( envp != NULL ) {
+        config.set( envp );
+        config.append( ".fgfsrc" );
+        fgParseOptions(config.str());
+    }
+
+#if defined( unix ) || defined( __CYGWIN__ )
+    // Check for ~/.fgfsrc.hostname
+    gethostname( name, 256 );
+    config.concat( "." );
+    config.concat( name );
+    fgParseOptions(config.str());
+#endif
+
+    // Parse remaining command line options
+    // These will override anything specified in a config file
+    fgParseArgs(argc, argv);
+
+    return true;
+}
+
+
 // find basic airport location info from airport database
 bool fgFindAirportID( const string& id, FGAirport *a ) {
     if ( id.length() ) {
index b535b03ddaed1300763da05dd884494ea8b79c13..dbc0cfd54c05147080eb242733b140745aa1a8b0 100644 (file)
@@ -1323,7 +1323,7 @@ static void fgIdleFunction ( void ) {
        // sleep(1);
        idle_state = 1000;
 
-       cout << "Panel visible = " << fgPanelVisible() << endl;
+       SG_LOG( SG_GENERAL, SG_INFO, "Panel visible = " << fgPanelVisible() );
        fgReshape( fgGetInt("/sim/startup/xsize"),
                   fgGetInt("/sim/startup/ysize") );
     } 
@@ -1533,12 +1533,11 @@ int mainLoop( int argc, char **argv ) {
     string base_version = fgBasePackageVersion();
     if ( !(base_version == required_version) ) {
         // tell the operator how to use this application
-        fgUsage();
 
-       cout << endl << "Base package check failed ... " \
+       cerr << endl << "Base package check failed ... " \
             << "Found version " << base_version << " at: " \
              << globals->get_fg_root() << endl;
-        cout << "Please upgrade to version" << required_version << endl;
+        cerr << "Please upgrade to version" << required_version << endl;
        exit(-1);
     }
 
@@ -1551,26 +1550,6 @@ int mainLoop( int argc, char **argv ) {
        exit(-1);
     }
 
-    // Initialize the localization routines
-    if (globals->get_locale() == NULL) {
-        char *language = getenv("LANG");
-        if (language == NULL) {
-            SG_LOG(SG_GENERAL, SG_ALERT, "Unable to detect the language" );
-            language = "C";
-        }
-
-        SGPropertyNode *locale = fgInitLocale(language);
-        if (!locale) {
-           cerr
-             << "Not internationalization settings specified in preferences.xml"
-             << endl;
-
-           return false;
-        }
-
-        globals->set_locale( locale );
-    }
-
     // Initialize the Window/Graphics environment.
     if( !fgGlutInit(&argc, argv) ) {
        SG_LOG( SG_GENERAL, SG_ALERT, "GLUT initialization failed ..." );
index 5d40f0b801eb662ac96238c8b24caa91966a7a02..9dd26a91213a33a80b80a2514970d68b54cdee61 100644 (file)
@@ -1164,6 +1164,8 @@ fgParseOptions (const string& path) {
 void 
 fgUsage (bool verbose)
 {
+    SGPropertyNode *locale = globals->get_locale();
+
     SGPropertyNode options_root;
     SGPath opath( globals->get_fg_root() );
     opath.append( "options.xml" );
@@ -1188,7 +1190,7 @@ fgUsage (bool verbose)
         exit(-1);
     }
 
-    SGPropertyNode *usage = options->getNode("usage");
+    SGPropertyNode *usage = locale->getNode(options->getStringValue("usage"));
     if (usage) {
         cout << "Usage: " << usage->getStringValue() << endl;
     }
@@ -1229,25 +1231,54 @@ fgUsage (bool verbose)
                     snprintf(cstr, 96, "\n   --%s\n%32c", tmp.c_str(), ' ');
                 }
 
+                // There may be more than one <description> tag assosiated
+                // with one option
+
                 msg += cstr;
-                SGPropertyNode *desc = option[k]->getNode("description");
-                if (desc) {
-                    msg += desc->getStringValue();
-
-                    for ( unsigned int l = 1;
-                          (desc = option[k]->getNode("description", l, false));
-                          l++ )
-                    {
-                        snprintf(cstr, 96, "\n%32c%s", ' ',
-                                 desc->getStringValue());
-                        msg += cstr;
-                    }
-                    msg += '\n';
-                }
+                vector<SGPropertyNode_ptr>desc =
+                                          option[k]->getChildren("description");
+
+                if (desc.size() > 0) {
+                   for ( unsigned int l = 0; l < desc.size(); l++) {
+
+                      // There may be more than one translation line.
+
+                      string t = desc[l]->getStringValue();
+                      SGPropertyNode *n = locale->getNode("strings");
+                      vector<SGPropertyNode_ptr>trans_desc =
+                               n->getChildren(t.substr(8).c_str());
+
+                      for ( unsigned int m = 0; m < trans_desc.size(); m++ ) {
+                         string t_str = trans_desc[m]->getStringValue();
+
+                         if ((m > 0) || ((l > 0) && m == 0)) {
+                            snprintf(cstr, 96, "%32c", ' ');
+                            msg += cstr;
+
+                         }
+
+                         // If the string is too large to fit on the screen,
+                         // then split it up in several pieces.
+
+                         while ( t_str.size() > 47 ) {
+
+                            unsigned int m = t_str.rfind(' ', 47);
+                            msg += t_str.substr(0, m);
+                            snprintf(cstr, 96, "\n%32c", ' ');
+                            msg += cstr;
+
+                            t_str.erase(t_str.begin(), t_str.begin() + m + 1);
+                        }
+                        msg += t_str + '\n';
+                     }
+                  }
+               }
             }
         }
 
-        SGPropertyNode *name = section[j]->getNode("name");
+        SGPropertyNode *name =
+                            locale->getNode(section[j]->getStringValue("name"));
+
         if (!msg.empty() && name) {
            cout << endl << name->getStringValue() << ":" << endl;
            cout << msg;
index 342918bd4390f0ac9ff5b9e37258a8796e3c2d46..73103bd08c6bdd2b72b0b1948772ae7bc80588ab 100644 (file)
@@ -160,10 +160,16 @@ static int gen_vasi_light_map() {
 
             // top half white, bottom half red
             env_map[i][j][0] = 255;
-            if ( i >= half_res ) {
+            if ( i > half_res ) {
+                // white
                 env_map[i][j][1] = 255;
                 env_map[i][j][2] = 255;
+            } else if ( i == half_res - 1 || i == half_res ) {
+                // pink
+                env_map[i][j][1] = 127;
+                env_map[i][j][2] = 127;
             } else {
+                // red
                 env_map[i][j][1] = 0;
                 env_map[i][j][2] = 0;
             }