From a8ae806f8b13fdc0b11cd6ca6a4dfe8a771d2fa7 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Sat, 23 May 2026 14:25:32 -0500 Subject: [PATCH] what --- .gitmodules | 3 + packages/cue4parse | 1 + packages/game/JSExport/GameInterface.cs | 92 ++++++++++++------------- packages/game/game.csproj | 2 + packages/game/src/index.ts | 2 +- 5 files changed, 52 insertions(+), 48 deletions(-) create mode 160000 packages/cue4parse diff --git a/.gitmodules b/.gitmodules index 94125afa0..b2050de33 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "packages/closed"] path = packages/closed url = https://github.com/blitzkit/closed.git +[submodule "packages/cue4parse"] + path = packages/cue4parse + url = https://github.com/tresabhi/CUE4Parse.git diff --git a/packages/cue4parse b/packages/cue4parse new file mode 160000 index 000000000..b42ab66a7 --- /dev/null +++ b/packages/cue4parse @@ -0,0 +1 @@ +Subproject commit b42ab66a7ad76a7f63c4d04e9628658729b3cb39 diff --git a/packages/game/JSExport/GameInterface.cs b/packages/game/JSExport/GameInterface.cs index 0260a03e8..74a524317 100644 --- a/packages/game/JSExport/GameInterface.cs +++ b/packages/game/JSExport/GameInterface.cs @@ -10,6 +10,7 @@ using CUE4Parse.UE4.Objects.Engine; using CUE4Parse.UE4.Objects.UObject; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.JavaScript.NodeApi; +using SharpGLTF.Schema2; using SkiaSharp; namespace BlitzKit.Game.JSExport; @@ -79,13 +80,13 @@ public partial class GameInterface [GeneratedRegex(@"T_UI_Flag_(\w+)_S")] private static partial Regex FlagNameRegex(); - public byte[] Flag(string nation) - { - var flagsBase = "Blitz/Content/UI/Textures/Flag/TankCard/"; + private readonly string flagsPrefix = "Blitz/Content/UI/Textures/Flag/TankCard/"; - foreach (var path in provider.Files.Keys) + public byte[]? Flag(string nation) + { + foreach (var path in files) { - if (!path.StartsWith(flagsBase)) + if (!path.StartsWith(flagsPrefix)) { continue; } @@ -100,34 +101,23 @@ public partial class GameInterface { if (provider.TryLoadPackageObject($"{path}.{fileName}", out var uTexture)) { - CTexture? cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile); - - if (cTexture is null) - { - Console.WriteLine($"No flag found for {nation}"); - return []; - } - - SKBitmap bitmap = cTexture.ToSkBitmap(); - SKData data = bitmap.Encode(SKEncodedImageFormat.Webp, 80); - - return data.ToArray(); + return Image(uTexture); } Console.WriteLine($"No flag found for {nation}"); - return []; + return null; } } Console.WriteLine($"No flag found for {nation}"); - return []; + return null; } private static readonly string equipmentPDAPrefix = "Blitz/Content/TanksStuff/Equipment/PDA_Equipment"; private static readonly string equipmentPDASuffix = ".uasset"; - public byte[] EquipmentIcon(string[] names) + public byte[]? EquipmentIcon(string[] names) { List candidates = []; @@ -154,38 +144,46 @@ public partial class GameInterface if (candidate is null) { Console.WriteLine($"No equipment pda found for {string.Join(", ", names)}"); - return []; + return null; } - var path = $"{candidate}.{Path.GetFileNameWithoutExtension(candidate)}"; + var pda = PDA(candidate); + var icon = pda.Get("Icon"); - if (provider.TryLoadPackageObject(path, out var pda)) + return Image(icon); + } + + private UPrimaryDataAsset PDA(string path) + { + var name = Path.GetFileNameWithoutExtension(path); + var fullPath = $"{path}.{name}"; + var pda = provider.LoadPackageObject(fullPath); + + return pda; + } + + private readonly SKEncodedImageFormat imageFormat = SKEncodedImageFormat.Webp; + private readonly int imageQuality = 80; + + private byte[]? Image(UTexture2D uTexture) + { + var cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile); + + if (cTexture is null) { - 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 []; - } - - try - { - var bitmap = cTexture.ToSkBitmap(); - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - - // var data = bitmap.Encode(SKEncodedImageFormat.Webp, 80); - - // return data.ToArray(); + Console.WriteLine($"Could not extract icon for {uTexture}"); + return null; } - Console.WriteLine($"Could not load {path} as pda"); - return []; + var bitmap = cTexture.ToSkBitmap(); + var data = bitmap.Encode(imageFormat, imageQuality); + + return data.ToArray(); + } + + private byte[]? Image(FSoftObjectPath image) + { + var uTexture = image.Load(); + return Image(uTexture); } } diff --git a/packages/game/game.csproj b/packages/game/game.csproj index 515925ed5..9c2b60559 100644 --- a/packages/game/game.csproj +++ b/packages/game/game.csproj @@ -6,11 +6,13 @@ enable esm true + linux-x64 + \ No newline at end of file diff --git a/packages/game/src/index.ts b/packages/game/src/index.ts index 55045b8a2..5fe16704c 100644 --- a/packages/game/src/index.ts +++ b/packages/game/src/index.ts @@ -1 +1 @@ -export * from "../bin/Debug/net9.0/game"; +export * from "../bin/Debug/net9.0/linux-x64/game";