feat: gamemode consumable and provisions

This commit is contained in:
TrèsAbhi committed 2024-08-14 14:04:06 -05:00
1 parent 94db2c9159
commit 97b251e3a3
14 files changed
+225 -216

No files matched your search

+4 -4
View File
@@ -4,14 +4,14 @@ import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
import { readStringDVPL } from '../../src/core/blitz/readStringDVPL'; import { readStringDVPL } from '../../src/core/blitz/readStringDVPL';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
export async function boosterIcons(production: boolean) { export async function boosterIcons(production: boolean) {
const boosterFiles = (await readdir(`${DATA}/${POI.boosterIcons}`)).filter( const boosterFiles = (await readdir(`${DATA}/Gfx/Shared/boosters`)).filter(
(file) => !file.endsWith('@2x.txt.dvpl') && !file.startsWith('texture0'), (file) => !file.endsWith('@2x.txt.dvpl') && !file.startsWith('texture0'),
); );
const image = sharp( const image = sharp(
await readDVPLFile(`${DATA}/${POI.boosterIcons}/texture0.packed.webp.dvpl`), await readDVPLFile(`${DATA}/Gfx/Shared/boosters/texture0.packed.webp.dvpl`),
); );
const changes: FileChange[] = []; const changes: FileChange[] = [];
@@ -22,7 +22,7 @@ export async function boosterIcons(production: boolean) {
if (name === undefined) return; if (name === undefined) return;
const sizes = ( const sizes = (
await readStringDVPL(`${DATA}/${POI.boosterIcons}/${file}`) await readStringDVPL(`${DATA}/Gfx/Shared/boosters/${file}`)
) )
.split('\n')[4] .split('\n')[4]
.split(' ') .split(' ')
+2 -2
View File
@@ -1,12 +1,12 @@
import { readDVPLFile } from '../../src/core/blitz/readDVPLFile'; import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
export async function camouflageIcons(production: boolean) { export async function camouflageIcons(production: boolean) {
console.log('Building camouflage icons...'); console.log('Building camouflage icons...');
const content = await readDVPLFile( const content = await readDVPLFile(
`${DATA}/${POI.defaultCamoIcon.replace('.webp', '.packed.webp.dvpl')}`, `${DATA}/Gfx/UI/Hangar/IconCamouflage.packed.webp.dvpl`,
).then((content) => content.toString('base64')); ).then((content) => content.toString('base64'));
const changes: FileChange[] = [ const changes: FileChange[] = [
{ {
+5 -3
View File
@@ -3,10 +3,10 @@ import sharp from 'sharp';
import { readDVPLFile } from '../../src/core/blitz/readDVPLFile'; import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
export async function circleFlags(production: boolean) { export async function circleFlags(production: boolean) {
const flags = await readdir(`${DATA}/${POI.flags}`); const flags = await readdir(`${DATA}/Gfx/Lobby/flags`);
const changes = await Promise.all( const changes = await Promise.all(
flags flags
.filter( .filter(
@@ -15,7 +15,9 @@ export async function circleFlags(production: boolean) {
!flag.endsWith('@2x.packed.webp.dvpl'), !flag.endsWith('@2x.packed.webp.dvpl'),
) )
.map(async (flag) => { .map(async (flag) => {
const image = sharp(await readDVPLFile(`${DATA}/${POI.flags}/${flag}`)); const image = sharp(
await readDVPLFile(`${DATA}/Gfx/Lobby/flags/${flag}`),
);
const content = ( const content = (
await image.trim({ threshold: 100 }).toBuffer() await image.trim({ threshold: 100 }).toBuffer()
).toString('base64'); ).toString('base64');
+2 -29
View File
@@ -2,39 +2,12 @@ import { readdir } from 'fs/promises';
import { argv } from 'process'; import { argv } from 'process';
const isDepot = argv.includes('--depot'); const isDepot = argv.includes('--depot');
export const WOTB_WIN32_DEPOT = 444202; export const WOTB_WIN32_DEPOT = 444202;
export const DATA = isDepot export const DATA = isDepot
? await (async () => { ? await (async () => {
const [installationVersion] = await readdir(`depots/${WOTB_WIN32_DEPOT}`); const [installationVersion] = await readdir(`depots/${WOTB_WIN32_DEPOT}`);
return `depots/${WOTB_WIN32_DEPOT}/${installationVersion}/Data`; return `depots/${WOTB_WIN32_DEPOT}/${installationVersion}/Data`;
})() })()
: 'C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz/Data'; : 'C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz/Data';
export const POI = {
vehicleDefinitions: 'XML/item_defs/vehicles',
strings: 'Strings',
cachedStrings: 'https://stufficons.wgcdn.co/localizations/en.yaml',
tankParameters: '3d/Tanks/Parameters',
smallIcons: 'Gfx/UI/BattleScreenHUD/SmallTankIcons',
bigIcons: 'Gfx/UI/BigTankIcons',
flags: 'Gfx/Lobby/flags',
'3d': '3d',
bigShellIcons: 'Gfx/Shared/tank-supply/ammunition/big',
moduleIcons: 'Gfx/UI/ModulesTechTree',
collisionMeshes: '3d/Tanks/CollisionMeshes',
optionalDevices: 'XML/item_defs/vehicles/common/optional_devices.xml',
optionalDeviceSlots:
'XML/item_defs/vehicles/common/optional_device_slots.xml',
optionalDeviceImageMappings:
'UI/Screens3/Lobby/Inventory/OptionalDevices/OptionalDevicesItemImage.style.yaml',
optionalDevicesImage:
'Gfx/UI/InventoryIcons/Big/OptionalDevices/texture0.packed.webp',
consumablesCommon: 'XML/item_defs/vehicles/common/consumables/common.xml',
consumableIcons: 'Gfx/UI/InventoryIcons/Big/Consumables',
provisionIcons: 'Gfx/UI/InventoryIcons/Big/Provisions',
equipmentItemImageMappings:
'UI/Screens3/Lobby/Inventory/Equipment/EquipmentItemImage.style.yaml',
provisionsCommon: 'XML/item_defs/vehicles/common/provisions/common.xml',
defaultCamoIcon: 'Gfx/UI/Hangar/IconCamouflage.webp',
boosterIcons: 'Gfx/Shared/boosters',
} as const;
+156 -128
View File
@@ -1,3 +1,4 @@
import { existsSync } from 'fs';
import sharp from 'sharp'; import sharp from 'sharp';
import { readDVPLFile } from '../../src/core/blitz/readDVPLFile'; import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
import { readStringDVPL } from '../../src/core/blitz/readStringDVPL'; import { readStringDVPL } from '../../src/core/blitz/readStringDVPL';
@@ -5,7 +6,7 @@ import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL'; import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
import { ConsumablesCommon, ProvisionsCommon } from './definitions'; import { ConsumablesCommon, ProvisionsCommon } from './definitions';
interface Mappings { interface Mappings {
@@ -16,149 +17,176 @@ interface Mappings {
}[]; }[];
} }
const listItemsPattern = /<items path="(.+)\.xml"\/>/g;
export async function consumableProvisionIcons(production: boolean) { export async function consumableProvisionIcons(production: boolean) {
console.log('Building consumable and provision icons...'); console.log('Building consumable and provision icons...');
const changes: FileChange[] = []; const changes: FileChange[] = [];
const consumablesTexture = sharp(
await readDVPLFile( const styles = [
`${DATA}/${POI.consumableIcons}/texture0.packed.webp.dvpl`, 'UI/Styles/Lobby/Inventory/InventoryNormalStyles.yaml',
'UI/Screens3/Lobby/Inventory/Equipment/EquipmentItemImage.style.yaml',
'UI/Styles/Lobby/Inventory/Event/InventoryNormalStyles.yaml',
'UI/Screens/Battle/Styles/BattleEquipmentStyles.yaml',
'UI/Styles/Lobby/Inventory/Event/InventoryBigStyles.yaml',
];
const styleSheets = await Promise.all(
styles.map(async (path) =>
Object.values(
(await readYAMLDVPL<Mappings>(`${DATA}/${path}.dvpl`)).StyleSheets,
),
), ),
); ).then((array) => array.flat());
const provisionsTexture = sharp(
await readDVPLFile(
`${DATA}/${POI.provisionIcons}/texture0.packed.webp.dvpl`,
),
);
const equipmentItemImageMappings = await readYAMLDVPL<Mappings>( for (const match of (
`${DATA}/${POI.equipmentItemImageMappings}.dvpl`, await readStringDVPL(
); `${DATA}/XML/item_defs/vehicles/common/consumables/list.xml.dvpl`,
const consumablesCommon = await readXMLDVPL<{ )
root: ConsumablesCommon; ).matchAll(listItemsPattern)) {
}>(`${DATA}/${POI.consumablesCommon}.dvpl`); const consumablesCommon = await readXMLDVPL<{
const provisionsCommon = await readXMLDVPL<{ root: ConsumablesCommon;
root: ProvisionsCommon; }>(
}>(`${DATA}/${POI.provisionsCommon}.dvpl`); `${DATA}/XML/item_defs/vehicles/common/consumables/${match[1]}.xml.dvpl`,
const styleSheets = Object.values(equipmentItemImageMappings.StyleSheets); );
await Promise.all( await Promise.all(
Object.values(consumablesCommon.root).map(async (consumable) => { Object.values(consumablesCommon.root).map(async (consumable) => {
const styleSheet = styleSheets.find((styleSheet) => const styleSheet = styleSheets.find((styleSheet) =>
styleSheet.selectors.includes( styleSheet.selectors.some((selector) =>
`.equipment_item.${consumable.icon} * .equipment-img`, selector.includes(consumable.icon),
), ),
);
if (!styleSheet) {
console.warn(
`No style sheet found for consumable ${consumable.icon}; skipping...`,
); );
return;
}
const configPath = styleSheet.properties['bg-sprite'] if (!styleSheet) {
.replace('~res:/', '') console.warn(
.replace('.psd', '') `No style sheet found for consumable ${consumable.icon}; skipping...`,
.replace('.txt', ''); );
return;
}
if (configPath.startsWith('Gfx/Shared')) { const configPath = styleSheet.properties['bg-sprite']
const image = sharp( .replace('~res:/', '')
await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`), .replace('.psd', '')
.replace('.txt', '');
if (existsSync(`${DATA}/${configPath}.packed.webp.dvpl`)) {
const image = sharp(
await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`),
);
const content = (
await image.trim({ threshold: 100 }).toBuffer()
).toString('base64');
changes.push({
path: `icons/consumables/${consumable.id}.webp`,
encoding: 'base64',
content,
});
} else {
const consumablesTexture = sharp(
await readDVPLFile(
`${`${DATA}/${configPath}`.split('/').slice(0, -1).join('/')}/texture0.packed.webp.dvpl`,
),
);
const sizes = (await readStringDVPL(`${DATA}/${configPath}.txt.dvpl`))
.split('\n')[4]
.split(' ')
.map(Number);
const content = (
await consumablesTexture
.clone()
.extract({
left: sizes[0],
top: sizes[1],
width: sizes[2],
height: sizes[3],
})
.toBuffer()
).toString('base64');
changes.push({
path: `icons/consumables/${consumable.id}.webp`,
encoding: 'base64',
content,
});
}
}),
);
}
for (const match of (
await readStringDVPL(
`${DATA}/XML/item_defs/vehicles/common/provisions/list.xml.dvpl`,
)
).matchAll(listItemsPattern)) {
const provisionsCommon = await readXMLDVPL<{
root: ProvisionsCommon;
}>(`${DATA}/XML/item_defs/vehicles/common/provisions/${match[1]}.xml.dvpl`);
await Promise.all(
Object.values(provisionsCommon.root).map(async (provision) => {
const styleSheet = styleSheets.find((styleSheet) =>
styleSheet.selectors.some((selector) =>
selector.includes(provision.icon),
),
); );
const content = (
await image.trim({ threshold: 100 }).toBuffer()
).toString('base64');
changes.push({ if (!styleSheet) {
path: `icons/consumables/${consumable.id}.webp`, console.warn(
encoding: 'base64', `No style sheet found for provision ${provision.icon}; skipping...`,
content, );
}); return;
} else { }
const sizes = (await readStringDVPL(`${DATA}/${configPath}.txt.dvpl`))
.split('\n')[4]
.split(' ')
.map(Number);
const content = (
await consumablesTexture
.clone()
.extract({
left: sizes[0],
top: sizes[1],
width: sizes[2],
height: sizes[3],
})
.toBuffer()
).toString('base64');
changes.push({ const configPath = styleSheet.properties['bg-sprite']
path: `icons/consumables/${consumable.id}.webp`, .replace('~res:/', '')
encoding: 'base64', .replace('.psd', '')
content, .replace('.txt', '');
});
}
}),
);
await Promise.all( if (existsSync(`${DATA}/${configPath}.packed.webp.dvpl`)) {
Object.values(provisionsCommon.root).map(async (provision) => { const image = sharp(
const styleSheet = styleSheets.find((styleSheet) => await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`),
styleSheet.selectors.includes( );
`.equipment_item.${provision.icon} * .equipment-img`, const content = (
), await image.trim({ threshold: 100 }).toBuffer()
); ).toString('base64');
if (!styleSheet) { changes.push({
console.warn( path: `icons/provisions/${provision.id}.webp`,
`No style sheet found for provision ${provision.icon}; skipping...`, encoding: 'base64',
); content,
return; });
} } else {
const provisionsTexture = sharp(
await readDVPLFile(
`${`${DATA}/${configPath}`.split('/').slice(0, -1).join('/')}/texture0.packed.webp.dvpl`,
),
);
const sizes = (await readStringDVPL(`${DATA}/${configPath}.txt.dvpl`))
.split('\n')[4]
.split(' ')
.map(Number);
const content = (
await provisionsTexture
.clone()
.extract({
left: sizes[0],
top: sizes[1],
width: sizes[2],
height: sizes[3],
})
.toBuffer()
).toString('base64');
const configPath = styleSheet.properties['bg-sprite'] changes.push({
.replace('~res:/', '') path: `icons/provisions/${provision.id}.webp`,
.replace('.psd', '') encoding: 'base64',
.replace('.txt', ''); content,
});
if (configPath.startsWith('Gfx/Shared')) { }
const image = sharp( }),
await readDVPLFile(`${DATA}/${configPath}.packed.webp.dvpl`), );
); }
const content = (
await image.trim({ threshold: 100 }).toBuffer()
).toString('base64');
changes.push({
path: `icons/provisions/${provision.id}.webp`,
encoding: 'base64',
content,
});
} else {
const sizes = (await readStringDVPL(`${DATA}/${configPath}.txt.dvpl`))
.split('\n')[4]
.split(' ')
.map(Number);
const content = (
await provisionsTexture
.clone()
.extract({
left: sizes[0],
top: sizes[1],
width: sizes[2],
height: sizes[3],
})
.toBuffer()
).toString('base64');
changes.push({
path: `icons/provisions/${provision.id}.webp`,
encoding: 'base64',
content,
});
}
}),
);
await commitAssets('consumable and provision icons', changes, production); await commitAssets('consumable and provision icons', changes, production);
} }
+18 -20
View File
@@ -38,7 +38,7 @@ import {
Tier, Tier,
Unlock, Unlock,
} from '../../src/core/blitzkit/tankDefinitions'; } from '../../src/core/blitzkit/tankDefinitions';
import { DATA, POI } from './constants'; import { DATA } from './constants';
import { Avatar } from './skillIcons'; import { Avatar } from './skillIcons';
import { TankParameters } from './tankIcons'; import { TankParameters } from './tankIcons';
@@ -444,18 +444,20 @@ export async function definitions(production: boolean) {
const skillDefinitions: SkillDefinitions = { const skillDefinitions: SkillDefinitions = {
classes: { lightTank: [], mediumTank: [], heavyTank: [], 'AT-SPG': [] }, classes: { lightTank: [], mediumTank: [], heavyTank: [], 'AT-SPG': [] },
}; };
const nations = await readdir(`${DATA}/${POI.vehicleDefinitions}`).then( const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
(nations) => nations.filter((nation) => nation !== 'common'), (nations) => nations.filter((nation) => nation !== 'common'),
); );
const tankStringIdMap: Record<string, number> = {}; const tankStringIdMap: Record<string, number> = {};
const stringsPreInstalled = await readYAMLDVPL<BlitzStrings>( const stringsPreInstalled = await readYAMLDVPL<BlitzStrings>(
`${DATA}/${POI.strings}/en.yaml.dvpl`, `${DATA}/Strings/en.yaml.dvpl`,
); );
const stringsCache = await fetch(POI.cachedStrings) const stringsCache = await fetch(
'https://stufficons.wgcdn.co/localizations/en.yaml',
)
.then((response) => response.text()) .then((response) => response.text())
.then((string) => parseYaml(string) as BlitzStrings); .then((string) => parseYaml(string) as BlitzStrings);
const optionalDevices = await readXMLDVPL<{ root: OptionalDevices }>( const optionalDevices = await readXMLDVPL<{ root: OptionalDevices }>(
`${DATA}/${POI.optionalDevices}.dvpl`, `${DATA}/XML/item_defs/vehicles/common/optional_devices.xml.dvpl`,
); );
const strings = { const strings = {
...stringsPreInstalled, ...stringsPreInstalled,
@@ -463,12 +465,12 @@ export async function definitions(production: boolean) {
}; };
const optionalDeviceSlots = await readXMLDVPL<{ const optionalDeviceSlots = await readXMLDVPL<{
root: OptionalDeviceSlots; root: OptionalDeviceSlots;
}>(`${DATA}/${POI.optionalDeviceSlots}.dvpl`); }>(`${DATA}/XML/item_defs/vehicles/common/optional_device_slots.xml.dvpl`);
const consumables = await readXMLDVPL<{ root: ConsumablesCommon }>( const consumables = await readXMLDVPL<{ root: ConsumablesCommon }>(
`${DATA}/${POI.consumablesCommon}.dvpl`, `${DATA}/XML/item_defs/vehicles/common/consumables/common.xml.dvpl`,
); );
const provisions = await readXMLDVPL<{ root: ProvisionsCommon }>( const provisions = await readXMLDVPL<{ root: ProvisionsCommon }>(
`${DATA}/${POI.provisionsCommon}.dvpl`, `${DATA}/XML/item_defs/vehicles/common/provisions/common.xml.dvpl`,
); );
const avatar = await readXMLDVPL<{ root: Avatar }>( const avatar = await readXMLDVPL<{ root: Avatar }>(
`${DATA}/XML/item_defs/tankmen/avatar.xml.dvpl`, `${DATA}/XML/item_defs/tankmen/avatar.xml.dvpl`,
@@ -506,32 +508,28 @@ export async function definitions(production: boolean) {
await Promise.all( await Promise.all(
nations.map(async (nation) => { nations.map(async (nation) => {
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>( const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`, `${DATA}/XML/item_defs/vehicles/${nation}/list.xml.dvpl`,
); );
const turretList = await readXMLDVPL<{ const turretList = await readXMLDVPL<{
root: TurretDefinitionsList; root: TurretDefinitionsList;
}>( }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/components/turrets.xml.dvpl`, `${DATA}/XML/item_defs/vehicles/${nation}/components/turrets.xml.dvpl`,
); );
const gunList = await readXMLDVPL<{ const gunList = await readXMLDVPL<{
root: GunDefinitionsList; root: GunDefinitionsList;
}>( }>(`${DATA}/XML/item_defs/vehicles/${nation}/components/guns.xml.dvpl`);
`${DATA}/${POI.vehicleDefinitions}/${nation}/components/guns.xml.dvpl`,
);
const shellList = await readXMLDVPL<{ const shellList = await readXMLDVPL<{
root: ShellDefinitionsList; root: ShellDefinitionsList;
}>( }>(`${DATA}/XML/item_defs/vehicles/${nation}/components/shells.xml.dvpl`);
`${DATA}/${POI.vehicleDefinitions}/${nation}/components/shells.xml.dvpl`,
);
const enginesList = await readXMLDVPL<{ const enginesList = await readXMLDVPL<{
root: EngineDefinitionsList; root: EngineDefinitionsList;
}>( }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/components/engines.xml.dvpl`, `${DATA}/XML/item_defs/vehicles/${nation}/components/engines.xml.dvpl`,
); );
const chassisList = await readXMLDVPL<{ const chassisList = await readXMLDVPL<{
root: ChassisDefinitionsList; root: ChassisDefinitionsList;
}>( }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/components/chassis.xml.dvpl`, `${DATA}/XML/item_defs/vehicles/${nation}/components/chassis.xml.dvpl`,
); );
function resolveUnlocks(unlocks?: Unlocks) { function resolveUnlocks(unlocks?: Unlocks) {
@@ -587,10 +585,10 @@ export async function definitions(production: boolean) {
? { type: 'credits', value: tank.price } ? { type: 'credits', value: tank.price }
: { type: 'gold', value: tank.price['#text'] }; : { type: 'gold', value: tank.price['#text'] };
const tankDefinition = await readXMLDVPL<{ root: VehicleDefinitions }>( const tankDefinition = await readXMLDVPL<{ root: VehicleDefinitions }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/${tankKey}.xml.dvpl`, `${DATA}/XML/item_defs/vehicles/${nation}/${tankKey}.xml.dvpl`,
); );
const tankParameters = await readYAMLDVPL<TankParameters>( const tankParameters = await readYAMLDVPL<TankParameters>(
`${DATA}/${POI.tankParameters}/${nation}/${tankKey}.yaml.dvpl`, `${DATA}/3d/Tanks/Parameters/${nation}/${tankKey}.yaml.dvpl`,
); );
const turretOrigin = tankDefinition.root.hull.turretPositions.turret const turretOrigin = tankDefinition.root.hull.turretPositions.turret
.split(' ') .split(' ')
+6 -4
View File
@@ -5,7 +5,7 @@ import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL'; import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
import { OptionalDevices } from './definitions'; import { OptionalDevices } from './definitions';
interface Mappings { interface Mappings {
@@ -22,13 +22,15 @@ export async function equipmentIcons(production: boolean) {
const changes: FileChange[] = []; const changes: FileChange[] = [];
const optionalDevices = await readXMLDVPL<{ root: OptionalDevices }>( const optionalDevices = await readXMLDVPL<{ root: OptionalDevices }>(
`${DATA}/${POI.optionalDevices}.dvpl`, `${DATA}/XML/item_defs/vehicles/common/optional_devices.xml.dvpl`,
); );
const mappings = await readYAMLDVPL<Mappings>( const mappings = await readYAMLDVPL<Mappings>(
`${DATA}/${POI.optionalDeviceImageMappings}.dvpl`, `${DATA}/UI/Screens3/Lobby/Inventory/OptionalDevices/OptionalDevicesItemImage.style.yaml.dvpl`,
); );
const image = sharp( const image = sharp(
await readDVPLFile(`${DATA}/${POI.optionalDevicesImage}.dvpl`), await readDVPLFile(
`${DATA}/Gfx/UI/InventoryIcons/Big/OptionalDevices/texture0.packed.webp.dvpl`,
),
); );
await Promise.all( await Promise.all(
+5 -3
View File
@@ -3,13 +3,13 @@ import sharp from 'sharp';
import { readDVPLFile } from '../../src/core/blitz/readDVPLFile'; import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
export async function moduleIcons(production: boolean) { export async function moduleIcons(production: boolean) {
console.log('Building module icons...'); console.log('Building module icons...');
const changes = await Promise.all( const changes = await Promise.all(
(await readdir(`${DATA}/${POI.moduleIcons}`)) (await readdir(`${DATA}/Gfx/UI/ModulesTechTree`))
.filter( .filter(
(file) => (file) =>
!file.endsWith('@2x.packed.webp.dvpl') && file.startsWith('vehicle'), !file.endsWith('@2x.packed.webp.dvpl') && file.startsWith('vehicle'),
@@ -18,7 +18,9 @@ export async function moduleIcons(production: boolean) {
const nameRaw = file.match(/vehicle(.+)\.packed\.webp\.dvpl/)![1]; const nameRaw = file.match(/vehicle(.+)\.packed\.webp\.dvpl/)![1];
const name = nameRaw[0].toLowerCase() + nameRaw.slice(1); const name = nameRaw[0].toLowerCase() + nameRaw.slice(1);
const content = ( const content = (
await sharp(await readDVPLFile(`${DATA}/${POI.moduleIcons}/${file}`)) await sharp(
await readDVPLFile(`${DATA}/Gfx/UI/ModulesTechTree/${file}`),
)
.trim() .trim()
.toBuffer() .toBuffer()
).toString('base64'); ).toString('base64');
+3 -3
View File
@@ -2,12 +2,12 @@ import { readdir } from 'fs/promises';
import { readBase64DVPL } from '../../src/core/blitz/readBase64DVPL'; import { readBase64DVPL } from '../../src/core/blitz/readBase64DVPL';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
export async function scratchedFlags(production: boolean) { export async function scratchedFlags(production: boolean) {
console.log('Building scratched flags...'); console.log('Building scratched flags...');
const flags = await readdir(`${DATA}/${POI.flags}`); const flags = await readdir(`${DATA}/Gfx/Lobby/flags`);
const changes = await Promise.all( const changes = await Promise.all(
flags flags
.filter( .filter(
@@ -16,7 +16,7 @@ export async function scratchedFlags(production: boolean) {
!flag.endsWith('@2x.packed.webp.dvpl'), !flag.endsWith('@2x.packed.webp.dvpl'),
) )
.map(async (flag) => { .map(async (flag) => {
const content = await readBase64DVPL(`${DATA}/${POI.flags}/${flag}`); const content = await readBase64DVPL(`${DATA}/Gfx/Lobby/flags/${flag}`);
const name = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1]; const name = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1];
return { return {
+6 -4
View File
@@ -4,24 +4,26 @@ import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
import { readStringDVPL } from '../../src/core/blitz/readStringDVPL'; import { readStringDVPL } from '../../src/core/blitz/readStringDVPL';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
export async function shellIcons(production: boolean) { export async function shellIcons(production: boolean) {
console.log('Building shell icons...'); console.log('Building shell icons...');
const image = sharp( const image = sharp(
await readDVPLFile( await readDVPLFile(
`${DATA}/${POI.bigShellIcons}/texture0.packed.webp.dvpl`, `${DATA}/Gfx/Shared/tank-supply/ammunition/big/texture0.packed.webp.dvpl`,
), ),
); );
const changes = await Promise.all( const changes = await Promise.all(
(await readdir(`${DATA}/${POI.bigShellIcons}`)) (await readdir(`${DATA}/Gfx/Shared/tank-supply/ammunition/big`))
.filter((file) => file.endsWith('_l.txt.dvpl')) .filter((file) => file.endsWith('_l.txt.dvpl'))
.map(async (file) => { .map(async (file) => {
const name = file.match(/(.+)_l\.txt\.dvpl/)![1]; const name = file.match(/(.+)_l\.txt\.dvpl/)![1];
const sizes = ( const sizes = (
await readStringDVPL(`${DATA}/${POI.bigShellIcons}/${file}`) await readStringDVPL(
`${DATA}/Gfx/Shared/tank-supply/ammunition/big/${file}`,
)
) )
.split('\n')[4] .split('\n')[4]
.split(' ') .split(' ')
+3 -3
View File
@@ -5,7 +5,7 @@ import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
import { toUniqueId } from '../../src/core/blitz/toUniqueId'; import { toUniqueId } from '../../src/core/blitz/toUniqueId';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
import { VehicleDefinitionList } from './definitions'; import { VehicleDefinitionList } from './definitions';
export async function tankArmors(production: boolean) { export async function tankArmors(production: boolean) {
@@ -13,14 +13,14 @@ export async function tankArmors(production: boolean) {
const changes: FileChange[] = []; const changes: FileChange[] = [];
const nodeIO = new NodeIO(); const nodeIO = new NodeIO();
const nations = await readdir(`${DATA}/${POI.vehicleDefinitions}`).then( const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
(nations) => nations.filter((nation) => nation !== 'common'), (nations) => nations.filter((nation) => nation !== 'common'),
); );
await Promise.all( await Promise.all(
nations.map(async (nation) => { nations.map(async (nation) => {
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>( const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`, `${DATA}/XML/item_defs/vehicles/${nation}/list.xml.dvpl`,
); );
await Promise.all( await Promise.all(
+4 -4
View File
@@ -7,7 +7,7 @@ import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL'; import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
import { VehicleDefinitionList } from './definitions'; import { VehicleDefinitionList } from './definitions';
export interface TankParameters { export interface TankParameters {
@@ -46,14 +46,14 @@ export async function tankIcons(production: boolean) {
console.log('Building tank icons...'); console.log('Building tank icons...');
const changes: FileChange[] = []; const changes: FileChange[] = [];
const nations = await readdir(`${DATA}/${POI.vehicleDefinitions}`).then( const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
(nations) => nations.filter((nation) => nation !== 'common'), (nations) => nations.filter((nation) => nation !== 'common'),
); );
await Promise.all( await Promise.all(
nations.map(async (nation) => { nations.map(async (nation) => {
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>( const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`, `${DATA}/XML/item_defs/vehicles/${nation}/list.xml.dvpl`,
); );
await Promise.all( await Promise.all(
@@ -63,7 +63,7 @@ export async function tankIcons(production: boolean) {
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}/${tankKey}.yaml.dvpl`, `${DATA}/3d/Tanks/Parameters/${nation}/${tankKey}.yaml.dvpl`,
); );
const smallPath = `${DATA}/${parameters.resourcesPath.smallIconPath const smallPath = `${DATA}/${parameters.resourcesPath.smallIconPath
.replace(/~res:\//, '') .replace(/~res:\//, '')
+4 -4
View File
@@ -6,7 +6,7 @@ import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
import { toUniqueId } from '../../src/core/blitz/toUniqueId'; import { toUniqueId } from '../../src/core/blitz/toUniqueId';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles'; import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
import { DATA, POI } from './constants'; import { DATA } from './constants';
import { VehicleDefinitionList } from './definitions'; import { VehicleDefinitionList } from './definitions';
import { TankParameters } from './tankIcons'; import { TankParameters } from './tankIcons';
@@ -14,7 +14,7 @@ export async function tankModels(production: boolean) {
console.log('Building tank models...'); console.log('Building tank models...');
const nodeIO = new NodeIO(); const nodeIO = new NodeIO();
const nations = await readdir(`${DATA}/${POI.vehicleDefinitions}`).then( const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
(nations) => nations.filter((nation) => nation !== 'common'), (nations) => nations.filter((nation) => nation !== 'common'),
); );
@@ -22,7 +22,7 @@ export async function tankModels(production: boolean) {
const nation = nations[nationIndex]; const nation = nations[nationIndex];
const changes: FileChange[] = []; const changes: FileChange[] = [];
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>( const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`, `${DATA}/XML/item_defs/vehicles/${nation}/list.xml.dvpl`,
); );
console.log(`Building models for ${nation}`); console.log(`Building models for ${nation}`);
@@ -33,7 +33,7 @@ export async function tankModels(production: boolean) {
const id = toUniqueId(nation, tank.id); const id = toUniqueId(nation, tank.id);
const parameters = await readYAMLDVPL<TankParameters>( const parameters = await readYAMLDVPL<TankParameters>(
`${DATA}/${POI.tankParameters}/${nation}/${tankKey}.yaml.dvpl`, `${DATA}/3d/Tanks/Parameters/${nation}/${tankKey}.yaml.dvpl`,
); );
const model = await extractModel( const model = await extractModel(
DATA, DATA,
+7 -5
View File
@@ -7,7 +7,7 @@ import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
import { toUniqueId } from '../../src/core/blitz/toUniqueId'; import { toUniqueId } from '../../src/core/blitz/toUniqueId';
import { commitAssets } from '../../src/core/blitzkit/commitAssets'; import { commitAssets } from '../../src/core/blitzkit/commitAssets';
import { VideoDefinitions } from '../../src/core/blitzkit/videos'; import { VideoDefinitions } from '../../src/core/blitzkit/videos';
import { DATA, POI } from './constants'; import { DATA } from './constants';
import { BlitzStrings, botPattern, VehicleDefinitionList } from './definitions'; import { BlitzStrings, botPattern, VehicleDefinitionList } from './definitions';
const youtubers = [ const youtubers = [
@@ -45,13 +45,15 @@ export async function videos(production: boolean) {
}); });
const youtube = google.youtube({ version: 'v3', auth }); const youtube = google.youtube({ version: 'v3', auth });
const nations = await readdir(`${DATA}/${POI.vehicleDefinitions}`).then( const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
(nations) => nations.filter((nation) => nation !== 'common'), (nations) => nations.filter((nation) => nation !== 'common'),
); );
const stringsPreInstalled = await readYAMLDVPL<BlitzStrings>( const stringsPreInstalled = await readYAMLDVPL<BlitzStrings>(
`${DATA}/${POI.strings}/en.yaml.dvpl`, `${DATA}/Strings/en.yaml.dvpl`,
); );
const stringsCache = await fetch(POI.cachedStrings) const stringsCache = await fetch(
'https://stufficons.wgcdn.co/localizations/en.yaml',
)
.then((response) => response.text()) .then((response) => response.text())
.then((string) => parseYaml(string) as BlitzStrings); .then((string) => parseYaml(string) as BlitzStrings);
const strings = { const strings = {
@@ -62,7 +64,7 @@ export async function videos(production: boolean) {
await Promise.all( await Promise.all(
nations.map(async (nation) => { nations.map(async (nation) => {
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>( const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`, `${DATA}/XML/item_defs/vehicles/${nation}/list.xml.dvpl`,
); );
await Promise.all( await Promise.all(