mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-26 20:19:50 +01:00
feat: optimized tank icon building
This commit is contained in:
1 parent
26852981ba
commit
0692933148
4 files changed
+36
-42
No files matched your search
@@ -25,15 +25,8 @@ if (allTargets || targets?.includes('definitions')) {
|
|||||||
await buildDefinitions();
|
await buildDefinitions();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (allTargets || targets?.includes('tankIcons')) {
|
||||||
allTargets ||
|
await buildTankIcons();
|
||||||
targets?.includes('bigTankIcons') ||
|
|
||||||
targets?.includes('smallTankIcons')
|
|
||||||
) {
|
|
||||||
await buildTankIcons(
|
|
||||||
allTargets || targets?.includes('bigTankIcons'),
|
|
||||||
allTargets || targets?.includes('smallTankIcons'),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allTargets || targets?.includes('scratchedFlags')) {
|
if (allTargets || targets?.includes('scratchedFlags')) {
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ export async function buildTankArmors() {
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
nations.map(async (nation) => {
|
nations.map(async (nation) => {
|
||||||
if (nation !== 'japan') return;
|
|
||||||
|
|
||||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||||
);
|
);
|
||||||
@@ -30,6 +28,8 @@ export async function buildTankArmors() {
|
|||||||
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
|
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
|
||||||
const id = toUniqueId(nation, tank.id);
|
const id = toUniqueId(nation, tank.id);
|
||||||
|
|
||||||
|
if (id !== 26897) return;
|
||||||
|
|
||||||
console.log(`Building armor ${id} @ ${nation}/${tankKey}`);
|
console.log(`Building armor ${id} @ ${nation}/${tankKey}`);
|
||||||
|
|
||||||
const model = await extractArmor(DATA, `${nation}-${tankKey}`);
|
const model = await extractArmor(DATA, `${nation}-${tankKey}`);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export interface TankParameters {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function buildTankIcons(big?: boolean, small?: boolean) {
|
export async function buildTankIcons() {
|
||||||
console.log('Building tank icons...');
|
console.log('Building tank icons...');
|
||||||
|
|
||||||
const changes: FileChange[] = [];
|
const changes: FileChange[] = [];
|
||||||
@@ -31,35 +31,36 @@ export async function buildTankIcons(big?: boolean, small?: boolean) {
|
|||||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const tankIndex in tanks.root) {
|
await Promise.all(
|
||||||
const tank = tanks.root[tankIndex];
|
Object.entries(tanks.root).map(async ([tankIndex, tank]) => {
|
||||||
const nationVehicleId = tank.id;
|
const nationVehicleId = tank.id;
|
||||||
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
|
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
|
||||||
const parameters = await readYAMLDVPL<TankParameters>(
|
const parameters = await readYAMLDVPL<TankParameters>(
|
||||||
`${DATA}/${POI.tankParameters}/${nation}/${tankIndex}.yaml.dvpl`,
|
`${DATA}/${POI.tankParameters}/${nation}/${tankIndex}.yaml.dvpl`,
|
||||||
);
|
);
|
||||||
const small = `${DATA}/${parameters.resourcesPath.smallIconPath
|
const small = `${DATA}/${parameters.resourcesPath.smallIconPath
|
||||||
.replace(/~res:\//, '')
|
.replace(/~res:\//, '')
|
||||||
.replace(/\..+/, '')}.packed.webp.dvpl`;
|
.replace(/\..+/, '')}.packed.webp.dvpl`;
|
||||||
const big = `${DATA}/${parameters.resourcesPath.bigIconPath
|
const big = `${DATA}/${parameters.resourcesPath.bigIconPath
|
||||||
.replace(/~res:\//, '')
|
.replace(/~res:\//, '')
|
||||||
.replace(/\..+/, '')}.packed.webp.dvpl`;
|
.replace(/\..+/, '')}.packed.webp.dvpl`;
|
||||||
|
|
||||||
if (big) {
|
if (big) {
|
||||||
changes.push({
|
changes.push({
|
||||||
content: await readBase64DVPL(big),
|
content: await readBase64DVPL(big),
|
||||||
encoding: 'base64',
|
encoding: 'base64',
|
||||||
path: `icons/tank/big/${id}.webp`,
|
path: `icons/tank/big/${id}.webp`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (small) {
|
if (small) {
|
||||||
changes.push({
|
changes.push({
|
||||||
content: await readBase64DVPL(small),
|
content: await readBase64DVPL(small),
|
||||||
encoding: 'base64',
|
encoding: 'base64',
|
||||||
path: `icons/tank/small/${id}.webp`,
|
path: `icons/tank/small/${id}.webp`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}),
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ export async function buildTankModels() {
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
nations.map(async (nation) => {
|
nations.map(async (nation) => {
|
||||||
if (nation !== 'japan') return;
|
|
||||||
|
|
||||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||||
);
|
);
|
||||||
@@ -45,6 +43,8 @@ export async function buildTankModels() {
|
|||||||
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
|
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
|
||||||
const id = toUniqueId(nation, tank.id);
|
const id = toUniqueId(nation, tank.id);
|
||||||
|
|
||||||
|
if (id !== 26897) return;
|
||||||
|
|
||||||
console.log(`Building model ${id} @ ${nation}/${tankKey}`);
|
console.log(`Building model ${id} @ ${nation}/${tankKey}`);
|
||||||
|
|
||||||
const parameters = await readYAMLDVPL<TankParameters>(
|
const parameters = await readYAMLDVPL<TankParameters>(
|
||||||
|
|||||||
Reference in new issue
Block a user