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

73 lines
1.9 KiB
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-08-16 21:08:50 -05:00
2024-08-27 14:40:43 -05:00
export async function flags() {
2025-10-23 21:22:21 -05:00
console.log("Building flags...");
2024-08-16 21:08:50 -05:00
2025-10-23 21:22:21 -05:00
using uploader = new AssetUploader("flags");
2026-04-01 21:40:15 -05:00
const circleFiles = await vfs
.dir(`Data/Gfx/Lobby/flags`)
.then((files) =>
files.filter(
(flag) =>
flag.startsWith("flag_profile-stat_") &&
!flag.endsWith("@2x.packed.webp"),
),
2025-11-26 13:18:44 -06:00
);
2026-04-01 21:40:15 -05:00
const scratchedFiles = await vfs
.dir(`Data/Gfx/Lobby/flags`)
.then((files) =>
files.filter(
2025-10-23 21:22:21 -05:00
(flag) =>
flag.startsWith("flag_tutor-tank_") &&
2026-04-01 21:40:15 -05:00
!flag.endsWith("@2x.packed.webp"),
),
);
const fadedFiles = await vfs
.dir(`Data/Gfx/Lobby/flags`)
.then((files) =>
files.filter(
(flag) =>
flag.startsWith("flag_filter_") && flag.endsWith("@2x.packed.webp"),
),
);
2024-08-16 21:08:50 -05:00
2025-10-23 21:22:21 -05:00
for (const flag of circleFiles) {
2025-11-26 13:18:44 -06:00
const image = sharp(await vfs.file(`Data/Gfx/Lobby/flags/${flag}`));
2025-10-23 21:22:21 -05:00
const content = await image.trim({ threshold: 100 }).toBuffer();
const name = flag.match(/flag_profile-stat_(.+)\.packed\.webp/)![1];
2024-08-16 21:08:50 -05:00
2025-10-23 21:22:21 -05:00
uploader.add({
content,
path: `flags/circle/${name}.webp`,
});
}
2024-08-16 21:08:50 -05:00
2025-10-23 21:22:21 -05:00
for (const flag of scratchedFiles) {
2025-11-26 13:18:44 -06:00
const content = await vfs.file(`Data/Gfx/Lobby/flags/${flag}`);
2025-10-23 21:22:21 -05:00
const name = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1];
2024-08-16 21:08:50 -05:00
2025-10-23 21:22:21 -05:00
uploader.add({
path: `flags/scratched/${name}.webp`,
content,
});
}
for (const flag of fadedFiles) {
2026-04-01 21:40:15 -05:00
const content = await sharp(await vfs.file(`Data/Gfx/Lobby/flags/${flag}`))
2025-10-23 21:22:21 -05:00
.trim({
threshold: 100,
background: { r: 0, g: 0, b: 0, alpha: 0 },
})
.toBuffer();
const name = flag.match(/flag_filter_(.+)@2x\.packed\.webp/)![1];
uploader.add({
content,
path: `flags/fade_small/${name}.webp`,
});
}
await uploader.flush();
2024-08-16 21:08:50 -05:00
}