diff --git a/YTSubConverter.Shared/Enumerations.cs b/YTSubConverter.Shared/Enumerations.cs index a80647c..b7edfa3 100644 --- a/YTSubConverter.Shared/Enumerations.cs +++ b/YTSubConverter.Shared/Enumerations.cs @@ -1,5 +1,11 @@ namespace YTSubConverter.Shared { + public enum LineMergeType + { + MoveNew, + MoveExisting + } + public enum AnchorPoint { TopLeft, diff --git a/YTSubConverter.Shared/Formats/Ass/AssDocument.cs b/YTSubConverter.Shared/Formats/Ass/AssDocument.cs index 76a3346..1a83d6b 100644 --- a/YTSubConverter.Shared/Formats/Ass/AssDocument.cs +++ b/YTSubConverter.Shared/Formats/Ass/AssDocument.cs @@ -67,6 +67,7 @@ private void Load(TextReader reader, List styleOptions) AssDocumentSection infoSection = fileSections["Script Info"]; VideoDimensions = new Size(infoSection.GetItemInt("PlayResX", 384), infoSection.GetItemInt("PlayResY", 288)); + LineMergeType = infoSection.GetItemString("Collisions") == "Reverse" ? LineMergeType.MoveExisting : LineMergeType.MoveNew; _styles = fileSections["V4+ Styles"].MapItems("Style", i => new AssStyle(i)) .ToDictionaryOverwrite(s => s.Name); diff --git a/YTSubConverter.Shared/Formats/SubtitleDocument.cs b/YTSubConverter.Shared/Formats/SubtitleDocument.cs index 8bd2065..51e6ff5 100644 --- a/YTSubConverter.Shared/Formats/SubtitleDocument.cs +++ b/YTSubConverter.Shared/Formats/SubtitleDocument.cs @@ -18,11 +18,13 @@ public abstract class SubtitleDocument protected SubtitleDocument() { VideoDimensions = new Size(1280, 720); + LineMergeType = LineMergeType.MoveNew; } protected SubtitleDocument(SubtitleDocument doc) { VideoDimensions = doc.VideoDimensions; + LineMergeType = doc.LineMergeType; Lines.AddRange(doc.Lines.Where(l => l.Sections.Any(s => s.Text.Length > 0))); } @@ -32,6 +34,12 @@ public Size VideoDimensions protected set; } + public LineMergeType LineMergeType + { + get; + protected set; + } + public List Lines { get; } = new List(); public static bool IsExtensionSupported(string extension) @@ -143,7 +151,7 @@ public void MergeSimultaneousLines() if (firstLine.Start < secondLine.Start) InsertConcatenedLine(lines, i, firstLine.Start, secondLine.Start, false, firstLine); - if (AnchorPointUtil.IsBottomAligned(firstLine.AnchorPoint)) + if (AnchorPointUtil.IsBottomAligned(firstLine.AnchorPoint) ^ (LineMergeType == LineMergeType.MoveExisting)) InsertConcatenedLine(lines, i, secondLine.Start, TimeUtil.Min(firstLine.End, secondLine.End), false, secondLine, firstLine); else InsertConcatenedLine(lines, i, secondLine.Start, TimeUtil.Min(firstLine.End, secondLine.End), false, firstLine, secondLine); diff --git a/YTSubConverter.Tests/Ass/Files/SimultaneousReverse.ass b/YTSubConverter.Tests/Ass/Files/SimultaneousReverse.ass new file mode 100644 index 0000000..0b8d0a0 --- /dev/null +++ b/YTSubConverter.Tests/Ass/Files/SimultaneousReverse.ass @@ -0,0 +1,27 @@ +[Script Info] +; Script generated by Aegisub 3.3.0 +; http://www.aegisub.org/ +Title: Default Aegisub file +ScriptType: v4.00+ +WrapStyle: 0 +ScaledBorderAndShadow: yes +PlayResX: 384 +PlayResY: 288 +YCbCr Matrix: None +Collisions: Reverse + +[Aegisub Project Garbage] +Last Style Storage: Default +Video AR Value: 1.333333 +Video Position: 129 + +[V4+ Styles] +Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding +Style: Default,Roboto,15,&H00FFFFFF,&HFFFFFFFF,&H3C000000,&H00000000,0,0,0,0,100,100,0,0,3,2,0,2,10,10,10,1 +Style: Soft shadow box,Roboto,15,&H00FFFFFF,&HFF0000FF,&H3C000000,&H00828282,0,0,0,0,100,100,0,0,3,2,2,2,10,10,10,1 + +[Events] +Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text +Dialogue: 0,0:00:00.00,0:00:04.37,Default,,0,0,0,,Line 1 +Dialogue: 0,0:00:00.60,0:00:03.70,Default,,0,0,0,,Line 2 +Dialogue: 0,0:00:01.40,0:00:02.37,Default,,0,0,0,,Line 3 diff --git a/YTSubConverter.Tests/Ass/Files/SimultaneousReverse.ytt b/YTSubConverter.Tests/Ass/Files/SimultaneousReverse.ytt new file mode 100644 index 0000000..c7f4c49 --- /dev/null +++ b/YTSubConverter.Tests/Ass/Files/SimultaneousReverse.ytt @@ -0,0 +1,5 @@ +

​ ​Line 1​ ​

​ ​Line 1​ ​​ +​​ ​Line 2​ ​

​ ​Line 1​ ​​ +​​ ​Line 2​ ​​ +​​ ​Line 3​ ​

​ ​Line 1​ ​​ +​​ ​Line 2​ ​

​ ​Line 1​ ​

\ No newline at end of file