From 61e149265d5e0643c550ed4144d30316cdec7b60 Mon Sep 17 00:00:00 2001 From: SysVR Date: Fri, 12 Jan 2024 09:14:30 +0900 Subject: [PATCH] "To avoid the process halting due to output errors, I have instead implemented output to a text file. After the output is complete, a text file containing error logs will be opened in Notepad." --- AssetStudio.GUI/Studio.cs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/AssetStudio.GUI/Studio.cs b/AssetStudio.GUI/Studio.cs index c7d7454f..74e0f9bb 100644 --- a/AssetStudio.GUI/Studio.cs +++ b/AssetStudio.GUI/Studio.cs @@ -525,6 +525,8 @@ public static void ExportAssets(string savePath, List toExportAssets, int toExportCount = toExportAssets.Count; int exportedCount = 0; + string logFilePath = ""; + bool ExportError = false; int i = 0; Progress.Reset(); foreach (var asset in toExportAssets) @@ -593,9 +595,31 @@ public static void ExportAssets(string savePath, List toExportAssets, } catch (Exception ex) { - MessageBox.Show($"Export {asset.Type}:{asset.Text} error\r\n{ex.Message}\r\n{ex.StackTrace}"); + try + { + string directory = AppDomain.CurrentDomain.BaseDirectory; + logFilePath = Path.Combine(directory, "log_error.txt"); + string prevLogFilePath = Path.Combine(directory, "log_error_prev.txt"); + if (!ExportError) + { + if (File.Exists(logFilePath)) + { + if (File.Exists(prevLogFilePath)) + { + File.Delete(prevLogFilePath); + } + File.Move(logFilePath, prevLogFilePath); + } + File.AppendAllText(logFilePath, $"Export Errors:" + $"Version {Application.ProductVersion}" + Environment.NewLine + $"----------" + Environment.NewLine); + ExportError = true; + }; + File.AppendAllText(logFilePath, $"Export {asset.Type}:{asset.Text} error\r\n{ex.Message}\r\n{ex.StackTrace}" + Environment.NewLine + Environment.NewLine); + } + catch (Exception ex2) + { + Console.WriteLine("Error saving to log file: " + ex2.Message); + } } - Progress.Report(++i, toExportCount); } @@ -605,6 +629,11 @@ public static void ExportAssets(string savePath, List toExportAssets, { statusText += $" {toExportCount - exportedCount} assets skipped (not extractable or files already exist)"; } + if (ExportError) + { + Process.Start("notepad.exe", logFilePath); + } + StatusStripUpdate(statusText);