From 1dc0706b8660fdf37fbc401d0c749259c01a781b Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Fri, 15 Mar 2024 13:51:41 +0100 Subject: [PATCH] Work on ttml imsc 1.1 properties --- src/libse/Common/Settings.cs | 16 ++++++++++++++++ src/libse/SubtitleFormats/TimedTextImsc11.cs | 3 ++- .../Forms/TimedTextPropertiesIms11.Designer.cs | 2 +- src/ui/Forms/TimedTextPropertiesIms11.cs | 10 ++++++---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/libse/Common/Settings.cs b/src/libse/Common/Settings.cs index a8f118b96..6a85915c6 100644 --- a/src/libse/Common/Settings.cs +++ b/src/libse/Common/Settings.cs @@ -833,6 +833,7 @@ namespace Nikse.SubtitleEdit.Core.Common public string TimedTextItunesTimeCodeFormat { get; set; } public string TimedTextItunesStyleAttribute { get; set; } public string TimedTextImsc11TimeCodeFormat { get; set; } + public string TimedTextImsc11FileExtension { get; set; } public int FcpFontSize { get; set; } @@ -921,6 +922,7 @@ $HorzAlign = Center TimedTextItunesTimeCodeFormat = "Frames"; TimedTextItunesStyleAttribute = "tts:fontStyle"; TimedTextImsc11TimeCodeFormat = "hh:mm:ss.ms"; + TimedTextImsc11FileExtension = ".xml"; FcpFontSize = 18; FcpFontName = "Lucida Grande"; @@ -7523,6 +7525,18 @@ $HorzAlign = Center settings.SubtitleSettings.TimedTextItunesStyleAttribute = subNode.InnerText; } + subNode = node.SelectSingleNode("TimedTextImsc11TimeCodeFormat"); + if (subNode != null) + { + settings.SubtitleSettings.TimedTextImsc11TimeCodeFormat = subNode.InnerText; + } + + subNode = node.SelectSingleNode("TimedTextImsc11FileExtension"); + if (subNode != null) + { + settings.SubtitleSettings.TimedTextImsc11FileExtension = subNode.InnerText; + } + subNode = node.SelectSingleNode("FcpFontSize"); if (subNode != null) { @@ -12219,6 +12233,8 @@ $HorzAlign = Center textWriter.WriteElementString("TimedTextItunesBottomExtent", settings.SubtitleSettings.TimedTextItunesBottomExtent); textWriter.WriteElementString("TimedTextItunesTimeCodeFormat", settings.SubtitleSettings.TimedTextItunesTimeCodeFormat); textWriter.WriteElementString("TimedTextItunesStyleAttribute", settings.SubtitleSettings.TimedTextItunesStyleAttribute); + textWriter.WriteElementString("TimedTextImsc11TimeCodeFormat", settings.SubtitleSettings.TimedTextImsc11TimeCodeFormat); + textWriter.WriteElementString("TimedTextImsc11FileExtension", settings.SubtitleSettings.TimedTextImsc11FileExtension); textWriter.WriteElementString("FcpFontSize", settings.SubtitleSettings.FcpFontSize.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("FcpFontName", settings.SubtitleSettings.FcpFontName); textWriter.WriteElementString("Cavena890StartOfMessage", settings.SubtitleSettings.Cavena890StartOfMessage); diff --git a/src/libse/SubtitleFormats/TimedTextImsc11.cs b/src/libse/SubtitleFormats/TimedTextImsc11.cs index c2980f0cf..4b7d65253 100644 --- a/src/libse/SubtitleFormats/TimedTextImsc11.cs +++ b/src/libse/SubtitleFormats/TimedTextImsc11.cs @@ -12,7 +12,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats /// public class TimedTextImsc11 : SubtitleFormat { - public override string Extension => ".xml"; public override string Name => "Timed Text IMSC 1.1"; private static string GetXmlStructure() @@ -46,6 +45,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats ".Replace('\'', '"'); } + public override string Extension => Configuration.Settings.SubtitleSettings.TimedTextImsc11FileExtension; + public override bool IsMine(List lines, string fileName) { if (fileName != null && !(fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))) diff --git a/src/ui/Forms/TimedTextPropertiesIms11.Designer.cs b/src/ui/Forms/TimedTextPropertiesIms11.Designer.cs index b08d2e0c1..90dd51ce0 100644 --- a/src/ui/Forms/TimedTextPropertiesIms11.Designer.cs +++ b/src/ui/Forms/TimedTextPropertiesIms11.Designer.cs @@ -1,6 +1,6 @@ namespace Nikse.SubtitleEdit.Forms { - partial class TimedTextPropertiesIms11 + sealed partial class TimedTextPropertiesIms11 { /// /// Required designer variable. diff --git a/src/ui/Forms/TimedTextPropertiesIms11.cs b/src/ui/Forms/TimedTextPropertiesIms11.cs index b7fd66b23..ffc05dba4 100644 --- a/src/ui/Forms/TimedTextPropertiesIms11.cs +++ b/src/ui/Forms/TimedTextPropertiesIms11.cs @@ -8,7 +8,7 @@ using System.Xml; namespace Nikse.SubtitleEdit.Forms { - public partial class TimedTextPropertiesIms11 : PositionAndSizeForm + public sealed partial class TimedTextPropertiesIms11 : PositionAndSizeForm { private readonly Subtitle _subtitle; private readonly XmlDocument _xml; @@ -21,6 +21,8 @@ namespace Nikse.SubtitleEdit.Forms UiUtil.FixFonts(this); Application.DoEvents(); + Text = string.Format(LanguageSettings.Current.Main.Menu.File.FormatXProperties, new TimedTextImsc11().Name); + _subtitle = subtitle; var notAvailable = "[" + LanguageSettings.Current.General.NotAvailable + "]"; comboBoxDropMode.Items[0] = notAvailable; @@ -126,7 +128,7 @@ namespace Nikse.SubtitleEdit.Forms } } - var ext = Configuration.Settings.SubtitleSettings.TimedText10FileExtension; + var ext = Configuration.Settings.SubtitleSettings.TimedTextImsc11FileExtension; comboBoxFileExtensions.SelectedIndex = 0; for (var index = 0; index < comboBoxFileExtensions.Items.Count; index++) { @@ -313,7 +315,7 @@ namespace Nikse.SubtitleEdit.Forms Configuration.Settings.SubtitleSettings.TimedTextImsc11TimeCodeFormat = comboBoxTimeCodeFormat.SelectedItem.ToString(); - var currentTimedTextExt = Configuration.Settings.SubtitleSettings.TimedText10FileExtension; + var currentTimedTextExt = Configuration.Settings.SubtitleSettings.TimedTextImsc11FileExtension; var newTimedTextExt = comboBoxFileExtensions.SelectedItem.ToString(); if (currentTimedTextExt != newTimedTextExt) { @@ -325,7 +327,7 @@ namespace Nikse.SubtitleEdit.Forms Configuration.Settings.General.FavoriteSubtitleFormats = favoriteFormats.Replace(currentTimedTextWithExt, newTimedTextWithExt); } - Configuration.Settings.SubtitleSettings.TimedText10FileExtension = newTimedTextExt; + Configuration.Settings.SubtitleSettings.TimedTextImsc11FileExtension = newTimedTextExt; } DialogResult = DialogResult.OK;