From 90707efd3f381a26ab1da35d35384c0f409785c2 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 16 May 2000 18:21:08 +0000 Subject: [PATCH] Changes by David Megginson. --- src/GUI/gui.cxx | 54 +++++++++++++++++++++++++++++++++++++++++++---- src/Main/bfi.cxx | 11 ++++++++++ src/Main/main.cxx | 10 ++++++++- src/Main/save.cxx | 8 +++---- 4 files changed, 74 insertions(+), 9 deletions(-) diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index 4c0799e9f..8ce464eac 100644 --- a/src/GUI/gui.cxx +++ b/src/GUI/gui.cxx @@ -66,6 +66,8 @@ #include
#include
#include
+#include
+#include
#ifdef FG_NETWORK_OLK #include #endif @@ -713,6 +715,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,6 +753,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) @@ -1362,8 +1399,11 @@ char *fileSubmenu [] = { "Print", #endif "Snap Shot", - /* "---------", "Save", */ - "Reset", NULL + "---------", + "Reset", + "Load flight", + "Save flight", + NULL }; puCallback fileSubmenuCb [] = { MayBeGoodBye, /* hideMenuCb, NULL, */ @@ -1372,7 +1412,11 @@ puCallback fileSubmenuCb [] = { #endif /* NULL, notCb, */ dumpSnapShot, - reInit, NULL + NULL, + reInit, + loadFlight, + saveFlight, + NULL }; /* @@ -1406,9 +1450,11 @@ puCallback aircraftSubmenuCb [] = { }; char *environmentSubmenu [] = { - "Airport", /* "Terrain", "Weather", */ NULL + "Toggle Clouds", + "Goto Airport", /* "Terrain", "Weather", */ NULL }; puCallback environmentSubmenuCb [] = { + toggleClouds, NewAirport, /* notCb, notCb, */ NULL }; diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index 46365b96f..0a06cc4ec 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -108,6 +108,16 @@ FGBFI::reinit () cout << "BFI: start reinit\n"; + setHeading(getHeading()); + setPitch(getPitch()); + setRoll(getRoll()); + setSpeedNorth(getSpeedNorth()); + setSpeedEast(getSpeedEast()); + setSpeedDown(getSpeedDown()); + setLatitude(getLatitude()); + setLongitude(getLongitude()); + setAltitude(getAltitude()); + setTargetAirport(""); // TODO: add more AP stuff double elevator = getElevator(); double aileron = getAileron(); @@ -1164,6 +1174,7 @@ FGBFI::setVisibility (double visibility) void FGBFI::setClouds (bool clouds) { + cout << "Set clouds to " << clouds << endl; current_options.set_clouds(clouds); needReinit(); } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 9446c7d47..d170f0dee 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -80,7 +80,12 @@ #include #include #include -#include + +// bfi.hxx has to be included before uiuc_aircraft.h because of nasty +// #defines in uiuc_aircraft.h +#include "bfi.hxx" + +// #include #include #include #include @@ -268,6 +273,9 @@ void fgInitVisuals( void ) { // Update all Visuals (redraws anything graphics related) void fgRenderFrame( void ) { + // Update the BFI. + FGBFI::update(); + fgLIGHT *l = &cur_light_params; FGTime *t = FGTime::cur_time_params; // FGView *v = ¤t_view; diff --git a/src/Main/save.cxx b/src/Main/save.cxx index 9c17714bb..2cb9dedde 100644 --- a/src/Main/save.cxx +++ b/src/Main/save.cxx @@ -70,11 +70,11 @@ fgSaveFlight (ostream &output) SAVE("longitude", FGBFI::getLongitude()); // KLUDGE: deal with gear wierdness - if (FGBFI::getAGL() < 6) { - SAVE("altitude", FGBFI::getAltitude() - 6); - } else { +// if (FGBFI::getAGL() < 6) { +// SAVE("altitude", FGBFI::getAltitude() - FGBFI::getAGL()); +// } else { SAVE("altitude", FGBFI::getAltitude()); - } +// } // // Orientation -- 2.39.5