mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: full names and better default names
This commit is contained in:
1 parent
f368769068
commit
638c2c73da
3 files changed
+21
-9
No files matched your search
@@ -4,6 +4,8 @@ export const DATA =
|
|||||||
export const POI = {
|
export const POI = {
|
||||||
vehicleDefinitions: 'XML/item_defs/vehicles',
|
vehicleDefinitions: 'XML/item_defs/vehicles',
|
||||||
strings: 'Strings',
|
strings: 'Strings',
|
||||||
|
cachedStrings:
|
||||||
|
'C:/Users/coola/Documents/DAVAProject/cache/localizations/en.yaml',
|
||||||
tankParameters: '3d/Tanks/Parameters',
|
tankParameters: '3d/Tanks/Parameters',
|
||||||
smallIcons: 'Gfx/UI/BattleScreenHUD/SmallTankIcons',
|
smallIcons: 'Gfx/UI/BattleScreenHUD/SmallTankIcons',
|
||||||
bigIcons: 'Gfx/UI/BigTankIcons',
|
bigIcons: 'Gfx/UI/BigTankIcons',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { parse } from 'path';
|
|||||||
import { Vector3Tuple } from 'three';
|
import { Vector3Tuple } from 'three';
|
||||||
import { TankType } from '../../src/components/Tanks';
|
import { TankType } from '../../src/components/Tanks';
|
||||||
import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
|
import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
|
||||||
|
import { readYAML } from '../../src/core/blitz/readYAML';
|
||||||
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
|
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/blitzkrieg/commitAssets';
|
import { commitAssets } from '../../src/core/blitzkrieg/commitAssets';
|
||||||
@@ -231,8 +232,6 @@ const blitzShellKindToBLitzkrieg: Record<ShellKind, ShellType> = {
|
|||||||
HIGH_EXPLOSIVE: 'he',
|
HIGH_EXPLOSIVE: 'he',
|
||||||
HOLLOW_CHARGE: 'hc',
|
HOLLOW_CHARGE: 'hc',
|
||||||
};
|
};
|
||||||
const LANGUAGE = 'en';
|
|
||||||
|
|
||||||
const missingStrings: Record<string, string> = {
|
const missingStrings: Record<string, string> = {
|
||||||
'#artefacts:tungstentip/name': 'Tungsten Shells',
|
'#artefacts:tungstentip/name': 'Tungsten Shells',
|
||||||
};
|
};
|
||||||
@@ -252,8 +251,9 @@ export async function buildDefinitions(production: boolean) {
|
|||||||
);
|
);
|
||||||
const tankStringIdMap: Record<string, number> = {};
|
const tankStringIdMap: Record<string, number> = {};
|
||||||
const strings = await readYAMLDVPL<Strings>(
|
const strings = await readYAMLDVPL<Strings>(
|
||||||
`${DATA}/${POI.strings}/${LANGUAGE}.yaml.dvpl`,
|
`${DATA}/${POI.strings}/en.yaml.dvpl`,
|
||||||
);
|
);
|
||||||
|
const stringsCache = await readYAML<Strings>(POI.cachedStrings);
|
||||||
const optionalDevices = await readXMLDVPL<{ root: OptionalDevices }>(
|
const optionalDevices = await readXMLDVPL<{ root: OptionalDevices }>(
|
||||||
`${DATA}/${POI.optionalDevices}.dvpl`,
|
`${DATA}/${POI.optionalDevices}.dvpl`,
|
||||||
);
|
);
|
||||||
@@ -331,12 +331,12 @@ export async function buildDefinitions(production: boolean) {
|
|||||||
equipment,
|
equipment,
|
||||||
name:
|
name:
|
||||||
(tank.shortUserString
|
(tank.shortUserString
|
||||||
? strings[tank.shortUserString]
|
? strings[tank.shortUserString] ??
|
||||||
|
stringsCache[tank.shortUserString]
|
||||||
: undefined) ??
|
: undefined) ??
|
||||||
strings[tank.userString] ??
|
strings[tank.userString] ??
|
||||||
tankKey
|
stringsCache[tank.userString],
|
||||||
.replaceAll('_', ' ')
|
name_full: strings[tank.userString] ?? stringsCache[tank.userString],
|
||||||
.replace(/^[A-Z]+([a-z]+)?([0-9]+)? /, ''),
|
|
||||||
nation,
|
nation,
|
||||||
tree_type: (tank.sellPrice ? 'gold' in tank.sellPrice : false)
|
tree_type: (tank.sellPrice ? 'gold' in tank.sellPrice : false)
|
||||||
? 'collector'
|
? 'collector'
|
||||||
@@ -355,8 +355,10 @@ export async function buildDefinitions(production: boolean) {
|
|||||||
turrets: [],
|
turrets: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (strings[tank.userString] !== tankDefinitions[tankId].name) {
|
if (
|
||||||
tankDefinitions[tankId].name_full = strings[tank.userString];
|
tankDefinitions[tankId].name === tankDefinitions[tankId].name_full
|
||||||
|
) {
|
||||||
|
delete tankDefinitions[tankId].name_full;
|
||||||
}
|
}
|
||||||
|
|
||||||
modelDefinitions[tankId] = {
|
modelDefinitions[tankId] = {
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { readFile } from 'fs/promises';
|
||||||
|
import { parse } from 'yaml';
|
||||||
|
|
||||||
|
export async function readYAML<Type>(file: string) {
|
||||||
|
const yaml = (await readFile(file)).toString();
|
||||||
|
|
||||||
|
return parse(yaml) as Type;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user