diff --git a/SpineViewer/Dialogs/ExportPreviewDialog.cs b/SpineViewer/Dialogs/ExportPreviewDialog.cs index b69143b..3519e53 100644 --- a/SpineViewer/Dialogs/ExportPreviewDialog.cs +++ b/SpineViewer/Dialogs/ExportPreviewDialog.cs @@ -37,7 +37,7 @@ namespace SpineViewer.Dialogs var outputDir = textBox_OutputDir.Text; if (string.IsNullOrEmpty(outputDir)) { - Result.OutputDir = null; + outputDir = null; } else { @@ -63,9 +63,16 @@ namespace SpineViewer.Dialogs 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; } @@ -87,7 +94,7 @@ namespace SpineViewer.Dialogs /// 预览图格式 /// [TypeConverter(typeof(ImageFormatConverter))] - [Category("导出参数"), DisplayName("预览图格式")] + [Category("图像"), DisplayName("预览图格式")] public ImageFormat ImageFormat { get => imageFormat; @@ -103,7 +110,7 @@ namespace SpineViewer.Dialogs /// 预览图分辨率 /// [TypeConverter(typeof(SizeConverter))] - [Category("导出参数"), DisplayName("分辨率")] + [Category("图像"), DisplayName("分辨率")] public Size Resolution { get => resolution; @@ -120,7 +127,7 @@ namespace SpineViewer.Dialogs /// 四周填充像素值 /// [TypeConverter(typeof(PaddingConverter))] - [Category("导出参数"), DisplayName("四周填充像素值")] + [Category("图像"), DisplayName("四周填充像素值")] public Padding Padding { get => padding; @@ -139,7 +146,7 @@ namespace SpineViewer.Dialogs /// DPI /// [TypeConverter(typeof(SizeFConverter))] - [Category("导出参数"), DisplayName("DPI")] + [Category("图像"), DisplayName("DPI")] public SizeF DPI { get => dpi; @@ -151,6 +158,12 @@ namespace SpineViewer.Dialogs } } private SizeF dpi = new(144, 144); + + /// + /// 名称后缀 + /// + [Category("其他"), DisplayName("名称后缀")] + public string NameSuffix { get; set; } = "(preview)"; } } diff --git a/SpineViewer/MainForm.cs b/SpineViewer/MainForm.cs index fe2e2e7..e1c5095 100644 --- a/SpineViewer/MainForm.cs +++ b/SpineViewer/MainForm.cs @@ -301,6 +301,7 @@ namespace SpineViewer var resolution = arguments.Resolution; var padding = arguments.Padding; var dpi = arguments.DPI; + var nameSuffix = arguments.NameSuffix; var renderSelectedOnly = spinePreviewer.RenderSelectedOnly; var tex = new SFML.Graphics.RenderTexture((uint)resolution.Width, (uint)resolution.Height); @@ -325,7 +326,7 @@ namespace SpineViewer if (renderSelectedOnly && !spine.IsSelected) 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 tmp = spine.CurrentAnimation;