]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/gui.cxx
Close all iochannel connections on exit.
[flightgear.git] / src / GUI / gui.cxx
index a084813c34d8392f7bc6b719ba68dc1bdcb89892..8fd6545d378b57f13a2789e4ed95260659702f05 100644 (file)
@@ -28,7 +28,7 @@
 #  include <config.h>
 #endif
 
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
 
 #ifdef FG_MATH_EXCEPTION_CLASH
 #  include <math.h>
 #endif
 
 #include <GL/glut.h>
-#include <XGL/xgl.h>
+#include <simgear/xgl/xgl.h>
 
 #if defined(FX) && defined(XMESA)
 #  include <GL/xmesa.h>
 #endif
 
+#include STL_FSTREAM
 #include STL_STRING
 
 #include <stdlib.h>
 #include <string.h>
 
+#include <simgear/constants.h>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/misc/fgpath.hxx>
+#include <simgear/screen/screen-dump.hxx>
+
 #include <Include/general.hxx>
-#include <Include/fg_constants.h>
-#include <Debug/logstream.hxx>
 #include <Aircraft/aircraft.hxx>
 #include <Airports/simple.hxx>
+#include <Autopilot/auto_gui.hxx>
+#include <Autopilot/newauto.hxx>
 #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/fg_io.hxx>
+#include <Main/globals.hxx>
+#include <Main/options.hxx>
 #include <Main/views.hxx>
-#include <Misc/fgpath.hxx>
-#include <Network/network.h>
-#include <Screen/screen-dump.hxx>
-#include <Time/fg_time.hxx>
+#include <Main/save.hxx>
+#ifdef FG_NETWORK_OLK
+#include <NetworkOLK/network.h>
+#endif
 
 #if defined( WIN32 ) && !defined( __CYGWIN__ )
-#  include <Screen/win32-printer.h>
+#  include <simgear/screen/win32-printer.h>
+#  include <simgear/screen/GlBitmaps.h>
 #endif
 
 /*
@@ -165,15 +175,15 @@ char *gui_msg_RESET;  // "RESET"
 static char global_dialog_string[256];
 
 // from autopilot.cxx
-extern void NewAltitude( puObject *cb );
-extern void NewHeading( puObject *cb );
-extern void fgAPAdjust( puObject * );
-extern void NewTgtAirport( puObject *cb );
-bool fgAPTerrainFollowEnabled( void );
-bool fgAPAltitudeEnabled( void );
-bool fgAPHeadingEnabled( void );
-bool fgAPWayPointEnabled( void );
-bool fgAPAutoThrottleEnabled( void );
+// extern void NewAltitude( puObject *cb );
+// extern void NewHeading( puObject *cb );
+// extern void fgAPAdjust( puObject * );
+// extern void NewTgtAirport( puObject *cb );
+// bool fgAPTerrainFollowEnabled( void );
+// bool fgAPAltitudeEnabled( void );
+// bool fgAPHeadingEnabled( void );
+// bool fgAPWayPointEnabled( void );
+// bool fgAPAutoThrottleEnabled( void );
 
 // from cockpit.cxx
 extern void fgLatLonFormatToggle( puObject *);
@@ -360,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 ) ;
@@ -394,20 +396,20 @@ void guiMotionFunc ( int x, int y )
                         offset = (_mY - y) * throttle_sensitivity;
                         controls.move_throttle(FGControls::ALL_ENGINES, offset);
                     } else if ( right_button() ) {
-                        if( !fgAPHeadingEnabled() ) {
+                        if( ! current_autopilot->get_HeadingEnabled() ) {
                             offset = (x - _mX) * rudder_sensitivity;
                             controls.move_rudder(offset);
                         }
-                        if( !fgAPAltitudeEnabled() ) {
+                        if( ! current_autopilot->get_AltitudeEnabled() ) {
                             offset = (_mY - y) * trim_sensitivity;
                             controls.move_elevator_trim(offset);
                         }
                     } else {
-                        if( !fgAPHeadingEnabled() ) {
+                        if( ! current_autopilot->get_HeadingEnabled() ) {
                             offset = (x - _mX) * aileron_sensitivity;
                             controls.move_aileron(offset);
                         }
-                        if( !fgAPAltitudeEnabled() ) {
+                        if( ! current_autopilot->get_AltitudeEnabled() ) {
                             offset = (_mY - y) * elevator_sensitivity;
                             controls.move_elevator(offset);
                         }
@@ -637,7 +639,9 @@ void guiMouseFunc(int button, int updown, int x, int y)
     // If we're in pointer mode, let PUI
     // know what's going on.
     if (mouse_mode == MOUSE_POINTER) {
-        puMouse (button, updown, x,y);
+      if (!puMouse (button, updown, x,y)) {
+       current_panel->doMouseAction(button, updown, x, y);
+      }
     }
     
     // Register the new position (if it
@@ -664,28 +668,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();
-
-        // this seems to be the only way to do this :-(
-        // problem is the viewport has been mucked with
-        xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
-        FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
-
-        if(toggle_pause)
-            t->togglePauseMode();
-    }
-}
-
 // Toggle the Menu and Mouse display state
 void guiToggleMenu(void)
 {
@@ -710,6 +692,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);
@@ -718,6 +730,11 @@ 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)
@@ -737,10 +754,16 @@ void goodBye(puObject *)
     //      "Program exiting normally at user request." );
     cout << "Program exiting normally at user request." << endl;
 
-    //  if(gps_bug)
-    //      fclose(gps_bug);
+#ifdef FG_NETWORK_OLK    
+    if ( current_options.get_network_olk() ) {
+       if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
+    }
+#endif
 
-    exit(-1);
+    // close all external I/O connections
+    fgIOShutdownAll();
+
+    exit(0);
 }
 
 
@@ -800,11 +823,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 );
@@ -847,6 +870,48 @@ void helpCb (puObject *)
     mkDialog ("Help started in netscape window.");
 }
 
+#if defined( WIN32 ) && !defined( __CYGWIN__)
+
+static void rotateView( double roll, double pitch, double yaw )
+{
+       // rotate view
+}
+
+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();
+    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 );
+               }
+       }
+       current_view.UpdateViewParams(cur_view_fdm);
+       current_options.set_fov(oldfov);
+       v->force_update_fov_math();
+       return b1->getBitmap();
+}
+#endif
 
 
 #if defined( WIN32 ) && !defined( __CYGWIN__)
@@ -861,12 +926,11 @@ void printScreen ( puObject *obj ) {
     BusyCursor( 0 );
     mainMenuBar->hide();
 
-    CGlPrinter p;
-    p.Begin( "FlightGear" );
-    fgInitVisuals();
-    fgReshape( p.GetHorzRes(), p.GetVertRes() );
-    fgRenderFrame();
-    p.End();
+    CGlPrinter p( CGlPrinter::PRINT_BITMAP );
+    int cur_width = current_view.get_winWidth( );
+    int cur_height = current_view.get_winHeight( );
+    p.Begin( "FlightGear", cur_width*3, cur_height*3 );
+       p.End( hiResScreenCapture(3) );
 
     if( menu_on ) {
        mainMenuBar->reveal();
@@ -880,10 +944,19 @@ void printScreen ( puObject *obj ) {
 #endif // #ifdef WIN32
 
 
-// do a screen snap shot
 void dumpSnapShot ( puObject *obj ) {
+    fgDumpSnapShot();
+}
+
+
+// do a screen snap shot
+void fgDumpSnapShot () {
     bool show_pu_cursor = false;
 
+    int freeze = globals->get_freeze();
+    if(!freeze)
+        globals->set_freeze( true );
+
     mainMenuBar->hide();
     TurnCursorOff();
     if ( !puCursorIsHidden() ) {
@@ -892,7 +965,7 @@ void dumpSnapShot ( puObject *obj ) {
     }
 
     fgInitVisuals();
-    fgReshape( current_options.get_xsize(), current_options.get_ysize() );
+    fgReshape( current_view.get_winWidth(), current_view.get_winHeight() );
 
     // we need two render frames here to clear the menu and cursor
     // ... not sure why but doing an extra fgFenderFrame() shoulnd't
@@ -915,6 +988,8 @@ void dumpSnapShot ( puObject *obj ) {
        mainMenuBar->reveal();
     }
 
+    if(!freeze)
+        globals->set_freeze( false );
 }
 
 
@@ -940,13 +1015,16 @@ void AptDialog_Cancel(puObject *)
 
 void AptDialog_OK (puObject *)
 {
-       fgAIRPORTS airports;
-       fgAIRPORT a;
+    FGPath path( current_options.get_fg_root() );
+    path.append( "Airports" );
+    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);
@@ -962,10 +1040,13 @@ void AptDialog_OK (puObject *)
                 "Attempting to set starting position from airport code "
                 << AptId );
 
-        airports.load("apt_simple");
         if ( airports.search( AptId, &a ) )
         {
             current_options.set_airport_id( AptId.c_str() );
+            current_options.set_altitude( -9999.0 );
+           // fgSetPosFromAirportID( AptId );
+           fgSetPosFromAirportIDandHdg( AptId, 
+                                        cur_fdm_state->get_Psi() * RAD_TO_DEG);
             BusyCursor(0);
             fgReInitSubsystems();
             BusyCursor(1);
@@ -974,8 +1055,8 @@ void AptDialog_OK (puObject *)
             mkDialog(AptId.c_str());
         }
     }
-    if( PauseMode != t->getPause() )
-        t->togglePauseMode();
+    if(!freeze)
+        globals->set_freeze( false );
 }
 
 void AptDialog_Reset(puObject *)
@@ -1029,6 +1110,8 @@ static void NewAirportInit(void)
     FG_FINALIZE_PUI_DIALOG( AptDialog );
 }
 
+#ifdef FG_NETWORK_OLK
+
 /// The beginnings of networking :-)
 //  Needs cleaning up but works
 //  These statics should disapear when this is a class
@@ -1039,6 +1122,7 @@ static puInput         *NetIdDialogInput = 0;
 
 static char NewNetId[16];
 static char NewNetIdLabel[] = "Enter New Callsign"; 
+extern char *fgd_callsign;
 
 static puOneShot       *NetIdDialogOkButton = 0;
 static puOneShot       *NetIdDialogCancelButton = 0;
@@ -1052,10 +1136,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" 
@@ -1065,16 +1148,19 @@ void NetIdDialog_OK (puObject *)
     
     NetIdDialog_Cancel( NULL );
     current_options.set_net_id( NetId.c_str() );
+    strcpy( fgd_callsign, net_callsign);
+//    strcpy( fgd_callsign, current_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", fgd_callsign );
     NetIdDialogInput->setValue( NewNetId );
 
     FG_PUSH_PUI_DIALOG( NetIdDialog );
@@ -1083,6 +1169,7 @@ void NewCallSign(puObject *cb)
 static void NewNetIdInit(void)
 {
     sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
+//    sprintf( NewNetId, "%s", fgd_callsign );
     int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
                                       NewNetIdLabel ) / 2;
 
@@ -1115,12 +1202,177 @@ static void net_display_toggle( puObject *cb)
         printf("Toggle net_hud_display : %d\n", net_hud_display);
 }
 
-static void net_blaster_toggle( puObject *cb)
+static void net_register( puObject *cb)
+{
+       fgd_send_com( "1", FGFS_host );
+        net_is_registered = 0;
+        printf("Registering to deamon\n");
+}
+
+static void net_unregister( puObject *cb)
+{
+       fgd_send_com( "8", FGFS_host );
+        net_is_registered = -1;
+        printf("Unregistering from deamon\n");
+}
+
+
+/*************** Deamon communication **********/
+
+//  These statics should disapear when this is a class
+static puDialogBox     *NetFGDDialog = 0;
+static puFrame         *NetFGDDialogFrame = 0;
+static puText          *NetFGDDialogMessage = 0;
+//static puInput         *NetFGDDialogInput = 0;
+
+//static char NewNetId[16];
+static char NewNetFGDLabel[] = "Scan for deamon                        "; 
+static char NewFGDHost[64] = "olk.mcp.de"; 
+static int  NewFGDPortLo = 10000;
+static int  NewFGDPortHi = 10001;
+//extern char *fgd_callsign;
+extern u_short base_port, end_port;
+extern int fgd_ip, verbose, current_port;
+extern char *fgd_host;
+
+
+static puOneShot       *NetFGDDialogOkButton = 0;
+static puOneShot       *NetFGDDialogCancelButton = 0;
+static puOneShot       *NetFGDDialogScanButton = 0;
+
+static puInput         *NetFGDHostDialogInput = 0;
+static puInput         *NetFGDPortLoDialogInput = 0;
+static puInput         *NetFGDPortHiDialogInput = 0;
+
+void NetFGDDialog_Cancel(puObject *)
+{
+    FG_POP_PUI_DIALOG( NetFGDDialog );
+}
+
+void NetFGDDialog_OK (puObject *)
+{
+    char *NetFGD;    
+
+    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(!freeze)
+        globals->set_freeze( false );
+}
+
+void NetFGDDialog_SCAN (puObject *)
+{
+    char *NetFGD;
+    int fgd_port;
+    
+    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);
+    strcpy( fgd_host, NetFGD);
+    NetFGDPortLoDialogInput->getValue( (int *) &base_port );
+    NetFGDPortHiDialogInput->getValue( (int *) &end_port );
+    printf("FGD: %s  Port-Start: %d Port-End: %d\n", fgd_host, 
+                 base_port, end_port);
+    net_resolv_fgd(fgd_host);
+    printf("Resolve : %d\n", net_r);
+    if(!freeze)
+        globals->set_freeze( false );
+    if ( net_r == 0 ) {
+      fgd_port = 10000;
+      strcpy( fgd_name, "");
+      for( current_port = base_port; ( current_port <= end_port); current_port++) {
+          fgd_send_com("0" , FGFS_host);
+          sprintf( NewNetFGDLabel , "Scanning for deamon Port: %d", current_port); 
+          printf("FGD: searching %s\n", fgd_name);
+          if ( strcmp( fgd_name, "") != 0 ) {
+             sprintf( NewNetFGDLabel , "Found %s at Port: %d", 
+                                              fgd_name, current_port);
+             fgd_port = current_port;
+             current_port = end_port+1;
+          }
+      }
+      current_port = end_port = base_port = fgd_port;
+    }
+    NetFGDDialog_Cancel( NULL );
+}
+
+
+void net_fgd_scan(puObject *cb)
+{
+    NewFGDPortLo = base_port;
+    NewFGDPortHi = end_port;
+    strcpy( NewFGDHost, fgd_host);
+    NetFGDPortLoDialogInput->setValue( NewFGDPortLo );
+    NetFGDPortHiDialogInput->setValue( NewFGDPortHi );
+    NetFGDHostDialogInput->setValue( NewFGDHost );
+
+    FG_PUSH_PUI_DIALOG( NetFGDDialog );
+}
+
+
+static void NewNetFGDInit(void)
 {
-       net_blast_toggle = (net_blast_toggle) ? 0 : -1;
-        printf("Toggle net_blast : %d\n", net_blast_toggle);
+//    sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
+//    sprintf( NewNetId, "%s", fgd_callsign );
+    int len = 170 - puGetStringWidth( puGetDefaultLabelFont(),
+                                      NewNetFGDLabel ) / 2;
+
+    NetFGDDialog = new puDialogBox (310, 30);
+    {
+        NetFGDDialogFrame   = new puFrame           (0,0,320, 170);
+        NetFGDDialogMessage = new puText            (len, 140);
+        NetFGDDialogMessage ->    setLabel          (NewNetFGDLabel);
+
+        NetFGDPortLoDialogInput   = new puInput           (50, 70, 127, 100);
+        NetFGDPortLoDialogInput   ->    setValue          (NewFGDPortLo);
+        NetFGDPortLoDialogInput   ->    acceptInput();
+
+        NetFGDPortHiDialogInput   = new puInput           (199, 70, 275, 100);
+        NetFGDPortHiDialogInput   ->    setValue          (NewFGDPortHi);
+        NetFGDPortHiDialogInput   ->    acceptInput();
+
+        NetFGDHostDialogInput   = new puInput           (50, 100, 275, 130);
+        NetFGDHostDialogInput   ->    setValue          (NewFGDHost);
+        NetFGDHostDialogInput   ->    acceptInput();
+
+        NetFGDDialogScanButton     =  new puOneShot   (130, 10, 200, 50);
+        NetFGDDialogScanButton     ->     setLegend   ("Scan");
+        NetFGDDialogScanButton     ->     setCallback (NetFGDDialog_SCAN);
+        NetFGDDialogScanButton     ->     makeReturnDefault(FALSE);
+
+        NetFGDDialogOkButton     =  new puOneShot   (50, 10, 120, 50);
+        NetFGDDialogOkButton     ->     setLegend   (gui_msg_OK);
+        NetFGDDialogOkButton     ->     setCallback (NetFGDDialog_OK);
+        NetFGDDialogOkButton     ->     makeReturnDefault(TRUE);
+
+        NetFGDDialogCancelButton =  new puOneShot   (210, 10, 280, 50);
+        NetFGDDialogCancelButton ->     setLegend   (gui_msg_CANCEL);
+        NetFGDDialogCancelButton ->     setCallback (NetFGDDialog_Cancel);
+
+    }
+    FG_FINALIZE_PUI_DIALOG( NetFGDDialog );
 }
 
+/*
+static void net_display_toggle( puObject *cb)
+{
+       net_hud_display = (net_hud_display) ? 0 : 1;
+        printf("Toggle net_hud_display : %d\n", net_hud_display);
+}
+
+*/
+
+#endif
+
 /***************  End Networking  **************/
 
 
@@ -1134,8 +1386,11 @@ char *fileSubmenu               [] = {
     "Print",
 #endif
     "Snap Shot",
-    /* "---------", "Save", */ 
-    "Reset", NULL
+    "---------", 
+    "Reset", 
+    "Load flight",
+    "Save flight",
+    NULL
 };
 puCallback fileSubmenuCb        [] = {
     MayBeGoodBye, /* hideMenuCb, NULL, */
@@ -1144,7 +1399,11 @@ puCallback fileSubmenuCb        [] = {
 #endif
     /* NULL, notCb, */
     dumpSnapShot,
-    reInit, NULL
+    NULL,
+    reInit, 
+    loadFlight,
+    saveFlight,
+    NULL
 };
 
 /*
@@ -1156,11 +1415,16 @@ 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           [] = {
@@ -1173,9 +1437,11 @@ puCallback aircraftSubmenuCb    [] = {
 };
 
 char *environmentSubmenu        [] = {
-    "Airport", /* "Terrain", "Weather", */ NULL
+    "Toggle Clouds",
+    "Goto Airport", /* "Terrain", "Weather", */ NULL
 };
 puCallback environmentSubmenuCb [] = {
+    toggleClouds,
     NewAirport, /* notCb, notCb, */ NULL
 };
 
@@ -1190,15 +1456,17 @@ puCallback optionsSubmenuCb     [] = {
 
 #ifdef FG_NETWORK_OLK
 char *networkSubmenu            [] = {
-    /* "Unregister from FGD ", "Send MSG to All", "Send MSG", "Show Pilots", */
-    /* "Register to FGD", */
-    /* "Scan for Deamons", */ "Enter Callsign", /* "Display Netinfos", */
-    "Toggle Display",
-    "Hyper Blast", NULL
+    "Unregister from FGD ", /* "Send MSG to All", "Send MSG", "Show Pilots", */
+    "Register to FGD",
+    "Scan for Deamons", "Enter Callsign", /* "Display Netinfos", */
+    "Toggle Display", NULL
 };
 puCallback networkSubmenuCb     [] = {
-    /* notCb, notCb, notCb, notCb, notCb, notCb, */ NewCallSign, /* notCb, */
-    net_display_toggle, net_blaster_toggle, NULL
+    /* notCb, notCb, notCb, notCb, */ 
+    net_unregister, 
+    net_register, 
+    net_fgd_scan, NewCallSign, 
+    net_display_toggle, NULL
 };
 #endif
 
@@ -1282,6 +1550,7 @@ void guiInit()
     NewAirportInit();
 #ifdef FG_NETWORK_OLK
     NewNetIdInit();
+    NewNetFGDInit();
 #endif
     mkDialogInit();
     
@@ -1294,7 +1563,9 @@ void guiInit()
     mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
     // mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
 #ifdef FG_NETWORK_OLK
-    mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
+    if ( current_options.get_network_olk() ) {
+       mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
+    }
 #endif
     mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
     mainMenuBar-> close ();