diff --git a/aegisub/build/Aegisub/Aegisub.vcxproj b/aegisub/build/Aegisub/Aegisub.vcxproj index 1c4205600..5c9e869c2 100644 --- a/aegisub/build/Aegisub/Aegisub.vcxproj +++ b/aegisub/build/Aegisub/Aegisub.vcxproj @@ -213,7 +213,6 @@ - @@ -403,7 +402,6 @@ - diff --git a/aegisub/build/Aegisub/Aegisub.vcxproj.filters b/aegisub/build/Aegisub/Aegisub.vcxproj.filters index dd1a771bb..3b718bcc5 100644 --- a/aegisub/build/Aegisub/Aegisub.vcxproj.filters +++ b/aegisub/build/Aegisub/Aegisub.vcxproj.filters @@ -582,9 +582,6 @@ Video\Visual tools - - Utilities - Features\About box @@ -1112,9 +1109,6 @@ Video\Visual tools - - Utilities - Commands diff --git a/aegisub/src/Makefile b/aegisub/src/Makefile index 6097b0db6..47444593f 100644 --- a/aegisub/src/Makefile +++ b/aegisub/src/Makefile @@ -219,7 +219,6 @@ SRC += \ spellchecker.cpp \ spline.cpp \ spline_curve.cpp \ - standard_paths.cpp \ string_codec.cpp \ subs_controller.cpp \ subs_edit_box.cpp \ diff --git a/aegisub/src/aegisublocale.cpp b/aegisub/src/aegisublocale.cpp index 4bcb1ccb8..70692e42d 100644 --- a/aegisub/src/aegisublocale.cpp +++ b/aegisub/src/aegisublocale.cpp @@ -36,10 +36,12 @@ #include "aegisublocale.h" -#include "standard_paths.h" +#include "options.h" + +#include #include -#include +#include #include #include @@ -54,7 +56,7 @@ wxTranslations *AegisubLocale::GetTranslations() { wxTranslations *translations = wxTranslations::Get(); if (!translations) { wxTranslations::Set(translations = new wxTranslations); - wxFileTranslationsLoader::AddCatalogLookupPathPrefix(StandardPaths::DecodePath("?data/locale/").wstring()); + wxFileTranslationsLoader::AddCatalogLookupPathPrefix(config::path->Decode("?data/locale/").wstring()); } return translations; } diff --git a/aegisub/src/ass_style_storage.cpp b/aegisub/src/ass_style_storage.cpp index f3c4f8ef9..a8f38db39 100644 --- a/aegisub/src/ass_style_storage.cpp +++ b/aegisub/src/ass_style_storage.cpp @@ -37,12 +37,13 @@ #include "ass_style_storage.h" #include "ass_style.h" -#include "standard_paths.h" +#include "options.h" #include "text_file_reader.h" #include "text_file_writer.h" #include "utils.h" #include +#include #include #include @@ -54,9 +55,9 @@ AssStyleStorage::~AssStyleStorage() { void AssStyleStorage::Save() const { if (storage_name.empty()) return; - agi::fs::CreateDirectory(StandardPaths::DecodePath("?user/catalog/")); + agi::fs::CreateDirectory(config::path->Decode("?user/catalog/")); - TextFileWriter file(StandardPaths::DecodePath("?user/catalog/" + storage_name + ".sty"), "UTF-8"); + TextFileWriter file(config::path->Decode("?user/catalog/" + storage_name + ".sty"), "UTF-8"); for (const AssStyle *cur : style) file.WriteLineToFile(cur->GetEntryData()); } @@ -66,7 +67,7 @@ void AssStyleStorage::Load(std::string const& name) { Clear(); try { - TextFileReader file(StandardPaths::DecodePath("?user/catalog/" + name + ".sty"), "UTF-8"); + TextFileReader file(config::path->Decode("?user/catalog/" + name + ".sty"), "UTF-8"); while (file.HasMoreLines()) { try { diff --git a/aegisub/src/audio_provider_avs.cpp b/aegisub/src/audio_provider_avs.cpp index 07ee347f2..9dba5c098 100644 --- a/aegisub/src/audio_provider_avs.cpp +++ b/aegisub/src/audio_provider_avs.cpp @@ -39,12 +39,12 @@ #include "audio_controller.h" #include "options.h" -#include "standard_paths.h" #include "utils.h" #include #include #include +#include #include @@ -67,7 +67,7 @@ AvisynthAudioProvider::AvisynthAudioProvider(agi::fs::path const& filename) { AVSValue args[3] = { env->SaveString(agi::fs::ShortName(filename).c_str()), false, true }; // Load DirectShowSource.dll from app dir if it exists - agi::fs::path dsspath(StandardPaths::DecodePath("?data/DirectShowSource.dll")); + agi::fs::path dsspath(config::path->Decode("?data/DirectShowSource.dll")); if (agi::fs::FileExists(dsspath)) env->Invoke("LoadPlugin", env->SaveString(agi::fs::ShortName(dsspath).c_str())); diff --git a/aegisub/src/auto4_base.cpp b/aegisub/src/auto4_base.cpp index b479bba81..da8b18360 100644 --- a/aegisub/src/auto4_base.cpp +++ b/aegisub/src/auto4_base.cpp @@ -42,7 +42,6 @@ #include "dialog_progress.h" #include "include/aegisub/context.h" #include "options.h" -#include "standard_paths.h" #include "string_codec.h" #include "subs_controller.h" #include "subtitle_format.h" @@ -284,7 +283,7 @@ namespace Automation4 { std::string include_paths = OPT_GET("Path/Automation/Include")->GetString(); boost::char_separator sep("|"); for (auto const& tok : boost::tokenizer>(include_paths, sep)) { - auto path = StandardPaths::DecodePath(tok); + auto path = config::path->Decode(tok); if (path.is_absolute() && agi::fs::DirectoryExists(path)) include_path.emplace_back(std::move(path)); } @@ -355,7 +354,7 @@ namespace Automation4 { boost::char_separator sep("|"); for (auto const& tok : boost::tokenizer>(path, sep)) { - auto dirname = StandardPaths::DecodePath(tok); + auto dirname = config::path->Decode(tok); if (!agi::fs::DirectoryExists(dirname)) continue; for (auto filename : agi::fs::DirectoryIterator(dirname, "*.*")) { diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index d19e2dbc5..0d652d441 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -46,15 +46,16 @@ #include "compat.h" #include "include/aegisub/context.h" #include "main.h" +#include "options.h" #include "selection_controller.h" #include "subs_controller.h" -#include "standard_paths.h" #include "video_context.h" #include "utils.h" #include #include #include +#include #include #include @@ -726,7 +727,7 @@ namespace Automation4 { { std::string path = luaL_checkstring(L, 1); lua_pop(L, 1); - push_value(L, StandardPaths::DecodePath(path)); + push_value(L, config::path->Decode(path)); return 1; } diff --git a/aegisub/src/command/tool.cpp b/aegisub/src/command/tool.cpp index 7a8691c03..a59dcd434 100644 --- a/aegisub/src/command/tool.cpp +++ b/aegisub/src/command/tool.cpp @@ -50,10 +50,11 @@ #include "../dialog_timing_processor.h" #include "../dialog_translation.h" #include "../include/aegisub/context.h" -#include "../standard_paths.h" +#include "../options.h" #include "../video_context.h" #include +#include #include #include @@ -72,7 +73,7 @@ struct tool_assdraw : public Command { STR_HELP("Launch ASSDraw3 tool for vector drawing") void operator()(agi::Context *) { - wxExecute("\"" + StandardPaths::DecodePath("?data/ASSDraw3.exe").wstring() + "\""); + wxExecute("\"" + config::path->Decode("?data/ASSDraw3.exe").wstring() + "\""); } }; @@ -310,7 +311,7 @@ namespace cmd { reg(new tool_time_postprocess); reg(new tool_translation_assistant); #ifdef _WIN32 - if (agi::fs::FileExists(StandardPaths::DecodePath("?data/ASSDraw3.exe"))) + if (agi::fs::FileExists(config::path->Decode("?data/ASSDraw3.exe"))) reg(new tool_assdraw); #endif reg(new tool_translation_assistant_commit); diff --git a/aegisub/src/dialog_autosave.cpp b/aegisub/src/dialog_autosave.cpp index 5808ea225..1b52f09ee 100644 --- a/aegisub/src/dialog_autosave.cpp +++ b/aegisub/src/dialog_autosave.cpp @@ -21,7 +21,8 @@ #include "compat.h" #include "libresrc/libresrc.h" #include "options.h" -#include "standard_paths.h" + +#include #include @@ -90,7 +91,7 @@ DialogAutosave::DialogAutosave(wxWindow *parent) } void DialogAutosave::Populate(std::map &files_map, std::string const& path, wxString const& filter, wxString const& name_fmt) { - wxString directory(StandardPaths::DecodePath(path).wstring()); + wxString directory(config::path->Decode(path).wstring()); wxDir dir; if (!dir.Open(directory)) return; diff --git a/aegisub/src/dialog_fonts_collector.cpp b/aegisub/src/dialog_fonts_collector.cpp index b21fd15f3..905cb6778 100644 --- a/aegisub/src/dialog_fonts_collector.cpp +++ b/aegisub/src/dialog_fonts_collector.cpp @@ -34,12 +34,12 @@ #include "options.h" #include "scintilla_text_ctrl.h" #include "selection_controller.h" -#include "standard_paths.h" #include "subs_controller.h" #include "utils.h" #include #include +#include #include #include @@ -206,13 +206,13 @@ DialogFontsCollector::DialogFontsCollector(agi::Context *c) collection_mode = new wxRadioBox(this, -1, _("Action"), wxDefaultPosition, wxDefaultSize, countof(modes), modes, 1); collection_mode->SetSelection(mid(0, OPT_GET("Tool/Fonts Collector/Action")->GetInt(), 4)); - if (StandardPaths::DecodePath("?script") == "?script") + if (config::path->Decode("?script") == "?script") collection_mode->Enable(2, false); wxStaticBoxSizer *destination_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Destination")); dest_label = new wxStaticText(this, -1, " "); - dest_ctrl = new wxTextCtrl(this, -1, StandardPaths::DecodePath(OPT_GET("Path/Fonts Collector Destination")->GetString()).wstring()); + dest_ctrl = new wxTextCtrl(this, -1, config::path->Decode(OPT_GET("Path/Fonts Collector Destination")->GetString()).wstring()); dest_browse_button = new wxButton(this, -1, _("&Browse...")); wxSizer *dest_browse_sizer = new wxBoxSizer(wxHORIZONTAL); @@ -268,7 +268,7 @@ void DialogFontsCollector::OnStart(wxCommandEvent &) { int action = collection_mode->GetSelection(); OPT_SET("Tool/Fonts Collector/Action")->SetInt(action); if (action != CheckFontsOnly) { - dest = StandardPaths::DecodePath(action == CopyToScriptFolder ? "?script/" : from_wx(dest_ctrl->GetValue())); + dest = config::path->Decode(action == CopyToScriptFolder ? "?script/" : from_wx(dest_ctrl->GetValue())); if (action != CopyToZip) { if (agi::fs::FileExists(dest)) @@ -372,7 +372,7 @@ void DialogFontsCollector::OnCollectionComplete(wxThreadEvent &) { start_btn->Enable(); close_btn->Enable(); collection_mode->Enable(); - if (StandardPaths::DecodePath("?script") == "?script") + if (config::path->Decode("?script") == "?script") collection_mode->Enable(2, false); wxCommandEvent evt; diff --git a/aegisub/src/dialog_shift_times.cpp b/aegisub/src/dialog_shift_times.cpp index 848ad958e..72974ec6d 100644 --- a/aegisub/src/dialog_shift_times.cpp +++ b/aegisub/src/dialog_shift_times.cpp @@ -32,7 +32,6 @@ #include "libresrc/libresrc.h" #include "options.h" #include "subs_controller.h" -#include "standard_paths.h" #include "timeedit_ctrl.h" #include "video_context.h" @@ -40,6 +39,7 @@ #include #include #include +#include #include #include @@ -99,7 +99,7 @@ static wxString get_history_string(json::Object &obj) { DialogShiftTimes::DialogShiftTimes(agi::Context *context) : wxDialog(context->parent, -1, _("Shift Times")) , context(context) -, history_filename(StandardPaths::DecodePath("?user/shift_history.json")) +, history_filename(config::path->Decode("?user/shift_history.json")) , history(new json::Array) , timecodes_loaded_slot(context->videoController->AddTimecodesListener(&DialogShiftTimes::OnTimecodesLoaded, this)) , selected_set_changed_slot(context->selectionController->AddSelectionListener(&DialogShiftTimes::OnSelectedSetChanged, this)) diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index 27940848e..3d1639fdd 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -48,11 +48,11 @@ #include "persist_location.h" #include "selection_controller.h" #include "subs_controller.h" -#include "standard_paths.h" #include "subtitle_format.h" #include "utils.h" #include +#include #include #include @@ -322,7 +322,7 @@ void DialogStyleManager::LoadCatalog() { CatalogList->Clear(); // Get saved style catalogs - for (auto const& file : agi::fs::DirectoryIterator(StandardPaths::DecodePath("?user/catalog/"), "*.sty")) + for (auto const& file : agi::fs::DirectoryIterator(config::path->Decode("?user/catalog/"), "*.sty")) CatalogList->Append(agi::fs::path(file).stem().wstring()); // Create a default storage if there are none @@ -387,7 +387,7 @@ void DialogStyleManager::OnCatalogDelete() { wxString message = wxString::Format(_("Are you sure you want to delete the storage \"%s\" from the catalog?"), name); int option = wxMessageBox(message, _("Confirm delete"), wxYES_NO | wxICON_EXCLAMATION , this); if (option == wxYES) { - agi::fs::Remove(StandardPaths::DecodePath("?user/catalog/" + from_wx(name) + ".sty")); + agi::fs::Remove(config::path->Decode("?user/catalog/" + from_wx(name) + ".sty")); CatalogList->Delete(CatalogList->GetSelection()); CatalogList->SetSelection(0); OnChangeCatalog(); diff --git a/aegisub/src/ffmpegsource_common.cpp b/aegisub/src/ffmpegsource_common.cpp index 8893aaaed..cd811bd95 100644 --- a/aegisub/src/ffmpegsource_common.cpp +++ b/aegisub/src/ffmpegsource_common.cpp @@ -42,10 +42,10 @@ #include "frame_main.h" #include "main.h" #include "options.h" -#include "standard_paths.h" #include "utils.h" #include +#include #include #include @@ -214,7 +214,7 @@ agi::fs::path FFmpegSourceProvider::GetCacheFilename(agi::fs::path const& filena hash.process_bytes(filename.string().c_str(), filename.string().size()); // Generate the filename - auto result = StandardPaths::DecodePath("?local/ffms2cache/" + std::to_string(hash.checksum()) + "_" + std::to_string(len) + "_" + std::to_string(agi::fs::ModifiedTime(filename)) + ".ffindex"); + auto result = config::path->Decode("?local/ffms2cache/" + std::to_string(hash.checksum()) + "_" + std::to_string(len) + "_" + std::to_string(agi::fs::ModifiedTime(filename)) + ".ffindex"); // Ensure that folder exists agi::fs::CreateDirectory(result.parent_path()); @@ -224,7 +224,7 @@ agi::fs::path FFmpegSourceProvider::GetCacheFilename(agi::fs::path const& filena /// @brief Starts the cache cleaner thread void FFmpegSourceProvider::CleanCache() { - ::CleanCache(StandardPaths::DecodePath("?local/ffms2cache/"), + ::CleanCache(config::path->Decode("?local/ffms2cache/"), "*.ffindex", OPT_GET("Provider/FFmpegSource/Cache/Size")->GetInt(), OPT_GET("Provider/FFmpegSource/Cache/Files")->GetInt()); diff --git a/aegisub/src/help_button.cpp b/aegisub/src/help_button.cpp index 1b277837e..e0fdc24fa 100644 --- a/aegisub/src/help_button.cpp +++ b/aegisub/src/help_button.cpp @@ -36,7 +36,10 @@ #include "help_button.h" -#include "standard_paths.h" +#include "options.h" + +#include +#include #include #include @@ -44,8 +47,6 @@ #include -#include - static std::map *pages = 0; static void init_static() { @@ -92,7 +93,7 @@ void HelpButton::OpenPage(wxString const& pageID) { wxString section; page = page.BeforeFirst('#', §ion); - wxFileName docFile(StandardPaths::DecodePath("?data/docs/").wstring(), page, "html", wxPATH_NATIVE); + wxFileName docFile(config::path->Decode("?data/docs/").wstring(), page, "html", wxPATH_NATIVE); wxString url; // If we can read a file by the constructed name, assume we have a local copy of the manual diff --git a/aegisub/src/hotkey.cpp b/aegisub/src/hotkey.cpp index 9375c52b0..6eda10c4f 100644 --- a/aegisub/src/hotkey.cpp +++ b/aegisub/src/hotkey.cpp @@ -25,7 +25,8 @@ #include "libresrc/libresrc.h" #include "command/command.h" #include "options.h" -#include "standard_paths.h" + +#include namespace { const char *removed_commands_6294[] = { @@ -123,7 +124,7 @@ namespace hotkey { agi::hotkey::Hotkey *inst = 0; void init() { inst = new agi::hotkey::Hotkey( - StandardPaths::DecodePath("?user/hotkey.json"), + config::path->Decode("?user/hotkey.json"), GET_DEFAULT_CONFIG(default_hotkey)); int last_version = OPT_GET("Version/Last Version")->GetInt(); diff --git a/aegisub/src/main.cpp b/aegisub/src/main.cpp index 87473a71b..cc924d828 100644 --- a/aegisub/src/main.cpp +++ b/aegisub/src/main.cpp @@ -50,7 +50,6 @@ #include "libresrc/libresrc.h" #include "options.h" #include "plugin_manager.h" -#include "standard_paths.h" #include "subs_controller.h" #include "subtitle_format.h" #include "version.h" @@ -140,13 +139,13 @@ bool AegisubApp::OnInit() { #ifdef __WXMSW__ // Try loading configuration from the install dir if one exists there try { - auto conf_local(StandardPaths::DecodePath("?data/config.json")); + auto conf_local(config::path->Decode("?data/config.json")); std::unique_ptr localConfig(agi::io::Open(conf_local)); config::opt = new agi::Options(conf_local, GET_DEFAULT_CONFIG(default_config)); // Local config, make ?user mean ?data so all user settings are placed in install dir - StandardPaths::SetPathValue("?user", StandardPaths::DecodePath("?data")); - StandardPaths::SetPathValue("?local", StandardPaths::DecodePath("?data")); + config::path->SetToken("?user", config::path->Decode("?data")); + config::path->SetToken("?local", config::path->Decode("?data")); } catch (agi::fs::FileSystemError const&) { // File doesn't exist or we can't read it // Might be worth displaying an error in the second case @@ -154,7 +153,7 @@ bool AegisubApp::OnInit() { #endif StartupLog("Create log writer"); - auto path_log = StandardPaths::DecodePath("?user/log/"); + auto path_log = config::path->Decode("?user/log/"); agi::fs::CreateDirectory(path_log); agi::log::log->Subscribe(new agi::log::JsonEmitter(path_log)); CleanCache(path_log, "*.json", 10, 100); @@ -162,7 +161,7 @@ bool AegisubApp::OnInit() { StartupLog("Load user configuration"); try { if (!config::opt) - config::opt = new agi::Options(StandardPaths::DecodePath("?user/config.json"), GET_DEFAULT_CONFIG(default_config)); + config::opt = new agi::Options(config::path->Decode("?user/config.json"), GET_DEFAULT_CONFIG(default_config)); std::istringstream stream(GET_DEFAULT_CONFIG(default_config_platform)); config::opt->ConfigNext(stream); } catch (agi::Exception& e) { @@ -186,7 +185,7 @@ bool AegisubApp::OnInit() { icon::icon_init(); StartupLog("Load MRU"); - config::mru = new agi::MRUManager(StandardPaths::DecodePath("?user/mru.json"), GET_DEFAULT_CONFIG(default_mru), config::opt); + config::mru = new agi::MRUManager(config::path->Decode("?user/mru.json"), GET_DEFAULT_CONFIG(default_mru), config::opt); agi::util::SetThreadName("AegiMain"); @@ -267,7 +266,7 @@ bool AegisubApp::OnInit() { #endif StartupLog("Clean old autosave files"); - CleanCache(StandardPaths::DecodePath(OPT_GET("Path/Auto/Save")->GetString()), "*.AUTOSAVE.ass", 100, 1000); + CleanCache(config::path->Decode(OPT_GET("Path/Auto/Save")->GetString()), "*.AUTOSAVE.ass", 100, 1000); StartupLog("Initialization complete"); return true; @@ -307,7 +306,7 @@ public: /// @brief Called at the start of walking the stack. /// @param cause cause of the crash. StackWalker::StackWalker(std::string const& cause) -: fp(StandardPaths::DecodePath("?user/crashlog.txt"), std::ios::app) +: fp(config::path->Decode("?user/crashlog.txt"), std::ios::app) { if (!fp.good()) return; @@ -343,7 +342,7 @@ const static wxString exception_message = _("Oops, Aegisub has crashed!\n\nAn at static void UnhandledExeception(bool stackWalk, agi::Context *c) { #if (!defined(_DEBUG) || defined(WITH_EXCEPTIONS)) && (wxUSE_ON_FATAL_EXCEPTION+0) if (c->ass && c->subsController) { - auto path = StandardPaths::DecodePath("?user/recovered"); + auto path = config::path->Decode("?user/recovered"); agi::fs::CreateDirectory(path); auto filename = c->subsController->Filename().stem(); @@ -415,7 +414,7 @@ int AegisubApp::OnRun() { // Report errors if (!error.empty()) { - boost::filesystem::ofstream file(StandardPaths::DecodePath("?user/crashlog.txt"), std::ios::app); + boost::filesystem::ofstream file(config::path->Decode("?user/crashlog.txt"), std::ios::app); if (file.is_open()) { file << agi::util::strftime("--- %y-%m-%d %H:%M:%S ------------------\n"); file << boost::format("VER - %s\n") % GetAegisubLongVersionString(); diff --git a/aegisub/src/menu.cpp b/aegisub/src/menu.cpp index 407db65a3..053359ff4 100644 --- a/aegisub/src/menu.cpp +++ b/aegisub/src/menu.cpp @@ -29,11 +29,11 @@ #include "libresrc/libresrc.h" #include "main.h" #include "options.h" -#include "standard_paths.h" #include #include #include +#include #include #include @@ -293,7 +293,7 @@ menu_map const& get_menus_root() { if (!root.empty()) return root; try { - root = agi::json_util::file(StandardPaths::DecodePath("?user/menu.json"), GET_DEFAULT_CONFIG(default_menu)); + root = agi::json_util::file(config::path->Decode("?user/menu.json"), GET_DEFAULT_CONFIG(default_menu)); return root; } catch (json::Reader::ParseException const& e) { diff --git a/aegisub/src/preferences_base.cpp b/aegisub/src/preferences_base.cpp index f51c5034e..d96e68870 100644 --- a/aegisub/src/preferences_base.cpp +++ b/aegisub/src/preferences_base.cpp @@ -16,6 +16,18 @@ /// @brief Base preferences dialogue classes /// @ingroup configuration_ui +#include "preferences_base.h" + +#include "colour_button.h" +#include "compat.h" +#include "include/aegisub/audio_player.h" +#include "include/aegisub/audio_provider.h" +#include "libresrc/libresrc.h" +#include "options.h" +#include "preferences.h" +#include "video_provider_manager.h" + +#include #include #include @@ -29,19 +41,6 @@ #include #include #include -#include - -#include "preferences_base.h" - -#include "colour_button.h" -#include "compat.h" -#include "include/aegisub/audio_player.h" -#include "include/aegisub/audio_provider.h" -#include "libresrc/libresrc.h" -#include "options.h" -#include "preferences.h" -#include "standard_paths.h" -#include "video_provider_manager.h" #define OPTION_UPDATER(type, evttype, opt, body) \ class type { \ @@ -63,7 +62,7 @@ OPTION_UPDATER(BoolUpdater, wxCommandEvent, OptionValueBool, !!evt.GetInt()); OPTION_UPDATER(ColourUpdater, wxThreadEvent, OptionValueColor, evt.GetPayload()); static void browse_button(wxTextCtrl *ctrl) { - wxDirDialog dlg(0, _("Please choose the folder:"), StandardPaths::DecodePath(from_wx(ctrl->GetValue())).wstring()); + wxDirDialog dlg(0, _("Please choose the folder:"), config::path->Decode(from_wx(ctrl->GetValue())).wstring()); if (dlg.ShowModal() == wxID_OK) { wxString dir = dlg.GetPath(); if (!dir.empty()) diff --git a/aegisub/src/spellchecker_hunspell.cpp b/aegisub/src/spellchecker_hunspell.cpp index 7062fae8f..794c69f92 100644 --- a/aegisub/src/spellchecker_hunspell.cpp +++ b/aegisub/src/spellchecker_hunspell.cpp @@ -24,13 +24,13 @@ #include "spellchecker_hunspell.h" #include "options.h" -#include "standard_paths.h" #include #include #include #include #include +#include #include @@ -160,11 +160,11 @@ std::vector HunspellSpellChecker::GetLanguageList() { std::vector dic, aff; // Get list of dictionaries - auto path = StandardPaths::DecodePath("?data/dictionaries/"); + auto path = config::path->Decode("?data/dictionaries/"); agi::fs::DirectoryIterator(path, "*.dic").GetAll(dic); agi::fs::DirectoryIterator(path, "*.aff").GetAll(aff); - path = StandardPaths::DecodePath(OPT_GET("Path/Dictionary")->GetString()); + path = config::path->Decode(OPT_GET("Path/Dictionary")->GetString()); agi::fs::DirectoryIterator(path, "*.dic").GetAll(dic); agi::fs::DirectoryIterator(path, "*.aff").GetAll(aff); @@ -200,15 +200,15 @@ void HunspellSpellChecker::OnLanguageChanged() { auto language = OPT_GET("Tool/Spell Checker/Language")->GetString(); if (language.empty()) return; - auto custDicRoot = StandardPaths::DecodePath(OPT_GET("Path/Dictionary")->GetString()); - auto dataDicRoot = StandardPaths::DecodePath("?data/dictionaries"); + auto custDicRoot = config::path->Decode(OPT_GET("Path/Dictionary")->GetString()); + auto dataDicRoot = config::path->Decode("?data/dictionaries"); // If the user has a dic/aff pair in their dictionary path for this language // use that; otherwise use the one from Aegisub's install dir, adding words // from the dic in the user's dictionary path if it exists auto affPath = custDicRoot/(language + ".aff"); auto dicPath = custDicRoot/(language + ".dic"); - userDicPath = StandardPaths::DecodePath("?user/dictionaries")/str(boost::format("user_%s.dic") % language); + userDicPath = config::path->Decode("?user/dictionaries")/str(boost::format("user_%s.dic") % language); if (!agi::fs::FileExists(affPath) || !agi::fs::FileExists(dicPath)) { affPath = dataDicRoot/(language + ".aff"); dicPath = dataDicRoot/(language + ".dic"); diff --git a/aegisub/src/standard_paths.cpp b/aegisub/src/standard_paths.cpp deleted file mode 100644 index d34fc8990..000000000 --- a/aegisub/src/standard_paths.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2013, Thomas Goyne -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// Aegisub Project http://www.aegisub.org/ - -/// @file standard_paths.cpp -/// @brief Encode and decode paths relative to various special locations -/// @ingroup utility -/// - -#include "config.h" - -#include "standard_paths.h" - -#include "options.h" - -#include - -agi::fs::path StandardPaths::DecodePath(std::string const& path) { - return config::path->Decode(path); -} - -void StandardPaths::SetPathValue(std::string const& path, agi::fs::path const& value) { - config::path->SetToken(path, value); -} diff --git a/aegisub/src/standard_paths.h b/aegisub/src/standard_paths.h deleted file mode 100644 index 2f8f2c93d..000000000 --- a/aegisub/src/standard_paths.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2013, Thomas Goyne -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// -// Aegisub Project http://www.aegisub.org/ - -/// @file standard_paths.h -/// @see standard_paths.cpp -/// @ingroup utility -/// - -#include - -#include - -class StandardPaths { -public: - static agi::fs::path DecodePath(std::string const& path); - static void SetPathValue(std::string const& path, agi::fs::path const& value); -}; diff --git a/aegisub/src/subs_controller.cpp b/aegisub/src/subs_controller.cpp index edde055fd..c04afacc1 100644 --- a/aegisub/src/subs_controller.cpp +++ b/aegisub/src/subs_controller.cpp @@ -25,12 +25,12 @@ #include "command/command.h" #include "include/aegisub/context.h" #include "options.h" -#include "standard_paths.h" #include "subtitle_format.h" #include "text_file_reader.h" #include "video_context.h" #include +#include #include #include @@ -131,7 +131,7 @@ void SubsController::Load(agi::fs::path const& filename, std::string const& char if (path_str.empty()) path = filename.parent_path(); else - path = StandardPaths::DecodePath(path_str); + path = config::path->Decode(path_str); agi::fs::CreateDirectory(path); agi::fs::Copy(filename, path/(filename.stem().string() + ".ORIGINAL" + filename.extension().string())); } @@ -148,10 +148,10 @@ void SubsController::Save(agi::fs::path const& filename, std::string const& enco try { autosaved_commit_id = saved_commit_id = commit_id; - // Have to set these now for the sake of things that want to save paths + // Have to set this now for the sake of things that want to save paths // relative to the script in the header this->filename = filename; - StandardPaths::SetPathValue("?script", filename.parent_path()); + config::path->SetToken("?script", filename.parent_path()); FileSave(); @@ -196,7 +196,7 @@ agi::fs::path SubsController::AutoSave() { if (commit_id == autosaved_commit_id) return ""; - auto path = StandardPaths::DecodePath(OPT_GET("Path/Auto/Save")->GetString()); + auto path = config::path->Decode(OPT_GET("Path/Auto/Save")->GetString()); if (path.empty()) path = filename.parent_path(); @@ -225,7 +225,7 @@ bool SubsController::CanSave() const { void SubsController::SetFileName(agi::fs::path const& path) { filename = path; - StandardPaths::SetPathValue("?script", path.parent_path()); + config::path->SetToken("?script", path.parent_path()); config::mru->Add("Subtitle", path); OPT_SET("Path/Last/Subtitles")->SetString(filename.parent_path().string()); } diff --git a/aegisub/src/subtitles_provider_csri.cpp b/aegisub/src/subtitles_provider_csri.cpp index c31db5d55..1da871bad 100644 --- a/aegisub/src/subtitles_provider_csri.cpp +++ b/aegisub/src/subtitles_provider_csri.cpp @@ -37,11 +37,12 @@ #ifdef WITH_CSRI #include "subtitles_provider_csri.h" +#include "options.h" #include "subtitle_format.h" -#include "standard_paths.h" #include "video_frame.h" #include +#include #include #include @@ -79,7 +80,7 @@ CSRISubtitlesProvider::~CSRISubtitlesProvider() { void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) { if (tempfile.empty()) - tempfile = unique_path(StandardPaths::DecodePath("?temp/csri-%%%%-%%%%-%%%%-%%%%.ass")); + tempfile = unique_path(config::path->Decode("?temp/csri-%%%%-%%%%-%%%%-%%%%.ass")); SubtitleFormat::GetWriter(tempfile)->WriteFile(subs, tempfile, "utf-8"); std::lock_guard lock(csri_mutex); diff --git a/aegisub/src/thesaurus.cpp b/aegisub/src/thesaurus.cpp index 7cca9b3b3..fe5c9d1e0 100644 --- a/aegisub/src/thesaurus.cpp +++ b/aegisub/src/thesaurus.cpp @@ -24,13 +24,13 @@ #include "thesaurus.h" #include "options.h" -#include "standard_paths.h" #include #include #include #include +#include #include Thesaurus::Thesaurus() @@ -56,11 +56,11 @@ std::vector Thesaurus::GetLanguageList() const { std::vector idx, dat; // Get list of dictionaries - auto path = StandardPaths::DecodePath("?data/dictionaries/"); + auto path = config::path->Decode("?data/dictionaries/"); agi::fs::DirectoryIterator(path, "th_*.idx").GetAll(idx); agi::fs::DirectoryIterator(path, "th_*.dat").GetAll(dat); - path = StandardPaths::DecodePath(OPT_GET("Path/Dictionary")->GetString()); + path = config::path->Decode(OPT_GET("Path/Dictionary")->GetString()); agi::fs::DirectoryIterator(path, "th_*.idx").GetAll(idx); agi::fs::DirectoryIterator(path, "th_*.dat").GetAll(dat); @@ -96,7 +96,7 @@ void Thesaurus::OnLanguageChanged() { auto language = OPT_GET("Tool/Thesaurus/Language")->GetString(); if (language.empty()) return; - auto path = StandardPaths::DecodePath(OPT_GET("Path/Dictionary")->GetString() + "/"); + auto path = config::path->Decode(OPT_GET("Path/Dictionary")->GetString() + "/"); // Get index and data paths auto idxpath = path/str(boost::format("th_%s.idx") % language); @@ -104,7 +104,7 @@ void Thesaurus::OnLanguageChanged() { // If they aren't in the user dictionary path, check the application directory if (!agi::fs::FileExists(idxpath) || !agi::fs::FileExists(datpath)) { - path = StandardPaths::DecodePath("?data/dictionaries/"); + path = config::path->Decode("?data/dictionaries/"); idxpath = path/str(boost::format("th_%s.idx") % language); datpath = path/str(boost::format("th_%s.dat") % language); diff --git a/aegisub/src/video_provider_avs.cpp b/aegisub/src/video_provider_avs.cpp index c551c20ac..1d0c5448e 100644 --- a/aegisub/src/video_provider_avs.cpp +++ b/aegisub/src/video_provider_avs.cpp @@ -35,16 +35,15 @@ #include "config.h" #ifdef WITH_AVISYNTH - #include "video_provider_avs.h" #include "options.h" -#include "standard_paths.h" #include #include #include #include +#include #include #include @@ -240,7 +239,7 @@ AVSValue AvisynthVideoProvider::Open(agi::fs::path const& filename) { // Try loading DirectShowSource2 if (!env->FunctionExists("dss2")) { - auto dss2path(StandardPaths::DecodePath("?data/avss.dll")); + auto dss2path(config::path->Decode("?data/avss.dll")); if (agi::fs::FileExists(dss2path)) env->Invoke("LoadPlugin", env->SaveString(agi::fs::ShortName(dss2path).c_str())); } @@ -254,7 +253,7 @@ AVSValue AvisynthVideoProvider::Open(agi::fs::path const& filename) { // Try DirectShowSource // Load DirectShowSource.dll from app dir if it exists - auto dsspath(StandardPaths::DecodePath("?data/DirectShowSource.dll")); + auto dsspath(config::path->Decode("?data/DirectShowSource.dll")); if (agi::fs::FileExists(dsspath)) env->Invoke("LoadPlugin", env->SaveString(agi::fs::ShortName(dsspath).c_str()));