mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
fix: re add blitzkit tank icons
This commit is contained in:
1 parent
db74058075
commit
d9fcbd028b
5 files changed
+135
-34
No files matched your search
@@ -0,0 +1,44 @@
|
|||||||
|
import { BLITZKIT_TANK_ICON_SIZE, fetchTankDefinitions } from '@blitzkit/core';
|
||||||
|
import { exec } from 'child_process';
|
||||||
|
import { launch } from 'puppeteer';
|
||||||
|
import sharp from 'sharp';
|
||||||
|
import { commitAssets } from '../core/github/commitAssets';
|
||||||
|
import { FileChange } from '../core/github/commitMultipleFiles';
|
||||||
|
|
||||||
|
export async function blitzkitTankIcons() {
|
||||||
|
console.log('Building tank icons...');
|
||||||
|
|
||||||
|
const child = exec('cd ../.. && bun dev:website');
|
||||||
|
const browser = await launch();
|
||||||
|
const page = await browser.newPage();
|
||||||
|
const tanks = Object.values(await fetchTankDefinitions());
|
||||||
|
const files: FileChange[] = [];
|
||||||
|
|
||||||
|
let index = 0;
|
||||||
|
for (const { id, name } of tanks) {
|
||||||
|
await page.setViewport({
|
||||||
|
width: BLITZKIT_TANK_ICON_SIZE.width - 1,
|
||||||
|
height: BLITZKIT_TANK_ICON_SIZE.height,
|
||||||
|
});
|
||||||
|
await page.goto(`http://localhost:4321/api/tankopedia/tank-icon/${id}/`, {
|
||||||
|
waitUntil: 'networkidle0',
|
||||||
|
});
|
||||||
|
const screenshot = await page.screenshot({
|
||||||
|
type: 'webp',
|
||||||
|
omitBackground: true,
|
||||||
|
});
|
||||||
|
const content = await sharp(screenshot).trim({ threshold: 100 }).toBuffer();
|
||||||
|
|
||||||
|
index++;
|
||||||
|
console.log(
|
||||||
|
`Rendered ${id} (${name}) ${((index / tanks.length) * 100).toFixed(2)}%`,
|
||||||
|
);
|
||||||
|
|
||||||
|
files.push({ path: `icons/tanks/blitzkit/${id}.webp`, content });
|
||||||
|
}
|
||||||
|
|
||||||
|
child.kill('SIGHUP');
|
||||||
|
await browser.close();
|
||||||
|
|
||||||
|
await commitAssets('tank icons', files);
|
||||||
|
}
|
||||||
@@ -39,9 +39,9 @@ import { readStringDVPL } from '../core/blitz/readStringDVPL';
|
|||||||
import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
|
import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
|
||||||
import { readYAMLDVPL } from '../core/blitz/readYAMLDVPL';
|
import { readYAMLDVPL } from '../core/blitz/readYAMLDVPL';
|
||||||
import { commitAssets } from '../core/github/commitAssets';
|
import { commitAssets } from '../core/github/commitAssets';
|
||||||
|
import { TankParameters } from './blitzkitTankIcons';
|
||||||
import { DATA } from './constants';
|
import { DATA } from './constants';
|
||||||
import { Avatar } from './skillIcons';
|
import { Avatar } from './skillIcons';
|
||||||
import { TankParameters } from './tankIcons';
|
|
||||||
|
|
||||||
function parseResearchCost(raw: number | string) {
|
function parseResearchCost(raw: number | string) {
|
||||||
if (typeof raw === 'number') {
|
if (typeof raw === 'number') {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const targets = argv
|
|||||||
?.split('=')[1]
|
?.split('=')[1]
|
||||||
.split(',');
|
.split(',');
|
||||||
|
|
||||||
|
import { blitzkitTankIcons } from './blitzkitTankIcons';
|
||||||
import { boosterIcons } from './boosterIcons';
|
import { boosterIcons } from './boosterIcons';
|
||||||
import { camouflageIcons } from './camouflageIcons';
|
import { camouflageIcons } from './camouflageIcons';
|
||||||
import { consumableProvisionIcons } from './consumableProvisionIcons';
|
import { consumableProvisionIcons } from './consumableProvisionIcons';
|
||||||
@@ -28,7 +29,6 @@ if (!targets && !allTargets) throw new Error('No target(s) specified');
|
|||||||
|
|
||||||
const methods = [
|
const methods = [
|
||||||
definitions,
|
definitions,
|
||||||
tankIcons,
|
|
||||||
tankModels,
|
tankModels,
|
||||||
tankArmors,
|
tankArmors,
|
||||||
gameModeBanners,
|
gameModeBanners,
|
||||||
@@ -41,6 +41,8 @@ const methods = [
|
|||||||
consumableProvisionIcons,
|
consumableProvisionIcons,
|
||||||
camouflageIcons,
|
camouflageIcons,
|
||||||
boosterIcons,
|
boosterIcons,
|
||||||
|
tankIcons,
|
||||||
|
blitzkitTankIcons,
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const method of methods) {
|
for (const method of methods) {
|
||||||
|
|||||||
@@ -1,44 +1,99 @@
|
|||||||
import { BLITZKIT_TANK_ICON_SIZE, fetchTankDefinitions } from '@blitzkit/core';
|
import { NATION_IDS } from '@blitzkit/core';
|
||||||
import { exec } from 'child_process';
|
import { readdir } from 'fs/promises';
|
||||||
import { launch } from 'puppeteer';
|
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
|
import { Vector3Tuple } from 'three';
|
||||||
|
import { readDVPLFile } from '../core/blitz/readDVPLFile';
|
||||||
|
import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
|
||||||
|
import { readYAMLDVPL } from '../core/blitz/readYAMLDVPL';
|
||||||
import { commitAssets } from '../core/github/commitAssets';
|
import { commitAssets } from '../core/github/commitAssets';
|
||||||
import { FileChange } from '../core/github/commitMultipleFiles';
|
import { FileChange } from '../core/github/commitMultipleFiles';
|
||||||
|
import { DATA } from './constants';
|
||||||
|
import { VehicleDefinitionList } from './definitions';
|
||||||
|
|
||||||
|
export interface TankParameters {
|
||||||
|
resourcesPath: {
|
||||||
|
smallIconPath: string;
|
||||||
|
bigIconPath: string;
|
||||||
|
blitzModelPath: string;
|
||||||
|
};
|
||||||
|
collision: {
|
||||||
|
[key: string]: {
|
||||||
|
points: Vector3Tuple;
|
||||||
|
bbox: {
|
||||||
|
min: Vector3Tuple;
|
||||||
|
max: Vector3Tuple;
|
||||||
|
};
|
||||||
|
averageThickness?: Record<string, number>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
maskSlice?: {
|
||||||
|
[key: string]:
|
||||||
|
| {
|
||||||
|
enabled: boolean;
|
||||||
|
planePosition: Vector3Tuple;
|
||||||
|
planeNormal: Vector3Tuple;
|
||||||
|
planeAxis: Vector3Tuple;
|
||||||
|
frustumConeBaseRadius: number;
|
||||||
|
frustumConeAngleDegrees: number;
|
||||||
|
planeSliceMode: number;
|
||||||
|
frustumConeSliceMode: number;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export async function tankIcons() {
|
export async function tankIcons() {
|
||||||
console.log('Building tank icons...');
|
console.log('Building tank icons...');
|
||||||
|
|
||||||
const child = exec('cd ../.. && bun dev:website');
|
const changes: FileChange[] = [];
|
||||||
const browser = await launch();
|
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
|
||||||
const page = await browser.newPage();
|
(nations) => nations.filter((nation) => nation !== 'common'),
|
||||||
const tanks = Object.values(await fetchTankDefinitions());
|
);
|
||||||
const files: FileChange[] = [];
|
|
||||||
|
|
||||||
let index = 0;
|
await Promise.all(
|
||||||
for (const { id, name } of tanks) {
|
nations.map(async (nation) => {
|
||||||
await page.setViewport({
|
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
width: BLITZKIT_TANK_ICON_SIZE.width - 1,
|
`${DATA}/XML/item_defs/vehicles/${nation}/list.xml.dvpl`,
|
||||||
height: BLITZKIT_TANK_ICON_SIZE.height,
|
);
|
||||||
});
|
|
||||||
await page.goto(`http://localhost:4321/api/tankopedia/tank-icon/${id}/`, {
|
|
||||||
waitUntil: 'networkidle0',
|
|
||||||
});
|
|
||||||
const screenshot = await page.screenshot({
|
|
||||||
type: 'webp',
|
|
||||||
omitBackground: true,
|
|
||||||
});
|
|
||||||
const content = await sharp(screenshot).trim({ threshold: 100 }).toBuffer();
|
|
||||||
|
|
||||||
index++;
|
await Promise.all(
|
||||||
console.log(
|
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
|
||||||
`Rendered ${id} (${name}) ${((index / tanks.length) * 100).toFixed(2)}%`,
|
if (tankKey.includes('tutorial_bot')) return;
|
||||||
);
|
|
||||||
|
|
||||||
files.push({ path: `icons/tanks/blitzkit/${id}.webp`, content });
|
const nationVehicleId = tank.id;
|
||||||
}
|
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
|
||||||
|
const parameters = await readYAMLDVPL<TankParameters>(
|
||||||
|
`${DATA}/3d/Tanks/Parameters/${nation}/${tankKey}.yaml.dvpl`,
|
||||||
|
);
|
||||||
|
const smallPath = `${DATA}/${parameters.resourcesPath.smallIconPath
|
||||||
|
.replace(/~res:\//, '')
|
||||||
|
.replace(/\..+/, '')}.packed.webp.dvpl`;
|
||||||
|
const bigPath = `${DATA}/${parameters.resourcesPath.bigIconPath
|
||||||
|
.replace(/~res:\//, '')
|
||||||
|
.replace(/\..+/, '')}.packed.webp.dvpl`;
|
||||||
|
const big = await sharp(await readDVPLFile(bigPath))
|
||||||
|
.trim()
|
||||||
|
.toBuffer();
|
||||||
|
const small = await sharp(await readDVPLFile(smallPath))
|
||||||
|
.trim()
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
child.kill('SIGHUP');
|
if (big) {
|
||||||
await browser.close();
|
changes.push({
|
||||||
|
content: big,
|
||||||
|
path: `icons/tanks/big/${id}.webp`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (small) {
|
||||||
|
changes.push({
|
||||||
|
content: small,
|
||||||
|
path: `icons/tanks/small/${id}.webp`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
await commitAssets('tank icons', files);
|
await commitAssets('tank icons', changes);
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,9 @@ import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
|
|||||||
import { readYAMLDVPL } from '../core/blitz/readYAMLDVPL';
|
import { readYAMLDVPL } from '../core/blitz/readYAMLDVPL';
|
||||||
import { commitAssets } from '../core/github/commitAssets';
|
import { commitAssets } from '../core/github/commitAssets';
|
||||||
import { FileChange } from '../core/github/commitMultipleFiles';
|
import { FileChange } from '../core/github/commitMultipleFiles';
|
||||||
|
import { TankParameters } from './blitzkitTankIcons';
|
||||||
import { DATA } from './constants';
|
import { DATA } from './constants';
|
||||||
import { VehicleDefinitionList } from './definitions';
|
import { VehicleDefinitionList } from './definitions';
|
||||||
import { TankParameters } from './tankIcons';
|
|
||||||
|
|
||||||
export async function tankModels() {
|
export async function tankModels() {
|
||||||
console.log('Building tank models...');
|
console.log('Building tank models...');
|
||||||
|
|||||||
Reference in new issue
Block a user