From 487d149587696cd83ccee7894a94924bffead64a Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Tue, 4 Aug 2026 14:17:12 -0500 Subject: [PATCH] shell icons --- packages/scripts/src/buildAssets/constants.ts | 14 ++--- .../scripts/src/buildAssets/shellIcons.ts | 42 -------------- .../[...chunk_api]/icons/shells/[id].webp.ts | 55 +++++++++++++++++++ 3 files changed, 61 insertions(+), 50 deletions(-) delete mode 100644 packages/scripts/src/buildAssets/shellIcons.ts create mode 100644 packages/website/src/pages/[...chunk_api]/icons/shells/[id].webp.ts diff --git a/packages/scripts/src/buildAssets/constants.ts b/packages/scripts/src/buildAssets/constants.ts index 1cc136550..3e5cf4720 100644 --- a/packages/scripts/src/buildAssets/constants.ts +++ b/packages/scripts/src/buildAssets/constants.ts @@ -1,11 +1,9 @@ -import { - AbstractVFS, - assertSecret, - LocalVFS, - MixedVFS, - SteamVFS, - ZipVFS, -} from "@blitzkit/core"; +import { assertSecret } from "@blitzkit/core"; +import { AbstractVFS } from "@blitzkit/core/src/blitzkit/vfs/abstract"; +import { LocalVFS } from "@blitzkit/core/src/blitzkit/vfs/local"; +import { MixedVFS } from "@blitzkit/core/src/blitzkit/vfs/mixed"; +import { SteamVFS } from "@blitzkit/core/src/blitzkit/vfs/steam"; +import { ZipVFS } from "@blitzkit/core/src/blitzkit/vfs/zip"; export const PATCHES_ROOT = "../../temp/patches"; diff --git a/packages/scripts/src/buildAssets/shellIcons.ts b/packages/scripts/src/buildAssets/shellIcons.ts deleted file mode 100644 index fabe047e1..000000000 --- a/packages/scripts/src/buildAssets/shellIcons.ts +++ /dev/null @@ -1,42 +0,0 @@ -import sharp from "sharp"; -import { AssetUploader } from "../core/github/assetUploader"; -import { vfs } from "./constants"; - -export async function shellIcons() { - console.log("Building shell icons..."); - - using uploader = new AssetUploader("shell icons"); - const image = sharp( - await vfs.file( - `Data/Gfx/Shared/tank-supply/ammunition/big/texture0.packed.webp`, - ), - ); - const files = await vfs - .dir(`Data/Gfx/Shared/tank-supply/ammunition/big`) - .then((files) => files.filter((file) => file.endsWith("_l.txt"))); - - for (const file of files) { - const name = file.match(/(.+)_l\.txt/)![1]; - const sizes = ( - await vfs.text(`Data/Gfx/Shared/tank-supply/ammunition/big/${file}`) - ) - .split("\n")[4] - .split(" ") - .map(Number); - - await uploader.add({ - content: await image - .clone() - .extract({ - left: sizes[0], - top: sizes[1], - width: sizes[2], - height: sizes[3], - }) - .toBuffer(), - path: `icons/shells/${name}.webp`, - }); - } - - await uploader.flush(); -} diff --git a/packages/website/src/pages/[...chunk_api]/icons/shells/[id].webp.ts b/packages/website/src/pages/[...chunk_api]/icons/shells/[id].webp.ts new file mode 100644 index 000000000..ad614b1a3 --- /dev/null +++ b/packages/website/src/pages/[...chunk_api]/icons/shells/[id].webp.ts @@ -0,0 +1,55 @@ +import type { APIContext, GetStaticPathsItem } from "astro"; +import sharp from "sharp"; +import { mixStaticPaths } from "../../../../core/blitzkit/mixStaticPaths"; +import { vfs } from "../../../../core/blitzkit/vfs"; +import { getStaticPaths as _getStaticPaths } from "../../_index"; + +export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => { + const paths: GetStaticPathsItem[] = []; + + const image = sharp( + await vfs.file( + `Data/Gfx/Shared/tank-supply/ammunition/big/texture0.packed.webp`, + ), + ); + const files = await vfs + .dir(`Data/Gfx/Shared/tank-supply/ammunition/big`) + .then((files) => files.filter((file) => file.endsWith("_l.txt"))); + + for (const file of files) { + const id = file.match(/(.+)_l\.txt/)![1]; + const sizes = ( + await vfs.text(`Data/Gfx/Shared/tank-supply/ammunition/big/${file}`) + ) + .split("\n")[4] + .split(" ") + .map(Number); + + paths.push({ + params: { id }, + props: { sizes }, + }); + } + + return paths; +}); + +export async function GET({ props }: APIContext<{ sizes: number[] }>) { + const image = sharp( + await vfs.file( + `Data/Gfx/Shared/tank-supply/ammunition/big/texture0.packed.webp`, + ), + ); + const buffer = await image + .clone() + .extract({ + left: props.sizes[0], + top: props.sizes[1], + width: props.sizes[2], + height: props.sizes[3], + }) + .toBuffer(); + const bytes = new Uint8Array(buffer); + + return new Response(bytes); +}