mirror of https://github.com/odrling/Aegisub
Properly fix "local config" option, previously it only made config.dat local and kept everything else in %APPDATA% still. Now fixed, along with a load of other problematic uses of relative paths. Still a lot more to go.
This also makes a bit of sense of the default options for various paths that previously were implicitly relative to ?user or ?data but never explicitly specified in options. Originally committed to SVN as r3130.
This commit is contained in:
parent
2f65a5bb68
commit
f1c7ed639d
|
@ -72,10 +72,10 @@ void BrowseButton::OnPressed(wxCommandEvent &event) {
|
||||||
if (type == BROWSE_FOLDER) {
|
if (type == BROWSE_FOLDER) {
|
||||||
// For some reason I can't make this work on Mac... -jfs
|
// For some reason I can't make this work on Mac... -jfs
|
||||||
#ifndef __WXMAC__
|
#ifndef __WXMAC__
|
||||||
wxString def = DecodeRelativePath(ctrl[0]->GetValue(),StandardPaths::DecodePath(_T("?user/")));
|
wxString def = StandardPaths::DecodePathMaybeRelative(ctrl[0]->GetValue(), _T("?user/"));
|
||||||
wxDirDialog dlg(0, _("Please choose the folder:"), def);
|
wxDirDialog dlg(0, _("Please choose the folder:"), def);
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
wxString dir = MakeRelativePath(dlg.GetPath(),StandardPaths::DecodePath(_T("?user/")));
|
wxString dir = StandardPaths::EncodePath(dlg.GetPath());
|
||||||
if (dir != _T("")) ctrl[0]->SetValue(dir);
|
if (dir != _T("")) ctrl[0]->SetValue(dir);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -718,7 +718,7 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) {
|
||||||
wxString path = Options.AsText(_T("Auto backup path"));
|
wxString path = Options.AsText(_T("Auto backup path"));
|
||||||
if (path.IsEmpty()) path = origfile.GetPath();
|
if (path.IsEmpty()) path = origfile.GetPath();
|
||||||
wxFileName dstpath(path);
|
wxFileName dstpath(path);
|
||||||
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePath(_T("?user/") + path);
|
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePathMaybeRelative(path, _T("?user/"));
|
||||||
path += _T("/");
|
path += _T("/");
|
||||||
dstpath.Assign(path);
|
dstpath.Assign(path);
|
||||||
if (!dstpath.DirExists()) wxMkdir(path);
|
if (!dstpath.DirExists()) wxMkdir(path);
|
||||||
|
|
|
@ -1519,7 +1519,7 @@ void FrameMain::OnAutoSave(wxTimerEvent &event) {
|
||||||
wxString path = Options.AsText(_T("Auto save path"));
|
wxString path = Options.AsText(_T("Auto save path"));
|
||||||
if (path.IsEmpty()) path = origfile.GetPath();
|
if (path.IsEmpty()) path = origfile.GetPath();
|
||||||
wxFileName dstpath(path);
|
wxFileName dstpath(path);
|
||||||
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePath(_T("?user/") + path);
|
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePathMaybeRelative(path, _T("?user/"));
|
||||||
path += _T("/");
|
path += _T("/");
|
||||||
dstpath.Assign(path);
|
dstpath.Assign(path);
|
||||||
if (!dstpath.DirExists()) wxMkdir(path);
|
if (!dstpath.DirExists()) wxMkdir(path);
|
||||||
|
|
|
@ -88,7 +88,7 @@ void HelpButton::OpenPage(const wxString pageID) {
|
||||||
docsPath.Replace(_T("\\"),_T("/"));
|
docsPath.Replace(_T("\\"),_T("/"));
|
||||||
docsPath = _T("/") + docsPath;
|
docsPath = _T("/") + docsPath;
|
||||||
#endif
|
#endif
|
||||||
wxString path = StandardPaths::DecodePath(wxString::Format(_T("file://%s/%s.html"),docsPath.c_str(),page.c_str()));
|
wxString path = wxString::Format(_T("file://%s/%s.html"),docsPath.c_str(),page.c_str());
|
||||||
wxLaunchDefaultBrowser(path);
|
wxLaunchDefaultBrowser(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,12 @@ bool AegisubApp::OnInit() {
|
||||||
wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat")));
|
||||||
#endif
|
#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")));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
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
|
||||||
|
@ -260,7 +266,7 @@ void AegisubApp::OnUnhandledException() {
|
||||||
wxString path = Options.AsText(_T("Auto recovery path"));
|
wxString path = Options.AsText(_T("Auto recovery path"));
|
||||||
if (path.IsEmpty()) path = StandardPaths::DecodePath(_T("?user/"));
|
if (path.IsEmpty()) path = StandardPaths::DecodePath(_T("?user/"));
|
||||||
wxFileName dstpath(path);
|
wxFileName dstpath(path);
|
||||||
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePath(_T("?user/")) + path;
|
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePathMaybeRelative(path, _T("?user/"));
|
||||||
path += _T("/");
|
path += _T("/");
|
||||||
dstpath.Assign(path);
|
dstpath.Assign(path);
|
||||||
if (!dstpath.DirExists()) wxMkdir(path);
|
if (!dstpath.DirExists()) wxMkdir(path);
|
||||||
|
@ -280,7 +286,7 @@ void AegisubApp::OnFatalException() {
|
||||||
wxString path = Options.AsText(_T("Auto recovery path"));
|
wxString path = Options.AsText(_T("Auto recovery path"));
|
||||||
if (path.IsEmpty()) path = StandardPaths::DecodePath(_T("?user/"));
|
if (path.IsEmpty()) path = StandardPaths::DecodePath(_T("?user/"));
|
||||||
wxFileName dstpath(path);
|
wxFileName dstpath(path);
|
||||||
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePath(_T("?user/")) + path;
|
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePathMaybeRelative(path, _T("?user/"));
|
||||||
path += _T("/");
|
path += _T("/");
|
||||||
dstpath.Assign(path);
|
dstpath.Assign(path);
|
||||||
if (!dstpath.DirExists()) wxMkdir(path);
|
if (!dstpath.DirExists()) wxMkdir(path);
|
||||||
|
|
|
@ -106,10 +106,10 @@ void OptionsManager::LoadDefaults(bool onlyDefaults,bool doOverride) {
|
||||||
SetModificationType(MOD_RESTART);
|
SetModificationType(MOD_RESTART);
|
||||||
SetInt(_T("Auto save every seconds"),60); // FIXME: this shouldn't need to require a restart
|
SetInt(_T("Auto save every seconds"),60); // FIXME: this shouldn't need to require a restart
|
||||||
SetModificationType(MOD_AUTOMATIC);
|
SetModificationType(MOD_AUTOMATIC);
|
||||||
SetText(_T("Auto save path"),_T("autosave")); // what does this mean on linux? actually this should be under $HOME on any OS
|
SetText(_T("Auto save path"),_T("?user/autosave"));
|
||||||
SetBool(_T("Auto backup"),true);
|
SetBool(_T("Auto backup"),true);
|
||||||
SetText(_T("Auto backup path"),_T("autoback"));
|
SetText(_T("Auto backup path"),_T("?user/autoback"));
|
||||||
SetText(_T("Auto recovery path"),_T("recovered"));
|
SetText(_T("Auto recovery path"),_T("?user/recovered"));
|
||||||
SetInt(_T("Autoload linked files"),2);
|
SetInt(_T("Autoload linked files"),2);
|
||||||
SetText(_T("Text actor separator"),_T(":"));
|
SetText(_T("Text actor separator"),_T(":"));
|
||||||
SetText(_T("Text comment starter"),_T("#"));
|
SetText(_T("Text comment starter"),_T("#"));
|
||||||
|
@ -119,7 +119,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults,bool doOverride) {
|
||||||
|
|
||||||
// Edit Box
|
// Edit Box
|
||||||
SetModificationType(MOD_RESTART);
|
SetModificationType(MOD_RESTART);
|
||||||
SetText(_T("Dictionaries path"),_T("dictionaries"));
|
SetText(_T("Dictionaries path"),_T("?data/dictionaries"));
|
||||||
SetText(_T("Spell Checker"),_T("hunspell"));
|
SetText(_T("Spell Checker"),_T("hunspell"));
|
||||||
SetModificationType(MOD_AUTOMATIC);
|
SetModificationType(MOD_AUTOMATIC);
|
||||||
SetBool(_T("Link time boxes commit"),true);
|
SetBool(_T("Link time boxes commit"),true);
|
||||||
|
|
|
@ -202,7 +202,7 @@ wxArrayString HunspellSpellChecker::GetSuggestions(wxString word) {
|
||||||
// Get list of available dictionaries
|
// Get list of available dictionaries
|
||||||
wxArrayString HunspellSpellChecker::GetLanguageList() {
|
wxArrayString HunspellSpellChecker::GetLanguageList() {
|
||||||
// Get dir name
|
// Get dir name
|
||||||
wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),StandardPaths::DecodePath(_T("?data/"))) + _T("/");
|
wxString path = StandardPaths::DecodePathMaybeRelative(Options.AsText(_T("Dictionaries path")), _T("?data")) + _T("/");
|
||||||
wxArrayString list;
|
wxArrayString list;
|
||||||
wxFileName folder(path);
|
wxFileName folder(path);
|
||||||
if (!folder.DirExists()) return list;
|
if (!folder.DirExists()) return list;
|
||||||
|
@ -240,7 +240,7 @@ void HunspellSpellChecker::SetLanguage(wxString language) {
|
||||||
|
|
||||||
// Get dir name
|
// Get dir name
|
||||||
//FIXME: this should use ?user instead of ?data; however, since it apparently works already on win32, I'm not gonna mess with it right now :p
|
//FIXME: this should use ?user instead of ?data; however, since it apparently works already on win32, I'm not gonna mess with it right now :p
|
||||||
wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),StandardPaths::DecodePath(_T("?data/"))) + _T("/");
|
wxString path = StandardPaths::DecodePathMaybeRelative(Options.AsText(_T("Dictionaries path")), _T("?data")) + _T("/");
|
||||||
wxString userPath = StandardPaths::DecodePath(_T("?user/dictionaries/user_"));
|
wxString userPath = StandardPaths::DecodePath(_T("?user/dictionaries/user_"));
|
||||||
|
|
||||||
// Get affix and dictionary paths
|
// Get affix and dictionary paths
|
||||||
|
|
|
@ -119,7 +119,7 @@ wxString StandardPaths::DoDecodePath(wxString path) {
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Encode path
|
// Encode path
|
||||||
wxString StandardPaths::DoEncodePath(wxString path) {
|
wxString StandardPaths::DoEncodePath(const wxString &path) {
|
||||||
// TODO
|
// TODO
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,16 @@ wxString StandardPaths::DoEncodePath(wxString path) {
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Set value of a ? path
|
// Set value of a ? path
|
||||||
void StandardPaths::DoSetPathValue(wxString path,wxString value) {
|
void StandardPaths::DoSetPathValue(const wxString &path, const wxString &value) {
|
||||||
paths[path] = value;
|
paths[path] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Decode a path that for legacy reasons might be relative to another path
|
||||||
|
wxString StandardPaths::DecodePathMaybeRelative(const wxString &path, const wxString &relativeTo) {
|
||||||
|
wxFileName res(DecodePath(path));
|
||||||
|
if (res.IsRelative())
|
||||||
|
res.Assign(DecodePath(relativeTo + _T("/") + path));
|
||||||
|
return res.GetFullPath();
|
||||||
|
}
|
||||||
|
|
|
@ -56,11 +56,12 @@ private:
|
||||||
StandardPaths& operator=(StandardPaths const&);
|
StandardPaths& operator=(StandardPaths const&);
|
||||||
|
|
||||||
wxString DoDecodePath(wxString path);
|
wxString DoDecodePath(wxString path);
|
||||||
wxString DoEncodePath(wxString path);
|
wxString DoEncodePath(const wxString &path);
|
||||||
void DoSetPathValue(wxString path,wxString value);
|
void DoSetPathValue(const wxString &path, const wxString &value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static wxString DecodePath(wxString path) { return GetInstance().DoDecodePath(path); }
|
static wxString DecodePath(const wxString &path) { return GetInstance().DoDecodePath(path); }
|
||||||
static wxString EncodePath(wxString path) { return GetInstance().DoEncodePath(path); }
|
static wxString DecodePathMaybeRelative(const wxString &path, const wxString &relativeTo);
|
||||||
static void SetPathValue(wxString path,wxString value) { GetInstance().DoSetPathValue(path,value); }
|
static wxString EncodePath(const wxString &path) { return GetInstance().DoEncodePath(path); }
|
||||||
|
static void SetPathValue(const wxString &path, const wxString &value) { GetInstance().DoSetPathValue(path,value); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,7 +96,7 @@ void MySpellThesaurus::Lookup(wxString word,ThesaurusEntryArray &result) {
|
||||||
// Get language list
|
// Get language list
|
||||||
wxArrayString MySpellThesaurus::GetLanguageList() {
|
wxArrayString MySpellThesaurus::GetLanguageList() {
|
||||||
// Get dir name
|
// Get dir name
|
||||||
wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),StandardPaths::DecodePath(_T("?data/"))) + _T("/");
|
wxString path = StandardPaths::DecodePathMaybeRelative(Options.AsText(_T("Dictionaries path")), _T("?data")) + _T("/");
|
||||||
wxArrayString list;
|
wxArrayString list;
|
||||||
wxFileName folder(path);
|
wxFileName folder(path);
|
||||||
if (!folder.DirExists()) return list;
|
if (!folder.DirExists()) return list;
|
||||||
|
@ -140,7 +140,7 @@ void MySpellThesaurus::SetLanguage(wxString language) {
|
||||||
if (language.IsEmpty()) return;
|
if (language.IsEmpty()) return;
|
||||||
|
|
||||||
// Get dir name
|
// Get dir name
|
||||||
wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),StandardPaths::DecodePath(_T("?data/"))) + _T("/");
|
wxString path = StandardPaths::DecodePathMaybeRelative(Options.AsText(_T("Dictionaries path")), _T("?data")) + _T("/");
|
||||||
|
|
||||||
// Get affix and dictionary paths
|
// Get affix and dictionary paths
|
||||||
wxString idxpath = path + _T("th_") + language + _T(".idx");
|
wxString idxpath = path + _T("th_") + language + _T(".idx");
|
||||||
|
|
Loading…
Reference in New Issue