mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 15:02:35 +01:00
Allow attachments for SSA
This commit is contained in:
parent
082fc4cb8a
commit
c111e2a65b
@ -175,6 +175,14 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||
sb.AppendLine(string.Format(paragraphWriteFormat, start, end, AdvancedSubStationAlpha.FormatText(text), style, p.Layer, actor, marginL, marginR, marginV, effect));
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(subtitle.Footer) &&
|
||||
(subtitle.Footer.Contains("[Fonts]" + Environment.NewLine) || subtitle.Footer.Contains("[Graphics]" + Environment.NewLine) || subtitle.Footer.Contains("[Aegisub Extradata]" + Environment.NewLine)))
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(subtitle.Footer);
|
||||
}
|
||||
|
||||
return sb.ToString().Trim() + Environment.NewLine;
|
||||
}
|
||||
|
||||
@ -378,6 +386,8 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||
_errorCount = 0;
|
||||
Errors = null;
|
||||
bool eventsStarted = false;
|
||||
var fontsStarted = false;
|
||||
var graphicsStarted = false;
|
||||
subtitle.Paragraphs.Clear();
|
||||
// "Marked", " Start", " End", " Style", " Name", " MarginL", " MarginR", " MarginV", " Effect", " Text"
|
||||
int indexLayer = 0;
|
||||
@ -394,6 +404,7 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||
int lineNumber = 0;
|
||||
|
||||
var header = new StringBuilder();
|
||||
var footer = new StringBuilder();
|
||||
for (int i1 = 0; i1 < lines.Count; i1++)
|
||||
{
|
||||
string line = lines[i1];
|
||||
@ -410,6 +421,24 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||
else if (line.Trim().Equals("[events]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
eventsStarted = true;
|
||||
fontsStarted = false;
|
||||
graphicsStarted = false;
|
||||
}
|
||||
else if (line.Trim().Equals("[fonts]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
eventsStarted = false;
|
||||
fontsStarted = true;
|
||||
graphicsStarted = false;
|
||||
footer.AppendLine();
|
||||
footer.AppendLine("[Fonts]");
|
||||
}
|
||||
else if (line.Trim().Equals("[graphics]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
eventsStarted = false;
|
||||
fontsStarted = false;
|
||||
graphicsStarted = true;
|
||||
footer.AppendLine();
|
||||
footer.AppendLine("[Graphics]");
|
||||
}
|
||||
else if (eventsStarted && !string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
@ -458,6 +487,14 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fontsStarted)
|
||||
{
|
||||
footer.AppendLine(line);
|
||||
}
|
||||
else if (graphicsStarted)
|
||||
{
|
||||
footer.AppendLine(line);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(s))
|
||||
{
|
||||
var text = string.Empty;
|
||||
@ -601,11 +638,17 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (header.Length > 0)
|
||||
{
|
||||
subtitle.Header = header.ToString();
|
||||
}
|
||||
|
||||
if (footer.Length > 0)
|
||||
{
|
||||
subtitle.Footer = footer.ToString().Trim();
|
||||
}
|
||||
|
||||
subtitle.Renumber();
|
||||
Errors = errors.ToString();
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
||||
var s = line.Trim();
|
||||
if (attachmentOn)
|
||||
{
|
||||
if (s == "[V4+ Styles]" || s == "[Events]")
|
||||
if (s == "[V4+ Styles]" || s == "[V4 Styles]" || s == "[Events]")
|
||||
{
|
||||
AddToListIfNotEmpty(attachmentContent.ToString(), attachmentFileName, attachments, category);
|
||||
attachmentOn = false;
|
||||
@ -356,7 +356,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
||||
{
|
||||
openFileDialog1.Title = LanguageSettings.Current.Main.Menu.File.Open.RemoveChar('&');
|
||||
openFileDialog1.FileName = string.Empty;
|
||||
openFileDialog1.Filter = AdvancedSubStationAlpha.NameOfFormat + " |*.ass";
|
||||
openFileDialog1.Filter = AdvancedSubStationAlpha.NameOfFormat + "|*.ass;" + SubStationAlpha.NameOfFormat + "|*.ssa;";
|
||||
openFileDialog1.FilterIndex = 0;
|
||||
openFileDialog1.Multiselect = false;
|
||||
var result = openFileDialog1.ShowDialog(this);
|
||||
|
@ -5044,6 +5044,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var oldFormat = _currentSubtitleFormat;
|
||||
_currentSubtitleFormat = newFormat;
|
||||
MakeFormatChange(newFormat, oldFormat);
|
||||
_converted = _currentSubtitleFormat != null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30398,6 +30399,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
toolStripButtonAssStyleManager.Visible = true;
|
||||
toolStripButtonAssProperties.Visible = true;
|
||||
toolStripButtonAssAttachments.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user