mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: migrate definitiosn
This commit is contained in:
1 parent
1cc15f64b0
commit
3efe807e35
2 files changed
+67
-55
No files matched your search
@@ -96,6 +96,24 @@ export class SteamVFS {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dir(path: string) {
|
||||||
|
const parentSegments = path.split("/").length;
|
||||||
|
const children: string[] = [];
|
||||||
|
|
||||||
|
for (const child of this.manifest.keys()) {
|
||||||
|
const childSegments = child.split("/");
|
||||||
|
|
||||||
|
if (
|
||||||
|
child.startsWith(path) &&
|
||||||
|
parentSegments + 1 === childSegments.length
|
||||||
|
) {
|
||||||
|
children.push(childSegments.at(-1)!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
async file(requested: string) {
|
async file(requested: string) {
|
||||||
const path = this.assert(requested);
|
const path = this.assert(requested);
|
||||||
const fileManifest = this.manifest.get(path)!;
|
const fileManifest = this.manifest.get(path)!;
|
||||||
|
|||||||
@@ -32,16 +32,12 @@ import {
|
|||||||
} from "@blitzkit/core";
|
} from "@blitzkit/core";
|
||||||
import { SUPPORTED_LOCALE_BLITZ_MAP } from "@blitzkit/i18n";
|
import { SUPPORTED_LOCALE_BLITZ_MAP } from "@blitzkit/i18n";
|
||||||
import locales from "@blitzkit/i18n/locales.json";
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
import { readdir } from "fs/promises";
|
|
||||||
import { deburr } from "lodash-es";
|
import { deburr } from "lodash-es";
|
||||||
import { parse as parsePath } from "path";
|
import { parse as parsePath } from "path";
|
||||||
import type { Vector3Tuple } from "three";
|
import type { Vector3Tuple } from "three";
|
||||||
import { parse as parseYaml } from "yaml";
|
import { parse as parseYaml } from "yaml";
|
||||||
import { readStringDVPL } from "../core/blitz/readStringDVPL";
|
|
||||||
import { readXMLDVPL } from "../core/blitz/readXMLDVPL";
|
|
||||||
import { readYAMLDVPL } from "../core/blitz/readYAMLDVPL";
|
|
||||||
import { AssetUploader } from "../core/github/assetUploader";
|
import { AssetUploader } from "../core/github/assetUploader";
|
||||||
import { DATA } from "./constants";
|
import { vfs } from "./constants";
|
||||||
import type { Avatar } from "./skillIcons";
|
import type { Avatar } from "./skillIcons";
|
||||||
import type { TankParameters } from "./tankIcons";
|
import type { TankParameters } from "./tankIcons";
|
||||||
|
|
||||||
@@ -540,9 +536,9 @@ export async function definitions() {
|
|||||||
|
|
||||||
using uploader = new AssetUploader("definitions");
|
using uploader = new AssetUploader("definitions");
|
||||||
const gameDefinitions: GameDefinitions = {
|
const gameDefinitions: GameDefinitions = {
|
||||||
version: (await readStringDVPL(`${DATA}/version.txt`)).split(" ")[0],
|
version: (await vfs.text('Data/version.txt')).split(" ")[0],
|
||||||
nations: (
|
nations: (
|
||||||
await readYAMLDVPL<AvailableNationsYaml>(`${DATA}/available_nations.yaml`)
|
await vfs.yaml<AvailableNationsYaml>('Data/available_nations.yaml')
|
||||||
).available_nations,
|
).available_nations,
|
||||||
gameModes: {},
|
gameModes: {},
|
||||||
roles: {},
|
roles: {},
|
||||||
@@ -565,12 +561,10 @@ export async function definitions() {
|
|||||||
[TankClass.TANK_DESTROYER]: { skills: [] },
|
[TankClass.TANK_DESTROYER]: { skills: [] },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
|
const nations = vfs.dir('Data/XML/item_defs/vehicles').filter((nation) => nation !== "common")
|
||||||
(nations) => nations.filter((nation) => nation !== "common")
|
|
||||||
);
|
|
||||||
const tankStringIdMap: Record<string, number> = {};
|
const tankStringIdMap: Record<string, number> = {};
|
||||||
const optionalDevices = await readXMLDVPL<{ root: OptionalDevices }>(
|
const optionalDevices = await vfs.xml<{ root: OptionalDevices }>(
|
||||||
`${DATA}/XML/item_defs/vehicles/common/optional_devices.xml`
|
'Data/XML/item_defs/vehicles/common/optional_devices.xml'
|
||||||
);
|
);
|
||||||
const stringsI18n: Record<string, Record<string, string>> = {};
|
const stringsI18n: Record<string, Record<string, string>> = {};
|
||||||
|
|
||||||
@@ -582,8 +576,8 @@ export async function definitions() {
|
|||||||
)
|
)
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((string) => parseYaml(string) as BlitzStrings);
|
.then((string) => parseYaml(string) as BlitzStrings);
|
||||||
const preInstalled = await readYAMLDVPL<BlitzStrings>(
|
const preInstalled = await vfs.yaml<BlitzStrings>(
|
||||||
`${DATA}/Strings/${blitzLocale}.yaml`
|
'Data/Strings/${blitzLocale}.yaml'
|
||||||
);
|
);
|
||||||
|
|
||||||
stringsI18n[locale] = {
|
stringsI18n[locale] = {
|
||||||
@@ -616,15 +610,15 @@ export async function definitions() {
|
|||||||
return { locales: collection } satisfies I18nString;
|
return { locales: collection } satisfies I18nString;
|
||||||
}
|
}
|
||||||
|
|
||||||
const optionalDeviceSlots = await readXMLDVPL<{
|
const optionalDeviceSlots = await vfs.xml<{
|
||||||
root: OptionalDeviceSlots;
|
root: OptionalDeviceSlots;
|
||||||
}>(`${DATA}/XML/item_defs/vehicles/common/optional_device_slots.xml`);
|
}>(`Data/XML/item_defs/vehicles/common/optional_device_slots.xml`);
|
||||||
const consumables: ConsumablesCommon = {};
|
const consumables: ConsumablesCommon = {};
|
||||||
const provisions: ProvisionsCommon = {};
|
const provisions: ProvisionsCommon = {};
|
||||||
|
|
||||||
for (const match of (
|
for (const match of (
|
||||||
await readStringDVPL(
|
await 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)) {
|
).matchAll(/<items path="(.+)\.xml"\/>/g)) {
|
||||||
if (match[1] === "prototypes") continue;
|
if (match[1] === "prototypes") continue;
|
||||||
@@ -632,16 +626,16 @@ export async function definitions() {
|
|||||||
Object.assign(
|
Object.assign(
|
||||||
consumables,
|
consumables,
|
||||||
(
|
(
|
||||||
await readXMLDVPL<{ root: ConsumablesCommon }>(
|
await 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 (
|
for (const match of (
|
||||||
await readStringDVPL(
|
await 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)) {
|
).matchAll(/<items path="(.+)\.xml"\/>/g)) {
|
||||||
if (match[1] === "prototypes") continue;
|
if (match[1] === "prototypes") continue;
|
||||||
@@ -649,34 +643,34 @@ export async function definitions() {
|
|||||||
Object.assign(
|
Object.assign(
|
||||||
provisions,
|
provisions,
|
||||||
(
|
(
|
||||||
await readXMLDVPL<{ root: ConsumablesCommon }>(
|
await 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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const avatar = await readXMLDVPL<{ root: Avatar }>(
|
const avatar = await vfs.xml<{ root: Avatar }>(
|
||||||
`${DATA}/XML/item_defs/tankmen/avatar.xml`
|
`Data/XML/item_defs/tankmen/avatar.xml`
|
||||||
);
|
);
|
||||||
const maps = await readYAMLDVPL<Maps>(`${DATA}/maps.yaml`);
|
const maps = await vfs.yaml<Maps>(`Data/maps.yaml`);
|
||||||
const tankXps = new Map<number, ResearchCost>();
|
const tankXps = new Map<number, ResearchCost>();
|
||||||
const camouflagesXml = await readXMLDVPL<{ root: CamouflagesXML }>(
|
const camouflagesXml = await vfs.xml<{ root: CamouflagesXML }>(
|
||||||
`${DATA}/XML/item_defs/vehicles/common/camouflages.xml`
|
`Data/XML/item_defs/vehicles/common/camouflages.xml`
|
||||||
);
|
);
|
||||||
const camouflagesYaml = await readYAMLDVPL<CamouflagesYaml>(
|
const camouflagesYaml = await vfs.yaml<CamouflagesYaml>(
|
||||||
`${DATA}/camouflages.yaml`
|
`Data/camouflages.yaml`
|
||||||
);
|
);
|
||||||
const camouflagesXmlEntries = Object.entries(camouflagesXml.root.camouflages);
|
const camouflagesXmlEntries = Object.entries(camouflagesXml.root.camouflages);
|
||||||
const squadBattleTypeStyles = await readYAMLDVPL<SquadBattleTypeStyles>(
|
const squadBattleTypeStyles = await vfs.yaml<SquadBattleTypeStyles>(
|
||||||
`${DATA}/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`
|
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`
|
||||||
);
|
);
|
||||||
const gameTypeSelectorStyles = await readYAMLDVPL<SquadBattleTypeStyles>(
|
const gameTypeSelectorStyles = await vfs.yaml<SquadBattleTypeStyles>(
|
||||||
`${DATA}/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`
|
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`
|
||||||
);
|
);
|
||||||
const gameModeNativeNames: Record<string, number> = {};
|
const gameModeNativeNames: Record<string, number> = {};
|
||||||
const combatRoles = await readYAMLDVPL<CombatRolesYaml>(
|
const combatRoles = await vfs.yaml<CombatRolesYaml>(
|
||||||
`${DATA}/XML/item_defs/vehicles/common/combat_roles.yaml`
|
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`
|
||||||
);
|
);
|
||||||
const consumableNativeNames: Record<string, number> = {};
|
const consumableNativeNames: Record<string, number> = {};
|
||||||
const provisionNativeNames: Record<string, number> = {};
|
const provisionNativeNames: Record<string, number> = {};
|
||||||
@@ -727,8 +721,8 @@ export async function definitions() {
|
|||||||
const idToNation: Record<number, string> = {};
|
const idToNation: Record<number, string> = {};
|
||||||
|
|
||||||
for (const nation of nations) {
|
for (const nation of nations) {
|
||||||
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tankList = await 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) {
|
for (const tankKey in tankList.root) {
|
||||||
@@ -811,24 +805,24 @@ export async function definitions() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (const nation of nations) {
|
for (const nation of nations) {
|
||||||
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tankList = await vfs.xml<{ root: VehicleDefinitionList }>(
|
||||||
`${DATA}/XML/item_defs/vehicles/${nation}/list.xml`
|
`Data/XML/item_defs/vehicles/${nation}/list.xml`
|
||||||
);
|
);
|
||||||
const turretList = await readXMLDVPL<{
|
const turretList = await vfs.xml<{
|
||||||
root: TurretDefinitionsList;
|
root: TurretDefinitionsList;
|
||||||
}>(`${DATA}/XML/item_defs/vehicles/${nation}/components/turrets.xml`);
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/turrets.xml`);
|
||||||
const gunList = await readXMLDVPL<{
|
const gunList = await vfs.xml<{
|
||||||
root: GunDefinitionsList;
|
root: GunDefinitionsList;
|
||||||
}>(`${DATA}/XML/item_defs/vehicles/${nation}/components/guns.xml`);
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/guns.xml`);
|
||||||
const shellList = await readXMLDVPL<{
|
const shellList = await vfs.xml<{
|
||||||
root: ShellDefinitionsList;
|
root: ShellDefinitionsList;
|
||||||
}>(`${DATA}/XML/item_defs/vehicles/${nation}/components/shells.xml`);
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/shells.xml`);
|
||||||
const enginesList = await readXMLDVPL<{
|
const enginesList = await vfs.xml<{
|
||||||
root: EngineDefinitionsList;
|
root: EngineDefinitionsList;
|
||||||
}>(`${DATA}/XML/item_defs/vehicles/${nation}/components/engines.xml`);
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/engines.xml`);
|
||||||
const chassisList = await readXMLDVPL<{
|
const chassisList = await vfs.xml<{
|
||||||
root: ChassisDefinitionsList;
|
root: ChassisDefinitionsList;
|
||||||
}>(`${DATA}/XML/item_defs/vehicles/${nation}/components/chassis.xml`);
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/chassis.xml`);
|
||||||
|
|
||||||
function resolveUnlocks(unlocks?: BlitzModuleType) {
|
function resolveUnlocks(unlocks?: BlitzModuleType) {
|
||||||
if (!unlocks) return [];
|
if (!unlocks) return [];
|
||||||
@@ -879,11 +873,11 @@ export async function definitions() {
|
|||||||
const trackXps = new Map<number, ResearchCost>();
|
const trackXps = new Map<number, ResearchCost>();
|
||||||
const tank = tankList.root[tankKey];
|
const tank = tankList.root[tankKey];
|
||||||
let tankPrice: TankPrice;
|
let tankPrice: TankPrice;
|
||||||
const tankDefinition = await readXMLDVPL<{ root: VehicleDefinitions }>(
|
const tankDefinition = await vfs.xml<{ root: VehicleDefinitions }>(
|
||||||
`${DATA}/XML/item_defs/vehicles/${nation}/${tankKey}.xml`
|
`Data/XML/item_defs/vehicles/${nation}/${tankKey}.xml`
|
||||||
);
|
);
|
||||||
const tankParameters = await readYAMLDVPL<TankParameters>(
|
const tankParameters = await vfs.yaml<TankParameters>(
|
||||||
`${DATA}/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`
|
`Data/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`
|
||||||
);
|
);
|
||||||
const turretOrigin = tankDefinition.root.hull.turretPositions.turret
|
const turretOrigin = tankDefinition.root.hull.turretPositions.turret
|
||||||
.split(" ")
|
.split(" ")
|
||||||
|
|||||||
Reference in new issue
Block a user