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-01-07 20:07:45 -06:00
|
|
|
|
2024-08-27 14:40:43 -05:00
|
|
|
export async function shellIcons() {
|
2025-10-23 21:22:21 -05:00
|
|
|
console.log("Building shell icons...");
|
2024-01-07 20:07:45 -06:00
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
using uploader = new AssetUploader("shell icons");
|
2024-01-07 20:07:45 -06:00
|
|
|
const image = sharp(
|
|
|
|
|
await readDVPLFile(
|
2025-10-23 21:22:21 -05:00
|
|
|
`${DATA}/Gfx/Shared/tank-supply/ammunition/big/texture0.packed.webp`
|
|
|
|
|
)
|
2024-01-07 20:07:45 -06:00
|
|
|
);
|
2025-10-23 21:22:21 -05:00
|
|
|
const files = await readdir(
|
|
|
|
|
`${DATA}/Gfx/Shared/tank-supply/ammunition/big`
|
|
|
|
|
).then((files) => files.filter((file) => file.endsWith("_l.txt")));
|
2024-01-07 20:07:45 -06:00
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
for (const file of files) {
|
|
|
|
|
const name = file.match(/(.+)_l\.txt/)![1];
|
|
|
|
|
const sizes = (
|
|
|
|
|
await readStringDVPL(
|
|
|
|
|
`${DATA}/Gfx/Shared/tank-supply/ammunition/big/${file}`
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.split("\n")[4]
|
|
|
|
|
.split(" ")
|
|
|
|
|
.map(Number);
|
2024-01-07 20:07:45 -06:00
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
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`,
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-01-07 20:07:45 -06:00
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
await uploader.flush();
|
2024-01-07 20:07:45 -06:00
|
|
|
}
|