Stefan Seifert: implement persistent dialog options, so changes in rendering, static LOD and sound settings dialogs are made permanent.
This commit is contained in:
parent
96c0a7bbc1
commit
f6174d2bf0
4 changed files with 35 additions and 6 deletions
|
@ -189,9 +189,26 @@ do_nasal (const SGPropertyNode * arg)
|
|||
static bool
|
||||
do_exit (const SGPropertyNode * arg)
|
||||
{
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Program exit requested.");
|
||||
fgExit(arg->getIntValue("status", 0));
|
||||
return true;
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Program exit requested.");
|
||||
|
||||
char* envp = ::getenv( "HOME" );
|
||||
if ( envp != NULL ) {
|
||||
SGPath config( globals->get_fg_root() );
|
||||
config.set( envp );
|
||||
config.append( ".fgfs" );
|
||||
config.append( "preferences.xml" );
|
||||
config.create_dir( 0700 );
|
||||
SG_LOG(SG_IO, SG_INFO, "Saving user preferences");
|
||||
try {
|
||||
writeProperties(config.str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
|
||||
} catch (const sg_exception &e) {
|
||||
guiErrorMessage("Error saving preferences: ", e);
|
||||
}
|
||||
|
||||
SG_LOG(SG_INPUT, SG_BULK, "Finished Saving user preferences");
|
||||
}
|
||||
fgExit(arg->getIntValue("status", 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -607,6 +607,18 @@ bool fgInitConfig ( int argc, char **argv ) {
|
|||
SG_LOG( SG_INPUT, SG_ALERT, "No default aircraft specified" );
|
||||
}
|
||||
|
||||
|
||||
char* envp = ::getenv( "HOME" );
|
||||
if ( envp != NULL ) {
|
||||
SGPath config( globals->get_fg_root() );
|
||||
config.set( envp );
|
||||
config.append( ".fgfs" );
|
||||
config.append( "preferences.xml" );
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Reading user preferences");
|
||||
fgLoadProps(config.str().c_str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
|
||||
SG_LOG(SG_INPUT, SG_BULK, "Finished Reading user preferences");
|
||||
}
|
||||
|
||||
// parse options after loading aircraft to ensure any user
|
||||
// overrides of defaults are honored.
|
||||
do_options(argc, argv);
|
||||
|
|
|
@ -585,7 +585,7 @@ fgLoadFlight (istream &input)
|
|||
|
||||
|
||||
bool
|
||||
fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root)
|
||||
fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root, int default_mode)
|
||||
{
|
||||
string fullpath;
|
||||
if (in_fg_root) {
|
||||
|
@ -597,7 +597,7 @@ fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root)
|
|||
}
|
||||
|
||||
try {
|
||||
readProperties(fullpath, props);
|
||||
readProperties(fullpath, props, default_mode);
|
||||
} catch (const sg_exception &e) {
|
||||
guiErrorMessage("Error reading properties: ", e);
|
||||
return false;
|
||||
|
|
|
@ -69,7 +69,7 @@ extern bool fgLoadFlight (istream &input);
|
|||
* otherwise.
|
||||
*/
|
||||
extern bool fgLoadProps (const char * path, SGPropertyNode * props,
|
||||
bool in_fg_root = true);
|
||||
bool in_fg_root = true, int default_mode = 0);
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue