From 99f41b9805d0965b0e6e866bd3db67cd913e30f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 2 Feb 2026 19:04:54 -0600 Subject: [PATCH] feat: exporting --- packages/game/JSExport/GameInterface.cs | 60 +++++------------------ packages/game/Models/BlitzFileProvider.cs | 22 +++++++++ packages/game/Synchronous/FileProvider.cs | 48 ------------------ packages/game/game.csproj | 1 + 4 files changed, 35 insertions(+), 96 deletions(-) delete mode 100644 packages/game/Synchronous/FileProvider.cs diff --git a/packages/game/JSExport/GameInterface.cs b/packages/game/JSExport/GameInterface.cs index ab98ff5ff..a92cc4bdf 100644 --- a/packages/game/JSExport/GameInterface.cs +++ b/packages/game/JSExport/GameInterface.cs @@ -1,6 +1,8 @@ -using System.Runtime.InteropServices; -using BlitzKit.Game.Models; -using CUE4Parse.Compression; +using BlitzKit.Game.Models; +using CUE4Parse_Conversion.Textures; +using CUE4Parse.UE4.Assets.Exports.Texture; +using CUE4Parse.UE4.Objects.Engine; +using CUE4Parse.UE4.Objects.UObject; using Microsoft.JavaScript.NodeApi; namespace BlitzKit.Game.JSExport; @@ -17,40 +19,6 @@ public class GameInterface { provider = new(directory); - provider.Initialize(); - provider.Mount(); - - Console.WriteLine("Mounted VFS:"); - Console.WriteLine(provider.MountedVfs.Count); - foreach (var vfs in provider.MountedVfs) - { - Console.WriteLine(vfs.Path); - } - - Console.WriteLine("Unloaded VFS:"); - Console.WriteLine(provider.UnloadedVfs.Count); - foreach (var vfs in provider.UnloadedVfs) - { - Console.WriteLine(vfs.Path); - } - - string libraryExtension; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - libraryExtension = "dll"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - libraryExtension = "so"; - } - else - { - throw new Exception("Unsupported OS"); - } - - OodleHelper.DownloadOodleDll($"../../temp/oodle.{libraryExtension}"); - OodleHelper.Initialize($"../../temp/oodle.{libraryExtension}"); - files = [.. provider.Files.Keys]; var tanksBase = "Blitz/Content/Tanks/"; @@ -63,12 +31,6 @@ public class GameInterface .Where(nation => !nation.EndsWith(".uasset") && nation != "TankStub") .Distinct(), ]; - - var pda = provider.LoadPackageObject( - "Blitz/Content/Tanks/USA/A97_M41_Bulldog/PDA_A97_M41_Bulldog.PDA_A97_M41_Bulldog" - ); - - Console.WriteLine(pda); } public string[] Files => files; @@ -80,12 +42,14 @@ public class GameInterface { var path = $"Blitz/Content/Tanks/{nation}/{tankId}/{pdaName}.{pdaName}"; - Console.WriteLine(path); - - if (provider.TryLoadPackageObject(path, out var pda)) + if (provider.TryLoadPackageObject(path, out var pda)) { - Console.WriteLine(pda); - Console.WriteLine(pda.GetType()); + var bigIcon = pda.Get("BigIcon").Load(); + + Console.WriteLine(bigIcon.Format); + Console.WriteLine(bigIcon.GetType()); + + bigIcon.Decode(ETexturePlatform.DesktopMobile); return []; } diff --git a/packages/game/Models/BlitzFileProvider.cs b/packages/game/Models/BlitzFileProvider.cs index cf4f142d6..057567d8d 100644 --- a/packages/game/Models/BlitzFileProvider.cs +++ b/packages/game/Models/BlitzFileProvider.cs @@ -1,3 +1,5 @@ +using System.Runtime.InteropServices; +using CUE4Parse.Compression; using CUE4Parse.FileProvider; using CUE4Parse.MappingsProvider; using CUE4Parse.UE4.Versions; @@ -15,5 +17,25 @@ public class BlitzFileProvider : DefaultFileProvider ) { MappingsContainer = new FileUsmapTypeMappingsProvider("../../packages/closed/blitz.usmap"); + + Initialize(); + Mount(); + + string libraryExtension; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + libraryExtension = "dll"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + libraryExtension = "so"; + } + else + { + throw new Exception("Unsupported OS"); + } + + OodleHelper.DownloadOodleDll($"../../temp/oodle.{libraryExtension}"); + OodleHelper.Initialize($"../../temp/oodle.{libraryExtension}"); } } diff --git a/packages/game/Synchronous/FileProvider.cs b/packages/game/Synchronous/FileProvider.cs deleted file mode 100644 index f460beb85..000000000 --- a/packages/game/Synchronous/FileProvider.cs +++ /dev/null @@ -1,48 +0,0 @@ -using CUE4Parse.FileProvider; -using CUE4Parse.UE4.Exceptions; -using CUE4Parse.UE4.Versions; -using CUE4Parse.Utils; - -namespace BlitzKit.Game.Synchronous; - -public class SynchronousFileProvider( - string directory, - SearchOption searchOption, - VersionContainer? versions = null, - StringComparer? pathComparer = null -) : DefaultFileProvider(directory, searchOption, versions, pathComparer) -{ - public new int Mount() - { - var countNewMounts = 0; - foreach (var reader in _unloadedVfs.Keys) - { - // VerifyGlobalData(reader); - - if (reader.IsEncrypted && CustomEncryption == null || !reader.HasDirectoryIndex) - continue; - - try - { - reader.MountTo(Files, PathComparer); - _unloadedVfs.TryRemove(reader, out _); - _mountedVfs[reader] = null; - Interlocked.Increment(ref countNewMounts); - // return reader; - } - catch (InvalidAesKeyException) - { - // Ignore this - } - catch (Exception e) - { - Log.Warning( - e, - $"Uncaught exception while loading file {reader.Path.SubstringAfterLast('/')}" - ); - } - } - - return countNewMounts; - } -} diff --git a/packages/game/game.csproj b/packages/game/game.csproj index cdae608f1..4f8bcb3e5 100644 --- a/packages/game/game.csproj +++ b/packages/game/game.csproj @@ -9,6 +9,7 @@ +