2025-10-23 21:22:21 -05:00
|
|
|
import { readdir } from "fs/promises";
|
|
|
|
|
import sharp from "sharp";
|
|
|
|
|
import { readDVPLFile } from "../../src/core/blitz/readDVPLFile";
|
|
|
|
|
import { readStringDVPL } from "../../src/core/blitz/readStringDVPL";
|
|
|
|
|
import { AssetUploader } from "../core/github/assetUploader";
|
|
|
|
|
import { DATA } from "./constants";
|
2024-02-13 19:46:34 -06:00
|
|
|
|
2024-08-27 14:40:43 -05:00
|
|
|
export async function boosterIcons() {
|
2025-10-23 21:22:21 -05:00
|
|
|
console.log("Building booster icons...");
|
|
|
|
|
|
|
|
|
|
using uploader = new AssetUploader("booster icons");
|
2024-08-14 14:04:06 -05:00
|
|
|
const boosterFiles = (await readdir(`${DATA}/Gfx/Shared/boosters`)).filter(
|
2025-10-23 21:22:21 -05:00
|
|
|
(file) => !file.includes("@2x.txt") && !file.startsWith("texture0")
|
2024-02-13 19:46:34 -06:00
|
|
|
);
|
|
|
|
|
const image = sharp(
|
2025-10-23 21:22:21 -05:00
|
|
|
await readDVPLFile(`${DATA}/Gfx/Shared/boosters/texture0.packed.webp`)
|
2024-02-13 19:46:34 -06:00
|
|
|
);
|
|
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
for (const file of boosterFiles) {
|
|
|
|
|
const name = file.match(/booster_(.+).txt/)?.[1];
|
|
|
|
|
|
|
|
|
|
if (name === undefined) continue;
|
|
|
|
|
|
|
|
|
|
const sizes = (await readStringDVPL(`${DATA}/Gfx/Shared/boosters/${file}`))
|
|
|
|
|
.split("\n")[4]
|
|
|
|
|
.split(" ")
|
|
|
|
|
.map(Number);
|
|
|
|
|
const content = await image
|
|
|
|
|
.clone()
|
|
|
|
|
.extract({
|
|
|
|
|
left: sizes[0],
|
|
|
|
|
top: sizes[1],
|
|
|
|
|
width: sizes[2],
|
|
|
|
|
height: sizes[3],
|
|
|
|
|
})
|
|
|
|
|
.toBuffer();
|
|
|
|
|
|
|
|
|
|
await uploader.add({
|
|
|
|
|
path: `icons/boosters/${name}.webp`,
|
|
|
|
|
content,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await uploader.flush();
|
2024-02-13 19:46:34 -06:00
|
|
|
}
|