# 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>
}
#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
}
#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
}
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 ) ;
// 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;
// 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;
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;
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
_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);
_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
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);
#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);
// 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);
}
}
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)
{
- current_options.toggle_panel();
+ globals->get_options()->toggle_panel();
}
//void MenuHideMenuCb(puObject *cb)
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);
}
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);
// 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);
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 );
extern FGInterface cur_view_fdm;
GLubyte *hiResScreenCapture( int multiplier )
{
- float oldfov = current_options.get_fov();
- float fov = oldfov / multiplier;
- FGView *v = ¤t_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
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) );
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( 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
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");
mainMenuBar->reveal();
}
+ if(!freeze)
+ globals->set_freeze( false );
}
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);
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);
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 );
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;
{
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"
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 );
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;
{
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, "");
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;
"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 [] = {
- "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
};
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" );
}
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.
}
}
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;
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 ();