Kill AssFile::AddComment and just add it when writing the file

This commit is contained in:
Thomas Goyne 2012-10-11 20:03:00 -07:00
parent a51b3d8d7f
commit 10f0f5fc7b
3 changed files with 6 additions and 23 deletions

View file

@ -56,7 +56,6 @@
#include "text_file_reader.h" #include "text_file_reader.h"
#include "text_file_writer.h" #include "text_file_writer.h"
#include "utils.h" #include "utils.h"
#include "version.h"
namespace std { namespace std {
template<> template<>
@ -111,8 +110,6 @@ void AssFile::Load(const wxString &_filename, wxString const& charset) {
filename = _filename; filename = _filename;
// Add comments and set vars // 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 // Push the initial state of the file onto the undo stack
@ -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<AssEntry*>::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 AssFile::GetStyles() const {
wxArrayString styles; wxArrayString styles;
for (std::list<AssEntry*>::const_iterator cur = Line.begin(); cur != Line.end(); ++cur) { for (std::list<AssEntry*>::const_iterator cur = Line.begin(); cur != Line.end(); ++cur) {

View file

@ -147,8 +147,6 @@ public:
wxString GetScriptInfo(wxString key) const; wxString GetScriptInfo(wxString key) const;
/// Set the value of a [Script Info] key. Adds it if it doesn't exist. /// Set the value of a [Script Info] key. Adds it if it doesn't exist.
void SetScriptInfo(wxString const& key, wxString const& value); 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 /// Type of changes made in a commit
enum CommitType { enum CommitType {

View file

@ -42,6 +42,7 @@
#include "compat.h" #include "compat.h"
#include "text_file_reader.h" #include "text_file_reader.h"
#include "text_file_writer.h" #include "text_file_writer.h"
#include "version.h"
DEFINE_SIMPLE_EXCEPTION(AssParseError, SubtitleFormatParseError, "subtitle_io/parse/ass") 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 { void AssSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename, wxString const& encoding) const {
TextFileWriter file(filename, encoding); 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"; bool ssa = filename.Right(4).Lower() == ".ssa";
wxString group = src->Line.front()->group; wxString group = src->Line.front()->group;