]> git.mxchange.org Git - flightgear.git/commitdiff
Erik Hofman:
authorcurt <curt>
Mon, 7 Oct 2002 15:45:00 +0000 (15:45 +0000)
committercurt <curt>
Mon, 7 Oct 2002 15:45:00 +0000 (15:45 +0000)
This adds supports for a language specific font, defined in locale.xml
I've also moved the fgInitLocale() routine from main.cxx to fg_init.cxx
to prevent an ungly extern definition in options.cxx.

src/GUI/gui.cxx
src/Main/fg_init.cxx
src/Main/fg_init.hxx
src/Main/main.cxx
src/Main/options.cxx

index 29638b8fb8d42cdc0f55186e0c38269166c8b3d3..5822150226cd57caa968373556e4c9dffb438415 100644 (file)
@@ -195,7 +195,8 @@ void guiInit()
     }
 
     // Install our fast fonts
-    fntpath.append(fgGetString("/sim/font", "typewriter.txf"));
+    SGPropertyNode *locale = globals->get_locale();
+    fntpath.append(locale->getStringValue("font", "typewriter.txf"));
     guiFntHandle = new fntTexFont ;
     guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
     puFont GuiFont ( guiFntHandle, 15 ) ;
index 5bc4c492141125f4b26ed2fa1238ceb0b54f9eb5..029356efd187eae02e6e70a587e66440ddb5f86e 100644 (file)
@@ -302,6 +302,96 @@ bool fgInitConfig ( int argc, char **argv ) {
     return true;
 }
 
+// Initialize the localization
+SGPropertyNode *fgInitLocale(const char *language) {
+   SGPropertyNode *c_node = NULL, *d_node = NULL;
+   SGPropertyNode *intl = fgGetNode("/sim/intl");
+
+   SG_LOG(SG_GENERAL, SG_INFO, "Selecting 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++) {
+
+      vector<SGPropertyNode_ptr> lang = locale[i]->getChildren("lang");
+      for (unsigned int j = 0; j < lang.size(); j++) {
+
+         if (!strcmp(lang[j]->getStringValue(), language)) {
+            c_node = locale[i];
+            break;
+         }
+      }
+   }
+
+
+   // Get the defaults
+   d_node = intl->getChild("locale");
+   if (!c_node)
+      c_node = d_node;
+
+   // Check for localized font
+   SGPropertyNode *font_n = c_node->getNode("font", true);
+   if ( !strcmp(font_n->getStringValue(), "") )
+      font_n->setStringValue(d_node->getStringValue("font", "typewriter.txf"));
+
+
+   //
+   // Load the default strings
+   //
+   SGPath d_path( globals->get_fg_root() );
+
+   const char *d_path_str = d_node->getStringValue("strings");
+   if (!d_path_str) {
+      SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file.");
+      return NULL;
+   }
+
+   d_path.append(d_path_str);
+   SG_LOG(SG_GENERAL, SG_INFO, "Reading localized strings from "
+                                  << d_path.str());
+
+   SGPropertyNode *strings = c_node->getNode("strings");
+   try {
+      readProperties(d_path.str(), strings);
+   } catch (const sg_exception &e) {
+      SG_LOG(SG_GENERAL, SG_ALERT, "Unable to read the localized strings");
+      return NULL;
+   }
+
+
+   //
+   // Load the language specific strings
+   //
+   if (c_node != d_node) {
+      SGPath c_path( globals->get_fg_root() );
+
+      const char *c_path_str = c_node->getStringValue("strings");
+      if (!c_path_str) {
+         SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file.");
+         return NULL;
+      }
+
+      c_path.append(c_path_str);
+      SG_LOG(SG_GENERAL, SG_INFO, "Reading localized strings from "
+                                     << c_path.str());
+
+      try {
+         readProperties(c_path.str(), strings);
+      } catch (const sg_exception &e) {
+         SG_LOG(SG_GENERAL, SG_ALERT, "Unable to read the localized strings");
+         return NULL;
+      }
+   }
+
+   return c_node;
+}
+
 
 // find basic airport location info from airport database
 bool fgFindAirportID( const string& id, FGAirport *a ) {
index caba67dc5c92a57215da592f73ebfa6b7b546741..58beebdf874273e58494bef1e9f5aed2b64e92d0 100644 (file)
@@ -57,6 +57,10 @@ string fgBasePackageVersion();
 bool fgInitConfig ( int argc, char **argv );
 
 
+// Initialize the localization
+SGPropertyNode *fgInitLocale(const char *language);
+
+
 // General house keeping initializations
 bool fgInitGeneral ( void );
 
index 6b461876c03aaf5863eca295605a5cd45e88ec0e..b535b03ddaed1300763da05dd884494ea8b79c13 100644 (file)
@@ -1478,91 +1478,6 @@ int fgGlutInitEvents( void ) {
     return 1;
 }
 
-// Initialize the localization
-SGPropertyNode *fgInitLocale(const char *language) {
-   SGPropertyNode *c_node = NULL, *d_node = NULL;
-   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++) {
-
-      vector<SGPropertyNode_ptr> lang = locale[i]->getChildren("lang");
-      for (unsigned int j = 0; j < lang.size(); j++) {
-
-         if (!strcmp(lang[j]->getStringValue(), language)) {
-            c_node = locale[i];
-            break;
-         }
-      }
-   }
-
-   // No <locale> tags defined
-   if (!c_node)
-      return NULL;
-
-   //
-   // Load the default strings
-   //
-   d_node = intl->getChild("locale");
-   SGPath d_path( globals->get_fg_root() );
-
-   if (!c_node)
-      c_node = d_node;
-
-   const char *d_path_str = d_node->getStringValue("strings");
-   if (!d_path_str) {
-      SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file.");
-      return NULL;
-   }
-
-   d_path.append(d_path_str);
-   SG_LOG(SG_GENERAL, SG_INFO, "Reading localized strings from "
-                                  << d_path.str());
-
-   SGPropertyNode *strings = c_node->getNode("strings");
-   try {
-      readProperties(d_path.str(), strings);
-   } catch (const sg_exception &e) {
-      SG_LOG(SG_GENERAL, SG_ALERT, "Unable to read the localized strings");
-      return NULL;
-   }
-
-
-   //
-   // Load the language specific strings
-   //
-   SGPath c_path( globals->get_fg_root() );
-
-   const char *c_path_str = c_node->getStringValue("strings");
-   if (!c_path_str) {
-      SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file.");
-      return NULL;
-   }
-
-   c_path.append(c_path_str);
-   SG_LOG(SG_GENERAL, SG_INFO, "Reading localized strings from "
-                                  << c_path.str());
-
-   try {
-      readProperties(c_path.str(), strings);
-   } catch (const sg_exception &e) {
-      SG_LOG(SG_GENERAL, SG_ALERT, "Unable to read the localized strings");
-      return NULL;
-   }
-
-   return c_node;
-}
-
-
 // Main loop
 int mainLoop( int argc, char **argv ) {
 
index f414b91ed0af2dd838395de9ab67838480f9fbe6..5d40f0b801eb662ac96238c8b24caa91966a7a02 100644 (file)
@@ -60,8 +60,6 @@
 #include "options.hxx"
 #include "viewmgr.hxx"
 
-// Hack: from main.cxx
-extern SGPropertyNode *fgInitLocale(const char *);
 
 SG_USING_STD(string);
 SG_USING_NAMESPACE(std);