mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 12:24:55 +01:00
migrate mixer
This commit is contained in:
49 files changed
+659
-859
No files matched your search
@@ -127,35 +127,35 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
.then((files) => files.filter((nation) => nation !== "common"));
|
||||
|
||||
this.optionalDevices = await this.vfs.xml<{ root: OptionalDevices }>(
|
||||
"Data/XML/item_defs/vehicles/common/optional_devices.xml",
|
||||
"Data/XML/item_defs/vehicles/common/optional_devices.xml"
|
||||
);
|
||||
this.optionalDeviceSlots = await this.vfs.xml<{
|
||||
root: OptionalDeviceSlots;
|
||||
}>("Data/XML/item_defs/vehicles/common/optional_device_slots.xml");
|
||||
this.tankmenAvatar = await this.vfs.xml<{ root: TankmenAvatar }>(
|
||||
"Data/XML/item_defs/tankmen/avatar.xml",
|
||||
"Data/XML/item_defs/tankmen/avatar.xml"
|
||||
);
|
||||
this.mapsYaml = await this.vfs.yaml<MapsYaml>("Data/maps.yaml");
|
||||
this.camouflagesXml = await this.vfs.xml<{ root: CamouflagesXml }>(
|
||||
"Data/XML/item_defs/vehicles/common/camouflages.xml",
|
||||
"Data/XML/item_defs/vehicles/common/camouflages.xml"
|
||||
);
|
||||
this.camouflagesYaml = await this.vfs.yaml<CamouflagesYaml>(
|
||||
"Data/camouflages.yaml",
|
||||
"Data/camouflages.yaml"
|
||||
);
|
||||
this.squadBattleTypeStyles = await this.vfs.yaml<SquadBattleTypeStylesYaml>(
|
||||
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`,
|
||||
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`
|
||||
);
|
||||
this.gameTypeSelectorStyles =
|
||||
await this.vfs.yaml<SquadBattleTypeStylesYaml>(
|
||||
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`,
|
||||
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`
|
||||
);
|
||||
this.combatRoles = await this.vfs.yaml<CombatRolesYaml>(
|
||||
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`,
|
||||
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`
|
||||
);
|
||||
this.tierEqualizer = await this.vfs.csv(
|
||||
// spell:disable-next-line
|
||||
`Data/XML/item_defs/vehicles/common/tier_equializer.csv`,
|
||||
{ delimiter: ";" },
|
||||
{ delimiter: ";" }
|
||||
);
|
||||
|
||||
this.version = (await this.vfs.text("Data/version.txt")).split(" ")[0];
|
||||
@@ -163,46 +163,49 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
console.log("Fetching game localizations...");
|
||||
|
||||
await Promise.all(
|
||||
locales.supported.map(async ({ locale }) => {
|
||||
locales.supported.map(async (supported) => {
|
||||
const root = `../../temp/game-strings/${this.version}`;
|
||||
const cachePath = `${root}/${locale}.json`;
|
||||
const cachePath = `${root}/${supported.locale}.json`;
|
||||
|
||||
if (existsSync(cachePath)) {
|
||||
console.log(` Cache hit for ${locale}`);
|
||||
console.log(` Cache hit for ${supported.locale}`);
|
||||
|
||||
const content = await readFile(cachePath, "utf-8");
|
||||
this.stringsI18n[locale] = JSON.parse(content) as BlitzStrings;
|
||||
this.stringsI18n[supported.locale] = JSON.parse(
|
||||
content
|
||||
) as BlitzStrings;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(` Cache miss for ${locale} (this will take a while...)`);
|
||||
console.log(
|
||||
` Cache miss for ${supported.locale} (this will take a while...)`
|
||||
);
|
||||
|
||||
const blitzLocale = locales.supported.find(
|
||||
(l) => l.locale === locale,
|
||||
)!.variant_blitz_local;
|
||||
const localLocale = supported.variant_blitz_local ?? supported.locale;
|
||||
const cdnLocale = supported.variant_blitz_cdn ?? supported.locale;
|
||||
const networkStrings = (await fetch(
|
||||
`https://stufficons.wgcdn.co/localizations/${blitzLocale}.yaml`,
|
||||
`https://stufficons.wgcdn.co/localizations/${cdnLocale}.yaml`
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then(parseYaml)) as BlitzStrings;
|
||||
const localStrings = await this.vfs.yaml<BlitzStrings>(
|
||||
`Data/Strings/${blitzLocale}.yaml`,
|
||||
`Data/Strings/${localLocale}.yaml`
|
||||
);
|
||||
const combined = { ...networkStrings, ...localStrings };
|
||||
|
||||
await mkdir(root, { recursive: true });
|
||||
await writeFile(cachePath, JSON.stringify(combined));
|
||||
|
||||
this.stringsI18n[locale] = combined;
|
||||
}),
|
||||
this.stringsI18n[supported.locale] = combined;
|
||||
})
|
||||
);
|
||||
|
||||
console.log("Fetching consumable and provision data...");
|
||||
|
||||
for (const match of (
|
||||
await this.vfs.text(
|
||||
`Data/XML/item_defs/vehicles/common/consumables/list.xml`,
|
||||
`Data/XML/item_defs/vehicles/common/consumables/list.xml`
|
||||
)
|
||||
).matchAll(/<items path="(.+)\.xml"\/>/g)) {
|
||||
if (match[1] === "prototypes") continue;
|
||||
@@ -211,15 +214,15 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
this.consumablesCommon,
|
||||
(
|
||||
await this.vfs.xml<{ root: ConsumablesCommon }>(
|
||||
`Data/XML/item_defs/vehicles/common/consumables/${match[1]}.xml`,
|
||||
`Data/XML/item_defs/vehicles/common/consumables/${match[1]}.xml`
|
||||
)
|
||||
).root,
|
||||
).root
|
||||
);
|
||||
}
|
||||
|
||||
for (const match of (
|
||||
await this.vfs.text(
|
||||
`Data/XML/item_defs/vehicles/common/provisions/list.xml`,
|
||||
`Data/XML/item_defs/vehicles/common/provisions/list.xml`
|
||||
)
|
||||
).matchAll(/<items path="(.+)\.xml"\/>/g)) {
|
||||
if (match[1] === "prototypes") continue;
|
||||
@@ -228,15 +231,15 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
this.provisionsCommon,
|
||||
(
|
||||
await this.vfs.xml<{ root: ConsumablesCommon }>(
|
||||
`Data/XML/item_defs/vehicles/common/provisions/${match[1]}.xml`,
|
||||
`Data/XML/item_defs/vehicles/common/provisions/${match[1]}.xml`
|
||||
)
|
||||
).root,
|
||||
).root
|
||||
);
|
||||
}
|
||||
|
||||
for (const nation of this.nationsDir!) {
|
||||
const tankList = await this.vfs.xml<{ root: VehicleDefinitionList }>(
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`
|
||||
);
|
||||
|
||||
for (const tankKey in tankList.root) {
|
||||
@@ -255,7 +258,7 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
protected getTankFilterIds(
|
||||
name: string,
|
||||
definitionKey: string,
|
||||
filter: "include" | "exclude",
|
||||
filter: "include" | "exclude"
|
||||
) {
|
||||
const keys = name.trim().split(/\s+/).filter(Boolean);
|
||||
|
||||
@@ -264,7 +267,7 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
|
||||
if (id === undefined) {
|
||||
console.warn(
|
||||
`Skipping unavailable tank "${key}" in ${filter} vehicle filter for "${definitionKey}"`,
|
||||
`Skipping unavailable tank "${key}" in ${filter} vehicle filter for "${definitionKey}"`
|
||||
);
|
||||
return [];
|
||||
}
|
||||
@@ -301,7 +304,7 @@ export function Cache(disableInDev = false) {
|
||||
const cache = new WeakMap<object, Map<string, Promise<unknown>>>();
|
||||
|
||||
return function <This, Arguments extends any[], Return>(
|
||||
target: (this: This, ...args: Arguments) => Promise<Return>,
|
||||
target: (this: This, ...args: Arguments) => Promise<Return>
|
||||
// TODO: evaluate if we need context to make the error trace easier
|
||||
// context: ClassMethodDecoratorContext<
|
||||
// This,
|
||||
|
||||
Reference in new issue
Block a user