From d60f4d4852d10ef42691f0739e6c88fbe43f8587 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 6 Sep 2000 00:09:32 +0000 Subject: [PATCH] A couple tweaks from David Megginson relating to his new panel data file support. --- src/Main/Makefile.am | 2 +- src/Main/bfi.cxx | 1 + src/Main/keyboard.cxx | 20 ++ src/Main/save.cxx | 423 +----------------------------------------- 4 files changed, 27 insertions(+), 419 deletions(-) diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index e487656db..8eaf2ca07 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -64,7 +64,7 @@ fgfs_LDADD = \ $(WEATHER_LIBS) \ $(top_builddir)/src/Joystick/libJoystick.a \ -lsgsky -lsgephem -lsgtiming -lsgio -lsgscreen -lsgmath -lsgbucket \ - -lsgdebug -lsgmagvar -lsgmisc \ + -lsgdebug -lsgmagvar -lsgmisc -lsgxml \ $(SERIAL_LIBS) \ -lplibpu -lplibfnt -lplibssg -lplibsg \ -lmk4 -lz \ diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index 1b085438f..e39d43921 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -58,6 +58,7 @@ #include "options.hxx" #include "save.hxx" #include "fg_init.hxx" +#include FG_USING_NAMESPACE(std); diff --git a/src/Main/keyboard.cxx b/src/Main/keyboard.cxx index dc52097a2..400fcd181 100644 --- a/src/Main/keyboard.cxx +++ b/src/Main/keyboard.cxx @@ -53,6 +53,8 @@ #include #include #include +#include +#include #include #include #include @@ -441,6 +443,24 @@ void GLUTspecialkey(int k, int x, int y) { } return; } + case GLUT_KEY_F3: { + ifstream input("panel.xml"); + if (!input.good()) { + FG_LOG(FG_INPUT, FG_ALERT, + "Cannot read panel configuration from panel.xml"); + return; + } + FGPanel * new_panel = fgReadPanel(input); + if (new_panel == 0) { + FG_LOG(FG_INPUT, FG_ALERT, + "Error reading new panel from panel.xml"); + return; + } + FG_LOG(FG_INPUT, FG_INFO, "Loaded new panel from panel.xml"); + delete current_panel; + current_panel = new_panel; + return; + } case GLUT_KEY_END: // numeric keypad 1 v->set_goal_view_offset( FG_PI * 0.75 ); return; diff --git a/src/Main/save.cxx b/src/Main/save.cxx index 0fd919c13..01a771fb1 100644 --- a/src/Main/save.cxx +++ b/src/Main/save.cxx @@ -21,27 +21,17 @@ // $Id$ -/* -TODO: -- use a separate options object so that we can roll back on error -- use proper FGFS logging -- add view direction, and other stuff -*/ - #ifdef HAVE_CONFIG_H # include #endif #include -#include -#include - -#include "bfi.hxx" +#include -FG_USING_NAMESPACE(std); +using std::istream; +using std::ostream; -#define SAVE(name, value) { output << name << ": " << value << endl; } /** * Save the current state of the simulator to a stream. @@ -49,97 +39,7 @@ FG_USING_NAMESPACE(std); bool fgSaveFlight (ostream &output) { - output << "#!fgfs" << endl; - - // - // Simulation - // - SAVE("flight-model", FGBFI::getFlightModel()); - if (FGBFI::getAircraft().length() > 0) - SAVE("aircraft", FGBFI::getAircraft()); - if (FGBFI::getAircraftDir().length() > 0) - SAVE("aircraft-dir", FGBFI::getAircraftDir()); - SAVE("time", FGBFI::getTimeGMT()); - SAVE("hud", FGBFI::getHUDVisible()); - SAVE("panel", FGBFI::getPanelVisible()); - - // - // Location - // - SAVE("latitude", FGBFI::getLatitude()); - SAVE("longitude", FGBFI::getLongitude()); - - // KLUDGE: deal with gear wierdness -// if (FGBFI::getAGL() < 6) { -// SAVE("altitude", FGBFI::getAltitude() - FGBFI::getAGL()); -// } else { - SAVE("altitude", FGBFI::getAltitude()); -// } - - // - // Orientation - // - SAVE("heading", FGBFI::getHeading()); - SAVE("pitch", FGBFI::getPitch()); - SAVE("roll", FGBFI::getRoll()); - - // - // Velocities - // - SAVE("speed-north", FGBFI::getSpeedNorth()); - SAVE("speed-east", FGBFI::getSpeedEast()); - SAVE("speed-down", FGBFI::getSpeedDown()); - - // - // Primary controls - // - SAVE("elevator", FGBFI::getElevator()); - SAVE("aileron", FGBFI::getAileron()); - SAVE("rudder", FGBFI::getRudder()); - // FIXME: save each throttle separately - SAVE("throttle", FGBFI::getThrottle()); - - // - // Secondary controls - // - SAVE("elevator-trim", FGBFI::getElevatorTrim()); - SAVE("flaps", FGBFI::getFlaps()); - SAVE("brake", FGBFI::getBrakes()); - - // - // Radio navigation - // - SAVE("nav1-active-frequency", FGBFI::getNAV1Freq()); - SAVE("nav1-standby-frequency", FGBFI::getNAV1AltFreq()); - SAVE("nav1-selected-radial", FGBFI::getNAV1SelRadial()); - SAVE("nav2-active-frequency", FGBFI::getNAV2Freq()); - SAVE("nav2-standby-frequency", FGBFI::getNAV2AltFreq()); - SAVE("nav2-selected-radial", FGBFI::getNAV2SelRadial()); - SAVE("adf-active-frequency", FGBFI::getADFFreq()); - SAVE("adf-standby-frequency", FGBFI::getADFAltFreq()); - SAVE("adf-rotation", FGBFI::getADFRotation()); - - // - // Autopilot and GPS - // - if (FGBFI::getTargetAirport().length() > 0) - SAVE("target-airport", FGBFI::getTargetAirport()); - SAVE("autopilot-altitude-lock", FGBFI::getAPAltitudeLock()); - SAVE("autopilot-altitude", FGBFI::getAPAltitude()); - SAVE("autopilot-heading-lock", FGBFI::getAPHeadingLock()); - SAVE("autopilot-heading", FGBFI::getAPHeadingMag()); - SAVE("autopilot-gps-lock", FGBFI::getGPSLock()); - SAVE("autopilot-gps-lat", FGBFI::getGPSTargetLatitude()); - SAVE("autopilot-gps-lon", FGBFI::getGPSTargetLongitude()); - - // - // Environment. - // - SAVE("visibility", FGBFI::getVisibility()); - SAVE("clouds", FGBFI::getClouds()); - SAVE("clouds-asl", FGBFI::getCloudsASL()); - - return true; + return writePropertyList(output, ¤t_properties); } @@ -149,320 +49,7 @@ fgSaveFlight (ostream &output) bool fgLoadFlight (istream &input) { -// FGInterface * f = current_aircraft.fdm_state; - string text; - double n; - long int i; - - if (!input.good() || input.eof()) { - cout << "Stream is no good!\n"; - return false; - } - - input >> text; - if (text != "#!fgfs") { - cerr << "Bad save file format!\n"; - return false; - } - - - while (input.good() && !input.eof()) { - input >> text; - - // - // Simulation. - // - - if (text == "flight-model:") { - input >> i; - cout << "flight model is " << i << endl; - FGBFI::setFlightModel(i); - } - - else if (text == "aircraft:") { - input >> text; - cout << "aircraft is " << text << endl; - FGBFI::setAircraft(text); - } - - else if (text == "aircraft-dir:") { - input >> text; - cout << "aircraft-dir is " << text << endl; - FGBFI::setAircraftDir(text); - } - - else if (text == "time:") { - input >> i; - cout << "saved time is " << i << endl; - FGBFI::setTimeGMT(i); - } - - else if (text == "hud:") { - input >> i; - cout << "hud status is " << i << endl; - FGBFI::setHUDVisible(i); - } - - else if (text == "panel:") { - input >> i; - cout << "panel status is " << i << endl; - FGBFI::setPanelVisible(i); - } - - // - // Location - // - - else if (text == "latitude:") { - input >> n; - cout << "latitude is " << n << endl; - FGBFI::setLatitude(n); - } - - else if (text == "longitude:") { - input >> n; - cout << "longitude is " << n << endl; - FGBFI::setLongitude(n); - } - - else if (text == "altitude:") { - input >> n; - cout << "altitude is " << n << endl; - FGBFI::setAltitude(n); - } - - // - // Orientation - // - - else if (text == "heading:") { - input >> n; - cout << "heading is " << n << endl; - FGBFI::setHeading(n); - } - - else if (text == "pitch:") { - input >> n; - cout << "pitch is " << n << endl; - FGBFI::setPitch(n); - } - - else if (text == "roll:") { - input >> n; - cout << "roll is " << n << endl; - FGBFI::setRoll(n); - } - - // - // Velocities - // - - else if (text == "speed-north:") { - input >> n; - cout << "speed north is " << n << endl; - FGBFI::setSpeedNorth(n); - } - - else if (text == "speed-east:") { - input >> n; - cout << "speed east is " << n << endl; - FGBFI::setSpeedEast(n); - } - - else if (text == "speed-down:") { - input >> n; - cout << "speed down is " << n << endl; - FGBFI::setSpeedDown(n); - } - - // - // Primary controls - // - - else if (text == "elevator:") { - input >> n; - cout << "elevator is " << n << endl; - FGBFI::setElevator(n); - } - - else if (text == "aileron:") { - input >> n; - cout << "aileron is " << n << endl; - FGBFI::setAileron(n); - } - - else if (text == "rudder:") { - input >> n; - cout << "rudder is " << n << endl; - FGBFI::setRudder(n); - } - - // FIXME: assumes single engine - else if (text == "throttle:") { - input >> n; - cout << "throttle is " << n << endl; - FGBFI::setThrottle(n); - } - - // - // Secondary controls - - else if (text == "elevator-trim:") { - input >> n; - cout << "elevator trim is " << n << endl; - FGBFI::setElevatorTrim(n); - } - - else if (text == "flaps:") { - input >> n; - cout << "flaps are " << n << endl; - FGBFI::setFlaps(n); - } - - else if (text == "brake:") { - input >> n; - cout << "brake is " << n << endl; - FGBFI::setBrakes(n); - } - - - // - // Radio navigation - // - - else if (text == "nav1-active-frequency:") { - input >> n; - FGBFI::setNAV1Freq(n); - } - - else if (text == "nav1-standby-frequency:") { - input >> n; - FGBFI::setNAV1AltFreq(n); - } - - else if (text == "nav1-selected-radial:") { - input >> n; - FGBFI::setNAV1SelRadial(n); - } - - else if (text == "nav2-active-frequency:") { - input >> n; - FGBFI::setNAV2Freq(n); - } - - else if (text == "nav2-standby-frequency:") { - input >> n; - FGBFI::setNAV2AltFreq(n); - } - - else if (text == "nav2-selected-radial:") { - input >> n; - FGBFI::setNAV2SelRadial(n); - } - - else if (text == "adf-active-frequency:") { - input >> n; - FGBFI::setADFFreq(n); - } - - else if (text == "adf-standby-frequency:") { - input >> n; - FGBFI::setADFAltFreq(n); - } - - else if (text == "adf-rotation:") { - input >> n; - FGBFI::setADFRotation(n); - } - - - // - // Autopilot and GPS - // - - else if (text == "target-airport:") { - input >> text; - cout << "target airport is " << text << endl; - FGBFI::setTargetAirport(text); - } - - else if (text == "autopilot-altitude-lock:") { - input >> i; - cout << "autopilot altitude lock is " << i << endl; - FGBFI::setAPAltitudeLock(i); - } - - else if (text == "autopilot-altitude:") { - input >> n; - cout << "autopilot altitude is " << n << endl; - FGBFI::setAPAltitude(n); - } - - else if (text == "autopilot-heading-lock:") { - input >> i; - cout << "autopilot heading lock is " << i << endl; - FGBFI::setAPHeadingLock(i); - } - - else if (text == "autopilot-heading:") { - input >> n; - cout << "autopilot heading is " << n << endl; - FGBFI::setAPHeadingMag(n); - } - - else if (text == "autopilot-gps-lock:") { - input >> i; - cout << "autopilot GPS lock is " << i << endl; - FGBFI::setGPSLock(i); - } - - else if (text == "autopilot-gps-lat:") { - input >> n; - cout << "GPS target latitude is " << n << endl; - FGBFI::setGPSTargetLatitude(n); - } - - else if (text == "autopilot-gps-lon:") { - input >> n; - cout << "GPS target longitude is " << n << endl; - FGBFI::setGPSTargetLongitude(n); - } - - // - // Environment. - // - - else if (text == "visibility:") { - input >> n; - cout << "visibility is " << n << endl; - FGBFI::setVisibility(n); - } - - else if (text == "clouds:") { - input >> i; - cout << "clouds is " << i << endl; - FGBFI::setClouds(i); - } - - else if (text == "clouds-asl:") { - input >> n; - cout << "clouds-asl is " << n << endl; - FGBFI::setCloudsASL(n); - } - - // - // Don't die if we don't recognize something - // - - else { - cerr << "Skipping unknown field: " << text << endl; - input >> text; - } - } - - FGBFI::update(); - - return true; + return readPropertyList(input, ¤t_properties); } // end of save.cxx -- 2.39.5