]> git.mxchange.org Git - flightgear.git/commitdiff
Erik Hofman:
authorcurt <curt>
Fri, 4 Oct 2002 15:19:07 +0000 (15:19 +0000)
committercurt <curt>
Fri, 4 Oct 2002 15:19:07 +0000 (15:19 +0000)
This patch fixes some bugs for correctly reporting un-updated
configuration files, and adds support for a --language=<code>
commandline option, overriding the language specified by the OS.

src/Main/main.cxx
src/Main/options.cxx

index 5d0f6fb30f76c4809354c3b1ac6b42cb04a36fe6..a9486a90f20c249ce46d1bded07c3e2776e25632 100644 (file)
@@ -477,6 +477,15 @@ void fgRenderFrame() {
             glEnable(GL_DEPTH_TEST);
             glEnable(GL_BLEND);
             glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) ;
+
+            /*
+            glEnable( GL_TEXTURE_2D );
+            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+            */
+
             if ( _bcloud_orig ) {
                 Point3D c = globals->get_scenery()->get_center();
                 sgClouds3d->Set_Cloud_Orig( &c );
@@ -778,6 +787,19 @@ void fgRenderFrame() {
             glDisable( GL_FOG );
             glDisable( GL_LIGHTING );
             // cout << "drawing new clouds" << endl;
+
+            glEnable(GL_DEPTH_TEST);
+            glEnable(GL_BLEND);
+            glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) ;
+
+            /*
+            glEnable( GL_TEXTURE_2D );
+            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+            */
+
             sgClouds3d->Draw((sgVec4 *)current__view->get_VIEW());
             glEnable( GL_FOG );
             glEnable( GL_LIGHTING );
@@ -1449,23 +1471,19 @@ int fgGlutInitEvents( void ) {
 }
 
 // Initialize the localization
-SGPropertyNode *fgInitLocale() {
+SGPropertyNode *fgInitLocale(const char *language) {
    SGPropertyNode *c_node = NULL, *d_node = NULL;
+   SGPropertyNode *intl = fgGetNode("/sim/intl");
 
-   // 
-   // Detect the current language
-   //
-   char *language = getenv("LANG");
-   if (language == NULL) {
-      SG_LOG(SG_GENERAL, SG_ALERT, "Unable to detect the current language" );
-      language = "C";
-   }
-
-   SGPropertyNode *intl = fgGetNode("/sim/intl", "");
+   SG_LOG(SG_GENERAL, SG_INFO, "Selected language: " << language );
 
+   // localization not defined
    if (!intl)
       return NULL;
   
+   //
+   // Select the proper language from the list
+   //
    vector<SGPropertyNode_ptr> locale = intl->getChildren("locale");
    for (unsigned int i = 0; i < locale.size(); i++) {
 
@@ -1479,6 +1497,9 @@ SGPropertyNode *fgInitLocale() {
       }
    }
 
+   // No <locale> tags defined
+   if (!c_node)
+      return NULL;
 
    //
    // Load the default strings
@@ -1608,12 +1629,24 @@ int mainLoop( int argc, char **argv ) {
     }
 
     // Initialize the localization routines
-    SGPropertyNode *locale = fgInitLocale();
-    if (!locale)
-       return false;
+    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;
 
-    globals->set_locale( locale );
+           return false;
+        }
 
+        globals->set_locale( locale );
+    }
 
     // Initialize the Window/Graphics environment.
     if( !fgGlutInit(&argc, argv) ) {
index 79c2ee290aa044ddbc0ebe5ffdfbc3f3e5632ad2..f414b91ed0af2dd838395de9ab67838480f9fbe6 100644 (file)
@@ -60,6 +60,9 @@
 #include "options.hxx"
 #include "viewmgr.hxx"
 
+// Hack: from main.cxx
+extern SGPropertyNode *fgInitLocale(const char *);
+
 SG_USING_STD(string);
 SG_USING_NAMESPACE(std);
 
@@ -601,6 +604,8 @@ parse_option (const string& arg)
     } else if ( (arg == "--verbose") || (arg == "-v") ) {
         // verbose help/usage request
         return(FG_OPTIONS_VERBOSE_HELP);
+    } else if ( arg.find( "--language=") == 0 ) {
+        globals->set_locale( fgInitLocale( arg.substr( 11 ).c_str() ) );
     } else if ( arg == "--disable-game-mode") {
        fgSetBool("/sim/startup/game-mode", false);
     } else if ( arg == "--enable-game-mode" ) {
@@ -1147,7 +1152,7 @@ fgParseOptions (const string& path) {
         }
 
        if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
-            cout << endl << "Config file parse error: " << path << " '" 
+            cerr << endl << "Config file parse error: " << path << " '" 
                    << line << "'" << endl;
            fgUsage();
            exit(-1);
@@ -1268,7 +1273,7 @@ void fgShowAircraft(void) {
 
    dirp = ulOpenDir(path.c_str());
    if (dirp == NULL) {
-      cout << "Unable to open aircraft directory." << endl;
+      cerr << "Unable to open aircraft directory." << endl;
       exit(-1);
    }