完善预览图导出参数
This commit is contained in:
@@ -37,7 +37,7 @@ namespace SpineViewer.Dialogs
|
|||||||
var outputDir = textBox_OutputDir.Text;
|
var outputDir = textBox_OutputDir.Text;
|
||||||
if (string.IsNullOrEmpty(outputDir))
|
if (string.IsNullOrEmpty(outputDir))
|
||||||
{
|
{
|
||||||
Result.OutputDir = null;
|
outputDir = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -63,9 +63,16 @@ namespace SpineViewer.Dialogs
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Result.OutputDir = Path.GetFullPath(outputDir);
|
outputDir = Path.GetFullPath(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outputDir is null && string.IsNullOrEmpty(Result.NameSuffix))
|
||||||
|
{
|
||||||
|
MessageBox.Info("输出文件夹和名称后缀不可同时为空,存在文件覆盖风险");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result.OutputDir = outputDir;
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +94,7 @@ namespace SpineViewer.Dialogs
|
|||||||
/// 预览图格式
|
/// 预览图格式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TypeConverter(typeof(ImageFormatConverter))]
|
[TypeConverter(typeof(ImageFormatConverter))]
|
||||||
[Category("导出参数"), DisplayName("预览图格式")]
|
[Category("图像"), DisplayName("预览图格式")]
|
||||||
public ImageFormat ImageFormat
|
public ImageFormat ImageFormat
|
||||||
{
|
{
|
||||||
get => imageFormat;
|
get => imageFormat;
|
||||||
@@ -103,7 +110,7 @@ namespace SpineViewer.Dialogs
|
|||||||
/// 预览图分辨率
|
/// 预览图分辨率
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TypeConverter(typeof(SizeConverter))]
|
[TypeConverter(typeof(SizeConverter))]
|
||||||
[Category("导出参数"), DisplayName("分辨率")]
|
[Category("图像"), DisplayName("分辨率")]
|
||||||
public Size Resolution
|
public Size Resolution
|
||||||
{
|
{
|
||||||
get => resolution;
|
get => resolution;
|
||||||
@@ -120,7 +127,7 @@ namespace SpineViewer.Dialogs
|
|||||||
/// 四周填充像素值
|
/// 四周填充像素值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TypeConverter(typeof(PaddingConverter))]
|
[TypeConverter(typeof(PaddingConverter))]
|
||||||
[Category("导出参数"), DisplayName("四周填充像素值")]
|
[Category("图像"), DisplayName("四周填充像素值")]
|
||||||
public Padding Padding
|
public Padding Padding
|
||||||
{
|
{
|
||||||
get => padding;
|
get => padding;
|
||||||
@@ -139,7 +146,7 @@ namespace SpineViewer.Dialogs
|
|||||||
/// DPI
|
/// DPI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TypeConverter(typeof(SizeFConverter))]
|
[TypeConverter(typeof(SizeFConverter))]
|
||||||
[Category("导出参数"), DisplayName("DPI")]
|
[Category("图像"), DisplayName("DPI")]
|
||||||
public SizeF DPI
|
public SizeF DPI
|
||||||
{
|
{
|
||||||
get => dpi;
|
get => dpi;
|
||||||
@@ -151,6 +158,12 @@ namespace SpineViewer.Dialogs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private SizeF dpi = new(144, 144);
|
private SizeF dpi = new(144, 144);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 名称后缀
|
||||||
|
/// </summary>
|
||||||
|
[Category("其他"), DisplayName("名称后缀")]
|
||||||
|
public string NameSuffix { get; set; } = "(preview)";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ namespace SpineViewer
|
|||||||
var resolution = arguments.Resolution;
|
var resolution = arguments.Resolution;
|
||||||
var padding = arguments.Padding;
|
var padding = arguments.Padding;
|
||||||
var dpi = arguments.DPI;
|
var dpi = arguments.DPI;
|
||||||
|
var nameSuffix = arguments.NameSuffix;
|
||||||
var renderSelectedOnly = spinePreviewer.RenderSelectedOnly;
|
var renderSelectedOnly = spinePreviewer.RenderSelectedOnly;
|
||||||
|
|
||||||
var tex = new SFML.Graphics.RenderTexture((uint)resolution.Width, (uint)resolution.Height);
|
var tex = new SFML.Graphics.RenderTexture((uint)resolution.Width, (uint)resolution.Height);
|
||||||
@@ -325,7 +326,7 @@ namespace SpineViewer
|
|||||||
if (renderSelectedOnly && !spine.IsSelected)
|
if (renderSelectedOnly && !spine.IsSelected)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var filename = $"(preview) {spine.Name}{imageFormat.GetSuffix()}"; // 加上 preview 是为了防止覆盖同名的 png 文件
|
var filename = $"{spine.Name}{nameSuffix}{imageFormat.GetSuffix()}";
|
||||||
var savePath = outputDir is null ? Path.Combine(spine.AssetsDir, filename) : Path.Combine(outputDir, filename);
|
var savePath = outputDir is null ? Path.Combine(spine.AssetsDir, filename) : Path.Combine(outputDir, filename);
|
||||||
|
|
||||||
var tmp = spine.CurrentAnimation;
|
var tmp = spine.CurrentAnimation;
|
||||||
|
|||||||
Reference in New Issue
Block a user