From a3ef701f17d9f02b74988b59dbb97ab8bd488c02 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 16 Feb 2012 21:21:55 +0000 Subject: [PATCH] Add a [Script Info] section in SetScriptInfo if none exists Originally committed to SVN as r6480. --- aegisub/src/ass_file.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index 4437ab9c3..a78e5d8d3 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -562,6 +562,16 @@ void AssFile::SetScriptInfo(wxString const& key, wxString const& value) { return; } } + + // Found a script info section, but not this key or anything after it, + // so add it at the end of the file + if (found_script_info) + Line.push_back(new AssEntry(key + ": " + value, "[Script Info]")); + // Script info section not found, so add it at the beginning of the file + else { + Line.push_front(new AssEntry(key + ": " + value, "[Script Info]")); + Line.push_front(new AssEntry("[Script Info]", "[Script Info]")); + } } void AssFile::GetResolution(int &sw,int &sh) {