mirror of https://github.com/odrling/Aegisub
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
|
@ -114,7 +114,6 @@ DialogOptions::DialogOptions(wxWindow *parent)
|
|||
AddCheckBox(generalPage,genSizer4,_("Show Splash Screen"),_T("Show splash"));
|
||||
#ifdef __WXMSW__
|
||||
AddCheckBox(generalPage,genSizer4,_("Auto Check for Updates"),_T("Auto check for updates"));
|
||||
AddCheckBox(generalPage,genSizer4,_("Save config.dat locally"),_T("Local config"));
|
||||
#endif
|
||||
genSizer4->AddGrowableCol(0,1);
|
||||
|
||||
|
@ -904,15 +903,7 @@ void DialogOptions::WriteToOptions(bool justApply) {
|
|||
}
|
||||
|
||||
// Save options
|
||||
#ifdef __WXMSW__
|
||||
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.SetFile(StandardPaths::DecodePath(_T("?user/config.dat")));
|
||||
Options.Save();
|
||||
|
||||
// Need restart?
|
||||
|
|
|
@ -147,27 +147,27 @@ bool AegisubApp::OnInit() {
|
|||
StartupLog(_T("Load configuration"));
|
||||
Options.LoadDefaults();
|
||||
#ifdef __WXMSW__
|
||||
// TODO: Display a messagebox about permission being needed to write to local config once the string freeze is over with
|
||||
if (wxFileName::IsFileWritable(StandardPaths::DecodePath(_T("?data/config.dat"))))
|
||||
// Try loading configuration from the install dir if one exists there
|
||||
if (wxFileName::FileExists(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();
|
||||
#ifdef __WXMSW__
|
||||
wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
||||
#endif
|
||||
}
|
||||
#ifdef __WXMSW__
|
||||
// Change ?user to point to ?data if we have local config
|
||||
if (Options.AsBool(_T("Local config"))) {
|
||||
StandardPaths::SetPathValue(_T("?user"), StandardPaths::DecodePath(_T("?data")));
|
||||
|
||||
if (Options.AsBool(_T("Local config"))) {
|
||||
// Local config, make ?user mean ?data so all user settings are placed in install dir
|
||||
StandardPaths::SetPathValue(_T("?user"), StandardPaths::DecodePath(_T("?data")));
|
||||
}
|
||||
else {
|
||||
// Not local config, we don't want that config.dat file here any more
|
||||
// It might be a leftover from a really old install
|
||||
wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
||||
}
|
||||
}
|
||||
#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"));
|
||||
Options.SetInt(_T("Last Version"),GetSVNRevision());
|
||||
Options.LoadDefaults(false,true); // Override options based on version number
|
||||
|
@ -207,7 +207,8 @@ bool AegisubApp::OnInit() {
|
|||
// Set association
|
||||
#ifndef _DEBUG
|
||||
StartupLog(_T("Install file type associations"));
|
||||
RegistryAssociate();
|
||||
if (!Options.AsBool(_T("Local config")))
|
||||
RegistryAssociate();
|
||||
#endif
|
||||
|
||||
// Get parameter subs
|
||||
|
|
Loading…
Reference in New Issue