From aa1f357538994c4e7708f960be9ecf64f79e636a Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Fri, 22 May 2026 19:42:32 -0500 Subject: [PATCH] equipment icon parsing on c# end --- packages/game/JSExport/GameInterface.cs | 59 +++++++++++++++++++------ 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/packages/game/JSExport/GameInterface.cs b/packages/game/JSExport/GameInterface.cs index 26cb27b78..10f85dee9 100644 --- a/packages/game/JSExport/GameInterface.cs +++ b/packages/game/JSExport/GameInterface.cs @@ -1,7 +1,10 @@ using System.Text.RegularExpressions; using BlitzKit.Game.Models; using CUE4Parse_Conversion.Textures; +using CUE4Parse.UE4.Assets.Exports; using CUE4Parse.UE4.Assets.Exports.Texture; +using CUE4Parse.UE4.Assets.Objects.Properties; +using CUE4Parse.UE4.IO.Objects; using CUE4Parse.UE4.Objects.Engine; using CUE4Parse.UE4.Objects.UObject; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -47,23 +50,24 @@ public partial class GameInterface if (provider.TryLoadPackageObject(path, out var pda)) { - FSoftObjectPath objectPath = pda.Get("BigIcon"); - UTexture2D uTexture = objectPath.Load(); - CTexture? cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile); + var icon = pda.Get("BigIcon"); + var uTexture = icon.Load(); + var cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile); if (cTexture is null) { + Console.WriteLine($"No tank big icon found for {tankId} in {pdaName}"); return []; } - SKBitmap bitmap = cTexture.ToSkBitmap(); - SKData data = bitmap.Encode(SKEncodedImageFormat.Webp, 80); - byte[] bytes = data.ToArray(); + var bitmap = cTexture.ToSkBitmap(); + var data = bitmap.Encode(SKEncodedImageFormat.Webp, 80); - return bytes; + return data.ToArray(); } } + Console.WriteLine($"No tank big icon found for {tankId} in {pdaName}"); return []; } @@ -95,20 +99,22 @@ public partial class GameInterface if (cTexture is null) { + Console.WriteLine($"No flag found for {nation}"); return []; } SKBitmap bitmap = cTexture.ToSkBitmap(); SKData data = bitmap.Encode(SKEncodedImageFormat.Webp, 80); - byte[] bytes = data.ToArray(); - return bytes; + return data.ToArray(); } + Console.WriteLine($"No flag found for {nation}"); return []; } } + Console.WriteLine($"No flag found for {nation}"); return []; } @@ -128,18 +134,45 @@ public partial class GameInterface ]); } - foreach (var candidate in candidates) + string? candidate = null; + foreach (var c in candidates) { - if (!files.Contains(candidate)) + if (!files.Contains(c)) { continue; } - Console.WriteLine(candidate); + candidate = c; + break; } - // TODO: warn if no equipment icons found + if (candidate is null) + { + Console.WriteLine($"No equipment pda found for {string.Join(", ", names)}"); + return []; + } + var path = $"{candidate}.{Path.GetFileNameWithoutExtension(candidate)}"; + + if (provider.TryLoadPackageObject(path, out var pda)) + { + var icon = pda.Get("Icon"); + var uTexture = icon.Load(); + var cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile); + + if (cTexture is null) + { + Console.WriteLine($"Could not extract icon for {path}"); + return []; + } + + var bitmap = cTexture.ToSkBitmap(); + var data = bitmap.Encode(SKEncodedImageFormat.Webp, 80); + + return data.ToArray(); + } + + Console.WriteLine($"Could not load {path} as pda"); return []; } }