mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
[GUI] A bit better(?) error handling
This commit is contained in:
parent
629c6248a4
commit
679e7041a6
@ -135,9 +135,14 @@ namespace AssetStudio
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NotSupportedException e)
|
||||
{
|
||||
Logger.Error(e.Message, e);
|
||||
reader.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error($"Error while reading assets file {reader.FullPath}", e);
|
||||
Logger.Warning($"Error while reading assets file {reader.FullPath}\r\n{e}");
|
||||
reader.Dispose();
|
||||
}
|
||||
}
|
||||
@ -164,9 +169,14 @@ namespace AssetStudio
|
||||
assetsFileList.Add(assetsFile);
|
||||
assetsFileListHash.Add(assetsFile.fileName);
|
||||
}
|
||||
catch (NotSupportedException e)
|
||||
{
|
||||
Logger.Error(e.Message, e);
|
||||
resourceFileReaders.Add(reader.FileName, reader);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error($"Error while reading assets file {reader.FullPath} from {Path.GetFileName(originalPath)}", e);
|
||||
Logger.Warning($"Error while reading assets file {reader.FullPath} from {Path.GetFileName(originalPath)}\r\n{e}");
|
||||
resourceFileReaders.Add(reader.FileName, reader);
|
||||
}
|
||||
}
|
||||
@ -201,7 +211,7 @@ namespace AssetStudio
|
||||
{
|
||||
str += $" from {Path.GetFileName(originalPath)}";
|
||||
}
|
||||
Logger.Error(str, e);
|
||||
Logger.Warning($"{str}\r\n{e}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -298,7 +308,7 @@ namespace AssetStudio
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error($"Error while reading zip split file {basePath}", e);
|
||||
Logger.Warning($"Error while reading zip split file {basePath}\r\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,7 +345,7 @@ namespace AssetStudio
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error($"Error while reading zip entry {entry.FullName}", e);
|
||||
Logger.Warning($"Error while reading zip entry {entry.FullName}\r\n{e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -354,7 +364,7 @@ namespace AssetStudio
|
||||
{
|
||||
if (assetsFile.IsVersionStripped && string.IsNullOrEmpty(SpecifyUnityVersion))
|
||||
{
|
||||
throw new Exception("The Unity version has been stripped, please set the version in the options");
|
||||
throw new NotSupportedException("The Unity version has been stripped, please set the version in the options");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(SpecifyUnityVersion))
|
||||
{
|
||||
@ -496,7 +506,7 @@ namespace AssetStudio
|
||||
.AppendLine($"Type {objectReader.type}")
|
||||
.AppendLine($"PathID {objectInfo.m_PathID}")
|
||||
.Append(e);
|
||||
Logger.Error(sb.ToString());
|
||||
Logger.Warning(sb.ToString());
|
||||
}
|
||||
|
||||
Progress.Report(++i, progressCount);
|
||||
|
@ -19,6 +19,7 @@ namespace AssetStudio
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine(message);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(e.ToString());
|
||||
Default.Log(LoggerEvent.Error, sb.ToString());
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ namespace AssetStudioGUI
|
||||
var fileNames = openFileDialog1.FileNames;
|
||||
var savePath = saveFolderDialog.Folder;
|
||||
var extractedCount = await Task.Run(() => ExtractFile(fileNames, savePath));
|
||||
StatusStripUpdate($"Finished extracting {extractedCount} files.");
|
||||
Logger.Info($"Finished extracting {extractedCount} files.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -203,7 +203,7 @@ namespace AssetStudioGUI
|
||||
var path = openFolderDialog.Folder;
|
||||
var savePath = saveFolderDialog.Folder;
|
||||
var extractedCount = await Task.Run(() => ExtractFolder(path, savePath));
|
||||
StatusStripUpdate($"Finished extracting {extractedCount} files.");
|
||||
Logger.Info($"Finished extracting {extractedCount} files.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,7 +213,7 @@ namespace AssetStudioGUI
|
||||
if (assetsManager.assetsFileList.Count == 0)
|
||||
{
|
||||
filterExcludeModeCheck(assetsManager.assetsFileList.Count);
|
||||
StatusStripUpdate("No Unity file can be loaded.");
|
||||
Logger.Info("No Unity file can be loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ namespace AssetStudioGUI
|
||||
{
|
||||
log += $" and {m_ObjectsCount - objectsCount} assets failed to read";
|
||||
}
|
||||
StatusStripUpdate(log);
|
||||
Logger.Info(log);
|
||||
}
|
||||
|
||||
private void typeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@ -397,7 +397,7 @@ namespace AssetStudioGUI
|
||||
Progress.Report(++i, count);
|
||||
}
|
||||
|
||||
StatusStripUpdate("Finished exporting class structures");
|
||||
Logger.Info("Finished exporting class structures");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1780,7 +1780,7 @@ namespace AssetStudioGUI
|
||||
ERRCHECK(result);
|
||||
if (version < FMOD.VERSION.number)
|
||||
{
|
||||
MessageBox.Show($"Error! You are using an old version of FMOD {version:X}. This program requires {FMOD.VERSION.number:X}.");
|
||||
Logger.Error($"Error! You are using an old version of FMOD {version:X}. This program requires {FMOD.VERSION.number:X}.");
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
@ -2036,7 +2036,7 @@ namespace AssetStudioGUI
|
||||
if (result != FMOD.RESULT.OK)
|
||||
{
|
||||
FMODreset();
|
||||
StatusStripUpdate($"FMOD error! {result} - {FMOD.Error.String(result)}");
|
||||
Logger.Warning($"FMOD error! {result} - {FMOD.Error.String(result)}");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -19,16 +19,22 @@ namespace AssetStudioGUI
|
||||
switch (loggerEvent)
|
||||
{
|
||||
case LoggerEvent.Error:
|
||||
MessageBox.Show(message, "Error");
|
||||
break;
|
||||
case LoggerEvent.Warning:
|
||||
if (ShowErrorMessage)
|
||||
{
|
||||
MessageBox.Show(message);
|
||||
MessageBox.Show(message, "Warning");
|
||||
}
|
||||
else
|
||||
{
|
||||
action("An error has occurred. Turn on \"Show all error messages\" to see details next time.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
action(message);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ namespace AssetStudioGUI
|
||||
|
||||
private static int ExtractBundleFile(FileReader reader, string savePath)
|
||||
{
|
||||
StatusStripUpdate($"Decompressing {reader.FileName} ...");
|
||||
Logger.Info($"Decompressing {reader.FileName} ...");
|
||||
var bundleFile = new BundleFile(reader);
|
||||
reader.Dispose();
|
||||
if (bundleFile.fileList.Length > 0)
|
||||
@ -97,7 +97,7 @@ namespace AssetStudioGUI
|
||||
|
||||
private static int ExtractWebDataFile(FileReader reader, string savePath)
|
||||
{
|
||||
StatusStripUpdate($"Decompressing {reader.FileName} ...");
|
||||
Logger.Info($"Decompressing {reader.FileName} ...");
|
||||
var webFile = new WebFile(reader);
|
||||
reader.Dispose();
|
||||
if (webFile.fileList.Length > 0)
|
||||
@ -134,7 +134,7 @@ namespace AssetStudioGUI
|
||||
|
||||
public static (string, List<TreeNode>) BuildAssetData()
|
||||
{
|
||||
StatusStripUpdate("Building asset list...");
|
||||
Logger.Info("Building asset list...");
|
||||
|
||||
string productName = null;
|
||||
var objectCount = assetsManager.assetsFileList.Sum(x => x.Objects.Count);
|
||||
@ -256,7 +256,7 @@ namespace AssetStudioGUI
|
||||
|
||||
visibleAssets = exportableAssets;
|
||||
|
||||
StatusStripUpdate("Building tree structure...");
|
||||
Logger.Info("Building tree structure...");
|
||||
|
||||
var treeNodeCollection = new List<TreeNode>();
|
||||
var treeNodeDictionary = new Dictionary<GameObject, GameObjectTreeNode>();
|
||||
@ -414,7 +414,7 @@ namespace AssetStudioGUI
|
||||
break;
|
||||
}
|
||||
exportPath += Path.DirectorySeparatorChar;
|
||||
StatusStripUpdate($"[{exportedCount}/{toExportCount}] Exporting {asset.TypeString}: {asset.Text}");
|
||||
Logger.Info($"[{exportedCount}/{toExportCount}] Exporting {asset.TypeString}: {asset.Text}");
|
||||
try
|
||||
{
|
||||
switch (exportType)
|
||||
@ -441,7 +441,7 @@ namespace AssetStudioGUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Export {asset.Type}:{asset.Text} error\r\n{ex.Message}\r\n{ex.StackTrace}");
|
||||
Logger.Error($"Export {asset.Type}:{asset.Text} error", ex);
|
||||
}
|
||||
|
||||
Progress.Report(++i, toExportCount);
|
||||
@ -454,7 +454,7 @@ namespace AssetStudioGUI
|
||||
statusText += $" {toExportCount - exportedCount} assets skipped (not extractable or files already exist)";
|
||||
}
|
||||
|
||||
StatusStripUpdate(statusText);
|
||||
Logger.Info(statusText);
|
||||
|
||||
if (Properties.Settings.Default.openAfterExport && exportedCount > 0)
|
||||
{
|
||||
@ -499,7 +499,7 @@ namespace AssetStudioGUI
|
||||
|
||||
var statusText = $"Finished exporting asset list with {toExportAssets.Count()} items.";
|
||||
|
||||
StatusStripUpdate(statusText);
|
||||
Logger.Info(statusText);
|
||||
|
||||
if (Properties.Settings.Default.openAfterExport && toExportAssets.Count() > 0)
|
||||
{
|
||||
@ -547,25 +547,25 @@ namespace AssetStudioGUI
|
||||
}
|
||||
Directory.CreateDirectory(targetPath);
|
||||
//导出FBX
|
||||
StatusStripUpdate($"Exporting {filename}.fbx");
|
||||
Logger.Info($"Exporting {filename}.fbx");
|
||||
try
|
||||
{
|
||||
ExportGameObject(j.gameObject, targetPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Export GameObject:{j.Text} error\r\n{ex.Message}\r\n{ex.StackTrace}");
|
||||
Logger.Error($"Export GameObject:{j.Text} error", ex);
|
||||
}
|
||||
|
||||
Progress.Report(++k, count);
|
||||
StatusStripUpdate($"Finished exporting {filename}.fbx");
|
||||
Logger.Info($"Finished exporting {filename}.fbx");
|
||||
}
|
||||
}
|
||||
if (Properties.Settings.Default.openAfterExport)
|
||||
{
|
||||
OpenFolderInExplorer(savePath);
|
||||
}
|
||||
StatusStripUpdate("Finished");
|
||||
Logger.Info("Finished");
|
||||
});
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ namespace AssetStudioGUI
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
Progress.Reset();
|
||||
StatusStripUpdate($"Exporting {animator.Text}");
|
||||
Logger.Info($"Exporting {animator.Text}");
|
||||
try
|
||||
{
|
||||
ExportAnimator(animator, exportPath, animationList);
|
||||
@ -592,12 +592,12 @@ namespace AssetStudioGUI
|
||||
OpenFolderInExplorer(exportPath);
|
||||
}
|
||||
Progress.Report(1, 1);
|
||||
StatusStripUpdate($"Finished exporting {animator.Text}");
|
||||
Logger.Info($"Finished exporting {animator.Text}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Export Animator:{animator.Text} error\r\n{ex.Message}\r\n{ex.StackTrace}");
|
||||
StatusStripUpdate("Error in export");
|
||||
Logger.Error($"Export Animator:{animator.Text} error", ex);
|
||||
Logger.Info("Error in export");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -615,16 +615,16 @@ namespace AssetStudioGUI
|
||||
Progress.Reset();
|
||||
foreach (var gameObject in gameObjects)
|
||||
{
|
||||
StatusStripUpdate($"Exporting {gameObject.m_Name}");
|
||||
Logger.Info($"Exporting {gameObject.m_Name}");
|
||||
try
|
||||
{
|
||||
ExportGameObject(gameObject, exportPath, animationList);
|
||||
StatusStripUpdate($"Finished exporting {gameObject.m_Name}");
|
||||
Logger.Info($"Finished exporting {gameObject.m_Name}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Export GameObject:{gameObject.m_Name} error\r\n{ex.Message}\r\n{ex.StackTrace}");
|
||||
StatusStripUpdate("Error in export");
|
||||
Logger.Error($"Export GameObject:{gameObject.m_Name} error", ex);
|
||||
Logger.Info("Error in export");
|
||||
}
|
||||
|
||||
Progress.Report(++i, count);
|
||||
@ -636,7 +636,7 @@ namespace AssetStudioGUI
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusStripUpdate("No Object selected for export.");
|
||||
Logger.Info("No Object selected for export.");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -647,17 +647,17 @@ namespace AssetStudioGUI
|
||||
{
|
||||
var name = Path.GetFileName(exportPath);
|
||||
Progress.Reset();
|
||||
StatusStripUpdate($"Exporting {name}");
|
||||
Logger.Info($"Exporting {name}");
|
||||
try
|
||||
{
|
||||
ExportGameObjectMerge(gameObjects, exportPath, animationList);
|
||||
Progress.Report(1, 1);
|
||||
StatusStripUpdate($"Finished exporting {name}");
|
||||
Logger.Info($"Finished exporting {name}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Export Model:{name} error\r\n{ex.Message}\r\n{ex.StackTrace}");
|
||||
StatusStripUpdate("Error in export");
|
||||
Logger.Error($"Export Model:{name} error", ex);
|
||||
Logger.Info("Error in export");
|
||||
}
|
||||
if (Properties.Settings.Default.openAfterExport)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user