Added fgLoadProps to load properties from a path relative to FG_ROOT.
This commit is contained in:
parent
a8f40e0771
commit
0de065b0ec
8 changed files with 41 additions and 18 deletions
|
@ -78,11 +78,9 @@ unsigned int Menu_size;
|
|||
void initMenu()
|
||||
{
|
||||
SGPropertyNode main;
|
||||
SGPath spath( globals->get_fg_root() );
|
||||
spath.append( "menu.xml" );
|
||||
|
||||
try {
|
||||
readProperties(spath.c_str(), &main);
|
||||
fgLoadProps("menu.xml", &main);
|
||||
} catch (const sg_exception &ex) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Error processing the menu file.");
|
||||
return;
|
||||
|
|
|
@ -205,13 +205,9 @@ do_panel_mouse_click (const SGPropertyNode * arg)
|
|||
static bool
|
||||
do_preferences_load (const SGPropertyNode * arg)
|
||||
{
|
||||
const string &path = arg->getStringValue("path", "preferences.xml");
|
||||
SGPath props_path(globals->get_fg_root());
|
||||
props_path.append(path);
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences from "
|
||||
<< props_path.str());
|
||||
try {
|
||||
readProperties(props_path.str(), globals->get_props());
|
||||
fgLoadProps(arg->getStringValue("path", "preferences.xml"),
|
||||
globals->get_props());
|
||||
} catch (const sg_exception &e) {
|
||||
guiErrorMessage("Error reading global preferences: ", e);
|
||||
return false;
|
||||
|
|
|
@ -389,10 +389,8 @@ bool fgInitConfig ( int argc, char **argv ) {
|
|||
fgSetDefaults();
|
||||
|
||||
// Read global preferences from $FG_ROOT/preferences.xml
|
||||
SGPath props_path(globals->get_fg_root());
|
||||
props_path.append("preferences.xml");
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
|
||||
readProperties(props_path.str(), globals->get_props());
|
||||
fgLoadProps("preferences.xml", globals->get_props());
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
|
||||
|
||||
// Detect the required language as early as possible
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#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
|
||||
|
||||
|
@ -679,6 +680,15 @@ fgLoadFlight (istream &input)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
fgLoadProps (const char * path, SGPropertyNode * props)
|
||||
{
|
||||
SGPath loadpath(globals->get_fg_root());
|
||||
loadpath.append(path);
|
||||
readProperties(loadpath.c_str(), props);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Property convenience functions.
|
||||
|
|
|
@ -64,6 +64,14 @@ extern bool fgSaveFlight (ostream &output, bool write_all = false);
|
|||
extern bool fgLoadFlight (istream &input);
|
||||
|
||||
|
||||
/**
|
||||
* Load properties from a file relative to $FG_ROOT.
|
||||
*
|
||||
* @param file The file name relative to $FG_ROOT.
|
||||
*/
|
||||
extern void fgLoadProps (const char * path, SGPropertyNode * props);
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Convenience functions for getting property values.
|
||||
|
|
|
@ -21,6 +21,21 @@ FGSubsystem::~FGSubsystem ()
|
|||
{
|
||||
}
|
||||
|
||||
void
|
||||
FGSubsystem::init ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FGSubsystem::bind ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FGSubsystem::unbind ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FGSubsystem::suspend ()
|
||||
{
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
* in the constructor, so that FlightGear can control the
|
||||
* initialization order.</p>
|
||||
*/
|
||||
virtual void init () = 0;
|
||||
virtual void init ();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
* publishes. It will be invoked after init, but before any
|
||||
* invocations of update.</p>
|
||||
*/
|
||||
virtual void bind () = 0;
|
||||
virtual void bind ();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -165,7 +165,7 @@ public:
|
|||
* publishes. It will be invoked by FlightGear (not the destructor)
|
||||
* just before the subsystem is removed.</p>
|
||||
*/
|
||||
virtual void unbind () = 0;
|
||||
virtual void unbind ();
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1160,13 +1160,11 @@ fgUsage (bool verbose)
|
|||
SGPropertyNode *locale = globals->get_locale();
|
||||
|
||||
SGPropertyNode options_root;
|
||||
SGPath opath( globals->get_fg_root() );
|
||||
opath.append( "options.xml" );
|
||||
|
||||
cout << "" << endl;
|
||||
|
||||
try {
|
||||
readProperties(opath.c_str(), &options_root);
|
||||
fgLoadProps("options.xml", &options_root);
|
||||
} catch (const sg_exception &ex) {
|
||||
cout << "Unable to read the help file." << endl;
|
||||
cout << "Make sure the file options.xml is located in the FlightGear base directory," << endl;
|
||||
|
|
Loading…
Add table
Reference in a new issue