Pass style catalog names instead of file names to AssFile::LoadDefault

This commit is contained in:
Niels Martin Hansen 2014-05-04 13:04:48 +02:00
parent 79b6ce2583
commit 82d7979f04
6 changed files with 9 additions and 8 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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);
}

View file

@ -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 <http://devel.aegisub.org/wiki/SubtitleFormats/SRT>

View file

@ -64,7 +64,7 @@ std::vector<std::string> 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;

View file

@ -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();