# 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 <Main/save.hxx>
#ifdef FG_NETWORK_OLK
#include <NetworkOLK/network.h>
#endif
-#include <Screen/screen-dump.hxx>
-#include <Time/fg_time.hxx>
#if defined( WIN32 ) && !defined( __CYGWIN__ )
-# include <Screen/win32-printer.h>
-# include <Screen/GlBitmaps.h>
+# include <simgear/screen/win32-printer.h>
+# include <simgear/screen/GlBitmaps.h>
#endif
/*
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 *);
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 ) ;
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);
}
// 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
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();
-
- // 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)
{
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)
cout << "Program exiting normally at user request." << endl;
#ifdef FG_NETWORK_OLK
- if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
+ if ( current_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);
}
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 );
// rotate view
}
-static GLBitmap *b1 = NULL;
+static GlBitmap *b1 = NULL;
extern FGInterface cur_view_fdm;
GLubyte *hiResScreenCapture( int multiplier )
{
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 );
}
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);
"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);
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
};
/*
};
*/
+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 [] = {
};
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 ();