From 45805b62721ce5b4ae975c1fd38395d22f42c236 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Wed, 22 Apr 2020 17:57:32 -0400 Subject: [PATCH] Improve batch exporting to catch files inside archives to skip errors. --- Toolbox/MainForm.cs | 77 +++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/Toolbox/MainForm.cs b/Toolbox/MainForm.cs index db3da7da..b905ab3d 100644 --- a/Toolbox/MainForm.cs +++ b/Toolbox/MainForm.cs @@ -1007,6 +1007,7 @@ namespace Toolbox Cursor.Current = Cursors.Default; } + #endregion #region TabMdiWindows @@ -1221,35 +1222,35 @@ namespace Toolbox } - private void BtnMdiClose_MouseEnter(object sender, System.EventArgs e) - { - BtnMdiClose.Image = Toolbox.Library.Properties.Resources.Close_Hover; - } + private void BtnMdiClose_MouseEnter(object sender, System.EventArgs e) + { + BtnMdiClose.Image = Toolbox.Library.Properties.Resources.Close_Hover; + } - private void BtnMdiClose_MouseLeave(object sender, System.EventArgs e) - { - BtnMdiClose.Image = Toolbox.Library.Properties.Resources.Close; - } + private void BtnMdiClose_MouseLeave(object sender, System.EventArgs e) + { + BtnMdiClose.Image = Toolbox.Library.Properties.Resources.Close; + } - private void BtnMdiMinMax_MouseEnter(object sender, EventArgs e) - { - BtnMdiMinMax.Image = Toolbox.Library.Properties.Resources.maximize_sele; - } + private void BtnMdiMinMax_MouseEnter(object sender, EventArgs e) + { + BtnMdiMinMax.Image = Toolbox.Library.Properties.Resources.maximize_sele; + } - private void BtnMdiMinMax_MouseLeave(object sender, EventArgs e) - { - BtnMdiMinMax.Image = Toolbox.Library.Properties.Resources.maximize; - } + private void BtnMdiMinMax_MouseLeave(object sender, EventArgs e) + { + BtnMdiMinMax.Image = Toolbox.Library.Properties.Resources.maximize; + } - private void BtnMdiMinimize_MouseEnter(object sender, EventArgs e) - { - BtnMdiMinimize.Image = Toolbox.Library.Properties.Resources.minimize_sele; - } + private void BtnMdiMinimize_MouseEnter(object sender, EventArgs e) + { + BtnMdiMinimize.Image = Toolbox.Library.Properties.Resources.minimize_sele; + } - private void BtnMdiMinimize_MouseLeave(object sender, EventArgs e) - { - BtnMdiMinimize.Image = Toolbox.Library.Properties.Resources.minimize; - } + private void BtnMdiMinimize_MouseLeave(object sender, EventArgs e) + { + BtnMdiMinimize.Image = Toolbox.Library.Properties.Resources.minimize; + } private void BtnMdiClose_Click(object sender, EventArgs e) { @@ -1378,13 +1379,14 @@ namespace Toolbox } } + private List failedFiles = new List(); private List batchExportFileList = new List(); private void BatchExportModels(string[] files, string outputFolder) { List Formats = new List(); Formats.Add("DAE (.dae)"); - List failedFiles = new List(); + failedFiles = new List(); BatchFormatExport form = new BatchFormatExport(Formats); if (form.ShowDialog() == DialogResult.OK) @@ -1392,15 +1394,17 @@ namespace Toolbox string extension = form.GetSelectedExtension(); foreach (var file in files) { + IFileFormat fileFormat = null; try { - var fileFormat = STFileLoader.OpenFileFormat(file); - SearchFileFormat(form.BatchSettings, fileFormat, extension, outputFolder, ExportMode.Models); + fileFormat = STFileLoader.OpenFileFormat(file); } catch (Exception ex) { failedFiles.Add($"{file} \n Error:\n {ex} \n"); } + + SearchFileFormat(form.BatchSettings, fileFormat, extension, outputFolder, ExportMode.Models); } batchExportFileList.Clear(); } @@ -1429,7 +1433,7 @@ namespace Toolbox Formats.Add("Tagged Image File Format (.tiff)"); Formats.Add("ASTC (.astc)"); - List failedFiles = new List(); + failedFiles = new List(); BatchFormatExport form = new BatchFormatExport(Formats); if (form.ShowDialog() == DialogResult.OK) @@ -1437,15 +1441,17 @@ namespace Toolbox string extension = form.GetSelectedExtension(); foreach (var file in files) { + IFileFormat fileFormat = null; try { - var fileFormat = STFileLoader.OpenFileFormat(file); - SearchFileFormat(form.BatchSettings, fileFormat, extension, outputFolder, ExportMode.Textures); + fileFormat = STFileLoader.OpenFileFormat(file); } catch (Exception ex) { failedFiles.Add($"{file} \n Error:\n {ex} \n"); } + + SearchFileFormat(form.BatchSettings, fileFormat, extension, outputFolder, ExportMode.Textures); } batchExportFileList.Clear(); } @@ -1538,7 +1544,16 @@ namespace Toolbox ArchiveFilePath = Path.Combine(outputFolder, Path.GetFileNameWithoutExtension(((IFileFormat)archiveFile).FileName)); foreach (var file in archiveFile.Files) - SearchFileFormat(settings, file.OpenFile(), extension, ArchiveFilePath, exportMode); + { + try + { + SearchFileFormat(settings, file.OpenFile(), extension, ArchiveFilePath, exportMode); + } + catch (Exception ex) + { + failedFiles.Add($"{file} \n Error:\n {ex} \n"); + } + } } } }