Compare commits

...
11 Commits
Author SHA1 Message Date
TrèsAbhi f6008bd288 feat: image 2026-02-02 20:09:46 -06:00
TrèsAbhi 1776c8fc15 feat: capture some error 2026-02-02 19:57:15 -06:00
TrèsAbhi 99f41b9805 feat: exporting 2026-02-02 19:04:54 -06:00
TrèsAbhi d4f11fc52a make mount sync 2026-02-02 18:17:25 -06:00
TrèsAbhi 750aeb39c9 reinit cue4parse 2026-02-02 18:14:02 -06:00
TrèsAbhi 0f355bc2fc make mount truely syncronous 2026-02-02 18:07:20 -06:00
TrèsAbhi 6ebd3063ed fix: remove oodle sync 2026-02-02 17:37:36 -06:00
TrèsAbhi b070cad92a SynchronousOodleHelper 2026-02-02 17:35:02 -06:00
TrèsAbhi 204fbbff59 feat: some cleanup 2026-02-02 17:28:24 -06:00
TrèsAbhi 98e7760142 feat: some syncronouse stuff 2026-02-02 17:24:20 -06:00
TrèsAbhi 6c1c088d44 feat: custom provider 2026-02-02 17:08:37 -06:00
7 changed files with 118 additions and 106 deletions

No files matched your search

+1
View File
@@ -192,6 +192,7 @@
"searchplayers",
"searchtanks",
"SHAREDEXP",
"Skia",
"SKLLD",
"sluggify",
"smoothstep",
+70
View File
@@ -0,0 +1,70 @@
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;
[JSExport]
public class GameInterface
{
private readonly BlitzFileProvider provider;
public string[] files;
public string[] tanksDirectoryNations;
public GameInterface(string directory)
{
provider = new(directory);
files = [.. provider.Files.Keys];
var tanksBase = "Blitz/Content/Tanks/";
tanksDirectoryNations =
[
.. files
.Where(path => path.StartsWith(tanksBase))
.Select(path => path[tanksBase.Length..])
.Select(path => path.Split('/')[0])
.Where(nation => !nation.EndsWith(".uasset") && nation != "TankStub")
.Distinct(),
];
}
public string[] Files => files;
public string[] TanksDirectoryNations => tanksDirectoryNations;
public byte[] TankBigIcon(string tankId, string pdaName)
{
foreach (var nation in tanksDirectoryNations)
{
var path = $"Blitz/Content/Tanks/{nation}/{tankId}/{pdaName}.{pdaName}";
if (provider.TryLoadPackageObject<UPrimaryDataAsset>(path, out var pda))
{
try
{
return pda.Get<FSoftObjectPath>("BigIcon")
.Load<UTexture2D>()
.Decode(ETexturePlatform.DesktopMobile)!
.ToSkBitmap()
.Encode(SkiaSharp.SKEncodedImageFormat.Webp, 80)
.ToArray();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
else
{
continue;
}
}
throw new FileNotFoundException($"Tank {tankId}/{pdaName} not found in any nation");
}
}
+41
View File
@@ -0,0 +1,41 @@
using System.Runtime.InteropServices;
using CUE4Parse.Compression;
using CUE4Parse.FileProvider;
using CUE4Parse.MappingsProvider;
using CUE4Parse.UE4.Versions;
namespace BlitzKit.Game.Models;
public class BlitzFileProvider : DefaultFileProvider
{
public BlitzFileProvider(string directory)
: base(
directory: directory,
searchOption: SearchOption.AllDirectories,
versions: new(EGame.GAME_UE5_5),
pathComparer: StringComparer.OrdinalIgnoreCase
)
{
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}");
}
}
+4
View File
@@ -1,13 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>BlitzKit.Game</RootNamespace>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NodeApiAssemblyJSModuleType>esm</NodeApiAssemblyJSModuleType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp.NativeAssets.Win32" Version="2.88.9" />
<ProjectReference Include="../cue4parse/CUE4Parse/CUE4Parse.csproj" />
<ProjectReference Include="../cue4parse/CUE4Parse-Conversion/CUE4Parse-Conversion.csproj" />
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.9.19" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.19" />
</ItemGroup>
-104
View File
@@ -1,104 +0,0 @@
using System.Runtime.InteropServices;
using CUE4Parse.Compression;
using CUE4Parse.FileProvider;
using CUE4Parse.MappingsProvider;
using CUE4Parse.UE4.Versions;
using Microsoft.JavaScript.NodeApi;
namespace game.src.classes;
[JSExport]
public class BlitzProvider
{
private readonly DefaultFileProvider provider;
public string[] files;
public string[] tanksDirectoryNations;
public BlitzProvider(string directory)
{
provider = new(
directory: directory,
searchOption: SearchOption.AllDirectories,
versions: new(EGame.GAME_UE5_5),
pathComparer: StringComparer.OrdinalIgnoreCase
)
{
MappingsContainer = new FileUsmapTypeMappingsProvider("../../packages/closed/blitz.usmap"),
};
provider.Initialize();
provider.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}");
// Console.WriteLine(
// provider.Files.Keys.Contains(
// "Blitz/Content/Tanks/USA/A97_M41_Bulldog/PDA_A97_M41_Bulldog.uasset"
// )
// );
// var pda = provider.LoadPackageObject(
// "Blitz/Content/Tanks/USA/A97_M41_Bulldog/PDA_A97_M41_Bulldog.PDA_A97_M41_Bulldog"
// );
// Console.WriteLine(pda);
files = [.. provider.Files.Keys];
Console.WriteLine(string.Join("\n", files));
var tanksBase = "Blitz/Content/Tanks/";
tanksDirectoryNations =
[
.. files
.Where(path => path.StartsWith(tanksBase))
.Select(path => path[tanksBase.Length..])
.Select(path => path.Split('/')[0])
.Where(nation => !nation.EndsWith(".uasset") && nation != "TankStub")
.Distinct(),
];
}
public string[] Files => files;
public string[] TanksDirectoryNations => tanksDirectoryNations;
public byte[] TankBigIcon(string tankId, string pdaName)
{
foreach (var nation in tanksDirectoryNations)
{
var path = $"Blitz/Content/Tanks/{nation}/{tankId}/{pdaName}.{pdaName}";
Console.WriteLine(path);
if (provider.TryLoadPackageObject(path, out var pda))
{
Console.WriteLine(pda);
Console.WriteLine(pda.GetType());
return [];
}
else
{
continue;
}
}
throw new FileNotFoundException($"Tank {tankId}/{pdaName} not found in any nation");
}
}
+1 -1
View File
@@ -1 +1 @@
export * from "../bin/Debug/net9.0/game";
export * from "../bin/Debug/net9.0/win-x64/game";