diff --git a/src/ass_file.cpp b/src/ass_file.cpp index c0e0ceb65..e7598054c 100644 --- a/src/ass_file.cpp +++ b/src/ass_file.cpp @@ -39,7 +39,7 @@ AssFile::~AssFile() { Events.clear_and_dispose([](AssDialogue *e) { delete e; }); } -void AssFile::LoadDefault(bool include_dialogue_line, agi::fs::path const& style_catalog_file) { +void AssFile::LoadDefault(bool include_dialogue_line, std::string const& style_catalog) { Info.emplace_back("Title", "Default Aegisub file"); Info.emplace_back("ScriptType", "v4.00+"); Info.emplace_back("WrapStyle", "0"); @@ -54,9 +54,9 @@ void AssFile::LoadDefault(bool include_dialogue_line, agi::fs::path const& style Styles.push_back(*new AssStyle); // Add/replace any catalog styles requested - if (!style_catalog_file.empty() && agi::fs::FileExists(style_catalog_file)) { + if (AssStyleStorage::CatalogExists(style_catalog)) { AssStyleStorage catalog; - catalog.Load(style_catalog_file); + catalog.LoadCatalog(style_catalog); catalog.ReplaceIntoFile(*this); } diff --git a/src/ass_file.h b/src/ass_file.h index 3ae05a42d..6e864c0cd 100644 --- a/src/ass_file.h +++ b/src/ass_file.h @@ -81,7 +81,8 @@ public: /// @brief Load default file /// @param defline Add a blank line to the file - void LoadDefault(bool defline = true, agi::fs::path const& style_catalog_file = agi::fs::path()); + /// @param style_catalog Style catalog name to fill styles from, blank to use default style + void LoadDefault(bool defline = true, std::string const& style_catalog = std::string()); /// Attach a file to the ass file void InsertAttachment(agi::fs::path const& filename); /// Get the names of all of the styles available diff --git a/src/subs_controller.cpp b/src/subs_controller.cpp index 28b6fdc80..a1fdeaf8d 100644 --- a/src/subs_controller.cpp +++ b/src/subs_controller.cpp @@ -291,7 +291,7 @@ void SubsController::Close() { filename.clear(); AssFile blank; blank.swap(*context->ass); - context->ass->LoadDefault(true, config::path->Decode("?user/catalog/" + OPT_GET("Subtitle Format/ASS/Default Style Catalog")->GetString() + ".sty")); + context->ass->LoadDefault(true, OPT_GET("Subtitle Format/ASS/Default Style Catalog")->GetString()); context->ass->Commit("", AssFile::COMMIT_NEW); FileOpen(filename); } diff --git a/src/subtitle_format_srt.cpp b/src/subtitle_format_srt.cpp index 5934f8aed..dad986d08 100644 --- a/src/subtitle_format_srt.cpp +++ b/src/subtitle_format_srt.cpp @@ -355,7 +355,7 @@ void SRTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, using namespace std; TextFileReader file(filename, encoding); - target->LoadDefault(false, config::path->Decode("?user/catalog/" + OPT_GET("Subtitle Format/SRT/Default Style Catalog")->GetString() + ".sty")); + target->LoadDefault(false, OPT_GET("Subtitle Format/SRT/Default Style Catalog")->GetString()); // See parsing algorithm at diff --git a/src/subtitle_format_ttxt.cpp b/src/subtitle_format_ttxt.cpp index f3a22c212..7bd5f3c35 100644 --- a/src/subtitle_format_ttxt.cpp +++ b/src/subtitle_format_ttxt.cpp @@ -64,7 +64,7 @@ std::vector TTXTSubtitleFormat::GetWriteWildcards() const { } void TTXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { - target->LoadDefault(false, config::path->Decode("?user/catalog/" + OPT_GET("Subtitle Format/TTXT/Default Style Catalog")->GetString() + ".sty")); + target->LoadDefault(false, OPT_GET("Subtitle Format/TTXT/Default Style Catalog")->GetString()); // Load XML document wxXmlDocument doc; diff --git a/src/subtitle_format_txt.cpp b/src/subtitle_format_txt.cpp index a11fddaa6..3a89b81dd 100644 --- a/src/subtitle_format_txt.cpp +++ b/src/subtitle_format_txt.cpp @@ -74,7 +74,7 @@ void TXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, TextFileReader file(filename, encoding, false); - target->LoadDefault(false, config::path->Decode("?user/catalog/" + OPT_GET("Subtitle Format/TXT/Default Style Catalog")->GetString() + ".sty")); + target->LoadDefault(false, OPT_GET("Subtitle Format/TXT/Default Style Catalog")->GetString()); std::string actor; std::string separator = OPT_GET("Tool/Import/Text/Actor Separator")->GetString();