subtitles: proper internal sorting
This commit is contained in:
parent
df45b49f91
commit
fbbc97731e
|
@ -24,6 +24,7 @@ namespace BizHawk.Client.Common
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
this.Sort();
|
||||||
ForEach(subtitle => sb.AppendLine(subtitle.ToString()));
|
ForEach(subtitle => sb.AppendLine(subtitle.ToString()));
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
@ -64,13 +65,13 @@ namespace BizHawk.Client.Common
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public new SubtitleList Sort()
|
public new void Sort()
|
||||||
{
|
{
|
||||||
List<Subtitle> subs = this.OrderBy(s => s.Frame).ThenBy(s => s.Y).ToList();
|
this.Sort((x, y) =>
|
||||||
SubtitleList ret = new SubtitleList();
|
{
|
||||||
foreach (var subtitle in subs)
|
int result = x.Frame.CompareTo(y.Frame);
|
||||||
ret.Add(subtitle);
|
return result != 0 ? result : x.Y.CompareTo(y.Y);
|
||||||
return ret;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToSubRip(double fps)
|
public string ToSubRip(double fps)
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace BizHawk.Client.Common
|
||||||
Subtitles.AddFromString(line);
|
Subtitles.AddFromString(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Subtitles = Subtitles.Sort();
|
Subtitles.Sort();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue