From 85ddedd4819907a856269566381ec5281e076442 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Thu, 4 Jun 2026 20:17:31 -0500 Subject: [PATCH] tank icons --- packages/closed | 2 +- packages/game/JSExport/GameInterface.cs | 44 ++----------------- packages/game/Models/BlitzFileProvider.cs | 1 + packages/i18n/strings/en.json | 3 +- .../index.module.css | 2 +- .../TankopediaLoadout/index.module.css | 8 +++- .../components/TankopediaLoadout/index.tsx | 40 +++++++++++++++-- .../src/pages/[media]/tanks/big/[id].webp.ts | 19 ++++---- .../src/pages/[models]/tanks/[id].glb.ts | 0 .../website-ue/src/tankopedia/tankState.ts | 4 ++ 10 files changed, 65 insertions(+), 58 deletions(-) create mode 100644 packages/website-ue/src/pages/[models]/tanks/[id].glb.ts diff --git a/packages/closed b/packages/closed index e14207178..ebdf6236c 160000 --- a/packages/closed +++ b/packages/closed @@ -1 +1 @@ -Subproject commit e14207178a88a34f77ed441169b1af53d5ad9b04 +Subproject commit ebdf6236ca33c7611464c500d3b83805856d8903 diff --git a/packages/game/JSExport/GameInterface.cs b/packages/game/JSExport/GameInterface.cs index 3b404aaa2..bff285fb0 100644 --- a/packages/game/JSExport/GameInterface.cs +++ b/packages/game/JSExport/GameInterface.cs @@ -24,56 +24,20 @@ public partial class GameInterface private readonly BlitzFileProvider provider; public HashSet files; - public string[] tanksDirectoryNations; public GameInterface(string directory, string map, string temp) { provider = new(directory, map, temp); - 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 HashSet Files => files; - public string[] TanksDirectoryNations => tanksDirectoryNations; - public byte[] TankBigIcon(string tankId, string pdaName) + public byte[] TankBigIcon(string tag) { - foreach (var nation in tanksDirectoryNations) - { - var path = $"Blitz/Content/Tanks/{nation}/{tankId}/{pdaName}.{pdaName}"; - - if (provider.TryLoadPackageObject(path, out var pda)) - { - var icon = pda.Get("BigIcon"); - var uTexture = icon.Load(); - var cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile); - - if (cTexture is null) - { - Console.WriteLine($"No tank big icon found for {tankId} in {pdaName}"); - return []; - } - - var bitmap = cTexture.ToSkBitmap(); - var data = bitmap.Encode(SKEncodedImageFormat.Webp, 80); - - return data.ToArray(); - } - } - - Console.WriteLine($"No tank big icon found for {tankId} in {pdaName}"); - return []; + var pda = provider.Discovered(tag); + var icon = pda.Get("BigIcon"); + return provider.Image(icon); } [GeneratedRegex(@"T_UI_Flag_(\w+)_S")] diff --git a/packages/game/Models/BlitzFileProvider.cs b/packages/game/Models/BlitzFileProvider.cs index 89f4bb777..020edcaf7 100644 --- a/packages/game/Models/BlitzFileProvider.cs +++ b/packages/game/Models/BlitzFileProvider.cs @@ -67,6 +67,7 @@ public partial class BlitzFileProvider : DefaultFileProvider public T Discovered(string path) where T : UObject { + Console.WriteLine(discovered[path]); return LoadPackageObject(discovered[path]); } diff --git a/packages/i18n/strings/en.json b/packages/i18n/strings/en.json index 40a7ed1f1..1158b0849 100644 --- a/packages/i18n/strings/en.json +++ b/packages/i18n/strings/en.json @@ -272,7 +272,8 @@ }, "loadout": { - "state": "State", + "dynamics": "Dynamics", + "status": "Status", "consumables": "Consumables", "modules": "Modules", "equipment": "Equipment", diff --git a/packages/website-ue/src/components/TankopediaCharacteristics/index.module.css b/packages/website-ue/src/components/TankopediaCharacteristics/index.module.css index 6bcd5ea62..a1b25fe43 100644 --- a/packages/website-ue/src/components/TankopediaCharacteristics/index.module.css +++ b/packages/website-ue/src/components/TankopediaCharacteristics/index.module.css @@ -1,5 +1,5 @@ .characteristics-wrapper { - margin: 0 var(--space-4); + margin: var(--space-4); --base-cell-width: 20rem; --group-span: 7; diff --git a/packages/website-ue/src/components/TankopediaLoadout/index.module.css b/packages/website-ue/src/components/TankopediaLoadout/index.module.css index e11c6766b..04a0e04a1 100644 --- a/packages/website-ue/src/components/TankopediaLoadout/index.module.css +++ b/packages/website-ue/src/components/TankopediaLoadout/index.module.css @@ -13,7 +13,13 @@ } } - .states { + .state { + display: flex; + flex-direction: column; + gap: var(--space-2); + } + + .status { display: flex; flex-direction: column; gap: var(--space-2); diff --git a/packages/website-ue/src/components/TankopediaLoadout/index.tsx b/packages/website-ue/src/components/TankopediaLoadout/index.tsx index fd36231d7..07555c654 100644 --- a/packages/website-ue/src/components/TankopediaLoadout/index.tsx +++ b/packages/website-ue/src/components/TankopediaLoadout/index.tsx @@ -55,22 +55,25 @@ export function TankopediaLoadout({ characteristics }: TankopediaLoadoutProps) { return ( <> - {showModules && } + + ); } function State() { const strings = useStrings(); - const status = Tankopedia.use((state) => state.protagonist.status); + + const shell = Tankopedia.use((state) => state.protagonist.shell); + const speed = Tankopedia.use((state) => state.protagonist.speed); return (
- {strings.tanks.loadout.state} + {strings.tanks.loadout.dynamics}
-
+
+ shell: {shell} + speed: {speed} +
+
+ ); +} + +function Status() { + const strings = useStrings(); + const status = Tankopedia.use((state) => state.protagonist.status); + + return ( +
+
+ {strings.tanks.loadout.status} + + { + Tankopedia.mutate((draft) => { + draft.protagonist.consumables = []; + }); + }} + > + + +
+ +
{vehicleStatusKeys.map((group, index) => (
{group.map((key) => ( diff --git a/packages/website-ue/src/pages/[media]/tanks/big/[id].webp.ts b/packages/website-ue/src/pages/[media]/tanks/big/[id].webp.ts index 9629c3007..556d72528 100644 --- a/packages/website-ue/src/pages/[media]/tanks/big/[id].webp.ts +++ b/packages/website-ue/src/pages/[media]/tanks/big/[id].webp.ts @@ -1,24 +1,23 @@ import type { APIContext } from "astro"; import { api } from "../../../../api/dynamic"; -import { - clientUnmountedResponse, - notFoundResponse, -} from "../../../../api/responses"; +import { clientUnmountedResponse } from "../../../../api/responses"; +import { mixStaticPaths } from "../../../../astro/mixStaticPaths"; +import { assertDiscoveryTag } from "../../../../game/assertDiscoveryTag"; import { game } from "../../../../game/game"; import { clientUnmounted } from "../../../../game/unmounted"; import { getStaticPaths as _getStaticPaths } from "../../../[api]/tanks/[id].json"; import { getStaticPaths as __getStaticPaths } from "../../_index"; -import { mixStaticPaths } from "../../../../astro/mixStaticPaths"; export const getStaticPaths = mixStaticPaths(__getStaticPaths, _getStaticPaths); export async function GET({ params }: APIContext) { if (clientUnmounted) return clientUnmountedResponse; - const tank = await api.tank(params.id); - const image = game!.tankBigIcon(params.id, tank.tank!.visual_data); + const item = api.metadata.item(params.id); + const assetDiscovery = item.BlitzStaticAssetsDiscovery(); + const tag = assertDiscoveryTag(assetDiscovery); + const icon = game!.tankBigIcon(tag); + const array = new Uint8Array(icon); - if (image.length === 0) return notFoundResponse; - - return new Response(new Uint8Array(image)); + return new Response(array); } diff --git a/packages/website-ue/src/pages/[models]/tanks/[id].glb.ts b/packages/website-ue/src/pages/[models]/tanks/[id].glb.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/website-ue/src/tankopedia/tankState.ts b/packages/website-ue/src/tankopedia/tankState.ts index 2f1979e74..881a2b090 100644 --- a/packages/website-ue/src/tankopedia/tankState.ts +++ b/packages/website-ue/src/tankopedia/tankState.ts @@ -17,6 +17,10 @@ export interface TankState { speed: number; terrainHardness: TerrainHardness; + isHullRotating: boolean; + isTurretRotating: boolean; + isGunRotating: boolean; + status: Record; }