shell icons

This commit is contained in:
tresabhi committed 2026-08-04 14:17:12 -05:00
1 parent 48c4a4c76d
commit 487d149587
3 files changed
+61 -50

No files matched your search

@@ -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);
}