mirror of https://github.com/odrling/Aegisub
Kill AssFile::AddComment and just add it when writing the file
This commit is contained in:
parent
a51b3d8d7f
commit
10f0f5fc7b
|
@ -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<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 styles;
|
||||
for (std::list<AssEntry*>::const_iterator cur = Line.begin(); cur != Line.end(); ++cur) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue