mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { readdir } from 'fs/promises';
|
|
import sharp from 'sharp';
|
|
import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
|
|
import { readStringDVPL } from '../../src/core/blitz/readStringDVPL';
|
|
import { commitAssets } from '../../src/core/blitzkit/commitAssets';
|
|
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
|
|
import { DATA } from './constants';
|
|
|
|
export async function shellIcons(production: boolean) {
|
|
console.log('Building shell icons...');
|
|
|
|
const image = sharp(
|
|
await readDVPLFile(
|
|
`${DATA}/Gfx/Shared/tank-supply/ammunition/big/texture0.packed.webp.dvpl`,
|
|
),
|
|
);
|
|
|
|
const changes = await Promise.all(
|
|
(await readdir(`${DATA}/Gfx/Shared/tank-supply/ammunition/big`))
|
|
.filter((file) => file.endsWith('_l.txt.dvpl'))
|
|
.map(async (file) => {
|
|
const name = file.match(/(.+)_l\.txt\.dvpl/)![1];
|
|
const sizes = (
|
|
await readStringDVPL(
|
|
`${DATA}/Gfx/Shared/tank-supply/ammunition/big/${file}`,
|
|
)
|
|
)
|
|
.split('\n')[4]
|
|
.split(' ')
|
|
.map(Number);
|
|
|
|
return {
|
|
content: (
|
|
await image
|
|
.clone()
|
|
.extract({
|
|
left: sizes[0],
|
|
top: sizes[1],
|
|
width: sizes[2],
|
|
height: sizes[3],
|
|
})
|
|
.toBuffer()
|
|
).toString('base64'),
|
|
encoding: 'base64',
|
|
path: `icons/shells/${name}.webp`,
|
|
} satisfies FileChange;
|
|
}),
|
|
);
|
|
|
|
await commitAssets('shell icons', changes, production);
|
|
}
|