mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
update (1)
This commit is contained in:
1 parent
2dc23ba09d
commit
32a7db238b
10 files changed
+81
-33
No files matched your search
@@ -2,6 +2,7 @@ import {
|
|||||||
AbstractVFS,
|
AbstractVFS,
|
||||||
Armor,
|
Armor,
|
||||||
AssaultRanges,
|
AssaultRanges,
|
||||||
|
AvailableNationsYaml,
|
||||||
BlitzCrewType,
|
BlitzCrewType,
|
||||||
BlitzModuleType,
|
BlitzModuleType,
|
||||||
BlitzStrings,
|
BlitzStrings,
|
||||||
@@ -22,6 +23,7 @@ import {
|
|||||||
Equalizer,
|
Equalizer,
|
||||||
EquipmentDefinitions,
|
EquipmentDefinitions,
|
||||||
EquipmentSlot,
|
EquipmentSlot,
|
||||||
|
GameDefinitions,
|
||||||
GunDefinition,
|
GunDefinition,
|
||||||
GunDefinitionsList,
|
GunDefinitionsList,
|
||||||
I18nString,
|
I18nString,
|
||||||
@@ -188,6 +190,11 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
);
|
);
|
||||||
|
|
||||||
console.log("Fetching game localizations...");
|
console.log("Fetching game localizations...");
|
||||||
|
|
||||||
|
if (import.meta.env.DEV) {
|
||||||
|
locales.supported = [locales.supported[0]];
|
||||||
|
}
|
||||||
|
|
||||||
let fetchedLocalizations = 0;
|
let fetchedLocalizations = 0;
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
locales.supported.map(async ({ locale }) => {
|
locales.supported.map(async ({ locale }) => {
|
||||||
@@ -1589,6 +1596,58 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
|
|
||||||
return skillDefinitions;
|
return skillDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cache()
|
||||||
|
async gameDefinitions() {
|
||||||
|
const gameDefinitions = GameDefinitions.create();
|
||||||
|
|
||||||
|
const consumableNativeNames: Record<string, number> = {};
|
||||||
|
const provisionNativeNames: Record<string, number> = {};
|
||||||
|
|
||||||
|
Object.entries(this.consumablesCommon).forEach(([key, consumable]) => {
|
||||||
|
consumableNativeNames[key] = consumable.id;
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.entries(this.provisionsCommon).forEach(([key, provision]) => {
|
||||||
|
provisionNativeNames[key] = provision.id;
|
||||||
|
});
|
||||||
|
|
||||||
|
const version = (await this.vfs.text("Data/version.txt")).split(" ")[0];
|
||||||
|
|
||||||
|
gameDefinitions.version = version;
|
||||||
|
gameDefinitions.nations = (
|
||||||
|
await this.vfs.yaml<AvailableNationsYaml>("Data/available_nations.yaml")
|
||||||
|
).available_nations;
|
||||||
|
|
||||||
|
for (const match of this.squadBattleTypeStyles!.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll(
|
||||||
|
/"(\d+)" -> "(battleType\/([a-zA-Z]+))"/g,
|
||||||
|
)) {
|
||||||
|
const id = Number(match[1]);
|
||||||
|
const name = this.getString(match[2]);
|
||||||
|
|
||||||
|
gameDefinitions.gameModes[id] = {
|
||||||
|
name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.entries(this.combatRoles!).forEach(([, value]) => {
|
||||||
|
gameDefinitions.roles[value.id] = { provisions: [], consumables: [] };
|
||||||
|
|
||||||
|
value.default_abilities.forEach((ability) => {
|
||||||
|
if (ability in consumableNativeNames) {
|
||||||
|
gameDefinitions.roles[value.id].consumables.push(
|
||||||
|
consumableNativeNames[ability],
|
||||||
|
);
|
||||||
|
} else if (ability in provisionNativeNames) {
|
||||||
|
gameDefinitions.roles[value.id].provisions.push(
|
||||||
|
provisionNativeNames[ability],
|
||||||
|
);
|
||||||
|
} else throw new Error(`Unknown ability ${ability}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return gameDefinitions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Cache(disableInDev = false) {
|
export function Cache(disableInDev = false) {
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
import { assertSecret } from "./assertSecret";
|
|
||||||
|
|
||||||
export function asset(path: string) {
|
|
||||||
return `${assertSecret(import.meta.env.PUBLIC_ASSET_BASE)}/${path}`;
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { fetchPB } from '../../protobuf';
|
import { staticAsset } from "@blitzkit/core";
|
||||||
import { AverageDefinitions } from '../../protos';
|
import { fetchPB } from "../../protobuf";
|
||||||
import { asset } from '../asset';
|
import { AverageDefinitions } from "../../protos";
|
||||||
|
|
||||||
export interface AverageDefinitionsManifest {
|
export interface AverageDefinitionsManifest {
|
||||||
version: 1;
|
version: 1;
|
||||||
@@ -11,13 +11,7 @@ export interface AverageDefinitionsManifest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchAverageDefinitions() {
|
export async function fetchAverageDefinitions() {
|
||||||
const manifestResponse = await fetch(asset('averages/manifest.json'));
|
return await fetchPB(staticAsset("averages.pb"), AverageDefinitions);
|
||||||
const manifestJson =
|
|
||||||
(await manifestResponse.json()) as AverageDefinitionsManifest;
|
|
||||||
return await fetchPB(
|
|
||||||
asset(`averages/${manifestJson.latest}.pb`),
|
|
||||||
AverageDefinitions,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from './constants';
|
export * from "./constants";
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
export * from "./assertSecret";
|
export * from "./assertSecret";
|
||||||
export * from "./asset";
|
|
||||||
export * from "./availableProvisions";
|
export * from "./availableProvisions";
|
||||||
export * from "./averageDefinitions";
|
export * from "./averageDefinitions";
|
||||||
// export * from './camouflageDefinitions';
|
// export * from './camouflageDefinitions';
|
||||||
@@ -16,6 +15,7 @@ export * from "./equipmentDefinitions";
|
|||||||
export * from "./eventManager";
|
export * from "./eventManager";
|
||||||
export * from "./getArchivedLatestSeasonNumber";
|
export * from "./getArchivedLatestSeasonNumber";
|
||||||
export * from "./sluggify";
|
export * from "./sluggify";
|
||||||
|
export * from "./staticAsset";
|
||||||
export * from "./vfs";
|
export * from "./vfs";
|
||||||
// export * from './getArchivedRatingInfo';
|
// export * from './getArchivedRatingInfo';
|
||||||
export * from "./getArchivedRatingLeaderboard";
|
export * from "./getArchivedRatingLeaderboard";
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { assertSecret } from "./assertSecret";
|
||||||
|
|
||||||
|
export function staticAsset(path: string) {
|
||||||
|
return `${assertSecret(import.meta.env.PUBLIC_STATIC_ASSET_BASE)}/${path}`;
|
||||||
|
}
|
||||||
@@ -12,10 +12,8 @@ import fuzzysort from "fuzzysort";
|
|||||||
import { times, uniq } from "lodash-es";
|
import { times, uniq } from "lodash-es";
|
||||||
import { memo, useEffect, useMemo, useState } from "react";
|
import { memo, useEffect, useMemo, useState } from "react";
|
||||||
import usePromise from "react-promise-suspense";
|
import usePromise from "react-promise-suspense";
|
||||||
import { awaitableGameDefinitions } from "../../core/awaitables/gameDefinitions";
|
|
||||||
import { awaitableModelDefinitions } from "../../core/awaitables/modelDefinitions";
|
|
||||||
import { awaitableTankDefinitions } from "../../core/awaitables/tankDefinitions";
|
|
||||||
import { awaitableTankNames } from "../../core/awaitables/tankNames";
|
import { awaitableTankNames } from "../../core/awaitables/tankNames";
|
||||||
|
import { api } from "../../core/blitzkit/api";
|
||||||
import { filterTanks } from "../../core/blitzkit/filterTanks";
|
import { filterTanks } from "../../core/blitzkit/filterTanks";
|
||||||
import { resolveReload } from "../../core/blitzkit/resolveReload";
|
import { resolveReload } from "../../core/blitzkit/resolveReload";
|
||||||
import { useLocale } from "../../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
@@ -47,9 +45,9 @@ const DEFAULT_LOADED_CARDS = 64;
|
|||||||
|
|
||||||
const [gameDefinitions, modelDefinitions, tankDefinitions, tankNames] =
|
const [gameDefinitions, modelDefinitions, tankDefinitions, tankNames] =
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
awaitableGameDefinitions,
|
api.gameDefinitions(),
|
||||||
awaitableModelDefinitions,
|
api.modelDefinitions(),
|
||||||
awaitableTankDefinitions,
|
api.tankDefinitions(),
|
||||||
awaitableTankNames,
|
awaitableTankNames,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
import { fetchGameDefinitions } from '@blitzkit/core';
|
|
||||||
|
|
||||||
export const awaitableGameDefinitions = fetchGameDefinitions();
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
import { fetchTankNames } from '@blitzkit/core';
|
import { fetchTankNames } from "@blitzkit/core";
|
||||||
|
|
||||||
export const awaitableTankNames = fetchTankNames();
|
export const awaitableTankNames = fetchTankNames();
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { PageWrapper } from "../../../components/PageWrapper";
|
import { PageWrapper } from "../../../../components/PageWrapper";
|
||||||
import { TankSearch } from "../../../components/TankSearch";
|
import { TankSearch } from "../../../../components/TankSearch";
|
||||||
import {
|
import {
|
||||||
LocaleProvider,
|
LocaleProvider,
|
||||||
type LocaleAcceptorProps,
|
type LocaleAcceptorProps,
|
||||||
} from "../../../hooks/useLocale";
|
} from "../../../../hooks/useLocale";
|
||||||
import type { MaybeSkeletonComponentProps } from "../../../types/maybeSkeletonComponentProps";
|
import type { MaybeSkeletonComponentProps } from "../../../../types/maybeSkeletonComponentProps";
|
||||||
|
|
||||||
export function Page({
|
export function Page({
|
||||||
locale,
|
locale,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { tools } from "../../../constants/tools";
|
import { tools } from "../../../../constants/tools";
|
||||||
import ToolLayout from "../../../layouts/ToolLayout.astro";
|
import ToolLayout from "../../../../layouts/ToolLayout.astro";
|
||||||
import { Page } from "./_index";
|
import { Page } from "./_index";
|
||||||
|
|
||||||
export { getStaticPaths } from "../index.astro";
|
export { getStaticPaths } from "../index.astro";
|
||||||
|
|||||||
Reference in new issue
Block a user