mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Fix assa background box issue - thx Érico :)
Showing multiple different boxes at the same time should now work
This commit is contained in:
parent
6fe7502fe7
commit
efb5d225fc
@ -46,6 +46,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
private bool _loading = true;
|
private bool _loading = true;
|
||||||
private string _assaBox;
|
private string _assaBox;
|
||||||
private readonly Random _random = new Random();
|
private readonly Random _random = new Random();
|
||||||
|
private string _boxStyleName;
|
||||||
private int _top;
|
private int _top;
|
||||||
private int _bottom;
|
private int _bottom;
|
||||||
private int _left;
|
private int _left;
|
||||||
@ -55,6 +56,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
private Color _boxOutlineColor;
|
private Color _boxOutlineColor;
|
||||||
private long _totalFrames;
|
private long _totalFrames;
|
||||||
private FileSystemWatcher _drawingFileWatcher;
|
private FileSystemWatcher _drawingFileWatcher;
|
||||||
|
private readonly Subtitle _wholeSubtitle;
|
||||||
|
|
||||||
public AssSetBackground(Subtitle subtitle, int[] selectedIndices, string videoFileName, VideoInfo videoInfo, double videoPositionSeconds)
|
public AssSetBackground(Subtitle subtitle, int[] selectedIndices, string videoFileName, VideoInfo videoInfo, double videoPositionSeconds)
|
||||||
{
|
{
|
||||||
@ -65,6 +67,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
_videoFileName = videoFileName;
|
_videoFileName = videoFileName;
|
||||||
_videoInfo = videoInfo;
|
_videoInfo = videoInfo;
|
||||||
_videoPositionSeconds = videoPositionSeconds;
|
_videoPositionSeconds = videoPositionSeconds;
|
||||||
|
_wholeSubtitle = subtitle;
|
||||||
|
|
||||||
_subtitleWithNewHeader = new Subtitle(subtitle, false);
|
_subtitleWithNewHeader = new Subtitle(subtitle, false);
|
||||||
if (string.IsNullOrWhiteSpace(_subtitleWithNewHeader.Header))
|
if (string.IsNullOrWhiteSpace(_subtitleWithNewHeader.Header))
|
||||||
@ -213,6 +216,15 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
buttonAssaDraw.Visible = File.Exists(Path.Combine(Configuration.PluginsDirectory, "AssaDraw.dll"));
|
buttonAssaDraw.Visible = File.Exists(Path.Combine(Configuration.PluginsDirectory, "AssaDraw.dll"));
|
||||||
progressBar1.Visible = false;
|
progressBar1.Visible = false;
|
||||||
labelProgress.Text = string.Empty;
|
labelProgress.Text = string.Empty;
|
||||||
|
|
||||||
|
var tryCount = 0;
|
||||||
|
_boxStyleName = "SE-box-bg";
|
||||||
|
var styleNames = AdvancedSubStationAlpha.GetStylesFromHeader(subtitle.Header);
|
||||||
|
while (styleNames.Any(p => p == _boxStyleName) && tryCount < 100)
|
||||||
|
{
|
||||||
|
_boxStyleName = $"SE-box-bg{_random.Next(1234)}";
|
||||||
|
tryCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SafeNumericUpDownAssign(NumericUpDown numericUpDown, int value)
|
private static void SafeNumericUpDownAssign(NumericUpDown numericUpDown, int value)
|
||||||
@ -292,8 +304,8 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
|
|
||||||
var p2 = new Paragraph(_assaBox ?? string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)
|
var p2 = new Paragraph(_assaBox ?? string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)
|
||||||
{
|
{
|
||||||
Layer = Configuration.Settings.Tools.AssaBgBoxLayer,
|
Layer = GetLayer(),
|
||||||
Extra = "SE-box-bg"
|
Extra = _boxStyleName,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!checkBoxOnlyDrawing.Checked)
|
if (!checkBoxOnlyDrawing.Checked)
|
||||||
@ -308,6 +320,19 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int GetLayer()
|
||||||
|
{
|
||||||
|
var layer = Configuration.Settings.Tools.AssaBgBoxLayer;
|
||||||
|
var tryCount = 0;
|
||||||
|
while (_wholeSubtitle.Paragraphs.Any(p => p.Layer == layer) && tryCount < 100)
|
||||||
|
{
|
||||||
|
layer = Configuration.Settings.Tools.AssaBgBoxLayer - _random.Next(8421);
|
||||||
|
tryCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
private void AddBgBoxStyles(Subtitle subtitle)
|
private void AddBgBoxStyles(Subtitle subtitle)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(subtitle.Header))
|
if (string.IsNullOrWhiteSpace(subtitle.Header))
|
||||||
@ -338,7 +363,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
var styleBoxBg = new SsaStyle
|
var styleBoxBg = new SsaStyle
|
||||||
{
|
{
|
||||||
Alignment = "7",
|
Alignment = "7",
|
||||||
Name = "SE-box-bg",
|
Name = _boxStyleName,
|
||||||
MarginLeft = 0,
|
MarginLeft = 0,
|
||||||
MarginRight = 0,
|
MarginRight = 0,
|
||||||
MarginVertical = 0,
|
MarginVertical = 0,
|
||||||
@ -482,8 +507,8 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
{
|
{
|
||||||
StartTime = { TotalMilliseconds = p.StartTime.TotalMilliseconds },
|
StartTime = { TotalMilliseconds = p.StartTime.TotalMilliseconds },
|
||||||
EndTime = { TotalMilliseconds = p.EndTime.TotalMilliseconds },
|
EndTime = { TotalMilliseconds = p.EndTime.TotalMilliseconds },
|
||||||
Layer = Configuration.Settings.Tools.AssaBgBoxLayer,
|
Layer = GetLayer(),
|
||||||
Extra = "SE-box-bg"
|
Extra = _boxStyleName,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!checkBoxOnlyDrawing.Checked)
|
if (!checkBoxOnlyDrawing.Checked)
|
||||||
|
Loading…
Reference in New Issue
Block a user