This commit is contained in:
2025-12-16 06:31:29 +09:00
parent bdfcf254a8
commit 4444a88746
32 changed files with 1204 additions and 464 deletions

View File

@@ -250,32 +250,40 @@ public sealed class CharacterAnalyzer : MediatorSubscriberBase, IDisposable
}
OriginalSize = normalSize;
CompressedSize = compressedsize.Item2.LongLength;
RefreshFormat();
}
public long OriginalSize { get; private set; } = OriginalSize;
public long CompressedSize { get; private set; } = CompressedSize;
public long Triangles { get; private set; } = Triangles;
public Lazy<string> Format = new(() =>
public Lazy<string> Format => _format ??= CreateFormatValue();
private Lazy<string>? _format;
public void RefreshFormat()
{
switch (FileType)
_format = CreateFormatValue();
}
private Lazy<string> CreateFormatValue()
=> new(() =>
{
case "tex":
{
try
{
using var stream = new FileStream(FilePaths[0], FileMode.Open, FileAccess.Read, FileShare.Read);
using var reader = new BinaryReader(stream);
reader.BaseStream.Position = 4;
var format = (TexFile.TextureFormat)reader.ReadInt32();
return format.ToString();
}
catch
{
return "Unknown";
}
}
default:
if (!string.Equals(FileType, "tex", StringComparison.Ordinal))
{
return string.Empty;
}
});
}
try
{
using var stream = new FileStream(FilePaths[0], FileMode.Open, FileAccess.Read, FileShare.Read);
using var reader = new BinaryReader(stream);
reader.BaseStream.Position = 4;
var format = (TexFile.TextureFormat)reader.ReadInt32();
return format.ToString();
}
catch
{
return "Unknown";
}
});
}
}