This commit is contained in:
tresabhi committed 2026-05-23 14:25:32 -05:00
1 parent 8a6841adea
commit a8ae806f8b
5 files changed
+46 -42

No files matched your search

+3
View File
@@ -1,3 +1,6 @@
[submodule "packages/closed"] [submodule "packages/closed"]
path = packages/closed path = packages/closed
url = https://github.com/blitzkit/closed.git url = https://github.com/blitzkit/closed.git
[submodule "packages/cue4parse"]
path = packages/cue4parse
url = https://github.com/tresabhi/CUE4Parse.git
Submodule packages/cue4parse added at b42ab66a7a.
+39 -41
View File
@@ -10,6 +10,7 @@ using CUE4Parse.UE4.Objects.Engine;
using CUE4Parse.UE4.Objects.UObject; using CUE4Parse.UE4.Objects.UObject;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.JavaScript.NodeApi; using Microsoft.JavaScript.NodeApi;
using SharpGLTF.Schema2;
using SkiaSharp; using SkiaSharp;
namespace BlitzKit.Game.JSExport; namespace BlitzKit.Game.JSExport;
@@ -79,13 +80,13 @@ public partial class GameInterface
[GeneratedRegex(@"T_UI_Flag_(\w+)_S")] [GeneratedRegex(@"T_UI_Flag_(\w+)_S")]
private static partial Regex FlagNameRegex(); private static partial Regex FlagNameRegex();
public byte[] Flag(string nation) private readonly string flagsPrefix = "Blitz/Content/UI/Textures/Flag/TankCard/";
{
var flagsBase = "Blitz/Content/UI/Textures/Flag/TankCard/";
foreach (var path in provider.Files.Keys) public byte[]? Flag(string nation)
{ {
if (!path.StartsWith(flagsBase)) foreach (var path in files)
{
if (!path.StartsWith(flagsPrefix))
{ {
continue; continue;
} }
@@ -100,34 +101,23 @@ public partial class GameInterface
{ {
if (provider.TryLoadPackageObject<UTexture2D>($"{path}.{fileName}", out var uTexture)) if (provider.TryLoadPackageObject<UTexture2D>($"{path}.{fileName}", out var uTexture))
{ {
CTexture? cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile); return Image(uTexture);
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();
} }
Console.WriteLine($"No flag found for {nation}"); Console.WriteLine($"No flag found for {nation}");
return []; return null;
} }
} }
Console.WriteLine($"No flag found for {nation}"); Console.WriteLine($"No flag found for {nation}");
return []; return null;
} }
private static readonly string equipmentPDAPrefix = private static readonly string equipmentPDAPrefix =
"Blitz/Content/TanksStuff/Equipment/PDA_Equipment"; "Blitz/Content/TanksStuff/Equipment/PDA_Equipment";
private static readonly string equipmentPDASuffix = ".uasset"; private static readonly string equipmentPDASuffix = ".uasset";
public byte[] EquipmentIcon(string[] names) public byte[]? EquipmentIcon(string[] names)
{ {
List<string> candidates = []; List<string> candidates = [];
@@ -154,38 +144,46 @@ public partial class GameInterface
if (candidate is null) if (candidate is null)
{ {
Console.WriteLine($"No equipment pda found for {string.Join(", ", names)}"); Console.WriteLine($"No equipment pda found for {string.Join(", ", names)}");
return []; return null;
} }
var path = $"{candidate}.{Path.GetFileNameWithoutExtension(candidate)}"; var pda = PDA(candidate);
if (provider.TryLoadPackageObject<UPrimaryDataAsset>(path, out var pda))
{
var icon = pda.Get<FSoftObjectPath>("Icon"); var icon = pda.Get<FSoftObjectPath>("Icon");
var uTexture = icon.Load<UTexture2D>();
return Image(icon);
}
private UPrimaryDataAsset PDA(string path)
{
var name = Path.GetFileNameWithoutExtension(path);
var fullPath = $"{path}.{name}";
var pda = provider.LoadPackageObject<UPrimaryDataAsset>(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); var cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile);
if (cTexture is null) if (cTexture is null)
{ {
Console.WriteLine($"Could not extract icon for {path}"); Console.WriteLine($"Could not extract icon for {uTexture}");
return []; return null;
} }
try
{
var bitmap = cTexture.ToSkBitmap(); var bitmap = cTexture.ToSkBitmap();
var data = bitmap.Encode(imageFormat, imageQuality);
return data.ToArray();
} }
catch (Exception ex)
private byte[]? Image(FSoftObjectPath image)
{ {
Console.WriteLine(ex); var uTexture = image.Load<UTexture2D>();
} return Image(uTexture);
// var data = bitmap.Encode(SKEncodedImageFormat.Webp, 80);
// return data.ToArray();
}
Console.WriteLine($"Could not load {path} as pda");
return [];
} }
} }
+2
View File
@@ -6,11 +6,13 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<NodeApiAssemblyJSModuleType>esm</NodeApiAssemblyJSModuleType> <NodeApiAssemblyJSModuleType>esm</NodeApiAssemblyJSModuleType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="../cue4parse/CUE4Parse/CUE4Parse.csproj" /> <ProjectReference Include="../cue4parse/CUE4Parse/CUE4Parse.csproj" />
<ProjectReference Include="../cue4parse/CUE4Parse-Conversion/CUE4Parse-Conversion.csproj" /> <ProjectReference Include="../cue4parse/CUE4Parse-Conversion/CUE4Parse-Conversion.csproj" />
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.9.19" /> <PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.9.19" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.19" /> <PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.19" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.9" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+1 -1
View File
@@ -1 +1 @@
export * from "../bin/Debug/net9.0/game"; export * from "../bin/Debug/net9.0/linux-x64/game";