//
// Written by Curtis Olson, started November 2002.
//
-// Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
# include <windows.h>
#endif
-// #include <stdlib.h>
-
-// #include <simgear/constants.h>
-// #include <simgear/debug/logstream.hxx>
+#include <simgear/structure/commands.hxx>
#include <simgear/misc/sg_path.hxx>
-// #include <Include/general.hxx>
-
-// #include <GL/glut.h>
-// #include <GL/gl.h>
-
-#include <Airports/simple.hxx>
-#include <FDM/flight.hxx>
-#include <Main/fg_init.hxx>
#include <Main/fg_props.hxx>
-#include <Scenery/tilemgr.hxx>
#include "gui.h"
#include "preset_dlg.hxx"
{
char *value;
PresetDialogInput->getValue(&value);
- cout << "setting " << PresetProperty << " = " << value << endl;
+ SG_LOG( SG_GENERAL, SG_DEBUG, "setting " << PresetProperty
+ << " = " << value );
fgSetString( PresetProperty.c_str(), value );
FG_POP_PUI_DIALOG( PresetDialog );
if ( fabs(fgGetDouble("/sim/presets/altitude-ft")) > 0.000001
&& fabs(fgGetDouble("/sim/presets/glideslope-deg")) > 0.000001 ) {
fgSetDouble("/sim/presets/altitude-ft", -9999.0);
- cout << "nuking altitude" << endl;
+ SG_LOG( SG_GENERAL, SG_DEBUG, "nuking altitude" );
}
} else if ( PresetProperty == "/sim/presets/altitude-ft" ) {
if ( fabs(fgGetDouble("/sim/presets/offset-distance")) > 0.000001
&& fabs(fgGetDouble("/sim/presets/glideslope-deg")) > 0.000001 ) {
fgSetDouble("/sim/presets/offset-distance", 0.0);
- cout << "nuking offset distance" << endl;
+ SG_LOG( SG_GENERAL, SG_DEBUG, "nuking offset distance" );
}
} else if ( PresetProperty == "/sim/presets/glideslope-deg" ) {
if ( fabs(fgGetDouble("/sim/presets/offset-distance")) > 0.000001
&& fabs(fgGetDouble("/sim/presets/altitude-ft")) > 0.000001 ) {
fgSetDouble("/sim/presets/altitude-ft", -9999.0);
- cout << "nuking altitude" << endl;
+ SG_LOG( SG_GENERAL, SG_DEBUG, "nuking altitude" );
}
}
}
PresetDialogResetButton -> setLegend (gui_msg_RESET);
PresetDialogResetButton -> setCallback (PresetDialog_Reset);
}
- cout << "PresetInit " << PresetValue << endl;
+ SG_LOG( SG_GENERAL, SG_DEBUG, "PresetInit " << PresetValue );
FG_FINALIZE_PUI_DIALOG( PresetDialog );
}
void fgPresetCommit(puObject *)
{
- static const SGPropertyNode *longitude
- = fgGetNode("/sim/presets/longitude-deg");
- static const SGPropertyNode *latitude
- = fgGetNode("/sim/presets/latitude-deg");
- static const SGPropertyNode *master_freeze
- = fgGetNode("/sim/freeze/master");
-
- SGPath path( globals->get_fg_root() );
- path.append( "Airports" );
- path.append( "simple.mk4" );
- FGAirports airports( path.c_str() );
-
- FGAirport a;
-
- bool freeze = master_freeze->getBoolValue();
- if ( !freeze ) {
- fgSetBool("/sim/freeze/master", true);
- }
-
- // unbind the current fdm state so property changes
- // don't get lost when we subsequently delete this fdm
- // and create a new one.
- cur_fdm_state->unbind();
-
- // invalidate lon/lat if an airport is specified in the presets
- string apt = fgGetString("/sim/presets/airport-id");
- if ( !apt.empty() ) {
- fgSetDouble("/sim/presets/longitude-deg", -9999.0 );
- fgSetDouble("/sim/presets/latitude-deg", -9999.0 );
- }
-
- // set position from presets
- fgInitPosition();
-
- // BusyCursor(0);
- fgReInitSubsystems();
-
- cout << "before tile_mgr init " << longitude->getDoubleValue() << " "
- << latitude->getDoubleValue() << endl;
-
- double visibility_meters = fgGetDouble("/environment/visibility-m");
- global_tile_mgr.update( visibility_meters );
- // BusyCursor(1);
-
- if ( !freeze ) {
- fgSetBool("/sim/freeze/master", false);
+ SGPropertyNode args;
+ if ( !globals->get_commands()->execute("presets-commit", &args) )
+ {
+ SG_LOG( SG_GENERAL, SG_ALERT, "Command: presets-commit failed.");
}
}