]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/gui.cxx
Moved random ground cover object management code (userdata.[ch]xx) over
[flightgear.git] / src / GUI / gui.cxx
index f0e40a9a44666b894f13ed0095f2387b37372c74..c4d1a05f23ed395be300bc70b6e2f78d1818dedf 100644 (file)
 #  include <windows.h>
 #endif
 
-#include <simgear/misc/props.hxx>
-#include <simgear/misc/props_io.hxx>
 #include <simgear/misc/exception.hxx>
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/props/props.hxx>
+#include <simgear/props/props_io.hxx>
 
 #include <plib/pu.h>
 
 
 #include "gui.h"
 #include "gui_local.hxx"
-#include "apt_dlg.hxx"
 #include "net_dlg.hxx"
+#include "preset_dlg.hxx"
 
 
 // main.cxx hack, should come from an include someplace
 extern void fgInitVisuals( void );
-extern void fgReshape( int width, int height );
 extern void fgRenderFrame( void );
 
 extern void initDialog (void);
@@ -63,104 +62,6 @@ extern void ConfirmExitDialogInit(void);
 
 puFont guiFnt = 0;
 fntTexFont *guiFntHandle = 0;
-int gui_menu_on = 0;
-puMenuBar    *mainMenuBar = 0;
-//static puButton     *hideMenuButton = 0;
-
-
-struct fg_gui_t {
-       char *name;
-       char **submenu;
-       puCallback *cb;
-} *Menu;
-unsigned int Menu_size;
-
-void initMenu()
-{
-     SGPropertyNode main;
-     SGPath spath( globals->get_fg_root() );
-     spath.append( "menu.xml" );
-
-     try {
-         readProperties(spath.c_str(), &main);
-     } catch (const sg_exception &ex) {
-         SG_LOG(SG_GENERAL, SG_ALERT, "Error processing the menu file.");
-         return;
-     }
-
-     SG_LOG(SG_GENERAL, SG_INFO, "Reading menu entries.");
-
-     // Make the menu bar
-     mainMenuBar = new puMenuBar ();
-
-     SGPropertyNode *menu = main.getChild("menu");
-
-     vector<SGPropertyNode_ptr>submenu = menu->getChildren("submenu");
-
-     Menu_size = 1+submenu.size();
-     Menu = (fg_gui_t *)calloc(Menu_size, sizeof(fg_gui_t));
-
-     for (unsigned int h = 0; h < submenu.size(); h++) {
-
-         vector<SGPropertyNode_ptr>option = submenu[h]->getChildren("option");
-
-         //
-         // Make sure all entries will fit into allocated memory
-         //
-         Menu[h].submenu = (char **)calloc(1+option.size(), sizeof(char *));
-         Menu[h].cb = (puCallback *)calloc(1+option.size(), sizeof(puCallback));
-
-         for (unsigned int i = 0; i < option.size(); i++) {
-
-             SGPropertyNode *name = option[i]->getNode("name");
-             SGPropertyNode *call = option[i]->getNode("call");
-             SGPropertyNode *sep = option[i]->getNode("seperator");
-
-             int pos = option.size()-i-1;
-             if (sep)
-                Menu[h].submenu[pos] = strdup("----------");
-
-             else if (call && strcmp(call->getStringValue(), ""))
-                 Menu[h].submenu[pos] = strdup(name->getStringValue());
-
-             else
-                 Menu[h].submenu[pos] = strdup("not specified");
-
-             Menu[h].cb[pos] = NULL;
-             for (unsigned int j=0; __fg_gui_fn[j].fn; j++)
-                 if (call &&
-                     !strcmp(call->getStringValue(), __fg_gui_fn[j].name) )
-                 {
-                     Menu[h].cb[pos] = __fg_gui_fn[j].fn;
-                     break;
-                 }
-         }
-
-         SGPropertyNode *name = submenu[h]->getNode("name");
-
-         Menu[h].name = strdup(name->getStringValue());
-         mainMenuBar->add_submenu(Menu[h].name, Menu[h].submenu, Menu[h].cb);
-
-    }
-
-    mainMenuBar->close();
-}
-
-
-// FIXME: Has to be called from somewhere
-//        or better yet, turn the menu into a class of its own
-void destroyMenu(void) {
-    for(unsigned int i=0; i < Menu_size; i++) {
-
-        free(Menu[i].name);
-
-                                // FIXME: don't use strdup/free
-        for(unsigned int j=0; Menu[i].submenu[j] != NULL; j++)
-           free(Menu[i].submenu[j]);
-    }
-}
-
-
 
 
 /* -------------------------------------------------------------------------
@@ -175,7 +76,7 @@ void guiInit()
     // Initialize PUI
     puInit();
     puSetDefaultStyle         ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
-    puSetDefaultColourScheme  (0.8, 0.8, 0.8, 0.4);
+    puSetDefaultColourScheme  (0.8, 0.8, 0.9, 0.8);
 
     initDialog();
 
@@ -190,7 +91,8 @@ void guiInit()
     }
 
     // Install our fast fonts
-    fntpath.append( "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 ) ;
@@ -225,7 +127,7 @@ void guiInit()
 
     // Set up our Dialog Boxes
     ConfirmExitDialogInit();
-    NewAirportInit();
+    fgPresetInit();
        
 #ifdef FG_NETWORK_OLK
     NewNetIdInit();
@@ -233,13 +135,4 @@ void guiInit()
 #endif
 
     mkDialogInit();
-
-    initMenu();
-    
-    // Set up menu bar toggle
-    gui_menu_on = ~0;
-
-    if (!strcmp(fgGetString("/sim/flight-model"), "ada")) {
-        guiToggleMenu(); // Menu off by default
-    }
 }