2024-08-15 21:08:02 -05:00
|
|
|
import sharp from 'sharp';
|
|
|
|
|
import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
|
2024-08-15 13:35:09 -05:00
|
|
|
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
|
2024-08-15 21:08:02 -05:00
|
|
|
import { commitAssets } from '../../src/core/blitzkit/commitAssets';
|
|
|
|
|
import { FileChange } from '../../src/core/blitzkit/commitMultipleFiles';
|
2024-08-15 13:35:09 -05:00
|
|
|
import { DATA } from './constants';
|
2024-08-15 21:08:02 -05:00
|
|
|
import { SquadBattleTypeStyles } from './definitions';
|
2024-08-15 13:35:09 -05:00
|
|
|
|
2024-08-27 14:40:43 -05:00
|
|
|
export async function gameModeBanners() {
|
2024-08-16 12:52:29 -05:00
|
|
|
console.log('Building game mode banners...');
|
|
|
|
|
|
2024-08-15 21:08:02 -05:00
|
|
|
const changes: FileChange[] = [];
|
|
|
|
|
const gameTypeSelectorStyles = await readYAMLDVPL<SquadBattleTypeStyles>(
|
|
|
|
|
`${DATA}/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml.dvpl`,
|
|
|
|
|
);
|
|
|
|
|
const squadBattleTypeStyles = await readYAMLDVPL<SquadBattleTypeStyles>(
|
2024-08-15 13:35:09 -05:00
|
|
|
`${DATA}/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml.dvpl`,
|
|
|
|
|
);
|
2024-08-15 21:08:02 -05:00
|
|
|
const bannerMatches: { name: string; path: string }[] = [];
|
2024-08-15 13:35:09 -05:00
|
|
|
|
2024-08-15 21:08:02 -05:00
|
|
|
for (const match of gameTypeSelectorStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll(
|
|
|
|
|
/eGameMode\.([a-zA-Z]+) -> "~res:([^"]+)"/g,
|
|
|
|
|
)) {
|
|
|
|
|
bannerMatches.push({ name: match[1], path: match[2] });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const match of squadBattleTypeStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll(
|
|
|
|
|
/"(\d+)" -> "battleType\/([a-zA-Z]+)"/g,
|
2024-08-15 13:35:09 -05:00
|
|
|
)) {
|
|
|
|
|
const id = Number(match[1]);
|
2024-08-15 21:08:02 -05:00
|
|
|
const name = match[2];
|
|
|
|
|
let path = bannerMatches.find(
|
|
|
|
|
(bannerMatch) => bannerMatch.name.toLowerCase() === name.toLowerCase(),
|
|
|
|
|
)?.path;
|
2024-08-15 13:35:09 -05:00
|
|
|
|
2024-08-15 21:08:02 -05:00
|
|
|
if (path === undefined) {
|
|
|
|
|
path = `/Gfx/UI/Hangar/GameTypes/battle-type_${name.toLowerCase()}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const content = (
|
|
|
|
|
await sharp(await readDVPLFile(`${DATA}${path}.packed.webp.dvpl`))
|
|
|
|
|
.trim({ background: { r: 0, g: 0, b: 0, alpha: 0 } })
|
|
|
|
|
.toBuffer()
|
|
|
|
|
).toString('base64');
|
|
|
|
|
|
|
|
|
|
changes.push({
|
|
|
|
|
path: `icons/game_mode_banners/${id}.webp`,
|
|
|
|
|
content,
|
|
|
|
|
encoding: 'base64',
|
|
|
|
|
});
|
2024-08-15 13:35:09 -05:00
|
|
|
}
|
2024-08-15 21:08:02 -05:00
|
|
|
|
2024-08-27 14:40:43 -05:00
|
|
|
await commitAssets('game mode banners', changes);
|
2024-08-15 13:35:09 -05:00
|
|
|
}
|