Trying to improve ssa/ass support + updated change log

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1655 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-02-21 08:31:17 +00:00
parent 47b0afb11b
commit bf77ff86f4
4 changed files with 76 additions and 10 deletions

View File

@ -15,7 +15,7 @@
* Updated German language file - thx Christoph Kitsche
* Remembers size of controls in main window better - thx George/Leszek
* Format Sami: html-decodes text + reads class attributes better
* Batch convert can now also do "Fix common errors" - thx Adem
* Batch convert can now also "Fix common errors" and more - thx Adem
* FIXED:
* VobSub files created by SE now have better compatibility - thx George
* Possible crash+bug in 'Fix common errors' on selected lines - thx Dan
@ -23,6 +23,7 @@
* Minor fix in 'Fix common errors -> Fix invalid italic tags' - thx azu
* List view height in "Set sync point" with large font - thx fox
* Can now load ass files with "[V4 Styles]" in header - thx Derek
* "Frame mode" no longer auto-changes duration/end-time - thx Gerard
3.3.1 (3rd February 2013)

View File

@ -34,6 +34,10 @@ namespace Nikse.SubtitleEdit.Logic
public string Actor { get; set; }
public string Effect { get; set; }
public string Layer { get; set; }
public string ID { get; set; }
public Paragraph()
@ -64,6 +68,8 @@ namespace Nikse.SubtitleEdit.Logic
Extra = paragraph.Extra;
IsComment = paragraph.IsComment;
Actor = paragraph.Actor;
Effect = paragraph.Effect;
Layer = paragraph.Layer;
ID = paragraph.ID;
}

View File

@ -97,8 +97,8 @@ Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour,
Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text";
const string timeCodeFormat = "{0}:{1:00}:{2:00}.{3:00}"; // h:mm:ss.cc
const string paragraphWriteFormat = "Dialogue: 0,{0},{1},{3},{4},0,0,0,,{2}";
const string commentWriteFormat = "Comment: 0,{0},{1},{3},{4},0,0,0,,{2}";
const string paragraphWriteFormat = "Dialogue: {6},{0},{1},{3},{4},0,0,0,{5},{2}";
const string commentWriteFormat = "Comment: {6},{0},{1},{3},{4},0,0,0,{5},{2}";
var sb = new StringBuilder();
System.Drawing.Color fontColor = System.Drawing.Color.FromArgb(Configuration.Settings.SubtitleSettings.SsaFontColorArgb);
@ -132,11 +132,20 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
string actor = "";
if (!string.IsNullOrEmpty(p.Actor))
actor = p.Actor;
string effect = "";
if (!string.IsNullOrEmpty(p.Effect))
effect = p.Effect;
string layer = "0";
if (!string.IsNullOrEmpty(p.Layer))
{
if (Utilities.IsInteger(p.Layer))
layer = p.Layer;
}
if (p.IsComment)
sb.AppendLine(string.Format(commentWriteFormat, start, end, FormatText(p), style, actor));
sb.AppendLine(string.Format(commentWriteFormat, start, end, FormatText(p), style, actor, effect, layer));
else
sb.AppendLine(string.Format(paragraphWriteFormat, start, end, FormatText(p), style, actor));
sb.AppendLine(string.Format(paragraphWriteFormat, start, end, FormatText(p), style, actor, effect, layer));
}
if (!string.IsNullOrEmpty(subtitle.Footer) && (subtitle.Footer.Contains("[Fonts]" + Environment.NewLine) || subtitle.Footer.Contains("[Graphics]" + Environment.NewLine)))
@ -608,10 +617,12 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
bool graphicsStarted = false;
subtitle.Paragraphs.Clear();
string[] format = "Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text".Split(',');
int indexLayer = 0;
int indexStart = 1;
int indexEnd = 2;
int indexStyle = 3;
int indexActor = 4;
int indexEffect = 8;
int indexText = 9;
var errors = new StringBuilder();
int lineNumber = 0;
@ -689,6 +700,10 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
indexStyle = i;
else if (format[i].Trim().ToLower() == "actor")
indexActor = i;
else if (format[i].Trim().ToLower() == "effect")
indexEffect = i;
else if (format[i].Trim().ToLower() == "layer")
indexLayer = i;
}
}
}
@ -699,6 +714,8 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
string end = string.Empty;
string style = string.Empty;
string actor = string.Empty;
string effect = string.Empty;
string layer = string.Empty;
string[] splittedLine;
@ -717,6 +734,10 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
style = splittedLine[i].Trim();
else if (i == indexActor)
actor = splittedLine[i].Trim();
else if (i == indexEffect)
effect = splittedLine[i].Trim();
else if (i == indexLayer)
layer = splittedLine[i].Trim();
else if (i == indexText)
text = splittedLine[i];
else if (i > indexText)
@ -734,6 +755,10 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
p.Extra = style;
if (!string.IsNullOrEmpty(actor))
p.Actor = actor;
if (!string.IsNullOrEmpty(effect))
p.Effect = effect;
if (!string.IsNullOrEmpty(layer))
p.Layer = layer;
p.IsComment = s.StartsWith("comment:");
subtitle.Paragraphs.Add(p);
}

View File

@ -66,8 +66,8 @@ Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text";
const string timeCodeFormat = "{0}:{1:00}:{2:00}.{3:00}"; // h:mm:ss.cc
const string paragraphWriteFormat = "Dialogue: Marked=0,{0},{1},{3},NTP,0000,0000,0000,!Effect,{2}";
const string commentWriteFormat = "Comment: Marked=0,{0},{1},{3},NTP,0000,0000,0000,!Effect,{2}";
const string paragraphWriteFormat = "Dialogue: Marked={4},{0},{1},{3},{5},0000,0000,0000,{6},{2}";
const string commentWriteFormat = "Comment: Marked={4},{0},{1},{3},{5},0000,0000,0000,{6},{2}";
var sb = new StringBuilder();
System.Drawing.Color fontColor = System.Drawing.Color.FromArgb(Configuration.Settings.SubtitleSettings.SsaFontColorArgb);
@ -100,12 +100,24 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
string start = string.Format(timeCodeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10);
string end = string.Format(timeCodeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10);
string style = "Default";
string actor = "NTP";
if (!string.IsNullOrEmpty(p.Actor))
actor = p.Actor;
string effect = "!Effect";
if (!string.IsNullOrEmpty(p.Effect))
effect = p.Effect;
string layer = "0";
if (!string.IsNullOrEmpty(p.Layer))
{
if (Utilities.IsInteger(p.Layer))
layer = p.Layer;
}
if (!string.IsNullOrEmpty(p.Extra) && isValidAssHeader && styles.Contains(p.Extra))
style = p.Extra;
if (p.IsComment)
sb.AppendLine(string.Format(commentWriteFormat, start, end, FormatText(p), style));
sb.AppendLine(string.Format(commentWriteFormat, start, end, FormatText(p), style, layer, actor, effect));
else
sb.AppendLine(string.Format(paragraphWriteFormat, start, end, FormatText(p), style));
sb.AppendLine(string.Format(paragraphWriteFormat, start, end, FormatText(p), style, layer, actor, effect));
}
return sb.ToString().Trim();
}
@ -345,9 +357,12 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
bool eventsStarted = false;
subtitle.Paragraphs.Clear();
string[] format = "Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text".Split(',');
int indexLayer = 0;
int indexStart = 1;
int indexEnd = 2;
int indexStyle = 3;
int indexName = 4;
int indexEffect = 8;
int indexText = 9;
var errors = new StringBuilder();
int lineNumber = 0;
@ -377,12 +392,16 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
format = line.ToLower().Substring(8).Split(',');
for (int i = 0; i < format.Length; i++)
{
if (format[i].Trim().ToLower() == "start")
if (format[i].Trim().ToLower() == "layer")
indexLayer = i;
else if (format[i].Trim().ToLower() == "start")
indexStart = i;
else if (format[i].Trim().ToLower() == "end")
indexEnd = i;
else if (format[i].Trim().ToLower() == "text")
indexText = i;
else if (format[i].Trim().ToLower() == "effect")
indexEffect = i;
else if (format[i].Trim().ToLower() == "style")
indexStyle = i;
}
@ -394,6 +413,9 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
string start = string.Empty;
string end = string.Empty;
string style = string.Empty;
string layer = string.Empty;
string effect = string.Empty;
string name = string.Empty;
string[] splittedLine;
@ -408,10 +430,16 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
start = splittedLine[i].Trim();
else if (i == indexEnd)
end = splittedLine[i].Trim();
else if (i == indexLayer)
layer = splittedLine[i];
else if (i == indexEffect)
effect = splittedLine[i];
else if (i == indexText)
text = splittedLine[i];
else if (i == indexStyle)
style = splittedLine[i];
else if (i == indexName)
name = splittedLine[i];
else if (i > indexText)
text += "," + splittedLine[i];
}
@ -425,6 +453,12 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
p.Text = AdvancedSubStationAlpha.GetFormattedText(text);
if (!string.IsNullOrEmpty(style))
p.Extra = style;
if (!string.IsNullOrEmpty(effect))
p.Extra = effect;
if (!string.IsNullOrEmpty(layer))
p.Extra = layer;
if (!string.IsNullOrEmpty(name))
p.Actor = name;
p.IsComment = s.StartsWith("comment:");
subtitle.Paragraphs.Add(p);
}