mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +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,
|
||||
Armor,
|
||||
AssaultRanges,
|
||||
AvailableNationsYaml,
|
||||
BlitzCrewType,
|
||||
BlitzModuleType,
|
||||
BlitzStrings,
|
||||
@@ -22,6 +23,7 @@ import {
|
||||
Equalizer,
|
||||
EquipmentDefinitions,
|
||||
EquipmentSlot,
|
||||
GameDefinitions,
|
||||
GunDefinition,
|
||||
GunDefinitionsList,
|
||||
I18nString,
|
||||
@@ -188,6 +190,11 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
||||
);
|
||||
|
||||
console.log("Fetching game localizations...");
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
locales.supported = [locales.supported[0]];
|
||||
}
|
||||
|
||||
let fetchedLocalizations = 0;
|
||||
await Promise.all(
|
||||
locales.supported.map(async ({ locale }) => {
|
||||
@@ -1589,6 +1596,58 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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 { AverageDefinitions } from '../../protos';
|
||||
import { asset } from '../asset';
|
||||
import { staticAsset } from "@blitzkit/core";
|
||||
import { fetchPB } from "../../protobuf";
|
||||
import { AverageDefinitions } from "../../protos";
|
||||
|
||||
export interface AverageDefinitionsManifest {
|
||||
version: 1;
|
||||
@@ -11,13 +11,7 @@ export interface AverageDefinitionsManifest {
|
||||
}
|
||||
|
||||
export async function fetchAverageDefinitions() {
|
||||
const manifestResponse = await fetch(asset('averages/manifest.json'));
|
||||
const manifestJson =
|
||||
(await manifestResponse.json()) as AverageDefinitionsManifest;
|
||||
return await fetchPB(
|
||||
asset(`averages/${manifestJson.latest}.pb`),
|
||||
AverageDefinitions,
|
||||
);
|
||||
return await fetchPB(staticAsset("averages.pb"), AverageDefinitions);
|
||||
}
|
||||
|
||||
export * from './constants';
|
||||
export * from "./constants";
|
||||
@@ -1,5 +1,4 @@
|
||||
export * from "./assertSecret";
|
||||
export * from "./asset";
|
||||
export * from "./availableProvisions";
|
||||
export * from "./averageDefinitions";
|
||||
// export * from './camouflageDefinitions';
|
||||
@@ -16,6 +15,7 @@ export * from "./equipmentDefinitions";
|
||||
export * from "./eventManager";
|
||||
export * from "./getArchivedLatestSeasonNumber";
|
||||
export * from "./sluggify";
|
||||
export * from "./staticAsset";
|
||||
export * from "./vfs";
|
||||
// export * from './getArchivedRatingInfo';
|
||||
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 { memo, useEffect, useMemo, useState } from "react";
|
||||
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 { api } from "../../core/blitzkit/api";
|
||||
import { filterTanks } from "../../core/blitzkit/filterTanks";
|
||||
import { resolveReload } from "../../core/blitzkit/resolveReload";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
@@ -47,9 +45,9 @@ const DEFAULT_LOADED_CARDS = 64;
|
||||
|
||||
const [gameDefinitions, modelDefinitions, tankDefinitions, tankNames] =
|
||||
await Promise.all([
|
||||
awaitableGameDefinitions,
|
||||
awaitableModelDefinitions,
|
||||
awaitableTankDefinitions,
|
||||
api.gameDefinitions(),
|
||||
api.modelDefinitions(),
|
||||
api.tankDefinitions(),
|
||||
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();
|
||||
@@ -1,10 +1,10 @@
|
||||
import { PageWrapper } from "../../../components/PageWrapper";
|
||||
import { TankSearch } from "../../../components/TankSearch";
|
||||
import { PageWrapper } from "../../../../components/PageWrapper";
|
||||
import { TankSearch } from "../../../../components/TankSearch";
|
||||
import {
|
||||
LocaleProvider,
|
||||
type LocaleAcceptorProps,
|
||||
} from "../../../hooks/useLocale";
|
||||
import type { MaybeSkeletonComponentProps } from "../../../types/maybeSkeletonComponentProps";
|
||||
} from "../../../../hooks/useLocale";
|
||||
import type { MaybeSkeletonComponentProps } from "../../../../types/maybeSkeletonComponentProps";
|
||||
|
||||
export function Page({
|
||||
locale,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
import { tools } from "../../../constants/tools";
|
||||
import ToolLayout from "../../../layouts/ToolLayout.astro";
|
||||
import { tools } from "../../../../constants/tools";
|
||||
import ToolLayout from "../../../../layouts/ToolLayout.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export { getStaticPaths } from "../index.astro";
|
||||
|
||||
Reference in new issue
Block a user