From 5cf14e78c4cc7e34f18a86decc99f4dfbb1873e9 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 4 Oct 2002 15:19:07 +0000 Subject: [PATCH] Erik Hofman: This patch fixes some bugs for correctly reporting un-updated configuration files, and adds support for a --language= commandline option, overriding the language specified by the OS. --- src/Main/main.cxx | 63 +++++++++++++++++++++++++++++++++----------- src/Main/options.cxx | 9 +++++-- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 5d0f6fb30..a9486a90f 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -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 locale = intl->getChildren("locale"); for (unsigned int i = 0; i < locale.size(); i++) { @@ -1479,6 +1497,9 @@ SGPropertyNode *fgInitLocale() { } } + // No 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) ) { diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 79c2ee290..f414b91ed 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -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); } -- 2.39.5