#include <simgear/misc/exception.hxx>
#include <simgear/magvar/magvar.hxx>
#include <simgear/timing/sg_time.hxx>
+#include <simgear/misc/sg_path.hxx>
#include STL_IOSTREAM
#include <Aircraft/aircraft.hxx>
#include <Time/tmp.hxx>
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
-#ifndef FG_NEW_ENVIRONMENT
+#ifdef FG_WEATHERCM
# include <WeatherCM/FGLocalWeatherDatabase.h>
#else
# include <Environment/environment.hxx>
-#endif // FG_NEW_ENVIRONMENT
+#endif // FG_WEATHERCM
#include <Objects/matlib.hxx>
#include <GUI/gui.h>
#include "fgfs.hxx"
#include "fg_props.hxx"
-#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
SG_USING_STD(istream);
SG_USING_STD(ostream);
-#endif
-#if !defined(FG_NEW_ENVIRONMENT)
+#ifdef FG_WEATHERCM
static double getWindNorth ();
static double getWindEast ();
static double getWindDown ();
-#endif // FG_NEW_ENVIRONMENT
+#endif // FG_WEATHERCM
static bool winding_ccw = true; // FIXME: temporary
static void
setFreeze (bool f)
{
- frozen = f;
- // Stop sound on a pause
- if (f)
- globals->get_soundmgr()->pause();
- else
- globals->get_soundmgr()->resume();
+ frozen = f;
+
+ // Stop sound on a pause
+ FGSoundMgr *s = globals->get_soundmgr();
+ if ( s != NULL ) {
+ if ( f ) {
+ s->pause();
+ } else {
+ s->resume();
+ }
+ }
}
}
-#if !defined(FG_NEW_ENVIRONMENT)
+#ifdef FG_WEATHERCM
/**
* Get the current visibility (meters).
static void
setWindEast (double speed)
{
- cout << "Set wind-east to " << speed << endl;
+ SG_LOG(SG_GENERAL, SG_INFO,, "Set wind-east to " << speed );
current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
speed,
getWindDown());
speed);
}
-#endif // FG_NEW_ENVIRONMENT
+#endif // FG_WEATHERCM
static long
getWarp ()
void
fgInitProps ()
{
+ SG_LOG(SG_GENERAL, SG_DEBUG, "start of fgInitProps()" );
// Simulation
fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
fgTie("/orientation/heading-magnetic-deg", getHeadingMag);
// Environment
-#if !defined(FG_NEW_ENVIRONMENT)
+#ifdef FG_WEATHERCM
fgTie("/environment/visibility-m", getVisibility, setVisibility);
fgSetArchivable("/environment/visibility-m");
fgTie("/environment/wind-from-north-fps", getWindNorth, setWindNorth);
fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
fgTie("/sim/temp/full-screen", getFullScreen, setFullScreen);
fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging);
-
+
+ SG_LOG(SG_GENERAL, SG_DEBUG, "end of fgInitProps()" );
}
fgSaveFlight (ostream &output, bool write_all)
{
- fgSetBool("/sim/startup/onground", false);
- fgSetArchivable("/sim/startup/onground");
- fgSetBool("/sim/startup/trim", false);
- fgSetArchivable("/sim/startup/trim");
- fgSetString("/sim/startup/speed-set", "UVW");
- fgSetArchivable("/sim/startup/speed-set");
+ fgSetBool("/sim/presets/onground", false);
+ fgSetArchivable("/sim/presets/onground");
+ fgSetBool("/sim/presets/trim", false);
+ fgSetArchivable("/sim/presets/trim");
+ fgSetString("/sim/presets/speed-set", "UVW");
+ fgSetArchivable("/sim/presets/speed-set");
try {
writeProperties(output, globals->get_props(), write_all);
return false;
}
- fgSetBool("/sim/startup/onground", false);
- fgSetBool("/sim/startup/trim", false);
- fgSetString("/sim/startup/speed-set", "UVW");
+ fgSetBool("/sim/presets/onground", false);
+ fgSetBool("/sim/presets/trim", false);
+ fgSetString("/sim/presets/speed-set", "UVW");
copyProperties(&props, globals->get_props());
// When loading a flight, make it the
}
+bool
+fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root)
+{
+ string fullpath;
+ if (in_fg_root) {
+ SGPath loadpath(globals->get_fg_root());
+ loadpath.append(path);
+ fullpath = loadpath.str();
+ } else {
+ fullpath = path;
+ }
+
+ try {
+ readProperties(fullpath, props);
+ } catch (const sg_exception &e) {
+ guiErrorMessage("Error reading properties: ", e);
+ return false;
+ }
+ return true;
+}
+
+
\f
////////////////////////////////////////////////////////////////////////
// Property convenience functions.
return (fgGetNode(path, false) != 0);
}
+void
+fgAddChangeListener (SGPropertyChangeListener * listener, const char * path)
+{
+ fgGetNode(path, true)->addChangeListener(listener);
+}
+
+void
+fgAddChangeListener (SGPropertyChangeListener * listener,
+ const char * path, int index)
+{
+ fgGetNode(path, index, true)->addChangeListener(listener);
+}
+
bool
fgGetBool (const char * name, bool defaultValue)
{