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 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(
|
2025-11-26 13:18:44 -06:00
|
|
|
await vfs.file(
|
2026-04-01 21:40:15 -05:00
|
|
|
`Data/Gfx/Shared/tank-supply/ammunition/big/texture0.packed.webp`,
|
|
|
|
|
),
|
2024-01-07 20:07:45 -06:00
|
|
|
);
|
2026-04-01 21:40:15 -05:00
|
|
|
const files = await vfs
|
|
|
|
|
.dir(`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 = (
|
2026-04-01 21:40:15 -05:00
|
|
|
await vfs.text(`Data/Gfx/Shared/tank-supply/ammunition/big/${file}`)
|
2025-10-23 21:22:21 -05:00
|
|
|
)
|
|
|
|
|
.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
|
|
|
}
|