]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/new_gui.cxx
Moved random ground cover object management code (userdata.[ch]xx) over
[flightgear.git] / src / GUI / new_gui.cxx
index 4e06c320c417001b6dee772c855646fa9c3edef9..63f41cba969ed3dc994eedf5b7233f6b6ee30a07 100644 (file)
@@ -5,12 +5,14 @@
 #include <plib/pu.h>
 #include <plib/ul.h>
 
+#include <simgear/compiler.h>
 #include <simgear/misc/exception.hxx>
 #include <Main/fg_props.hxx>
 
 #include "menubar.hxx"
 #include "dialog.hxx"
 
+SG_USING_STD(map);
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -37,9 +39,7 @@ NewGUI::init ()
     ulMakePath(path1, globals->get_fg_root().c_str(), "gui");
     ulMakePath(path2, path1, "dialogs");
     readDir(path2);
-#if !defined(FG_OLD_MENUBAR)
     _menubar->init();
-#endif
 }
 
 void
@@ -140,6 +140,19 @@ NewGUI::clear ()
     _dialog_props.clear();
 }
 
+static bool
+test_extension (const char * path, const char * ext)
+{
+    int pathlen = strlen(path);
+    int extlen = strlen(ext);
+    
+    for (int i = 1; i <= pathlen && i <= extlen; i++) {
+        if (path[pathlen-i] != ext[extlen-i])
+            return false;
+    }
+    return true;
+}
+
 void
 NewGUI::readDir (const char * path)
 {
@@ -159,10 +172,7 @@ NewGUI::readDir (const char * path)
 
         ulMakePath(subpath, path, dirEnt->d_name);
 
-        if (dirEnt->d_isdir) {
-            if (dirEnt->d_name[0] != '.')
-                readDir(subpath);
-        } else {
+        if (!dirEnt->d_isdir && test_extension(subpath, ".xml")) {
             SGPropertyNode * props = new SGPropertyNode;
             try {
                 readProperties(subpath, props);