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

47 lines
1.4 KiB
TypeScript
Raw Normal View History

2025-10-13 23:15:32 -05:00
import { TankClass } from "@blitzkit/core";
import sharp from "sharp";
import { readDVPLFile } from "../core/blitz/readDVPLFile";
import { readXMLDVPL } from "../core/blitz/readXMLDVPL";
2025-10-23 21:22:21 -05:00
import { AssetUploader } from "../core/github/assetUploader";
2025-10-13 23:15:32 -05:00
import { DATA } from "./constants";
2024-03-31 18:17:48 -05:00
interface SkillIcon {
name: string;
state: number;
}
2024-03-31 18:24:19 -05:00
export interface Avatar {
2024-03-31 18:17:48 -05:00
roles: unknown;
skillsByClasses: Record<TankClass, string>;
skills: {
[name: string]: {
2024-03-31 18:24:19 -05:00
userString: string;
effectDescription: string;
tipDescription: string;
2024-03-31 18:17:48 -05:00
icon: SkillIcon | SkillIcon[];
2025-10-13 23:15:32 -05:00
type: "continuous" | "trigger";
2024-03-31 18:17:48 -05:00
};
};
}
2024-08-27 14:40:43 -05:00
export async function skillIcons() {
2025-10-13 23:15:32 -05:00
console.log("Building skill icons...");
2024-03-31 18:17:48 -05:00
const avatar = await readXMLDVPL<{ root: Avatar }>(
2025-10-13 23:15:32 -05:00
`${DATA}/XML/item_defs/tankmen/avatar.xml`
2024-03-31 18:17:48 -05:00
);
2025-10-23 21:22:21 -05:00
using uploader = new AssetUploader("skill icons");
2024-03-31 18:17:48 -05:00
2025-10-23 21:22:21 -05:00
for (const key in avatar.root.skills) {
const skill = avatar.root.skills[key];
const icon = Array.isArray(skill.icon) ? skill.icon[0] : skill.icon;
const name = icon.name.split("/").at(-1)!.replace(/_\d$/, "");
const path = `${DATA}${icon.name.replace("~res:", "")}.packed.webp`;
const image = sharp(await readDVPLFile(path)).trim();
const content = await image.toBuffer();
2024-03-31 18:17:48 -05:00
2025-10-23 21:22:21 -05:00
await uploader.add({ content, path: `icons/skills/${name}.webp` });
}
await uploader.flush();
2024-03-31 18:17:48 -05:00
}