More cleanup of local config:
* Remove option from Options dialogue, it's an install-time thing really * Don't try to do file associations at startup if we're portable * General clean up of config handling code; properly make ?user point to ?data and then everything magically follows, makes a lot of handling cleaner Originally committed to SVN as r3131.
This commit is contained in:
parent
f1c7ed639d
commit
26c9dd2ce6
2 changed files with 20 additions and 28 deletions
|
@ -114,7 +114,6 @@ DialogOptions::DialogOptions(wxWindow *parent)
|
||||||
AddCheckBox(generalPage,genSizer4,_("Show Splash Screen"),_T("Show splash"));
|
AddCheckBox(generalPage,genSizer4,_("Show Splash Screen"),_T("Show splash"));
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
AddCheckBox(generalPage,genSizer4,_("Auto Check for Updates"),_T("Auto check for updates"));
|
AddCheckBox(generalPage,genSizer4,_("Auto Check for Updates"),_T("Auto check for updates"));
|
||||||
AddCheckBox(generalPage,genSizer4,_("Save config.dat locally"),_T("Local config"));
|
|
||||||
#endif
|
#endif
|
||||||
genSizer4->AddGrowableCol(0,1);
|
genSizer4->AddGrowableCol(0,1);
|
||||||
|
|
||||||
|
@ -904,15 +903,7 @@ void DialogOptions::WriteToOptions(bool justApply) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save options
|
// Save options
|
||||||
#ifdef __WXMSW__
|
Options.SetFile(StandardPaths::DecodePath(_T("?user/config.dat")));
|
||||||
if (Options.AsBool(_T("Local config"))) Options.SetFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
|
||||||
else {
|
|
||||||
#endif
|
|
||||||
Options.SetFile(StandardPaths::DecodePath(_T("?user/config.dat")));
|
|
||||||
#ifdef __WXMSW__
|
|
||||||
wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Options.Save();
|
Options.Save();
|
||||||
|
|
||||||
// Need restart?
|
// Need restart?
|
||||||
|
|
|
@ -147,27 +147,27 @@ bool AegisubApp::OnInit() {
|
||||||
StartupLog(_T("Load configuration"));
|
StartupLog(_T("Load configuration"));
|
||||||
Options.LoadDefaults();
|
Options.LoadDefaults();
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
// TODO: Display a messagebox about permission being needed to write to local config once the string freeze is over with
|
// Try loading configuration from the install dir if one exists there
|
||||||
if (wxFileName::IsFileWritable(StandardPaths::DecodePath(_T("?data/config.dat"))))
|
if (wxFileName::FileExists(StandardPaths::DecodePath(_T("?data/config.dat")))) {
|
||||||
Options.SetFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
Options.SetFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
||||||
else
|
|
||||||
Options.SetFile(StandardPaths::DecodePath(_T("?user/config.dat")));
|
|
||||||
Options.Load();
|
|
||||||
if (!Options.AsBool(_T("Local config")) && Options.GetFile() != StandardPaths::DecodePath(_T("?user/config.dat")))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
Options.SetFile(StandardPaths::DecodePath(_T("?user/config.dat")));
|
|
||||||
Options.Load();
|
Options.Load();
|
||||||
#ifdef __WXMSW__
|
|
||||||
wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
if (Options.AsBool(_T("Local config"))) {
|
||||||
#endif
|
// Local config, make ?user mean ?data so all user settings are placed in install dir
|
||||||
}
|
StandardPaths::SetPathValue(_T("?user"), StandardPaths::DecodePath(_T("?data")));
|
||||||
#ifdef __WXMSW__
|
}
|
||||||
// Change ?user to point to ?data if we have local config
|
else {
|
||||||
if (Options.AsBool(_T("Local config"))) {
|
// Not local config, we don't want that config.dat file here any more
|
||||||
StandardPaths::SetPathValue(_T("?user"), StandardPaths::DecodePath(_T("?data")));
|
// It might be a leftover from a really old install
|
||||||
|
wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// TODO: Check if we can write to config.dat and warn the user if we can't
|
||||||
|
// If we had local config, ?user now means ?data so this will still be loaded from the correct location
|
||||||
|
Options.SetFile(StandardPaths::DecodePath(_T("?user/config.dat")));
|
||||||
|
Options.Load();
|
||||||
|
|
||||||
StartupLog(_T("Store options back"));
|
StartupLog(_T("Store options back"));
|
||||||
Options.SetInt(_T("Last Version"),GetSVNRevision());
|
Options.SetInt(_T("Last Version"),GetSVNRevision());
|
||||||
Options.LoadDefaults(false,true); // Override options based on version number
|
Options.LoadDefaults(false,true); // Override options based on version number
|
||||||
|
@ -207,7 +207,8 @@ bool AegisubApp::OnInit() {
|
||||||
// Set association
|
// Set association
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
StartupLog(_T("Install file type associations"));
|
StartupLog(_T("Install file type associations"));
|
||||||
RegistryAssociate();
|
if (!Options.AsBool(_T("Local config")))
|
||||||
|
RegistryAssociate();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get parameter subs
|
// Get parameter subs
|
||||||
|
|
Loading…
Reference in a new issue