mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 11:17:05 +02:00
feat: functionality and icons
This commit is contained in:
1 parent
035f751bf1
commit
787d3ae6ea
8 files changed
+253
-40
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import sharp from 'sharp';
|
||||
|
||||
const cache: Record<string, string> = {};
|
||||
|
||||
export async function iconPng(url: string) {
|
||||
if (cache[url]) return cache[url];
|
||||
|
||||
const imageResponse = await fetch(url);
|
||||
const imageBufferWEBP = await imageResponse.arrayBuffer();
|
||||
const imageBufferPNG = await sharp(imageBufferWEBP).png().toBuffer();
|
||||
cache[url] = `data:image/png;base64,${imageBufferPNG.toString('base64')}`;
|
||||
|
||||
return cache[url];
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { readFile } from 'fs/promises';
|
||||
import { deburr } from 'lodash';
|
||||
import { Vector2Tuple } from 'three';
|
||||
import { TankClass, TreeType } from '../../../components/Tanks';
|
||||
import { asset } from '../asset';
|
||||
import { fetchCdonLz4 } from '../fetchCdonLz4';
|
||||
import { superDecompress } from '../superDecompress';
|
||||
import { TIERS } from './constants';
|
||||
|
||||
export type ShellType = 'ap' | 'ap_cr' | 'hc' | 'he';
|
||||
@@ -142,14 +142,14 @@ export type ShellDefinition = {
|
||||
explosionRadius?: number;
|
||||
};
|
||||
|
||||
export const tankDefinitions = fetchCdonLz4<TankDefinitions>(
|
||||
asset('definitions/tanks.cdon.lz4'),
|
||||
);
|
||||
|
||||
// export const tankDefinitions = readFile('test.tanks.cdon.lz4').then((data) =>
|
||||
// superDecompress<TankDefinitions>(data.buffer),
|
||||
// export const tankDefinitions = fetchCdonLz4<TankDefinitions>(
|
||||
// asset('definitions/tanks.cdon.lz4'),
|
||||
// );
|
||||
|
||||
export const tankDefinitions = readFile('test.tanks.cdon.lz4').then((data) =>
|
||||
superDecompress<TankDefinitions>(data.buffer),
|
||||
);
|
||||
|
||||
const entries = new Promise<TankDefinition[]>(async (resolve) => {
|
||||
resolve(Object.entries(await tankDefinitions).map(([, entry]) => entry));
|
||||
});
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import sharp from 'sharp';
|
||||
import { iconPng } from './iconPng';
|
||||
import { tankIcon } from './tankIcon';
|
||||
|
||||
export async function tankIconPng(id: number) {
|
||||
const imageResponse = await fetch(tankIcon(id));
|
||||
const imageBufferWEBP = await imageResponse.arrayBuffer();
|
||||
const imageBufferPNG = await sharp(imageBufferWEBP).png().toBuffer();
|
||||
return `data:image/png;base64,${imageBufferPNG.toString('base64')}`;
|
||||
export function tankIconPng(id: number) {
|
||||
return iconPng(tankIcon(id));
|
||||
}
|
||||
Reference in new issue
Block a user