]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/gui.cxx
Added a viewmgr system and made corresponding changes to support it.
[flightgear.git] / src / GUI / gui.cxx
index 08e19fbc08c421582a943c594a43755384ba36ea..617973b0c429b606df617de3d2ce789690f20109 100644 (file)
@@ -45,6 +45,7 @@
 #  include <GL/xmesa.h>
 #endif
 
+#include STL_FSTREAM
 #include STL_STRING
 
 #include <stdlib.h>
 #include <Cockpit/panel.hxx>
 #include <Controls/controls.hxx>
 #include <FDM/flight.hxx>
-#include <Main/options.hxx>
+#include <Main/bfi.hxx>
 #include <Main/fg_init.hxx>
-#include <Main/views.hxx>
+#include <Main/fg_io.hxx>
+#include <Main/globals.hxx>
+#include <Main/save.hxx>
 #ifdef FG_NETWORK_OLK
 #include <NetworkOLK/network.h>
 #endif
-#include <Time/fg_time.hxx>
 
 #if defined( WIN32 ) && !defined( __CYGWIN__ )
 #  include <simgear/screen/win32-printer.h>
@@ -296,7 +298,8 @@ static inline void TurnCursorOn( void )
     }
 #endif
 #if defined(X_CURSOR_TWEAKS)
-    glutWarpPointer( current_view.get_winWidth()/2, current_view.get_winHeight()/2);
+    glutWarpPointer( globals->get_options()->get_xsize()/2,
+                    globals->get_options()->get_ysize()/2);
 #endif
 }
 
@@ -306,7 +309,8 @@ static inline void TurnCursorOff( void )
 #if defined(WIN32_CURSOR_TWEAKS)
     glutSetCursor(GLUT_CURSOR_NONE);
 #elif defined(X_CURSOR_TWEAKS)
-    glutWarpPointer( current_view.get_winWidth(), current_view.get_winHeight());
+    glutWarpPointer( globals->get_options()->get_xsize(),
+                    globals->get_options()->get_ysize());
 #endif
 }
 
@@ -366,14 +370,6 @@ void guiMotionFunc ( int x, int y )
     int ww, wh, need_warp = 0;
     float W, H;
     double offset;
-//  FGTime *t = FGTime::cur_time_params;
-//  if( mouse_timed_out ) {
-//      if( t->get_cur_time() > mouse_off_time ) {
-//          moused_timed_out = 0;
-//          TurnCursorOn();
-//          glutPostRedisplay () ;
-//      }
-//  }
 
     if (mouse_mode == MOUSE_POINTER) {
         puMouse ( x, y ) ;
@@ -385,14 +381,14 @@ void guiMotionFunc ( int x, int y )
         // reset left click MOUSE_VIEW toggle feature
         _mVtoggle = 0;
         
-        ww = current_view.get_winWidth();
-        wh = current_view.get_winHeight();
+        ww = globals->get_options()->get_xsize();
+        wh = globals->get_options()->get_ysize();
         
         switch (mouse_mode) {
             case MOUSE_YOKE:
                 if( !mouse_joystick_control ) {
                     mouse_joystick_control = 1;
-                    current_options.set_control_mode( fgOPTIONS::FG_MOUSE );
+                    globals->get_options()->set_control_mode( FGOptions::FG_MOUSE );
                 } else {
                     if ( left_button() ) {
                         offset = (_mX - x) * brake_sensitivity;
@@ -480,7 +476,7 @@ void guiMotionFunc ( int x, int y )
                 // do horizontal pan
                 // this could be done in above quat
                 // but requires redoing view pipeline
-                offset = current_view.get_goal_view_offset();
+                offset = globals->get_current_view()->get_goal_view_offset();
                 offset += ((_mX - x) * FG_2PI / W );
                 while (offset < 0.0) {
                     offset += FG_2PI;
@@ -488,9 +484,9 @@ void guiMotionFunc ( int x, int y )
                 while (offset > FG_2PI) {
                     offset -= FG_2PI;
                 }
-                current_view.set_goal_view_offset(offset);
+                globals->get_current_view()->set_goal_view_offset(offset);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                current_view.set_view_offset(offset);
+                globals->get_current_view()->set_view_offset(offset);
 #endif
                 break;
             
@@ -547,9 +543,9 @@ void guiMouseFunc(int button, int updown, int x, int y)
                         curquat[1] = _quat[1];
                         curquat[2] = _quat[2];
                         curquat[3] = _quat[3];
-                        current_view.set_goal_view_offset(_view_offset);
+                        globals->get_current_view()->set_goal_view_offset(_view_offset);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                        current_view.set_view_offset(_view_offset);
+                        globals->get_current_view()->set_view_offset(_view_offset);
 #endif
                     } else {
                         // center view
@@ -561,13 +557,14 @@ void guiMouseFunc(int button, int updown, int x, int y)
                         _quat[1] = curquat[1];
                         _quat[2] = curquat[2];
                         _quat[3] = curquat[3];
-                        x = current_view.get_winWidth()/2;
-                        y = current_view.get_winHeight()/2;
+                        x = globals->get_options()->get_xsize()/2;
+                        y = globals->get_options()->get_ysize()/2;
                         Quat0();
-                        _view_offset = current_view.get_goal_view_offset();
-                        current_view.set_goal_view_offset(0.0);
+                        _view_offset =
+                           globals->get_current_view()->get_goal_view_offset();
+                        globals->get_current_view()->set_goal_view_offset(0.0);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                        current_view.set_view_offset(0.0);
+                        globals->get_current_view()->set_view_offset(0.0);
 #endif
                     }
                     glutWarpPointer( x , y);
@@ -583,8 +580,8 @@ void guiMouseFunc(int button, int updown, int x, int y)
                     _savedX = x;
                     _savedY = y;
                     // start with zero point in center of screen
-                    _mX = current_view.get_winWidth()/2;
-                    _mY = current_view.get_winHeight()/2;
+                    _mX = globals->get_options()->get_xsize()/2;
+                    _mY = globals->get_options()->get_ysize()/2;
                     
                     // try to have the MOUSE_YOKE position
                     // reflect the current stick position
@@ -599,9 +596,9 @@ void guiMouseFunc(int button, int updown, int x, int y)
                     
                 case MOUSE_YOKE:
                     mouse_mode = MOUSE_VIEW;
-                    current_options.set_control_mode( fgOPTIONS::FG_JOYSTICK );
-                    x = current_view.get_winWidth()/2;
-                    y = current_view.get_winHeight()/2;
+                    globals->get_options()->set_control_mode( FGOptions::FG_JOYSTICK );
+                    x = globals->get_options()->get_xsize()/2;
+                    y = globals->get_options()->get_ysize()/2;
                     _mVtoggle = 0;
                     Quat0();
                     build_rotmatrix(quat_mat, curquat);
@@ -616,9 +613,9 @@ void guiMouseFunc(int button, int updown, int x, int y)
 #ifdef RESET_VIEW_ON_LEAVING_MOUSE_VIEW
                     Quat0();
                     build_rotmatrix(quat_mat, curquat);
-                    current_view.set_goal_view_offset(0.0);
+                    globals->get_current_view()->set_goal_view_offset(0.0);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                    current_view.set_view_offset(0.0);
+                    globals->get_current_view()->set_view_offset(0.0);
 #endif
 #endif      // RESET_VIEW_ON_LEAVING_MOUSE_VIEW
                     glutSetCursor(GLUT_CURSOR_INHERIT);
@@ -644,7 +641,7 @@ void guiMouseFunc(int button, int updown, int x, int y)
     // know what's going on.
     if (mouse_mode == MOUSE_POINTER) {
       if (!puMouse (button, updown, x,y)) {
-       current_panel.doMouseAction(button, updown, x, y);
+       current_panel->doMouseAction(button, updown, x, y);
       }
     }
     
@@ -672,23 +669,6 @@ void mkDialog (const char *txt)
     FG_PUSH_PUI_DIALOG( dialogBox );
 }
 
-// Repair any damage done to the Panel by other Gui Items
-void guiFixPanel( void )
-{
-    int toggle_pause;
-
-    if ( current_options.get_panel_status() ) {
-        FGView *v = &current_view;
-        FGTime *t = FGTime::cur_time_params;
-
-        if( (toggle_pause = !t->getPause()) )
-            t->togglePauseMode();
-
-        if(toggle_pause)
-            t->togglePauseMode();
-    }
-}
-
 // Toggle the Menu and Mouse display state
 void guiToggleMenu(void)
 {
@@ -713,6 +693,36 @@ void guiToggleMenu(void)
 the Gui callback functions 
 ____________________________________________________________________*/
 
+static void saveFlight(puObject *cv)
+{
+    BusyCursor(0);
+    ofstream output("fgfs.sav");
+    if (output.good() && fgSaveFlight(output)) {
+      output.close();
+      mkDialog("Saved flight to ./fgfs.sav");
+      FG_LOG(FG_INPUT, FG_INFO, "Saved flight to fgfs.sav");
+    } else {
+      mkDialog("Cannot save flight to ./fgfs.sav");
+      FG_LOG(FG_INPUT, FG_ALERT, "Cannot save flight to fgfs.sav");
+    }
+    BusyCursor(1);
+}
+
+static void loadFlight(puObject *cb)
+{
+    BusyCursor(0);
+    ifstream input("fgfs.sav");
+    if (input.good() && fgLoadFlight(input)) {
+      input.close();
+      mkDialog("Loaded flight from fgfs.sav");
+      FG_LOG(FG_INPUT, FG_INFO, "Restored flight from ./fgfs.sav");
+    } else {
+      mkDialog("Failed to load flight from fgfs.sav");
+      FG_LOG(FG_INPUT, FG_ALERT, "Cannot load flight from ./fgfs.sav");
+    }
+    BusyCursor(1);
+}
+
 void reInit(puObject *cb)
 {
     BusyCursor(0);
@@ -721,11 +731,16 @@ void reInit(puObject *cb)
     fgReInitSubsystems();
     BusyCursor(1);
 }
+
+static void toggleClouds(puObject *cb)
+{
+    FGBFI::setClouds( !FGBFI::getClouds() );
+}
        
 // This is the accessor function
 void guiTogglePanel(puObject *cb)
 {
-    current_options.toggle_panel();
+    globals->get_options()->toggle_panel();
 }
     
 //void MenuHideMenuCb(puObject *cb)
@@ -741,15 +756,15 @@ void goodBye(puObject *)
     cout << "Program exiting normally at user request." << endl;
 
 #ifdef FG_NETWORK_OLK    
-    if ( current_options.get_network_olk() ) {
+    if ( globals->get_options()->get_network_olk() ) {
        if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
     }
 #endif
 
-    //  if(gps_bug)
-    //      fclose(gps_bug);
+    // close all external I/O connections
+    fgIOShutdownAll();
 
-    exit(-1);
+    exit(0);
 }
 
 
@@ -761,8 +776,8 @@ void goAwayCb (puObject *me)
 void mkDialogInit (void)
 {
     //  printf("mkDialogInit\n");
-    int x = (current_options.get_xsize()/2 - 400/2);
-    int y = (current_options.get_ysize()/2 - 100/2);
+    int x = (globals->get_options()->get_xsize()/2 - 400/2);
+    int y = (globals->get_options()->get_ysize()/2 - 100/2);
     dialogBox = new puDialogBox (x, y); // 150, 50
     {
         dialogFrame = new puFrame (0,0,400,100);
@@ -794,8 +809,8 @@ void ConfirmExitDialogInit(void)
     //  printf("ConfirmExitDialogInit\n");
     int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
 
-    int x = (current_options.get_xsize()/2 - 400/2);
-    int y = (current_options.get_ysize()/2 - 100/2);
+    int x = (globals->get_options()->get_xsize()/2 - 400/2);
+    int y = (globals->get_options()->get_ysize()/2 - 100/2);
        
     YNdialogBox = new puDialogBox (x, y); // 150, 50
     //  YNdialogBox = new puDialogBox (150, 50);
@@ -809,11 +824,11 @@ void ConfirmExitDialogInit(void)
         
         YNdialogBoxOkButton =  new puOneShot      (100, 10, 160, 50);
         YNdialogBoxOkButton -> setLegend          (gui_msg_OK);
+        YNdialogBoxOkButton -> makeReturnDefault  (TRUE );
         YNdialogBoxOkButton -> setCallback        (goodBye);
         
         YNdialogBoxNoButton =  new puOneShot      (240, 10, 300, 50);
         YNdialogBoxNoButton -> setLegend          (gui_msg_NO);
-        //      YNdialogBoxNoButton -> makeReturnDefault  (TRUE );
         YNdialogBoxNoButton -> setCallback        (goAwayYesNoCb);
     }
     FG_FINALIZE_PUI_DIALOG( YNdialogBox );
@@ -867,35 +882,30 @@ static GlBitmap *b1 = NULL;
 extern FGInterface cur_view_fdm;
 GLubyte *hiResScreenCapture( int multiplier )
 {
-       float oldfov = current_options.get_fov();
-       float fov = oldfov / multiplier;
-       FGView *v = &current_view;
-       current_options.set_fov(fov);
-       v->force_update_fov_math();
+    float oldfov = globals->get_options()->get_fov();
+    float fov = oldfov / multiplier;
+    FGViewer *v = globals->get_current_view();
+    globals->get_options()->set_fov(fov);
     fgInitVisuals();
-    int cur_width = current_view.get_winWidth( );
-    int cur_height = current_view.get_winHeight( );
-       if (b1) delete( b1 );
-       // New empty (mostly) bitmap
-       b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
-       int x,y;
-       for ( y = 0; y < multiplier; y++ )
-       {
-               for ( x = 0; x < multiplier; x++ )
-               {
-                       fgReshape( cur_width, cur_height );
-                       // pan to tile
-                       rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
-                       fgRenderFrame();
-                       // restore view
-                       GlBitmap b2;
-                       b1->copyBitmap( &b2, cur_width*x, cur_height*y );
-               }
+    int cur_width = globals->get_options()->get_xsize( );
+    int cur_height = globals->get_options()->get_ysize( );
+    if (b1) delete( b1 );
+    // New empty (mostly) bitmap
+    b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
+    int x,y;
+    for ( y = 0; y < multiplier; y++ ) {
+       for ( x = 0; x < multiplier; x++ ) {
+           fgReshape( cur_width, cur_height );
+           // pan to tile
+           rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
+           fgRenderFrame();
+           // restore view
+           GlBitmap b2;
+           b1->copyBitmap( &b2, cur_width*x, cur_height*y );
        }
-       current_view.UpdateViewParams(cur_view_fdm);
-       current_options.set_fov(oldfov);
-       v->force_update_fov_math();
-       return b1->getBitmap();
+    }
+    globals->get_options()->set_fov(oldfov);
+    return b1->getBitmap();
 }
 #endif
 
@@ -913,8 +923,8 @@ void printScreen ( puObject *obj ) {
     mainMenuBar->hide();
 
     CGlPrinter p( CGlPrinter::PRINT_BITMAP );
-    int cur_width = current_view.get_winWidth( );
-    int cur_height = current_view.get_winHeight( );
+    int cur_width = globals->get_options()->get_xsize( );
+    int cur_height = globals->get_options()->get_ysize( );
     p.Begin( "FlightGear", cur_width*3, cur_height*3 );
        p.End( hiResScreenCapture(3) );
 
@@ -939,6 +949,10 @@ void dumpSnapShot ( puObject *obj ) {
 void fgDumpSnapShot () {
     bool show_pu_cursor = false;
 
+    int freeze = globals->get_freeze();
+    if(!freeze)
+        globals->set_freeze( true );
+
     mainMenuBar->hide();
     TurnCursorOff();
     if ( !puCursorIsHidden() ) {
@@ -947,7 +961,8 @@ void fgDumpSnapShot () {
     }
 
     fgInitVisuals();
-    fgReshape( current_options.get_xsize(), current_options.get_ysize() );
+    fgReshape( globals->get_options()->get_xsize(),
+              globals->get_options()->get_ysize() );
 
     // we need two render frames here to clear the menu and cursor
     // ... not sure why but doing an extra fgFenderFrame() shoulnd't
@@ -956,8 +971,8 @@ void fgDumpSnapShot () {
     fgRenderFrame();
 
     my_glDumpWindow( "fgfs-screen.ppm", 
-                    current_options.get_xsize(), 
-                    current_options.get_ysize() );
+                    globals->get_options()->get_xsize(), 
+                    globals->get_options()->get_ysize() );
     
     mkDialog ("Snap shot saved to fgfs-screen.ppm");
 
@@ -970,6 +985,8 @@ void fgDumpSnapShot () {
        mainMenuBar->reveal();
     }
 
+    if(!freeze)
+        globals->set_freeze( false );
 }
 
 
@@ -995,16 +1012,16 @@ void AptDialog_Cancel(puObject *)
 
 void AptDialog_OK (puObject *)
 {
-    FGPath path( current_options.get_fg_root() );
+    FGPath path( globals->get_options()->get_fg_root() );
     path.append( "Airports" );
-    path.append( "simple.gdbm" );
+    path.append( "simple.mk4" );
     FGAirports airports( path.c_str() );
+
     FGAirport a;
     
-    FGTime *t = FGTime::cur_time_params;
-    int PauseMode = t->getPause();
-    if(!PauseMode)
-        t->togglePauseMode();
+    int freeze = globals->get_freeze();
+    if(!freeze)
+        globals->set_freeze( true );
 
     char *s;
     AptDialogInput->getValue(&s);
@@ -1022,7 +1039,11 @@ void AptDialog_OK (puObject *)
 
         if ( airports.search( AptId, &a ) )
         {
-            current_options.set_airport_id( AptId.c_str() );
+            globals->get_options()->set_airport_id( AptId.c_str() );
+            globals->get_options()->set_altitude( -9999.0 );
+           // fgSetPosFromAirportID( AptId );
+           fgSetPosFromAirportIDandHdg( AptId, 
+                                        cur_fdm_state->get_Psi() * RAD_TO_DEG);
             BusyCursor(0);
             fgReInitSubsystems();
             BusyCursor(1);
@@ -1031,22 +1052,22 @@ void AptDialog_OK (puObject *)
             mkDialog(AptId.c_str());
         }
     }
-    if( PauseMode != t->getPause() )
-        t->togglePauseMode();
+    if(!freeze)
+        globals->set_freeze( false );
 }
 
 void AptDialog_Reset(puObject *)
 {
-    //  strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
-    sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
+    //  strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 );
+    sprintf( NewAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
     AptDialogInput->setValue ( NewAirportId );
     AptDialogInput->setCursor( 0 ) ;
 }
 
 void NewAirport(puObject *cb)
 {
-    //  strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
-    sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
+    //  strncpy( NewAirportId, globals->get_options()->get_airport_id().c_str(), 16 );
+    sprintf( NewAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
 //     cout << "NewAirport " << NewAirportId << endl;
     AptDialogInput->setValue( NewAirportId );
 
@@ -1055,7 +1076,7 @@ void NewAirport(puObject *cb)
 
 static void NewAirportInit(void)
 {
-    sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
+    sprintf( NewAirportId, "%s", globals->get_options()->get_airport_id().c_str() );
     int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
                                       NewAirportLabel ) / 2;
 
@@ -1112,10 +1133,9 @@ void NetIdDialog_OK (puObject *)
 {
     string NetId;
     
-    FGTime *t = FGTime::cur_time_params;
-    int PauseMode = t->getPause();
-    if(!PauseMode)
-        t->togglePauseMode();
+    bool freeze = globals->get_freeze();
+    if(!freeze)
+        globals->set_freeze( true );
 /*  
    The following needs some cleanup because 
    "string options.NetId" and "char *net_callsign" 
@@ -1124,19 +1144,19 @@ void NetIdDialog_OK (puObject *)
     NetId = net_callsign;
     
     NetIdDialog_Cancel( NULL );
-    current_options.set_net_id( NetId.c_str() );
+    globals->get_options()->set_net_id( NetId.c_str() );
     strcpy( fgd_callsign, net_callsign);
-//    strcpy( fgd_callsign, current_options.get_net_id().c_str());
+//    strcpy( fgd_callsign, globals->get_options()->get_net_id().c_str());
 /* Entering a callsign indicates : user wants Net HUD Info */
     net_hud_display = 1;
 
-    if( PauseMode != t->getPause() )
-        t->togglePauseMode();
+    if(!freeze)
+        globals->set_freeze( false );
 }
 
 void NewCallSign(puObject *cb)
 {
-    sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
+    sprintf( NewNetId, "%s", globals->get_options()->get_net_id().c_str() );
 //    sprintf( NewNetId, "%s", fgd_callsign );
     NetIdDialogInput->setValue( NewNetId );
 
@@ -1145,7 +1165,7 @@ void NewCallSign(puObject *cb)
 
 static void NewNetIdInit(void)
 {
-    sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
+    sprintf( NewNetId, "%s", globals->get_options()->get_net_id().c_str() );
 //    sprintf( NewNetId, "%s", fgd_callsign );
     int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
                                       NewNetIdLabel ) / 2;
@@ -1231,16 +1251,16 @@ void NetFGDDialog_OK (puObject *)
 {
     char *NetFGD;    
 
-    FGTime *t = FGTime::cur_time_params;
-    int PauseMode = t->getPause();
-    if(!PauseMode) t->togglePauseMode();
+    bool freeze = globals->get_freeze();
+    if(!freeze)
+        globals->set_freeze( true );
     NetFGDHostDialogInput->getValue( &NetFGD );
     strcpy( fgd_host, NetFGD);
     NetFGDPortLoDialogInput->getValue( (int *) &base_port );
     NetFGDPortHiDialogInput->getValue( (int *) &end_port );
     NetFGDDialog_Cancel( NULL );
-    if( PauseMode != t->getPause() )
-        t->togglePauseMode();
+    if(!freeze)
+        globals->set_freeze( false );
 }
 
 void NetFGDDialog_SCAN (puObject *)
@@ -1248,9 +1268,9 @@ void NetFGDDialog_SCAN (puObject *)
     char *NetFGD;
     int fgd_port;
     
-    FGTime *t = FGTime::cur_time_params;
-    int PauseMode = t->getPause();
-    if(!PauseMode) t->togglePauseMode();
+    bool freeze = globals->get_freeze();
+    if(!freeze)
+        globals->set_freeze( true );
 //    printf("Vor getvalue %s\n");
     NetFGDHostDialogInput->getValue( &NetFGD );
 //    printf("Vor strcpy %s\n", (char *) NetFGD);
@@ -1261,7 +1281,8 @@ void NetFGDDialog_SCAN (puObject *)
                  base_port, end_port);
     net_resolv_fgd(fgd_host);
     printf("Resolve : %d\n", net_r);
-    if( PauseMode != t->getPause() )  t->togglePauseMode();
+    if(!freeze)
+        globals->set_freeze( false );
     if ( net_r == 0 ) {
       fgd_port = 10000;
       strcpy( fgd_name, "");
@@ -1297,7 +1318,7 @@ void net_fgd_scan(puObject *cb)
 
 static void NewNetFGDInit(void)
 {
-//    sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
+//    sprintf( NewNetId, "%s", globals->get_options()->get_net_id().c_str() );
 //    sprintf( NewNetId, "%s", fgd_callsign );
     int len = 170 - puGetStringWidth( puGetDefaultLabelFont(),
                                       NewNetFGDLabel ) / 2;
@@ -1362,8 +1383,11 @@ char *fileSubmenu               [] = {
     "Print",
 #endif
     "Snap Shot",
-    /* "---------", "Save", */ 
-    "Reset", NULL
+    "---------", 
+    "Reset", 
+    "Load flight",
+    "Save flight",
+    NULL
 };
 puCallback fileSubmenuCb        [] = {
     MayBeGoodBye, /* hideMenuCb, NULL, */
@@ -1372,7 +1396,11 @@ puCallback fileSubmenuCb        [] = {
 #endif
     /* NULL, notCb, */
     dumpSnapShot,
-    reInit, NULL
+    NULL,
+    reInit, 
+    loadFlight,
+    saveFlight,
+    NULL
 };
 
 /*
@@ -1384,26 +1412,44 @@ puCallback editSubmenuCb        [] = {
 };
 */
 
+extern void fgHUDalphaAdjust( puObject * );
 char *viewSubmenu               [] = {
-    /* "Cockpit View > ", "View >","------------", */ "Toggle Panel...", NULL
+    "HUD Alpha",
+    /* "Cockpit View > ", "View >","------------", */
+    "Toggle Panel...", NULL
 };
 puCallback viewSubmenuCb        [] = {
-    /* notCb, notCb, NULL, */ guiTogglePanel, NULL
+    fgHUDalphaAdjust,
+    /* notCb, notCb, NULL, */
+    guiTogglePanel, NULL
 };
 
-char *aircraftSubmenu           [] = {
-    "Autopilot", "Heading", "Altitude", "Navigation", "Airport", 
-    /* "Communication", */ NULL
+//  "---------", 
+
+char *autopilotSubmenu           [] = {
+    "Toggle HUD Format", "Adjust AP Settings",
+    "---------", 
+    "Clear Route", "Skip Current Waypoint", "Add Waypoint",
+    "---------", 
+    "Set Altitude", "Set Heading",
+    NULL
 };
-puCallback aircraftSubmenuCb    [] = {
-    fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, NewTgtAirport, 
+
+puCallback autopilotSubmenuCb    [] = {
+    fgLatLonFormatToggle, fgAPAdjust,
+    NULL,
+    ClearRoute, PopWayPoint, AddWayPoint,
+    NULL,
+    NewAltitude, NewHeading,
     /* notCb, */ NULL
 };
 
 char *environmentSubmenu        [] = {
-    "Airport", /* "Terrain", "Weather", */ NULL
+    "Toggle Clouds",
+    "Goto Airport", /* "Terrain", "Weather", */ NULL
 };
 puCallback environmentSubmenuCb [] = {
+    toggleClouds,
     NewAirport, /* notCb, notCb, */ NULL
 };
 
@@ -1467,7 +1513,7 @@ void guiInit()
     if ( envp != NULL ) {
         fntpath.set( envp );
     } else {
-        fntpath.set( current_options.get_fg_root() );
+        fntpath.set( globals->get_options()->get_fg_root() );
        fntpath.append( "Fonts" );
     }
 
@@ -1479,7 +1525,7 @@ void guiInit()
     puSetDefaultFonts( GuiFont, GuiFont ) ;
     guiFnt = puGetDefaultLabelFont();
   
-    if ( current_options.get_mouse_pointer() == 0 ) {
+    if ( globals->get_options()->get_mouse_pointer() == 0 ) {
         // no preference specified for mouse pointer, attempt to autodetect...
         // Determine if we need to render the cursor, or if the windowing
         // system will do it.  First test if we are rendering with glide.
@@ -1494,9 +1540,9 @@ void guiInit()
             }
         }
         mouse_active = ~mouse_active;
-    } else if ( current_options.get_mouse_pointer() == 1 ) {
+    } else if ( globals->get_options()->get_mouse_pointer() == 1 ) {
         // don't show pointer
-    } else if ( current_options.get_mouse_pointer() == 2 ) {
+    } else if ( globals->get_options()->get_mouse_pointer() == 2 ) {
         // force showing pointer
         puShowCursor();
         mouse_active = ~mouse_active;
@@ -1521,11 +1567,13 @@ void guiInit()
     mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
     // mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
     mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
-    mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
     mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
+    mainMenuBar -> add_submenu ("Autopilot", autopilotSubmenu, autopilotSubmenuCb);
     // mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
 #ifdef FG_NETWORK_OLK
-    mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
+    if ( globals->get_options()->get_network_olk() ) {
+       mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
+    }
 #endif
     mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
     mainMenuBar-> close ();