2025-10-13 23:15:32 -05:00
|
|
|
import { TankClass } from "@blitzkit/core";
|
|
|
|
|
import sharp from "sharp";
|
2025-10-23 21:22:21 -05:00
|
|
|
import { AssetUploader } from "../core/github/assetUploader";
|
2025-11-26 13:18:44 -06:00
|
|
|
import { vfs } 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
|
|
|
|
2025-11-26 13:18:44 -06:00
|
|
|
const avatar = await vfs.xml<{ root: Avatar }>(
|
2026-04-01 21:40:15 -05:00
|
|
|
`Data/XML/item_defs/tankmen/avatar.xml`,
|
2024-03-31 18:17:48 -05:00
|
|
|
);
|
2025-12-10 17:31:03 -06:00
|
|
|
const 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$/, "");
|
2025-11-26 13:18:44 -06:00
|
|
|
const path = `Data${icon.name.replace("~res:", "")}.packed.webp`;
|
|
|
|
|
const image = sharp(await vfs.file(path)).trim();
|
2025-10-23 21:22:21 -05:00
|
|
|
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
|
|
|
}
|