From d0fc49ca67ad1fe8ccf3cb3b364d6d36a9a8c60c Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Thu, 21 Jun 2007 00:46:50 +0000 Subject: [PATCH] Replaced all references to absolute paths with ?user, ?data or ?temp. Some bugs might have resulted, but it seems to work-ish. Originally committed to SVN as r1277. --- aegisub/aegisublocale.cpp | 6 +-- aegisub/ass_style_storage.cpp | 19 ++------ aegisub/audio_provider_hd.cpp | 6 +-- aegisub/auto4_base.cpp | 11 +++-- aegisub/browse_button.cpp | 6 +-- aegisub/dialog_options.cpp | 18 +++++-- aegisub/dialog_shift_times.cpp | 10 ++-- aegisub/dialog_style_manager.cpp | 17 ++----- aegisub/frame_main.cpp | 4 +- aegisub/frame_main_events.cpp | 9 +++- aegisub/main.cpp | 80 ++++--------------------------- aegisub/main.h | 4 -- aegisub/options.cpp | 8 ++-- aegisub/spellchecker_hunspell.cpp | 6 +-- aegisub/thesaurus_myspell.cpp | 6 +-- aegisub/video_context.cpp | 14 ++---- aegisub/video_provider_avs.cpp | 10 ++-- 17 files changed, 76 insertions(+), 158 deletions(-) diff --git a/aegisub/aegisublocale.cpp b/aegisub/aegisublocale.cpp index e8642d8d0..090c5f9b2 100644 --- a/aegisub/aegisublocale.cpp +++ b/aegisub/aegisublocale.cpp @@ -43,7 +43,7 @@ #include #include #include "aegisublocale.h" -#include "main.h" +#include "standard_paths.h" /////////////// @@ -65,7 +65,7 @@ void AegisubLocale::Init(int language) { curCode = language; locale = new wxLocale(language); #ifdef __WINDOWS__ - locale->AddCatalogLookupPathPrefix(AegisubApp::folderName + _T("locale/")); + locale->AddCatalogLookupPathPrefix(StandardPaths::DecodePath(_T("?data/locale/"))); #endif locale->AddCatalog(_T("aegisub")); locale->AddCatalog(_T("wxstd")); @@ -115,7 +115,7 @@ wxArrayInt AegisubLocale::GetAvailableLanguages() { wxString temp1; // Open directory - wxString folder = AegisubApp::folderName + _T("/locale/"); + wxString folder = StandardPaths::DecodePath(_T("?data/locale/")); wxDir dir; if (!dir.Exists(folder)) return final; if (!dir.Open(folder)) return final; diff --git a/aegisub/ass_style_storage.cpp b/aegisub/ass_style_storage.cpp index 86407f59f..5476049a7 100644 --- a/aegisub/ass_style_storage.cpp +++ b/aegisub/ass_style_storage.cpp @@ -36,13 +36,13 @@ //////////// // Includes +#include #include "ass_style_storage.h" #include "ass_style.h" #include "ass_file.h" -#include "main.h" #include "text_file_reader.h" #include "text_file_writer.h" -#include +#include "standard_paths.h" /////////////////////// @@ -50,12 +50,7 @@ void AssStyleStorage::Save(wxString name) { if (name.IsEmpty()) return; - wxString filename = AegisubApp::folderName; - filename += _T("/catalog/"); - filename += name; - filename += _T(".sty"); - - TextFileWriter file(filename, _T("UTF-8")); + TextFileWriter file(StandardPaths::DecodePath(_T("?data/catalog/")+name+_T(".sty")), _T("UTF-8")); for (std::list::iterator cur=style.begin();cur!=style.end();cur++) { file.WriteLineToFile((*cur)->GetEntryData()); @@ -67,15 +62,9 @@ void AssStyleStorage::Save(wxString name) { // Load styles from disk void AssStyleStorage::Load(wxString name) { if (name.IsEmpty()) return; - - wxString filename = AegisubApp::folderName; - filename += _T("/catalog/"); - filename += name; - filename += _T(".sty"); - Clear(); - TextFileReader file(filename, _T("UTF-8")); + TextFileReader file(StandardPaths::DecodePath(_T("?data/catalog/")+name+_T(".sty")), _T("UTF-8")); AssStyle *curStyle; while (file.HasMoreLines()) { diff --git a/aegisub/audio_provider_hd.cpp b/aegisub/audio_provider_hd.cpp index 5c8b24bed..f25725ee0 100644 --- a/aegisub/audio_provider_hd.cpp +++ b/aegisub/audio_provider_hd.cpp @@ -41,7 +41,7 @@ #include #include "dialog_progress.h" #include "audio_provider_hd.h" -#include "main.h" +#include "standard_paths.h" #include "options.h" #include "utils.h" @@ -142,10 +142,10 @@ void HDAudioProvider::GetAudio(void *buf, __int64 start, __int64 count) { wxString HDAudioProvider::DiskCachePath() { // Default wxString path = Options.AsText(_T("Audio HD Cache Location")); - if (path == _T("default")) return AegisubApp::folderName; + if (path == _T("default")) return StandardPaths::DecodePath(_T("?temp/")); // Specified - return DecodeRelativePath(path,AegisubApp::folderName); + return DecodeRelativePath(path,StandardPaths::DecodePath(_T("?user/"))); } diff --git a/aegisub/auto4_base.cpp b/aegisub/auto4_base.cpp index b44e3dcd0..e8243b550 100644 --- a/aegisub/auto4_base.cpp +++ b/aegisub/auto4_base.cpp @@ -38,6 +38,7 @@ #include "options.h" #include "string_codec.h" #include "ass_file.h" +#include "standard_paths.h" #include #include #include @@ -515,7 +516,7 @@ namespace Automation4 { wxStringTokenizer toker(Options.AsText(_T("Automation Include Path")), _T("|"), wxTOKEN_STRTOK); while (toker.HasMoreTokens()) { // todo? make some error reporting here - wxFileName path(toker.GetNextToken()); + wxFileName path(StandardPaths::DecodePath(toker.GetNextToken())); if (!path.IsOk()) continue; if (path.IsRelative()) continue; if (!path.DirExists()) continue; @@ -648,18 +649,18 @@ namespace Automation4 { wxStringTokenizer tok(path, _T("|"), wxTOKEN_STRTOK); while (tok.HasMoreTokens()) { wxDir dir; - wxString dirname = tok.GetNextToken(); + wxString dirname = StandardPaths::DecodePath(tok.GetNextToken()); if (!dir.Exists(dirname)) { - wxLogWarning(_T("A directory was specified in the Automation autoload path, but it doesn't exist: %s"), dirname.c_str()); + //wxLogWarning(_T("A directory was specified in the Automation autoload path, but it doesn't exist: %s"), dirname.c_str()); continue; } if (!dir.Open(dirname)) { - wxLogWarning(_T("Failed to open a directory in the Automation autoload path: %s"), dirname.c_str()); + //wxLogWarning(_T("Failed to open a directory in the Automation autoload path: %s"), dirname.c_str()); continue; } wxString fn; - wxFileName script_path(path, _T("")); + wxFileName script_path(dirname + _T("/"), _T("")); bool more = dir.GetFirst(&fn, wxEmptyString, wxDIR_FILES); while (more) { script_path.SetName(fn); diff --git a/aegisub/browse_button.cpp b/aegisub/browse_button.cpp index b2c8d502d..d21fa2be8 100644 --- a/aegisub/browse_button.cpp +++ b/aegisub/browse_button.cpp @@ -41,7 +41,7 @@ #include #include "browse_button.h" #include "utils.h" -#include "main.h" +#include "standard_paths.h" /////////////// @@ -68,8 +68,8 @@ void BrowseButton::Bind(wxTextCtrl *control,int pos) { void BrowseButton::OnPressed(wxCommandEvent &event) { // Folder if (type == BROWSE_FOLDER) { - wxString def = DecodeRelativePath(ctrl[0]->GetValue(),AegisubApp::folderName); - wxString dir = MakeRelativePath(wxDirSelector(_("Please choose the folder:"),def),AegisubApp::folderName); + wxString def = DecodeRelativePath(ctrl[0]->GetValue(),StandardPaths::DecodePath(_T("?user/"))); + wxString dir = MakeRelativePath(wxDirSelector(_("Please choose the folder:"),def),StandardPaths::DecodePath(_T("?user/"))); if (dir != _T("")) ctrl[0]->SetValue(dir); } diff --git a/aegisub/dialog_options.cpp b/aegisub/dialog_options.cpp index 825c213da..cbfbbf3db 100644 --- a/aegisub/dialog_options.cpp +++ b/aegisub/dialog_options.cpp @@ -44,8 +44,9 @@ #endif #include "options.h" #include +#include #include "frame_main.h" -#include "main.h" +#include "standard_paths.h" #include "validators.h" #include "colour_button.h" #include "subs_edit_box.h" @@ -709,7 +710,10 @@ void DialogOptions::OnOK(wxCommandEvent &event) { int answer = wxMessageBox(_("Aegisub must restart for the changes to take effect. Restart now?"),_("Restart Aegisub"),wxYES_NO); if (answer == wxYES) { FrameMain *frame = (FrameMain*) GetParent(); - if (frame->Close()) wxExecute(AegisubApp::fullPath); + if (frame->Close()) { + wxStandardPaths stand; + wxExecute(stand.GetExecutablePath()); + } } } } @@ -739,7 +743,10 @@ void DialogOptions::OnCancel(wxCommandEvent &event) { int answer = wxMessageBox(_("Aegisub must restart for the changes to take effect. Restart now?"),_("Restart Aegisub"),wxYES_NO); if (answer == wxYES) { FrameMain *frame = (FrameMain*) GetParent(); - if (frame->Close()) wxExecute(AegisubApp::fullPath); + if (frame->Close()) { + wxStandardPaths stand; + wxExecute(stand.GetExecutablePath()); + } } } } @@ -871,7 +878,10 @@ void DialogOptions::WriteToOptions(bool justApply) { int answer = wxMessageBox(_("Aegisub must restart for the changes to take effect. Restart now?"),_("Restart Aegisub"),wxYES_NO); if (answer == wxYES) { FrameMain *frame = (FrameMain*) GetParent(); - if (frame->Close()) wxExecute(AegisubApp::fullPath); + if (frame->Close()) { + wxStandardPaths stand; + wxExecute(stand.GetExecutablePath()); + } } } } diff --git a/aegisub/dialog_shift_times.cpp b/aegisub/dialog_shift_times.cpp index 361ef4069..a5c5b6a82 100644 --- a/aegisub/dialog_shift_times.cpp +++ b/aegisub/dialog_shift_times.cpp @@ -40,21 +40,19 @@ #include #include #include +#include #include "dialog_shift_times.h" #include "video_display.h" #include "vfr.h" #include "subs_grid.h" #include "options.h" -#include "main.h" +#include "standard_paths.h" #include "ass_file.h" #include "ass_time.h" #include "ass_dialogue.h" #include "subs_edit_box.h" -#define SHIFT_HISTORY_FILE (AegisubApp::folderName + _T("shift_history.txt")) - - /////////////// // Constructor DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid) @@ -172,7 +170,7 @@ DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid) } // Load history - LoadHistory(SHIFT_HISTORY_FILE); + LoadHistory(StandardPaths::DecodePath(_T("?user/shift_history.txt"))); } @@ -190,7 +188,7 @@ END_EVENT_TABLE() ///////////////// // Clear History void DialogShiftTimes::OnClear(wxCommandEvent &event) { - remove(SHIFT_HISTORY_FILE.mb_str(wxConvLocal)); + wxRemoveFile(StandardPaths::DecodePath(_T("?user/shift_history.txt"))); History->Clear(); } diff --git a/aegisub/dialog_style_manager.cpp b/aegisub/dialog_style_manager.cpp index 0e9756b1b..95666cb87 100644 --- a/aegisub/dialog_style_manager.cpp +++ b/aegisub/dialog_style_manager.cpp @@ -44,7 +44,7 @@ #include "ass_style.h" #include "ass_file.h" #include "ass_dialogue.h" -#include "main.h" +#include "standard_paths.h" #include "options.h" #include "subs_grid.h" @@ -203,8 +203,7 @@ void DialogStyleManager::LoadCatalog () { CatalogList->Clear(); // Create catalog if it doesn't exist - wxString dirname = AegisubApp::folderName; - dirname += _T("/catalog/"); + wxString dirname = StandardPaths::DecodePath(_T("?user/catalog/")); if (!wxDirExists(dirname)) { if (!wxMkdir(dirname)) { throw _T("Error creating directory!"); @@ -219,8 +218,7 @@ void DialogStyleManager::LoadCatalog () { } // Get dir - dirname = AegisubApp::folderName; - dirname += _T("/catalog/*.sty"); + dirname = StandardPaths::DecodePath(_T("?user/catalog/*.sty")); // Populate wxString curfile = wxFindFirstFile(dirname,wxFILE); @@ -411,8 +409,7 @@ void DialogStyleManager::OnCatalogNew (wxCommandEvent &event) { StorageActions(true); // Save - wxString dirname = AegisubApp::folderName; - dirname += _T("/catalog/"); + wxString dirname = StandardPaths::DecodePath(_T("?user/catalog/")); if (!wxDirExists(dirname)) { if (!wxMkdir(dirname)) { throw _T("Error creating directory!"); @@ -435,11 +432,7 @@ void DialogStyleManager::OnCatalogDelete (wxCommandEvent &event) { message += _("\" from the catalog?"); int option = wxMessageBox(message, _("Confirm delete"), wxYES_NO | wxICON_EXCLAMATION , this); if (option == wxYES) { - wxString filename = AegisubApp::folderName; - filename += _T("/catalog/"); - filename += name; - filename += _T(".sty"); - wxRemoveFile(filename); + wxRemoveFile(StandardPaths::DecodePath(_T("?user/catalog/") + name + _T(".sty"))); CatalogList->Delete(sel); StorageList->Clear(); StorageActions(false); diff --git a/aegisub/frame_main.cpp b/aegisub/frame_main.cpp index 25e45c7d3..6e7ac2b3d 100644 --- a/aegisub/frame_main.cpp +++ b/aegisub/frame_main.cpp @@ -596,7 +596,7 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) { wxString path = Options.AsText(_T("Auto backup path")); if (path.IsEmpty()) path = origfile.GetPath(); wxFileName dstpath(path); - if (!dstpath.IsAbsolute()) path = AegisubApp::folderName + path; + if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePath(_T("?user/") + path); path += _T("/"); dstpath.Assign(path); if (!dstpath.DirExists()) wxMkdir(path); @@ -1140,7 +1140,7 @@ void FrameMain::OpenHelp(wxString page) { if (!page.IsEmpty()) page = _T("::") + page; wxFileType *type = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("chm")); if (type) { - wxString command = type->GetOpenCommand(AegisubApp::folderName + _T("Aegisub.chm")); + wxString command = type->GetOpenCommand(StandardPaths::DecodePath(_T("?data/Aegisub.chm"))); if (!command.empty()) wxExecute(command + page); } } diff --git a/aegisub/frame_main_events.cpp b/aegisub/frame_main_events.cpp index 1dd9605b7..e8c933227 100644 --- a/aegisub/frame_main_events.cpp +++ b/aegisub/frame_main_events.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include "subs_grid.h" #include "frame_main.h" #include "video_display.h" @@ -80,6 +81,7 @@ #include "dialog_dummy_video.h" #include "dialog_spellchecker.h" #include "dialog_associations.h" +#include "standard_paths.h" //////////////////// @@ -1352,7 +1354,7 @@ void FrameMain::OnAutoSave(wxTimerEvent &event) { wxString path = Options.AsText(_T("Auto save path")); if (path.IsEmpty()) path = origfile.GetPath(); wxFileName dstpath(path); - if (!dstpath.IsAbsolute()) path = AegisubApp::folderName + path; + if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePath(_T("?user/") + path); path += _T("/"); dstpath.Assign(path); if (!dstpath.DirExists()) wxMkdir(path); @@ -1517,7 +1519,10 @@ void FrameMain::OnChooseLanguage (wxCommandEvent &event) { int result = wxMessageBox(_T("Aegisub needs to be restarted so that the new language can be applied. Restart now?"),_T("Restart Aegisub?"),wxICON_QUESTION | wxYES_NO); if (result == wxYES) { // Restart Aegisub - if (Close()) wxExecute(AegisubApp::fullPath); + if (Close()) { + wxStandardPaths stand; + wxExecute(stand.GetExecutablePath()); + } } } } diff --git a/aegisub/main.cpp b/aegisub/main.cpp index d5595a76e..a0536fca5 100644 --- a/aegisub/main.cpp +++ b/aegisub/main.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include "main.h" #include "frame_main.h" #include "options.h" @@ -58,6 +59,7 @@ #include "auto4_base.h" #include "subtitle_format.h" #include "video_context.h" +#include "standard_paths.h" /////////////////// @@ -85,14 +87,12 @@ bool AegisubApp::OnInit() { #endif // Set config file - GetFullPath(argv[0]); - GetFolderName(); - Options.SetFile(folderName + _T("/config.dat")); + Options.SetFile(StandardPaths::DecodePath(_T("?user/config.dat"))); Options.Load(); AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times")); // Set hotkeys file - Hotkeys.SetFile(folderName + _T("/hotkeys.dat")); + Hotkeys.SetFile(StandardPaths::DecodePath(_T("?user/hotkeys.dat"))); Hotkeys.Load(); #ifdef __WINDOWS__ @@ -217,7 +217,7 @@ void StackWalker::OnStackFrame(const wxStackFrame &frame) { } StackWalker::StackWalker() { - file.open(wxString(AegisubApp::folderName + _T("/stack.txt")).mb_str(),std::ios::out | std::ios::app); + file.open(wxString(StandardPaths::DecodePath(_T("?user/stack.txt"))).mb_str(),std::ios::out | std::ios::app); if (file.is_open()) { file << std::endl << "Begining stack dump:\n"; } @@ -268,7 +268,9 @@ void AegisubApp::RegistryAssociate () { #if defined(__WINDOWS__) // Command to open with this wxString command; - command << _T("\"") << fullPath << _T("\" \"%1\""); + wxStandardPaths stand; + wxString fullPath = stand.GetExecutablePath(); + command = _T("\"") + fullPath + _T("\" \"%1\""); // Main program association wxRegKey *key = new wxRegKey(_T("HKEY_CURRENT_USER\\Software\\Classes\\Aegisub")); @@ -317,66 +319,6 @@ void AegisubApp::RegistryAssociate () { } -///////////////////////////// -// Gets and stores full path -void AegisubApp::GetFullPath(wxString arg) { - if (wxIsAbsolutePath(arg)) { - fullPath = arg; - return; - } - - // Is it a relative path? - wxString currentDir(wxFileName::GetCwd()); - if (currentDir.Last() != wxFILE_SEP_PATH) currentDir += wxFILE_SEP_PATH; - wxString str = currentDir + arg; - if (wxFileExists(str)) { - fullPath = str; - return; - } - - // OK, it's neither an absolute path nor a relative path. - // Search PATH. - wxPathList pathList; - pathList.AddEnvList(_T("PATH")); - str = pathList.FindAbsoluteValidPath(arg); - if (!str.IsEmpty()) { - fullPath = str; - return; - } - - fullPath = _T(""); - return; -} - - -/////////////////////////////////// -// Gets folder name from full path -void AegisubApp::GetFolderName () { -#if defined(__WINDOWS__) - folderName = _T(""); - wxFileName path(fullPath); -#elif defined(__APPLE__) - wxFileName path; - path.AssignHomeDir(); - path.AppendDir(_T("Library")); - path.AppendDir(_T("Application Support")); - if (!path.DirExists()) - path.Mkdir(); - path.AppendDir(_T("Aegisub")); - if (!path.DirExists()) - path.Mkdir(); -#else - wxFileName path; - path.AssignHomeDir(); - path.AppendDir(_T(".aegisub")); - if (!path.DirExists()) - path.Mkdir(); -#endif - folderName += path.GetPath(wxPATH_GET_VOLUME); - folderName += _T("/"); -} - - //////////// // Open URL void AegisubApp::OpenURL(wxString url) { @@ -397,12 +339,6 @@ void AegisubApp::MacOpenFile(const wxString &filename) { #endif -/////////// -// Statics -wxString AegisubApp::fullPath; -wxString AegisubApp::folderName; - - /////////////// // Event table BEGIN_EVENT_TABLE(AegisubApp,wxApp) diff --git a/aegisub/main.h b/aegisub/main.h index c1759cda5..0aafc6421 100644 --- a/aegisub/main.h +++ b/aegisub/main.h @@ -64,13 +64,9 @@ public: FrameMain *frame; Automation4::AutoloadScriptManager *global_scripts; - static wxString fullPath; - static wxString folderName; static AegisubApp* Get() { return (AegisubApp*) wxTheApp; } static void OpenURL(wxString url); - void GetFullPath(wxString arg); - void GetFolderName(); void RegistryAssociate(); void AssociateType(wxString type); diff --git a/aegisub/options.cpp b/aegisub/options.cpp index 8eba1196e..ba1249e49 100644 --- a/aegisub/options.cpp +++ b/aegisub/options.cpp @@ -42,7 +42,6 @@ #include #include #include "options.h" -#include "main.h" #include "text_file_reader.h" #include "text_file_writer.h" #include "colorspace.h" @@ -190,10 +189,9 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) { // Automation // The path changes only take effect when a script is (re)loaded but Automatic should be good enough, it certainly doesn't warrart a restart SetModificationType(MOD_AUTOMATIC); - // TODO: these paths should be different on non-Windows systems - SetText(_T("Automation Base Path"), AegisubApp::folderName + _T("automation/")); - SetText(_T("Automation Include Path"), AegisubApp::folderName + _T("automation/include/")); - SetText(_T("Automation Autoload Path"), AegisubApp::folderName + _T("automation/autoload/")); + SetText(_T("Automation Base Path"), _T("?data/automation/")); + SetText(_T("Automation Include Path"), _T("?user/automation/include/|?data/automation/include/")); + SetText(_T("Automation Autoload Path"), _T("?user/automation/autoload/|?data/automation/include/")); SetInt(_T("Automation Trace Level"), 3); SetInt(_T("Automation Thread Priority"), 1); // "below normal" SetInt(_T("Automation Autoreload Mode"), 0); // never diff --git a/aegisub/spellchecker_hunspell.cpp b/aegisub/spellchecker_hunspell.cpp index 5d75e4680..171bdf4ae 100644 --- a/aegisub/spellchecker_hunspell.cpp +++ b/aegisub/spellchecker_hunspell.cpp @@ -37,7 +37,7 @@ /////////// // Headers #include "spellchecker.h" -#include "main.h" +#include "standard_paths.h" #include "utils.h" #include "options.h" #include @@ -228,7 +228,7 @@ wxArrayString HunspellSpellChecker::GetSuggestions(wxString word) { // Get list of available dictionaries wxArrayString HunspellSpellChecker::GetLanguageList() { // Get dir name - wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/"); + wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),StandardPaths::DecodePath(_T("?data/"))) + _T("/"); wxArrayString list; wxFileName folder(path); if (!folder.DirExists()) return list; @@ -265,7 +265,7 @@ void HunspellSpellChecker::SetLanguage(wxString language) { if (language.IsEmpty()) return; // Get dir name - wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/"); + wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),StandardPaths::DecodePath(_T("?data/"))) + _T("/"); // Get affix and dictionary paths affpath = path + language + _T(".aff"); diff --git a/aegisub/thesaurus_myspell.cpp b/aegisub/thesaurus_myspell.cpp index d79aba3db..350260bb8 100644 --- a/aegisub/thesaurus_myspell.cpp +++ b/aegisub/thesaurus_myspell.cpp @@ -41,7 +41,7 @@ #include #include "thesaurus_myspell.h" #include "mythes.hxx" -#include "main.h" +#include "standard_paths.h" #include "options.h" #include "utils.h" @@ -94,7 +94,7 @@ void MySpellThesaurus::Lookup(wxString word,ThesaurusEntryArray &result) { // Get language list wxArrayString MySpellThesaurus::GetLanguageList() { // Get dir name - wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/"); + wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),StandardPaths::DecodePath(_T("?data/"))) + _T("/"); wxArrayString list; wxFileName folder(path); if (!folder.DirExists()) return list; @@ -138,7 +138,7 @@ void MySpellThesaurus::SetLanguage(wxString language) { if (language.IsEmpty()) return; // Get dir name - wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/"); + wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),StandardPaths::DecodePath(_T("?data/"))) + _T("/"); // Get affix and dictionary paths wxString idxpath = path + _T("th_") + language + _T(".idx"); diff --git a/aegisub/video_context.cpp b/aegisub/video_context.cpp index 0d9aa3c52..bffee042a 100644 --- a/aegisub/video_context.cpp +++ b/aegisub/video_context.cpp @@ -65,7 +65,6 @@ #include "options.h" #include "subs_edit_box.h" #include "audio_display.h" -#include "main.h" #include "video_slider.h" #include "video_box.h" #include "utils.h" @@ -591,17 +590,10 @@ void VideoContext::SaveSnapshot(bool raw) { wxString option = Options.AsText(_("Video Screenshot Path")); wxFileName videoFile(videoName); wxString basepath; - if (option == _T("?video")) { - basepath = videoFile.GetPath(); + if (option[0] == _T('?')) { + basepath = StandardPaths::DecodePath(option); } - else if (option == _T("?script")) { - if (grid->ass->filename.IsEmpty()) basepath = videoFile.GetPath(); - else { - wxFileName file2(grid->ass->filename); - basepath = file2.GetPath(); - } - } - else basepath = DecodeRelativePath(option,((AegisubApp*)wxTheApp)->folderName); + else basepath = DecodeRelativePath(option,StandardPaths::DecodePath(_T("?user/"))); basepath += _T("/") + videoFile.GetName(); // Get full path diff --git a/aegisub/video_provider_avs.cpp b/aegisub/video_provider_avs.cpp index 596e99f3a..ba285336e 100644 --- a/aegisub/video_provider_avs.cpp +++ b/aegisub/video_provider_avs.cpp @@ -46,7 +46,7 @@ #include "subtitles_provider.h" #include "video_context.h" #include "options.h" -#include "main.h" +#include "standard_paths.h" #include "vfr.h" #include "ass_file.h" #include "gl_wrap.h" @@ -231,7 +231,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori bool ffsource = false; if (env->FunctionExists("ffmpegsource")) ffsource = true; if (!ffsource) { - wxFileName ffsourcepath(AegisubApp::folderName + _T("ffmpegsource.dll")); + wxFileName ffsourcepath(StandardPaths::DecodePath(_T("?data/ffmpegsource.dll"))); if (ffsourcepath.FileExists()) { AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading FFMpegSource")); env->Invoke("LoadPlugin",env->SaveString(ffsourcepath.GetFullPath().mb_str(wxConvLocal))); @@ -257,7 +257,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori bool dss2 = false; if (env->FunctionExists("dss2")) dss2 = true; if (!dss2) { - wxFileName dss2path(AegisubApp::folderName + _T("avss.dll")); + wxFileName dss2path(StandardPaths::DecodePath(_T("?data/avss.dll"))); if (dss2path.FileExists()) { AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading DirectShowSource2")); env->Invoke("LoadPlugin",env->SaveString(dss2path.GetFullPath().mb_str(wxConvLocal))); @@ -480,7 +480,7 @@ void AvisynthVideoProvider::LoadVSFilter() { AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Loading VSFilter")); // Loading an avisynth plugin multiple times does almost nothing - wxFileName vsfilterPath(AegisubApp::folderName + _T("vsfilter.dll")); + wxFileName vsfilterPath(StandardPaths::DecodePath(_T("?data/vsfilter.dll"))); rendererCallString = _T("TextSub"); if (vsfilterPath.FileExists()) { @@ -525,7 +525,7 @@ void AvisynthVideoProvider::LoadASA() { AVSTRACE(_T("AvisynthVideoProvider::LoadASA: Loading asa")); // Loading an avisynth plugin multiple times does almost nothing - wxFileName asaPath(AegisubApp::folderName + _T("asa.dll")); + wxFileName asaPath(StandardPaths::DecodePath(_T("?data/asa.dll"))); rendererCallString = _T("asa"); if (asaPath.FileExists()) {