From cf67815d539efdb8905df8c4f4c0d42bc6971efe Mon Sep 17 00:00:00 2001 From: VaDiM Date: Fri, 25 Aug 2023 21:45:29 +0300 Subject: [PATCH 1/3] Minor fixes --- AssetStudioCLI/CLILogger.cs | 7 +- AssetStudioCLI/Exporter.cs | 84 ++++++++++----- AssetStudioCLI/Options/CLIOptions.cs | 3 +- AssetStudioGUI/AboutForm.cs | 8 -- AssetStudioGUI/AssetStudioGUIForm.cs | 48 ++++----- AssetStudioUtility/SpriteHelper.cs | 149 ++++++++++++++------------- 6 files changed, 162 insertions(+), 137 deletions(-) diff --git a/AssetStudioCLI/CLILogger.cs b/AssetStudioCLI/CLILogger.cs index e74f29d7..9aeac570 100644 --- a/AssetStudioCLI/CLILogger.cs +++ b/AssetStudioCLI/CLILogger.cs @@ -25,11 +25,12 @@ public CLILogger() { logOutput = CLIOptions.o_logOutput.Value; logMinLevel = CLIOptions.o_logLevel.Value; - LogName = $"AssetStudioCLI_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.log"; + var appAssembly = typeof(Program).Assembly.GetName(); + LogName = $"{appAssembly.Name}_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.log"; LogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LogName); + var arch = Environment.Is64BitProcess ? "x64" : "x32"; - var ver = typeof(Program).Assembly.GetName().Version; - LogToFile(LoggerEvent.Verbose, $"---AssetStudioCLI v{ver} | Logger launched---\n" + + LogToFile(LoggerEvent.Verbose, $"---{appAssembly.Name} v{appAssembly.Version} [{arch}] | Logger launched---\n" + $"CMD Args: {string.Join(" ", CLIOptions.cliArgs)}"); } diff --git a/AssetStudioCLI/Exporter.cs b/AssetStudioCLI/Exporter.cs index 77cc99ad..94ce07c8 100644 --- a/AssetStudioCLI/Exporter.cs +++ b/AssetStudioCLI/Exporter.cs @@ -17,6 +17,30 @@ public static bool ExportTexture2D(AssetItem item, string exportPath) var type = CLIOptions.o_imageFormat.Value; if (!TryExportFile(exportPath, item, "." + type.ToString().ToLower(), out var exportFullPath)) return false; + + if (CLIOptions.o_logLevel.Value <= LoggerEvent.Debug) + { + var sb = new StringBuilder(); + sb.AppendLine($"Converting \"{m_Texture2D.m_Name}\" to {type}.."); + sb.AppendLine($"Width: {m_Texture2D.m_Width}"); + sb.AppendLine($"Height: {m_Texture2D.m_Height}"); + sb.AppendLine($"Format: {m_Texture2D.m_TextureFormat}"); + switch (m_Texture2D.m_TextureSettings.m_FilterMode) + { + case 0: sb.AppendLine("Filter Mode: Point "); break; + case 1: sb.AppendLine("Filter Mode: Bilinear "); break; + case 2: sb.AppendLine("Filter Mode: Trilinear "); break; + } + sb.AppendLine($"Anisotropic level: {m_Texture2D.m_TextureSettings.m_Aniso}"); + sb.AppendLine($"Mip map bias: {m_Texture2D.m_TextureSettings.m_MipBias}"); + switch (m_Texture2D.m_TextureSettings.m_WrapMode) + { + case 0: sb.AppendLine($"Wrap mode: Repeat"); break; + case 1: sb.AppendLine($"Wrap mode: Clamp"); break; + } + Logger.Debug(sb.ToString()); + } + var image = m_Texture2D.ConvertToImage(flip: true); if (image == null) { @@ -29,7 +53,7 @@ public static bool ExportTexture2D(AssetItem item, string exportPath) { image.WriteToStream(file, type); } - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } } @@ -38,7 +62,7 @@ public static bool ExportTexture2D(AssetItem item, string exportPath) if (!TryExportFile(exportPath, item, ".tex", out var exportFullPath)) return false; File.WriteAllBytes(exportFullPath, m_Texture2D.image_data.GetData()); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } } @@ -59,13 +83,16 @@ public static bool ExportAudioClip(AssetItem item, string exportPath) if (!TryExportFile(exportPath, item, ".wav", out exportFullPath)) return false; - var sb = new StringBuilder(); - sb.AppendLine($"Converting \"{m_AudioClip.m_Name}\" to wav.."); - sb.AppendLine(m_AudioClip.version[0] < 5 ? $"AudioClip type: {m_AudioClip.m_Type}" : $"AudioClip compression format: {m_AudioClip.m_CompressionFormat}"); - sb.AppendLine($"AudioClip channel count: {m_AudioClip.m_Channels}"); - sb.AppendLine($"AudioClip sample rate: {m_AudioClip.m_Frequency}"); - sb.AppendLine($"AudioClip bit depth: {m_AudioClip.m_BitsPerSample}"); - Logger.Debug(sb.ToString()); + if (CLIOptions.o_logLevel.Value <= LoggerEvent.Debug) + { + var sb = new StringBuilder(); + sb.AppendLine($"Converting \"{m_AudioClip.m_Name}\" to wav.."); + sb.AppendLine(m_AudioClip.version[0] < 5 ? $"AudioClip type: {m_AudioClip.m_Type}" : $"AudioClip compression format: {m_AudioClip.m_CompressionFormat}"); + sb.AppendLine($"AudioClip channel count: {m_AudioClip.m_Channels}"); + sb.AppendLine($"AudioClip sample rate: {m_AudioClip.m_Frequency}"); + sb.AppendLine($"AudioClip bit depth: {m_AudioClip.m_BitsPerSample}"); + Logger.Debug(sb.ToString()); + } var buffer = converter.ConvertToWav(m_AudioData); if (buffer == null) @@ -82,7 +109,7 @@ public static bool ExportAudioClip(AssetItem item, string exportPath) File.WriteAllBytes(exportFullPath, m_AudioData); } - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } @@ -94,16 +121,19 @@ public static bool ExportVideoClip(AssetItem item, string exportPath) if (!TryExportFile(exportPath, item, Path.GetExtension(m_VideoClip.m_OriginalPath), out var exportFullPath)) return false; - var sb = new StringBuilder(); - sb.AppendLine($"VideoClip format: {m_VideoClip.m_Format}"); - sb.AppendLine($"VideoClip width: {m_VideoClip.Width}"); - sb.AppendLine($"VideoClip height: {m_VideoClip.Height}"); - sb.AppendLine($"VideoClip frame rate: {m_VideoClip.m_FrameRate}"); - sb.AppendLine($"VideoClip split alpha: {m_VideoClip.m_HasSplitAlpha}"); - Logger.Debug(sb.ToString()); + if (CLIOptions.o_logLevel.Value <= LoggerEvent.Debug) + { + var sb = new StringBuilder(); + sb.AppendLine($"VideoClip format: {m_VideoClip.m_Format}"); + sb.AppendLine($"VideoClip width: {m_VideoClip.Width}"); + sb.AppendLine($"VideoClip height: {m_VideoClip.Height}"); + sb.AppendLine($"VideoClip frame rate: {m_VideoClip.m_FrameRate:.0##}"); + sb.AppendLine($"VideoClip split alpha: {m_VideoClip.m_HasSplitAlpha}"); + Logger.Debug(sb.ToString()); + } m_VideoClip.m_VideoData.WriteData(exportFullPath); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } return false; @@ -116,7 +146,7 @@ public static bool ExportMovieTexture(AssetItem item, string exportPath) return false; File.WriteAllBytes(exportFullPath, m_MovieTexture.m_MovieData); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } @@ -128,7 +158,7 @@ public static bool ExportShader(AssetItem item, string exportPath) var str = m_Shader.Convert(); File.WriteAllText(exportFullPath, str); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } @@ -156,7 +186,7 @@ public static bool ExportTextAsset(AssetItem item, string exportPath) return false; File.WriteAllBytes(exportFullPath, m_TextAsset.m_Script); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } @@ -176,7 +206,7 @@ public static bool ExportMonoBehaviour(AssetItem item, string exportPath) var str = JsonConvert.SerializeObject(type, Formatting.Indented); File.WriteAllText(exportFullPath, str); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } return false; @@ -196,7 +226,7 @@ public static bool ExportFont(AssetItem item, string exportPath) return false; File.WriteAllBytes(exportFullPath, m_Font.m_FontData); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } return false; @@ -217,7 +247,7 @@ public static bool ExportSprite(AssetItem item, string exportPath) { image.WriteToStream(file, type); } - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } } @@ -230,7 +260,7 @@ public static bool ExportRawFile(AssetItem item, string exportPath) return false; File.WriteAllBytes(exportFullPath, item.Asset.GetRawData()); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } @@ -247,7 +277,7 @@ public static bool ExportDumpFile(AssetItem item, string exportPath) if (str != null) { File.WriteAllText(exportFullPath, str); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" saved to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" saved to \"{exportFullPath}\""); return true; } return false; @@ -365,7 +395,7 @@ private static bool ExportMesh(AssetItem item, string exportPath) sb.Replace("NaN", "0"); File.WriteAllText(exportFullPath, sb.ToString()); - Logger.Debug($"{item.TypeString}: \"{item.Text}\" exported to \"{exportFullPath}\""); + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportFullPath}\""); return true; } diff --git a/AssetStudioCLI/Options/CLIOptions.cs b/AssetStudioCLI/Options/CLIOptions.cs index b1d87a6f..f8b8de9b 100644 --- a/AssetStudioCLI/Options/CLIOptions.cs +++ b/AssetStudioCLI/Options/CLIOptions.cs @@ -761,7 +761,8 @@ public static void ShowHelp(bool showUsageOnly = false) } else { - Console.WriteLine($"# {appAssembly.Name}\n# Based on AssetStudioMod v{appAssembly.Version}\n"); + var arch = Environment.Is64BitProcess ? "x64" : "x32"; + Console.WriteLine($"# {appAssembly.Name} [{arch}]\n# Based on AssetStudioMod v{appAssembly.Version}\n"); Console.WriteLine($"{usage}\n\n{helpMessage}"); } } diff --git a/AssetStudioGUI/AboutForm.cs b/AssetStudioGUI/AboutForm.cs index baee692b..307a60e6 100644 --- a/AssetStudioGUI/AboutForm.cs +++ b/AssetStudioGUI/AboutForm.cs @@ -1,14 +1,6 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Diagnostics; -using System.Drawing; using System.IO; -using System.Linq; -using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace AssetStudioGUI diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs index 55db6353..4186eff9 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.cs @@ -1,6 +1,5 @@ using AssetStudio; using Newtonsoft.Json; -using OpenTK; using OpenTK.Graphics.OpenGL; using System; using System.Collections.Generic; @@ -21,6 +20,7 @@ using Font = AssetStudio.Font; using Microsoft.WindowsAPICodePack.Taskbar; #if NET472 +using OpenTK; using Vector3 = OpenTK.Vector3; using Vector4 = OpenTK.Vector4; #else @@ -785,42 +785,42 @@ private void PreviewAsset(AssetItem assetItem) return; try { - switch (assetItem.Asset) + switch (assetItem.Type) { - case Texture2D m_Texture2D: - PreviewTexture2D(assetItem, m_Texture2D); + case ClassIDType.Texture2D: + PreviewTexture2D(assetItem, assetItem.Asset as Texture2D); break; - case AudioClip m_AudioClip: - PreviewAudioClip(assetItem, m_AudioClip); + case ClassIDType.AudioClip: + PreviewAudioClip(assetItem, assetItem.Asset as AudioClip); break; - case Shader m_Shader: - PreviewShader(m_Shader); + case ClassIDType.Shader: + PreviewShader(assetItem.Asset as Shader); break; - case TextAsset m_TextAsset: - PreviewTextAsset(m_TextAsset); + case ClassIDType.TextAsset: + PreviewTextAsset(assetItem.Asset as TextAsset); break; - case MonoBehaviour m_MonoBehaviour: - PreviewMonoBehaviour(m_MonoBehaviour); + case ClassIDType.MonoBehaviour: + PreviewMonoBehaviour(assetItem.Asset as MonoBehaviour); break; - case Font m_Font: - PreviewFont(m_Font); + case ClassIDType.Font: + PreviewFont(assetItem.Asset as Font); break; - case Mesh m_Mesh: - PreviewMesh(m_Mesh); + case ClassIDType.Mesh: + PreviewMesh(assetItem.Asset as Mesh); break; - case VideoClip m_VideoClip: - PreviewVideoClip(assetItem, m_VideoClip); + case ClassIDType.VideoClip: + PreviewVideoClip(assetItem, assetItem.Asset as VideoClip); break; - case MovieTexture _: + case ClassIDType.MovieTexture: StatusStripUpdate("Only supported export."); break; - case Sprite m_Sprite: - PreviewSprite(assetItem, m_Sprite); + case ClassIDType.Sprite: + PreviewSprite(assetItem, assetItem.Asset as Sprite); break; - case Animator _: + case ClassIDType.Animator: StatusStripUpdate("Can be exported to FBX file."); break; - case AnimationClip _: + case ClassIDType.AnimationClip: StatusStripUpdate("Can be exported with Animator or Objects"); break; default: @@ -1029,7 +1029,7 @@ private void PreviewVideoClip(AssetItem assetItem, VideoClip m_VideoClip) var sb = new StringBuilder(); sb.AppendLine($"Width: {m_VideoClip.Width}"); sb.AppendLine($"Height: {m_VideoClip.Height}"); - sb.AppendLine($"Frame rate: {m_VideoClip.m_FrameRate}"); + sb.AppendLine($"Frame rate: {m_VideoClip.m_FrameRate:.0##}"); sb.AppendLine($"Split alpha: {m_VideoClip.m_HasSplitAlpha}"); assetItem.InfoText = sb.ToString(); diff --git a/AssetStudioUtility/SpriteHelper.cs b/AssetStudioUtility/SpriteHelper.cs index 8d6d735a..382bd081 100644 --- a/AssetStudioUtility/SpriteHelper.cs +++ b/AssetStudioUtility/SpriteHelper.cs @@ -34,7 +34,11 @@ public static Image GetImage(this Sprite m_Sprite, SpriteMaskMode sprite { if (m_Sprite.m_RD.texture.TryGet(out var m_Texture2D) && m_Sprite.m_RD.alphaTexture.TryGet(out var m_AlphaTexture2D) && spriteMaskMode != SpriteMaskMode.Off) { - var tex = CutImage(m_Sprite, m_Texture2D, m_Sprite.m_RD.textureRect, m_Sprite.m_RD.textureRectOffset, m_Sprite.m_RD.downscaleMultiplier, m_Sprite.m_RD.settingsRaw); + Image tex = null; + if (spriteMaskMode != SpriteMaskMode.MaskOnly) + { + tex = CutImage(m_Sprite, m_Texture2D, m_Sprite.m_RD.textureRect, m_Sprite.m_RD.textureRectOffset, m_Sprite.m_RD.downscaleMultiplier, m_Sprite.m_RD.settingsRaw); + } var alphaTex = CutImage(m_Sprite, m_AlphaTexture2D, m_Sprite.m_RD.textureRect, m_Sprite.m_RD.textureRectOffset, m_Sprite.m_RD.downscaleMultiplier, m_Sprite.m_RD.settingsRaw); switch (spriteMaskMode) @@ -46,7 +50,6 @@ public static Image GetImage(this Sprite m_Sprite, SpriteMaskMode sprite tex.ApplyRGBMask(alphaTex); return tex; case SpriteMaskMode.MaskOnly: - tex.Dispose(); return alphaTex; } } @@ -89,92 +92,90 @@ private static Image CutImage(Sprite m_Sprite, Texture2D m_Texture2D, Re var originalImage = m_Texture2D.ConvertToImage(false); if (originalImage != null) { - using (originalImage) + if (downscaleMultiplier > 0f && downscaleMultiplier != 1f) { - if (downscaleMultiplier > 0f && downscaleMultiplier != 1f) + var width = (int)(m_Texture2D.m_Width / downscaleMultiplier); + var height = (int)(m_Texture2D.m_Height / downscaleMultiplier); + originalImage.Mutate(x => x.Resize(width, height)); + } + var rectX = (int)Math.Floor(textureRect.x); + var rectY = (int)Math.Floor(textureRect.y); + var rectRight = (int)Math.Ceiling(textureRect.x + textureRect.width); + var rectBottom = (int)Math.Ceiling(textureRect.y + textureRect.height); + rectRight = Math.Min(rectRight, originalImage.Width); + rectBottom = Math.Min(rectBottom, originalImage.Height); + var rect = new Rectangle(rectX, rectY, rectRight - rectX, rectBottom - rectY); + var spriteImage = originalImage.Clone(x => x.Crop(rect)); + originalImage.Dispose(); + if (settingsRaw.packed == 1) + { + //RotateAndFlip + switch (settingsRaw.packingRotation) { - var width = (int)(m_Texture2D.m_Width / downscaleMultiplier); - var height = (int)(m_Texture2D.m_Height / downscaleMultiplier); - originalImage.Mutate(x => x.Resize(width, height)); + case SpritePackingRotation.FlipHorizontal: + spriteImage.Mutate(x => x.Flip(FlipMode.Horizontal)); + break; + case SpritePackingRotation.FlipVertical: + spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); + break; + case SpritePackingRotation.Rotate180: + spriteImage.Mutate(x => x.Rotate(180)); + break; + case SpritePackingRotation.Rotate90: + spriteImage.Mutate(x => x.Rotate(270)); + break; } - var rectX = (int)Math.Floor(textureRect.x); - var rectY = (int)Math.Floor(textureRect.y); - var rectRight = (int)Math.Ceiling(textureRect.x + textureRect.width); - var rectBottom = (int)Math.Ceiling(textureRect.y + textureRect.height); - rectRight = Math.Min(rectRight, originalImage.Width); - rectBottom = Math.Min(rectBottom, originalImage.Height); - var rect = new Rectangle(rectX, rectY, rectRight - rectX, rectBottom - rectY); - var spriteImage = originalImage.Clone(x => x.Crop(rect)); - if (settingsRaw.packed == 1) + } + + //Tight + if (settingsRaw.packingMode == SpritePackingMode.Tight) + { + try { - //RotateAndFlip - switch (settingsRaw.packingRotation) + var matrix = Matrix3x2.CreateScale(m_Sprite.m_PixelsToUnits); + matrix *= Matrix3x2.CreateTranslation(m_Sprite.m_Rect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, m_Sprite.m_Rect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y); + var triangles = GetTriangles(m_Sprite.m_RD); + var points = triangles.Select(x => x.Select(y => new PointF(y.X, y.Y)).ToArray()); + var pathBuilder = new PathBuilder(matrix); + foreach (var p in points) { - case SpritePackingRotation.FlipHorizontal: - spriteImage.Mutate(x => x.Flip(FlipMode.Horizontal)); - break; - case SpritePackingRotation.FlipVertical: - spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); - break; - case SpritePackingRotation.Rotate180: - spriteImage.Mutate(x => x.Rotate(180)); - break; - case SpritePackingRotation.Rotate90: - spriteImage.Mutate(x => x.Rotate(270)); - break; + pathBuilder.AddLines(p); + pathBuilder.CloseFigure(); } - } - - //Tight - if (settingsRaw.packingMode == SpritePackingMode.Tight) - { - try + var path = pathBuilder.Build(); + var options = new DrawingOptions { - var matrix = Matrix3x2.CreateScale(m_Sprite.m_PixelsToUnits); - matrix *= Matrix3x2.CreateTranslation(m_Sprite.m_Rect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, m_Sprite.m_Rect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y); - var triangles = GetTriangles(m_Sprite.m_RD); - var points = triangles.Select(x => x.Select(y => new PointF(y.X, y.Y)).ToArray()); - var pathBuilder = new PathBuilder(matrix); - foreach (var p in points) + GraphicsOptions = new GraphicsOptions { - pathBuilder.AddLines(p); - pathBuilder.CloseFigure(); - } - var path = pathBuilder.Build(); - var options = new DrawingOptions - { - GraphicsOptions = new GraphicsOptions - { - Antialias = false, - AlphaCompositionMode = PixelAlphaCompositionMode.DestOut - } - }; - if (triangles.Length < 1024) - { - var rectP = new RectangularPolygon(0, 0, rect.Width, rect.Height); - spriteImage.Mutate(x => x.Fill(options, SixLabors.ImageSharp.Color.Red, rectP.Clip(path))); - spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); - return spriteImage; - } - using (var mask = new Image(rect.Width, rect.Height, SixLabors.ImageSharp.Color.Black)) - { - mask.Mutate(x => x.Fill(options, SixLabors.ImageSharp.Color.Red, path)); - var brush = new ImageBrush(mask); - spriteImage.Mutate(x => x.Fill(options, brush)); - spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); - return spriteImage; + Antialias = false, + AlphaCompositionMode = PixelAlphaCompositionMode.DestOut } + }; + if (triangles.Length < 1024) + { + var rectP = new RectangularPolygon(0, 0, rect.Width, rect.Height); + spriteImage.Mutate(x => x.Fill(options, SixLabors.ImageSharp.Color.Red, rectP.Clip(path))); + spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); + return spriteImage; } - catch + using (var mask = new Image(rect.Width, rect.Height, SixLabors.ImageSharp.Color.Black)) { - // ignored + mask.Mutate(x => x.Fill(options, SixLabors.ImageSharp.Color.Red, path)); + var brush = new ImageBrush(mask); + spriteImage.Mutate(x => x.Fill(options, brush)); + spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); + return spriteImage; } } - - //Rectangle - spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); - return spriteImage; + catch + { + // ignored + } } + + //Rectangle + spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); + return spriteImage; } return null; From c8a21838c979d5d8b942e2cb5c970f09aa679d1f Mon Sep 17 00:00:00 2001 From: VaDiM Date: Sun, 27 Aug 2023 01:33:34 +0300 Subject: [PATCH 2/3] Some changes to motion list for l2d models - Motion list is now sorted - Motions divided into groups (each motion is a separate group) - Motion names are used as group names --- .../CubismLive2DExtractor/Live2DExtractor.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractor.cs b/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractor.cs index d8b0a6f5..c312fb6f 100644 --- a/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractor.cs +++ b/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractor.cs @@ -99,7 +99,7 @@ public static void ExtractLive2D(IGrouping assets, s } //motion - var motions = new JArray(); + var motions = new SortedDictionary(); if (gameObjects.Count > 0) { @@ -205,11 +205,8 @@ public static void ExtractLive2D(IGrouping assets, s } json.Meta.TotalUserDataSize = totalUserDataSize; - motions.Add(new JObject - { - { "Name", animation.Name }, - { "File", $"motions/{animation.Name}.motion3.json" } - }); + var motionPath = new JObject(new JProperty("File", $"motions/{animation.Name}.motion3.json")); + motions.Add(animation.Name, new JArray(motionPath)); File.WriteAllText($"{destMotionPath}{animation.Name}.motion3.json", JsonConvert.SerializeObject(json, Formatting.Indented, new MyJsonConverter())); } } @@ -307,7 +304,7 @@ public static void ExtractLive2D(IGrouping assets, s { Moc = $"{modelName}.moc3", Textures = textures.ToArray(), - Motions = new JObject { { "", motions } }, + Motions = JObject.FromObject(motions), Expressions = expressions, }, Groups = groups.ToArray() From 171962e61f080ea5d957e369ac2607e2ce4b8b3b Mon Sep 17 00:00:00 2001 From: VaDiM Date: Sun, 27 Aug 2023 01:47:06 +0300 Subject: [PATCH 3/3] Update version to v0.17.2 - Updated projects and dependencies --- AssetStudio.PInvoke/AssetStudio.PInvoke.csproj | 2 +- AssetStudio/AssetStudio.csproj | 6 +++--- AssetStudioCLI/AssetStudioCLI.csproj | 2 +- .../AssetStudioFBXWrapper.csproj | 2 +- AssetStudioGUI/AssetStudioGUI.csproj | 17 +++++++++-------- AssetStudioUtility/AssetStudioUtility.csproj | 10 +++++++--- CHANGELOG.md | 14 ++++++++++++++ .../Texture2DDecoderWrapper.csproj | 2 +- 8 files changed, 37 insertions(+), 18 deletions(-) diff --git a/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj b/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj index 8fc7047f..fc533b6d 100644 --- a/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj +++ b/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj @@ -3,7 +3,7 @@ net472;net6.0;net6.0-windows;net7.0;net7.0-windows true - 0.17.1.0 + 0.17.2.0 Copyright © Perfare 2020-2022; Copyright © hozuki 2020 embedded diff --git a/AssetStudio/AssetStudio.csproj b/AssetStudio/AssetStudio.csproj index 72952762..90b4762b 100644 --- a/AssetStudio/AssetStudio.csproj +++ b/AssetStudio/AssetStudio.csproj @@ -2,13 +2,13 @@ net472;net6.0;net6.0-windows;net7.0;net7.0-windows - 0.17.1.0 - Copyright © Perfare 2018-2022 + 0.17.2.0 + Copyright © Perfare 2018-2022; Copyright © aelurum 2023 embedded - + diff --git a/AssetStudioCLI/AssetStudioCLI.csproj b/AssetStudioCLI/AssetStudioCLI.csproj index cd4c7372..326ad44a 100644 --- a/AssetStudioCLI/AssetStudioCLI.csproj +++ b/AssetStudioCLI/AssetStudioCLI.csproj @@ -5,7 +5,7 @@ net472;net6.0;net7.0 AssetStudioMod by aelurum AssetStudioModCLI - 0.17.1.0 + 0.17.2.0 Copyright © Perfare; Copyright © aelurum 2023 AnyCPU embedded diff --git a/AssetStudioFBXWrapper/AssetStudioFBXWrapper.csproj b/AssetStudioFBXWrapper/AssetStudioFBXWrapper.csproj index aea91284..816445ed 100644 --- a/AssetStudioFBXWrapper/AssetStudioFBXWrapper.csproj +++ b/AssetStudioFBXWrapper/AssetStudioFBXWrapper.csproj @@ -3,7 +3,7 @@ net472;net6.0;net6.0-windows;net7.0;net7.0-windows true - 0.17.1.0 + 0.17.2.0 Copyright © Perfare 2018-2022; Copyright © hozuki 2020 embedded diff --git a/AssetStudioGUI/AssetStudioGUI.csproj b/AssetStudioGUI/AssetStudioGUI.csproj index 7fa43dfd..9ea2e5db 100644 --- a/AssetStudioGUI/AssetStudioGUI.csproj +++ b/AssetStudioGUI/AssetStudioGUI.csproj @@ -7,7 +7,7 @@ Resources\as.ico AssetStudioMod by aelurum AssetStudioModGUI - 0.17.1.0 + 0.17.2.0 Copyright © Perfare 2018-2022; Copyright © aelurum 2021-2023 embedded @@ -53,8 +53,15 @@ + + + + + + - + + Libraries\OpenTK.WinForms.dll @@ -65,12 +72,6 @@ - - - - - - diff --git a/AssetStudioUtility/AssetStudioUtility.csproj b/AssetStudioUtility/AssetStudioUtility.csproj index 9797dbe5..5fc92665 100644 --- a/AssetStudioUtility/AssetStudioUtility.csproj +++ b/AssetStudioUtility/AssetStudioUtility.csproj @@ -2,15 +2,14 @@ net472;net6.0;net6.0-windows;net7.0;net7.0-windows - 0.17.1.0 - Copyright © Perfare 2018-2022 + 0.17.2.0 + Copyright © Perfare 2018-2022; Copyright © aelurum 2023 embedded - @@ -23,6 +22,11 @@ 0.17.0 + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index a1253312..d2802873 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## v0.17.2.0 [27-08-2023] +- [GUI] Improved Scene Hierarchy tab + - Added "Related assets" item to the context menu (https://github.com/aelurum/AssetStudio/issues/7) +- [GUI] Added app.manifest for net472 build + - Added long paths support (win10 v1607+) + - Fixed blurring at high DPI with scaling +- [CLI] Fixed sprite export in sprite only mode +- Made some changes to motion list for live2d models + - Motion list is now sorted + - Motions divided into groups (each motion is a separate group) + - Motion names are used as group names +- Updated dependencies +- Made some other minor fixes and improvements + ## v0.17.1.0 [12-07-2023] #### Breaking Changes - With the drag&drop fix (https://github.com/aelurum/AssetStudio/commit/2f8f57c1a63893c0b0d2a55349d6cb6d8f8a5a3b), functions `LoadFiles` and `LoadFolder` in AssetsManager have been replaced with one universal function `LoadFilesAndFolders` diff --git a/Texture2DDecoderWrapper/Texture2DDecoderWrapper.csproj b/Texture2DDecoderWrapper/Texture2DDecoderWrapper.csproj index 920f182e..fba7713d 100644 --- a/Texture2DDecoderWrapper/Texture2DDecoderWrapper.csproj +++ b/Texture2DDecoderWrapper/Texture2DDecoderWrapper.csproj @@ -3,7 +3,7 @@ net472 true - 0.17.1.0 + 0.17.2.0 Copyright © Perfare 2020-2022; Copyright © hozuki 2020 embedded