#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 <Sound/soundmgr.hxx>
#include "globals.hxx"
#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 bool fdm_data_logging = false; // FIXME: temporary
+static bool frozen = false; // FIXME: temporary
+
\f
////////////////////////////////////////////////////////////////////////
getLoggingClasses ()
{
sgDebugClass classes = logbuf::get_log_classes();
- string result = "";
+ static string result = ""; // FIXME
for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
if ((classes&log_class_mappings[i].c) > 0) {
- if (result != (string)"")
+ if (!result.empty())
result += '|';
result += log_class_mappings[i].name;
}
return;
}
- if (classes == "" || classes == "all") { // default
+ if (classes.empty() || classes == "all") { // default
logbuf::set_log_classes(SG_ALL);
SG_LOG(SG_GENERAL, SG_INFO, "Enabled all logging classes: "
<< getLoggingClasses());
logbuf::set_log_priority(SG_BULK);
} else if (priority == "debug") {
logbuf::set_log_priority(SG_DEBUG);
- } else if (priority == "" || priority == "info") { // default
+ } else if (priority.empty() || priority == "info") { // default
logbuf::set_log_priority(SG_INFO);
} else if (priority == "warn") {
logbuf::set_log_priority(SG_WARN);
}
+/**
+ * Return the current frozen state.
+ */
+static bool
+getFreeze ()
+{
+ return frozen;
+}
+
+
+/**
+ * Set the current frozen state.
+ */
+static void
+setFreeze (bool f)
+{
+ frozen = f;
+
+ // Stop sound on a pause
+ FGSoundMgr *s = globals->get_soundmgr();
+ if ( s != NULL ) {
+ if ( f ) {
+ s->pause();
+ } else {
+ s->resume();
+ }
+ }
+}
+
+
/**
* Return the current aircraft directory (UIUC) as a string.
*/
/**
* Return the number of milliseconds elapsed since simulation started.
*/
-static long
-getElapsedTime_ms ()
+static double
+getElapsedTime_sec ()
{
- return globals->get_elapsed_time_ms();
+ return globals->get_sim_time_sec();
}
static const char *
getDateString ()
{
- string out;
- char buf[64];
+ static char buf[64]; // FIXME
struct tm * t = globals->get_time_params()->getGmt();
sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec);
- out = buf;
- return out.c_str();
+ return buf;
}
static const char *
getGMTString ()
{
- string out;
- char buf[16];
+ static char buf[16]; // FIXME
struct tm *t = globals->get_time_params()->getGmt();
sprintf(buf, " %.2d:%.2d:%.2d",
t->tm_hour, t->tm_min, t->tm_sec);
// cout << t << " " << buf << endl;
- out = buf;
- return out.c_str();
+ return buf;
}
}
-#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("/sim/freeze", getFreeze, setFreeze);
+ fgTie("/sim/freeze/master", getFreeze, setFreeze);
fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
- fgTie("/sim/time/elapsed-ms", getElapsedTime_ms);
+ fgTie("/sim/time/elapsed-sec", getElapsedTime_sec);
fgTie("/sim/time/gmt", getDateString, setDateString);
fgSetArchivable("/sim/time/gmt");
fgTie("/sim/time/gmt-string", getGMTString);
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)
{