mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: missing tank icon handling
This commit is contained in:
1 parent
2504833a29
commit
fd6b69edc1
3 files changed
+20
-13
No files matched your search
@@ -4,6 +4,7 @@ using CUE4Parse.UE4.Assets.Exports.Texture;
|
|||||||
using CUE4Parse.UE4.Objects.Engine;
|
using CUE4Parse.UE4.Objects.Engine;
|
||||||
using CUE4Parse.UE4.Objects.UObject;
|
using CUE4Parse.UE4.Objects.UObject;
|
||||||
using Microsoft.JavaScript.NodeApi;
|
using Microsoft.JavaScript.NodeApi;
|
||||||
|
using SkiaSharp;
|
||||||
|
|
||||||
namespace BlitzKit.Game.JSExport;
|
namespace BlitzKit.Game.JSExport;
|
||||||
|
|
||||||
@@ -44,20 +45,20 @@ public class GameInterface
|
|||||||
|
|
||||||
if (provider.TryLoadPackageObject<UPrimaryDataAsset>(path, out var pda))
|
if (provider.TryLoadPackageObject<UPrimaryDataAsset>(path, out var pda))
|
||||||
{
|
{
|
||||||
try
|
FSoftObjectPath objectPath = pda.Get<FSoftObjectPath>("BigIcon");
|
||||||
|
UTexture2D uTexture = objectPath.Load<UTexture2D>();
|
||||||
|
CTexture? cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile);
|
||||||
|
|
||||||
|
if (cTexture is null)
|
||||||
{
|
{
|
||||||
return pda.Get<FSoftObjectPath>("BigIcon")
|
continue;
|
||||||
.Load<UTexture2D>()
|
|
||||||
.Decode(ETexturePlatform.DesktopMobile)!
|
|
||||||
.ToSkBitmap()
|
|
||||||
.Encode(SkiaSharp.SKEncodedImageFormat.Webp, 80)
|
|
||||||
.ToArray();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e);
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SKBitmap bitmap = cTexture.ToSkBitmap();
|
||||||
|
SKData data = bitmap.Encode(SKEncodedImageFormat.Webp, 80);
|
||||||
|
byte[] bytes = data.ToArray();
|
||||||
|
|
||||||
|
return bytes;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -65,6 +66,6 @@ public class GameInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new FileNotFoundException($"Tank {tankId}/{pdaName} not found in any nation");
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<Solution>
|
||||||
|
<Project Path="game.csproj" />
|
||||||
|
</Solution>
|
||||||
@@ -7,5 +7,8 @@ export { getStaticPaths } from "./[id].pb";
|
|||||||
export async function GET({ params }: APIContext<never, { id: string }>) {
|
export async function GET({ params }: APIContext<never, { id: string }>) {
|
||||||
const tank = await api.tank(params.id);
|
const tank = await api.tank(params.id);
|
||||||
const image = game.tankBigIcon(params.id, tank.tank!.visual_data);
|
const image = game.tankBigIcon(params.id, tank.tank!.visual_data);
|
||||||
|
|
||||||
|
if (image.length === 0) return new Response(null, { status: 404 });
|
||||||
|
|
||||||
return new Response(new Uint8Array(image));
|
return new Response(new Uint8Array(image));
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user