# 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/fg_io.hxx>
+#include <Main/globals.hxx>
+#include <Main/options.hxx>
#include <Main/views.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>
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 ) ;
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 = ¤t_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)
{
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);
fgReInitSubsystems();
BusyCursor(1);
}
+
+static void toggleClouds(puObject *cb)
+{
+ FGBFI::setClouds( !FGBFI::getClouds() );
+}
// This is the accessor function
void guiTogglePanel(puObject *cb)
}
#endif
- // if(gps_bug)
- // fclose(gps_bug);
+ // close all external I/O connections
+ fgIOShutdownAll();
- exit(-1);
+ exit(0);
}
void fgDumpSnapShot () {
bool show_pu_cursor = false;
+ int freeze = globals->get_freeze();
+ if(!freeze)
+ globals->set_freeze( true );
+
mainMenuBar->hide();
TurnCursorOff();
if ( !puCursorIsHidden() ) {
}
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
mainMenuBar->reveal();
}
+ if(!freeze)
+ globals->set_freeze( false );
}
{
FGPath path( current_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);
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);
mkDialog(AptId.c_str());
}
}
- if( PauseMode != t->getPause() )
- t->togglePauseMode();
+ if(!freeze)
+ globals->set_freeze( false );
}
void AptDialog_Reset(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"
/* 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)
{
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 *)
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);
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, "");
"Print",
#endif
"Snap Shot",
- /* "---------", "Save", */
- "Reset", NULL
+ "---------",
+ "Reset",
+ "Load flight",
+ "Save flight",
+ NULL
};
puCallback fileSubmenuCb [] = {
MayBeGoodBye, /* hideMenuCb, NULL, */
#endif
/* NULL, notCb, */
dumpSnapShot,
- reInit, NULL
+ NULL,
+ reInit,
+ loadFlight,
+ saveFlight,
+ NULL
};
/*
};
char *environmentSubmenu [] = {
- "Airport", /* "Terrain", "Weather", */ NULL
+ "Toggle Clouds",
+ "Goto Airport", /* "Terrain", "Weather", */ NULL
};
puCallback environmentSubmenuCb [] = {
+ toggleClouds,
NewAirport, /* notCb, notCb, */ NULL
};
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 ();