mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-28 12:23:24 +01:00
Compare commits
3
Commits
a149af50fd
...
fd6b69edc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd6b69edc1 | ||
|
|
2504833a29 | ||
|
|
6d31dcb74b |
No files matched your search
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"folders": [
|
|
||||||
{
|
|
||||||
"path": ".",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "C:/Program Files/WindowsApps/7458BE2C.WorldofTanksBlitz_11.1.256.0_x64__x4tje2y229k00/Data",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,7 @@ using CUE4Parse.UE4.Assets.Exports.Texture;
|
|||||||
using CUE4Parse.UE4.Objects.Engine;
|
using CUE4Parse.UE4.Objects.Engine;
|
||||||
using CUE4Parse.UE4.Objects.UObject;
|
using CUE4Parse.UE4.Objects.UObject;
|
||||||
using Microsoft.JavaScript.NodeApi;
|
using Microsoft.JavaScript.NodeApi;
|
||||||
|
using SkiaSharp;
|
||||||
|
|
||||||
namespace BlitzKit.Game.JSExport;
|
namespace BlitzKit.Game.JSExport;
|
||||||
|
|
||||||
@@ -44,20 +45,20 @@ public class GameInterface
|
|||||||
|
|
||||||
if (provider.TryLoadPackageObject<UPrimaryDataAsset>(path, out var pda))
|
if (provider.TryLoadPackageObject<UPrimaryDataAsset>(path, out var pda))
|
||||||
{
|
{
|
||||||
try
|
FSoftObjectPath objectPath = pda.Get<FSoftObjectPath>("BigIcon");
|
||||||
|
UTexture2D uTexture = objectPath.Load<UTexture2D>();
|
||||||
|
CTexture? cTexture = uTexture.Decode(ETexturePlatform.DesktopMobile);
|
||||||
|
|
||||||
|
if (cTexture is null)
|
||||||
{
|
{
|
||||||
return pda.Get<FSoftObjectPath>("BigIcon")
|
continue;
|
||||||
.Load<UTexture2D>()
|
|
||||||
.Decode(ETexturePlatform.DesktopMobile)!
|
|
||||||
.ToSkBitmap()
|
|
||||||
.Encode(SkiaSharp.SKEncodedImageFormat.Webp, 80)
|
|
||||||
.ToArray();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e);
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SKBitmap bitmap = cTexture.ToSkBitmap();
|
||||||
|
SKData data = bitmap.Encode(SKEncodedImageFormat.Webp, 80);
|
||||||
|
byte[] bytes = data.ToArray();
|
||||||
|
|
||||||
|
return bytes;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -65,6 +66,6 @@ public class GameInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new FileNotFoundException($"Tank {tankId}/{pdaName} not found in any nation");
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<Solution>
|
||||||
|
<Project Path="game.csproj" />
|
||||||
|
</Solution>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
|
import type { PopularTank } from "@protos/blitzkit/popular_tanks";
|
||||||
import { api } from "../../core/api/dynamic";
|
import { api } from "../../core/api/dynamic";
|
||||||
import { useAwait } from "../../hooks/useAwait";
|
import { useAwait } from "../../hooks/useAwait";
|
||||||
import { useGameStrings } from "../../hooks/useGameStrings";
|
import { useGameStrings } from "../../hooks/useGameStrings";
|
||||||
import { useLocale } from "../../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import type { PopularTank } from "../../protos/popular_tanks";
|
|
||||||
import { LinkI18n } from "../LinkI18n";
|
import { LinkI18n } from "../LinkI18n";
|
||||||
import { Text } from "../Text";
|
import { Text } from "../Text";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
.text {
|
.text {
|
||||||
font-size: var(--font-size-regular);
|
font-size: var(--font-size-regular);
|
||||||
color: var(--gray-12);
|
|
||||||
|
|
||||||
&[data-size="minor"] {
|
&[data-size="minor"] {
|
||||||
font-size: var(--font-size-minor);
|
font-size: var(--font-size-minor);
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ export function Text({
|
|||||||
color = "gray",
|
color = "gray",
|
||||||
...props
|
...props
|
||||||
}: TextProps) {
|
}: TextProps) {
|
||||||
|
const scale = color === "gray" && lowContrast ? "white" : color;
|
||||||
|
let power: string | number = 12;
|
||||||
|
|
||||||
|
if (lowContrast) {
|
||||||
|
power = color === "gray" ? "a9" : 11;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={classNames(styles.text, className)}
|
className={classNames(styles.text, className)}
|
||||||
@@ -28,7 +35,9 @@ export function Text({
|
|||||||
data-size={size}
|
data-size={size}
|
||||||
data-weight={weight}
|
data-weight={weight}
|
||||||
data-align={align === "left" ? undefined : align}
|
data-align={align === "left" ? undefined : align}
|
||||||
style={{ color: `var(--${color}-${lowContrast ? 10 : 12})` }}
|
style={{
|
||||||
|
color: `var(--${scale}-${power})`,
|
||||||
|
}}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const toolStrings = strings.tools[tool.id as keyof typeof strings.tools];
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
.tool-card {
|
.tool-card {
|
||||||
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 10rem;
|
height: 10rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ export abstract class AbstractAPI {
|
|||||||
export function Cache<Arguments extends unknown[]>(
|
export function Cache<Arguments extends unknown[]>(
|
||||||
discriminator: (...args: Arguments) => string = (...args) => args.join("-"),
|
discriminator: (...args: Arguments) => string = (...args) => args.join("-"),
|
||||||
) {
|
) {
|
||||||
const cache = new WeakMap<object, Map<string, unknown>>();
|
const cache = new WeakMap<object, Map<string, Promise<unknown>>>();
|
||||||
|
|
||||||
return function (
|
return function (
|
||||||
_target: unknown,
|
_target: unknown,
|
||||||
@@ -73,18 +73,32 @@ export function Cache<Arguments extends unknown[]>(
|
|||||||
) {
|
) {
|
||||||
const original = descriptor.value;
|
const original = descriptor.value;
|
||||||
|
|
||||||
descriptor.value = async function (...args: Arguments) {
|
descriptor.value = function (...args: Arguments) {
|
||||||
const key = discriminator(...args);
|
const key = discriminator(...args);
|
||||||
const thisCache = cache.get(this) ?? new Map<string, unknown>();
|
|
||||||
|
|
||||||
if (!cache.has(this)) cache.set(this, thisCache);
|
let thisCache = cache.get(this);
|
||||||
if (thisCache.has(key)) return thisCache.get(key);
|
|
||||||
|
|
||||||
const result = await original.apply(this, args);
|
if (!thisCache) {
|
||||||
|
thisCache = new Map();
|
||||||
|
cache.set(this, thisCache);
|
||||||
|
}
|
||||||
|
|
||||||
thisCache.set(key, result);
|
if (thisCache.has(key)) {
|
||||||
|
return thisCache.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
const promise = (async () => {
|
||||||
|
try {
|
||||||
|
return await original.apply(this, args);
|
||||||
|
} catch (error) {
|
||||||
|
thisCache!.delete(key);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
thisCache.set(key, promise);
|
||||||
|
|
||||||
|
return promise;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -243,10 +243,6 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
strings[key] = parsed[key].replaceAll('\\"', '"');
|
strings[key] = parsed[key].replaceAll('\\"', '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
|
||||||
namespaceStrings["ProfileAvatarEntity__1_ct_legendary__DisplayName"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Object.assign(strings, namespaceStrings);
|
Object.assign(strings, namespaceStrings);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -7,5 +7,8 @@ export { getStaticPaths } from "./[id].pb";
|
|||||||
export async function GET({ params }: APIContext<never, { id: string }>) {
|
export async function GET({ params }: APIContext<never, { id: string }>) {
|
||||||
const tank = await api.tank(params.id);
|
const tank = await api.tank(params.id);
|
||||||
const image = game.tankBigIcon(params.id, tank.tank!.visual_data);
|
const image = game.tankBigIcon(params.id, tank.tank!.visual_data);
|
||||||
|
|
||||||
|
if (image.length === 0) return new Response(null, { status: 404 });
|
||||||
|
|
||||||
return new Response(new Uint8Array(image));
|
return new Response(new Uint8Array(image));
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user