mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-11-12 23:32:42 -05:00
Some minor improvements
This commit is contained in:
@ -438,14 +438,16 @@ namespace AssetStudio
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var blockInfo in m_BlocksInfo)
|
||||
for (var i = 0; i < m_BlocksInfo.Length; i++)
|
||||
{
|
||||
var blockInfo = m_BlocksInfo[i];
|
||||
var compressionType = (CompressionType)(blockInfo.flags & StorageBlockFlags.CompressionTypeMask);
|
||||
|
||||
if (customBlockCompression != CompressionType.Auto && compressionType > 0)
|
||||
{
|
||||
compressionType = customBlockCompression;
|
||||
}
|
||||
var debugMsg = $"[{i:D2}] Compression: {compressionType} | UncompressedSize: {blockInfo.uncompressedSize} | CompressedSize: {blockInfo.compressedSize} ";
|
||||
|
||||
long numWrite;
|
||||
var errorMsg = string.Empty;
|
||||
@ -468,7 +470,8 @@ namespace AssetStudio
|
||||
sharedCompressedBuff.AsSpan().Clear();
|
||||
sharedUncompressedBuff.AsSpan().Clear();
|
||||
|
||||
_ = reader.Read(sharedCompressedBuff, 0, compressedSize);
|
||||
var read = reader.Read(sharedCompressedBuff, 0, compressedSize);
|
||||
debugMsg += $"(read: {read.ToString().ColorIf(read != compressedSize, ColorConsole.BrightRed)})";
|
||||
var compressedSpan = new ReadOnlySpan<byte>(sharedCompressedBuff, 0, compressedSize);
|
||||
var uncompressedSpan = new Span<byte>(sharedUncompressedBuff, 0, uncompressedSize);
|
||||
|
||||
@ -476,7 +479,6 @@ namespace AssetStudio
|
||||
if (numWrite == uncompressedSize)
|
||||
{
|
||||
blocksStream.Write(sharedUncompressedBuff, 0, uncompressedSize);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case CompressionType.Lzham:
|
||||
@ -484,6 +486,7 @@ namespace AssetStudio
|
||||
default:
|
||||
throw new IOException($"Unknown block compression type: {compressionType}.\nYou may try to specify the compression type manually.\n");
|
||||
}
|
||||
Logger.Debug(debugMsg);
|
||||
|
||||
if (numWrite != blockInfo.uncompressedSize)
|
||||
{
|
||||
|
||||
@ -10,9 +10,9 @@ namespace AssetStudio
|
||||
Black = "\u001b[30m",
|
||||
Red = "\u001b[31m",
|
||||
Green = "\u001b[32m",
|
||||
Yellow = "\u001b[33m", //remapped to ~BrightWhite in Windows PowerShell 6
|
||||
Yellow = "\u001b[33m", //remapped to ~BrightWhite in Windows PowerShell 6
|
||||
Blue = "\u001b[34m",
|
||||
Magenta = "\u001b[35m", //remapped to ~Blue in Windows PowerShell 6
|
||||
Magenta = "\u001b[35m", //remapped to ~Blue in Windows PowerShell 6
|
||||
Cyan = "\u001b[36m",
|
||||
White = "\u001b[37m",
|
||||
BrightBlack = "\u001b[30;1m",
|
||||
@ -28,13 +28,22 @@ namespace AssetStudio
|
||||
public static string Color(this string str, string ansiColor)
|
||||
{
|
||||
if (!ColorConsoleHelper.isAnsiCodesSupported)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
return $"{ansiColor}{str}{Reset}";
|
||||
}
|
||||
|
||||
public static string ColorIf(this string str, bool isTrue, string ansiColor, string defaultAnsiColor = null)
|
||||
{
|
||||
if (isTrue)
|
||||
return str.Color(ansiColor);
|
||||
|
||||
if (defaultAnsiColor != null)
|
||||
return str.Color(defaultAnsiColor);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void AnsiCodesTest()
|
||||
{
|
||||
Console.WriteLine("ANSI escape codes test");
|
||||
@ -45,5 +54,4 @@ namespace AssetStudio
|
||||
Console.WriteLine("\u001b[34;1m E \u001b[35;1m F \u001b[36;1m G \u001b[37;1m H \u001b[0m");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1272,7 +1272,7 @@ namespace AssetStudioCLI.Options
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Unknown Error.".Color(ColorConsole.Red));
|
||||
Console.WriteLine("Unknown Error.".Color(ColorConsole.BrightRed));
|
||||
Console.WriteLine(ex);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -794,13 +794,10 @@ namespace AssetStudioCLI
|
||||
{
|
||||
Logger.Default.Log(LoggerEvent.Info, "Nothing exported.", ignoreLevel: true);
|
||||
}
|
||||
else if (toExportCount > exportedCount)
|
||||
{
|
||||
Logger.Default.Log(LoggerEvent.Info, $"Finished exporting {exportedCount} asset(s) to \"{CLIOptions.o_outputFolder.Value.Color(Ansi.BrightYellow)}\".", ignoreLevel: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Default.Log(LoggerEvent.Info, $"Finished exporting {exportedCount} asset(s) to \"{CLIOptions.o_outputFolder.Value.Color(Ansi.BrightGreen)}\".", ignoreLevel: true);
|
||||
var outPath = CLIOptions.o_outputFolder.Value.ColorIf(toExportCount > exportedCount, Ansi.BrightYellow, Ansi.BrightGreen);
|
||||
Logger.Default.Log(LoggerEvent.Info, $"Finished exporting {exportedCount} asset(s) to \"{outPath}\".", ignoreLevel: true);
|
||||
}
|
||||
|
||||
if (toExportCount > exportedCount)
|
||||
|
||||
Reference in New Issue
Block a user