Clean-up: move autosave.xml loading code to proper method
This commit is contained in:
parent
3100da1602
commit
90ce4ec93d
3 changed files with 18 additions and 24 deletions
|
@ -548,34 +548,16 @@ bool fgInitConfig ( int argc, char **argv )
|
|||
return false;
|
||||
}
|
||||
|
||||
SGPropertyNode autosave;
|
||||
|
||||
|
||||
SGPath autosaveFile = simgear::Dir(dataPath).file("autosave.xml");
|
||||
if (autosaveFile.exists()) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << autosaveFile.str());
|
||||
try {
|
||||
readProperties(autosaveFile.str(), &autosave, SGPropertyNode::USERARCHIVE);
|
||||
} catch (sg_exception& e) {
|
||||
SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
|
||||
<< "(from " << e.getOrigin() << ")");
|
||||
}
|
||||
}
|
||||
globals->loadUserSettings(dataPath);
|
||||
|
||||
// Scan user config files and command line for a specified aircraft.
|
||||
flightgear::Options::sharedInstance()->initAircraft();
|
||||
|
||||
FindAndCacheAircraft f(&autosave);
|
||||
FindAndCacheAircraft f(globals->get_props());
|
||||
if (!f.loadAircraft()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
copyProperties(&autosave, globals->get_props());
|
||||
|
||||
// TODO Move some of the code above into loadUserSettings after the 2.6 release
|
||||
// call dummy function, for now just to indicate that data was loaded
|
||||
globals->loadUserSettings();
|
||||
|
||||
// parse options after loading aircraft to ensure any user
|
||||
// overrides of defaults are honored.
|
||||
flightgear::Options::sharedInstance()->processOptions();
|
||||
|
|
|
@ -444,11 +444,23 @@ FGGlobals::restoreInitialState ()
|
|||
|
||||
// Load user settings from autosave.xml
|
||||
void
|
||||
FGGlobals::loadUserSettings()
|
||||
FGGlobals::loadUserSettings(const SGPath& dataPath)
|
||||
{
|
||||
// dummy method for now.
|
||||
//TODO Move code loading autosave.xml in here after the 2.6.0 release.
|
||||
// remember that we have (tried) to load any existing autsave.xml
|
||||
haveUserSettings = true;
|
||||
|
||||
SGPath autosaveFile = simgear::Dir(dataPath).file("autosave.xml");
|
||||
SGPropertyNode autosave;
|
||||
if (autosaveFile.exists()) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << autosaveFile.str());
|
||||
try {
|
||||
readProperties(autosaveFile.str(), &autosave, SGPropertyNode::USERARCHIVE);
|
||||
} catch (sg_exception& e) {
|
||||
SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
|
||||
<< "(from " << e.getOrigin() << ")");
|
||||
}
|
||||
}
|
||||
copyProperties(&autosave, globals->get_props());
|
||||
}
|
||||
|
||||
// Save user settings in autosave.xml
|
||||
|
|
|
@ -330,7 +330,7 @@ public:
|
|||
/**
|
||||
* Load user settings from autosave.xml
|
||||
*/
|
||||
void loadUserSettings();
|
||||
void loadUserSettings(const SGPath& datapath);
|
||||
|
||||
/**
|
||||
* Save user settings in autosave.xml
|
||||
|
|
Loading…
Add table
Reference in a new issue