From 10f0f5fc7be6da83c059ab6564f7f56cd62dd814 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 11 Oct 2012 20:03:00 -0700 Subject: [PATCH] Kill AssFile::AddComment and just add it when writing the file --- aegisub/src/ass_file.cpp | 22 +--------------------- aegisub/src/ass_file.h | 2 -- aegisub/src/subtitle_format_ass.cpp | 5 +++++ 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index 90967bb25..005915d76 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -56,7 +56,6 @@ #include "text_file_reader.h" #include "text_file_writer.h" #include "utils.h" -#include "version.h" namespace std { template<> @@ -111,9 +110,7 @@ void AssFile::Load(const wxString &_filename, wxString const& charset) { filename = _filename; // Add comments and set vars - AddComment(wxString("Script generated by Aegisub ") + GetAegisubLongVersionString()); - AddComment("http://www.aegisub.org/"); - SetScriptInfo("ScriptType","v4.00+"); + SetScriptInfo("ScriptType", "v4.00+"); // Push the initial state of the file onto the undo stack UndoStack.clear(); @@ -401,23 +398,6 @@ void AssFile::GetResolution(int &sw,int &sh) const { } } -void AssFile::AddComment(wxString comment) { - comment.Prepend("; "); - int step = 0; - - for (std::list::iterator cur = Line.begin(); cur != Line.end(); ++cur) { - // Start of group - if (step == 0 && (*cur)->group == "[Script Info]") - step = 1; - - // First line after a ; - else if (step == 1 && !(*cur)->GetEntryData().StartsWith(";")) { - Line.insert(cur, new AssEntry(comment, "[Script Info]")); - break; - } - } -} - wxArrayString AssFile::GetStyles() const { wxArrayString styles; for (std::list::const_iterator cur = Line.begin(); cur != Line.end(); ++cur) { diff --git a/aegisub/src/ass_file.h b/aegisub/src/ass_file.h index 736883730..2ff292075 100644 --- a/aegisub/src/ass_file.h +++ b/aegisub/src/ass_file.h @@ -147,8 +147,6 @@ public: wxString GetScriptInfo(wxString key) const; /// Set the value of a [Script Info] key. Adds it if it doesn't exist. void SetScriptInfo(wxString const& key, wxString const& value); - // Add a ";" comment in the [Script Info] section - void AddComment(wxString comment); /// Type of changes made in a commit enum CommitType { diff --git a/aegisub/src/subtitle_format_ass.cpp b/aegisub/src/subtitle_format_ass.cpp index ce0498f39..431246301 100644 --- a/aegisub/src/subtitle_format_ass.cpp +++ b/aegisub/src/subtitle_format_ass.cpp @@ -42,6 +42,7 @@ #include "compat.h" #include "text_file_reader.h" #include "text_file_writer.h" +#include "version.h" DEFINE_SIMPLE_EXCEPTION(AssParseError, SubtitleFormatParseError, "subtitle_io/parse/ass") @@ -85,6 +86,10 @@ void AssSubtitleFormat::ReadFile(AssFile *target, wxString const& filename, wxSt void AssSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename, wxString const& encoding) const { TextFileWriter file(filename, encoding); + + file.WriteLineToFile(wxString("Script generated by Aegisub ") + GetAegisubLongVersionString()); + file.WriteLineToFile("http://www.aegisub.org/"); + bool ssa = filename.Right(4).Lower() == ".ssa"; wxString group = src->Line.front()->group;