Files
blitzkit/packages/scripts/src/buildAssets/moduleIcons.ts
T

34 lines
892 B
TypeScript
Raw Normal View History

2025-10-23 21:22:21 -05:00
import sharp from "sharp";
import { AssetUploader } from "../core/github/assetUploader";
2025-11-26 13:18:44 -06:00
import { vfs } from "./constants";
2024-01-07 20:07:45 -06:00
2024-08-27 14:40:43 -05:00
export async function moduleIcons() {
2025-10-23 21:22:21 -05:00
console.log("Building module icons...");
2024-01-07 20:07:45 -06:00
2025-10-23 21:22:21 -05:00
using uploader = new AssetUploader("module icons");
2026-04-01 21:40:15 -05:00
const files = await vfs
.dir(`Data/Gfx/UI/ModulesTechTree`)
.then((files) =>
files.filter(
(file) =>
!file.endsWith("@2x.packed.webp") && file.startsWith("vehicle"),
),
);
2024-01-07 20:07:45 -06:00
2025-10-23 21:22:21 -05:00
for (const file of files) {
const nameRaw = file.match(/vehicle(.+)\.packed\.webp/)![1];
const name = nameRaw[0].toLowerCase() + nameRaw.slice(1);
const content = await sharp(
2026-04-01 21:40:15 -05:00
await vfs.file(`Data/Gfx/UI/ModulesTechTree/${file}`),
2025-10-23 21:22:21 -05:00
)
.trim()
.toBuffer();
await uploader.add({
content,
path: `icons/modules/${name}.webp`,
});
}
await uploader.flush();
2024-01-07 20:07:45 -06:00
}