mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 15:52:55 +01:00
flatten components
This commit is contained in:
150 files changed
+2158
-6893
No files matched your search
+6
-6
@@ -2,12 +2,12 @@ import { alias } from "@blitzkit/core";
|
|||||||
import { Avatar } from "@blitzkit/protos";
|
import { Avatar } from "@blitzkit/protos";
|
||||||
import { Cross1Icon, DownloadIcon } from "@radix-ui/react-icons";
|
import { Cross1Icon, DownloadIcon } from "@radix-ui/react-icons";
|
||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import { useIntersection } from "../hooks/useIntersection";
|
import { useIntersection } from "../../hooks/useIntersection";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import type { MaybeSkeletonComponentProps } from "../types/maybeSkeletonComponentProps";
|
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
||||||
import { LazyImage } from "./LazyImage";
|
import { LazyImage } from "../LazyImage";
|
||||||
import { Skeleton } from "./Skeleton";
|
import { Skeleton } from "../Skeleton";
|
||||||
import { Text } from "./Text";
|
import { Text } from "../Text";
|
||||||
|
|
||||||
type GalleryCardProps = MaybeSkeletonComponentProps<{
|
type GalleryCardProps = MaybeSkeletonComponentProps<{
|
||||||
avatar: Avatar;
|
avatar: Avatar;
|
||||||
File renamed without changes.
+7
-7
@@ -5,13 +5,13 @@ import type { QuicklimeEvent } from "quicklime";
|
|||||||
import { useEffect, useMemo, useRef } from "react";
|
import { useEffect, useMemo, useRef } from "react";
|
||||||
import { PerspectiveCamera, Vector3 } from "three";
|
import { PerspectiveCamera, Vector3 } from "three";
|
||||||
import { OrbitControls as OrbitControlsClass } from "three-stdlib";
|
import { OrbitControls as OrbitControlsClass } from "three-stdlib";
|
||||||
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
import { applyPitchYawLimits } from "../../core/blitz/applyPitchYawLimits";
|
||||||
import { Pose, poseEvent } from "../core/blitzkit/pose";
|
import { Pose, poseEvent } from "../../core/blitzkit/pose";
|
||||||
import { controlsEnabledEvent } from "../core/controlsEnabled";
|
import { controlsEnabledEvent } from "../../core/controlsEnabled";
|
||||||
import { useDuelModels } from "../hooks/useDuelModels";
|
import { useDuelModels } from "../../hooks/useDuelModels";
|
||||||
import { getDuelModules, useDuelModules } from "../hooks/useDuelModules";
|
import { getDuelModules, useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { hasEquipment } from "../hooks/useEquipment";
|
import { hasEquipment } from "../../hooks/useEquipment";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
|
|
||||||
const poseDistances: Record<Pose, number> = {
|
const poseDistances: Record<Pose, number> = {
|
||||||
[Pose.HullDown]: 15,
|
[Pose.HullDown]: 15,
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { TankClass } from "@blitzkit/protos";
|
import { TankClass } from "@blitzkit/protos";
|
||||||
import type { ComponentProps, ReactNode } from "react";
|
import type { ComponentProps, ReactNode } from "react";
|
||||||
import { ClassHeavy } from "./components/ClassHeavy";
|
import { ClassIconHeavy } from "../ClassIconHeavy";
|
||||||
import { ClassLight } from "./components/ClassLight";
|
import { ClassIconLight } from "../ClassIconLight";
|
||||||
import { ClassMedium } from "./components/ClassMedium";
|
import { ClassIconMedium } from "../ClassIconMedium";
|
||||||
import { ClassTankDestroyer } from "./components/ClassTankDestroyer";
|
import { ClassIconTankDestroyer } from "../ClassIconTankDestroyer";
|
||||||
|
|
||||||
interface ClassIconProps extends ComponentProps<"svg"> {
|
interface ClassIconProps extends ComponentProps<"svg"> {
|
||||||
class: TankClass;
|
class: TankClass;
|
||||||
@@ -13,10 +13,10 @@ const classIcons: Record<
|
|||||||
TankClass,
|
TankClass,
|
||||||
(props: ComponentProps<"svg">) => ReactNode
|
(props: ComponentProps<"svg">) => ReactNode
|
||||||
> = {
|
> = {
|
||||||
[TankClass.TANK_CLASS_TANK_DESTROYER]: ClassTankDestroyer,
|
[TankClass.TANK_CLASS_TANK_DESTROYER]: ClassIconTankDestroyer,
|
||||||
[TankClass.TANK_CLASS_HEAVY]: ClassHeavy,
|
[TankClass.TANK_CLASS_HEAVY]: ClassIconHeavy,
|
||||||
[TankClass.TANK_CLASS_LIGHT]: ClassLight,
|
[TankClass.TANK_CLASS_LIGHT]: ClassIconLight,
|
||||||
[TankClass.TANK_CLASS_MEDIUM]: ClassMedium,
|
[TankClass.TANK_CLASS_MEDIUM]: ClassIconMedium,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ClassIcon({ class: tankClass, ...props }: ClassIconProps) {
|
export function ClassIcon({ class: tankClass, ...props }: ClassIconProps) {
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import type { ComponentProps } from 'react';
|
import type { ComponentProps } from "react";
|
||||||
|
|
||||||
export function ClassHeavy(props: ComponentProps<'svg'>) {
|
export function ClassIconHeavy(props: ComponentProps<"svg">) {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
width="64"
|
width="64"
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import type { ComponentProps } from 'react';
|
import type { ComponentProps } from "react";
|
||||||
|
|
||||||
export function ClassLight(props: ComponentProps<'svg'>) {
|
export function ClassIconLight(props: ComponentProps<"svg">) {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
width="64"
|
width="64"
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import type { ComponentProps } from 'react';
|
import type { ComponentProps } from "react";
|
||||||
|
|
||||||
export function ClassMedium(props: ComponentProps<'svg'>) {
|
export function ClassIconMedium(props: ComponentProps<"svg">) {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
width="64"
|
width="64"
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import type { ComponentProps } from 'react';
|
import type { ComponentProps } from "react";
|
||||||
|
|
||||||
export function ClassTankDestroyer(props: ComponentProps<'svg'>) {
|
export function ClassIconTankDestroyer(props: ComponentProps<"svg">) {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
width="64"
|
width="64"
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useStrings } from "../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
import { Button, type ButtonProps } from "./Button";
|
import { Button, type ButtonProps } from "../Button";
|
||||||
import { Tooltip } from "./Tooltip";
|
import { Tooltip } from "../Tooltip";
|
||||||
|
|
||||||
const COPIED_TOOLTIP_DURATION = 2000;
|
const COPIED_TOOLTIP_DURATION = 2000;
|
||||||
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { Code, Tooltip, type CodeProps } from "@radix-ui/themes";
|
import { Code, Tooltip, type CodeProps } from "@radix-ui/themes";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
|
|
||||||
export interface CopyableCodeProps extends CodeProps {
|
export interface CopyableCodeProps extends CodeProps {
|
||||||
copy?: string;
|
copy?: string;
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
import { Code, Flex, Heading, Link, Text } from "@radix-ui/themes";
|
import { Code, Flex, Heading, Link, Text } from "@radix-ui/themes";
|
||||||
import { useEffect, useState, type ReactNode } from "react";
|
import { useEffect, useState, type ReactNode } from "react";
|
||||||
import type { MaybeSkeletonComponentProps } from "../types/maybeSkeletonComponentProps";
|
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
||||||
import { InlineSkeleton } from "./InlineSkeleton";
|
import { InlineSkeleton } from "../InlineSkeleton";
|
||||||
import { LazyImage } from "./LazyImage";
|
import { LazyImage } from "../LazyImage";
|
||||||
|
|
||||||
const TIME = 1794675600 * 1000;
|
const TIME = 1794675600 * 1000;
|
||||||
const HREF = "https://preview.blitzkit.app/tanks";
|
const HREF = "https://preview.blitzkit.app/tanks";
|
||||||
File renamed without changes.
@@ -0,0 +1,57 @@
|
|||||||
|
import { compositeStats } from "@blitzkit/core";
|
||||||
|
import { api } from "../../api/dynamic";
|
||||||
|
import type { breakdownConfig } from "../../config/embeds";
|
||||||
|
import { awaitableAverageDefinitions } from "../../core/awaitables/averageDefinitions";
|
||||||
|
import { useEmbedStateCurry } from "../../stores/embedState/utilities";
|
||||||
|
import { BreakdownEmbedCard, BreakdownEmbedWrapper } from "../TanksEmbed";
|
||||||
|
|
||||||
|
const [tankDefinitions, averageDefinitions] = await Promise.all([
|
||||||
|
api.tanks(),
|
||||||
|
|
||||||
|
awaitableAverageDefinitions,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const fakeCompositeStats = compositeStats(
|
||||||
|
{
|
||||||
|
battle_life_time: 5 * 50 * 60,
|
||||||
|
battles: 50,
|
||||||
|
capture_points: 5,
|
||||||
|
damage_dealt: 3201 * 50,
|
||||||
|
damage_received: 1093 * 50,
|
||||||
|
dropped_capture_points: 40,
|
||||||
|
frags: 99,
|
||||||
|
frags8p: 0,
|
||||||
|
hits: 50 * 13,
|
||||||
|
losses: 20,
|
||||||
|
max_frags: 7,
|
||||||
|
max_xp: 1203,
|
||||||
|
shots: 50 * 14,
|
||||||
|
spotted: 50 * 1.5,
|
||||||
|
survived_battles: 32,
|
||||||
|
win_and_survived: 28,
|
||||||
|
wins: 30,
|
||||||
|
xp: 1230 * 50,
|
||||||
|
},
|
||||||
|
averageDefinitions.averages[7297].mu!,
|
||||||
|
);
|
||||||
|
|
||||||
|
export function EmbedBreakdownPreview() {
|
||||||
|
const tanks = Object.values(tankDefinitions.tanks);
|
||||||
|
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BreakdownEmbedWrapper>
|
||||||
|
{useEmbedState("show_total") && (
|
||||||
|
<BreakdownEmbedCard composite={fakeCompositeStats} tank={null} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{tanks.slice(0, useEmbedState("list_max_tanks")).map((tank) => (
|
||||||
|
<BreakdownEmbedCard
|
||||||
|
composite={fakeCompositeStats}
|
||||||
|
key={tank.id}
|
||||||
|
tank={tank}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</BreakdownEmbedWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
+6
-71
@@ -1,18 +1,15 @@
|
|||||||
import {
|
import {
|
||||||
calculateCompositeStats,
|
calculateCompositeStats,
|
||||||
compositeStats,
|
|
||||||
compositeStatsKeys,
|
|
||||||
deltaTankStats,
|
deltaTankStats,
|
||||||
getTankStats,
|
getTankStats,
|
||||||
idToRegion,
|
idToRegion,
|
||||||
sumCompositeStats,
|
sumCompositeStats,
|
||||||
type IndividualTankStats,
|
type IndividualTankStats,
|
||||||
} from "@blitzkit/core";
|
} from "@blitzkit/core";
|
||||||
import locales from "@blitzkit/i18n/locales.json";
|
|
||||||
import { ReloadIcon } from "@radix-ui/react-icons";
|
import { ReloadIcon } from "@radix-ui/react-icons";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { api } from "../../api/dynamic";
|
import { api } from "../../api/dynamic";
|
||||||
import { breakdownConfig } from "../../config/embeds";
|
import type { breakdownConfig } from "../../config/embeds";
|
||||||
import { awaitableAverageDefinitions } from "../../core/awaitables/averageDefinitions";
|
import { awaitableAverageDefinitions } from "../../core/awaitables/averageDefinitions";
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
import { EmbedBreakdown } from "../../stores/embedBreakdown";
|
import { EmbedBreakdown } from "../../stores/embedBreakdown";
|
||||||
@@ -20,75 +17,13 @@ import { useEmbedStateCurry } from "../../stores/embedState/utilities";
|
|||||||
import { ContextMenu } from "../ContextMenu";
|
import { ContextMenu } from "../ContextMenu";
|
||||||
import { BreakdownEmbedCard, BreakdownEmbedWrapper } from "../TanksEmbed";
|
import { BreakdownEmbedCard, BreakdownEmbedWrapper } from "../TanksEmbed";
|
||||||
|
|
||||||
const allStrings = await Promise.all(
|
|
||||||
locales.supported.map(async ({ locale }) => ({
|
|
||||||
locale,
|
|
||||||
strings: await api.strings(locale),
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
|
|
||||||
export const compositeStatsKeysOptions = compositeStatsKeys.map((value) => ({
|
|
||||||
value,
|
|
||||||
locales: allStrings.reduce((accumulator, { locale, strings }) => {
|
|
||||||
return {
|
|
||||||
...accumulator,
|
|
||||||
[locale]: strings.common.composite_stats[value],
|
|
||||||
};
|
|
||||||
}, {}),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const [tankDefinitions, averageDefinitions] = await Promise.all([
|
const [tankDefinitions, averageDefinitions] = await Promise.all([
|
||||||
api.tanks(),
|
api.tanks(),
|
||||||
|
|
||||||
awaitableAverageDefinitions,
|
awaitableAverageDefinitions,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const fakeCompositeStats = compositeStats(
|
export function EmbedBreakdownRenderer() {
|
||||||
{
|
|
||||||
battle_life_time: 5 * 50 * 60,
|
|
||||||
battles: 50,
|
|
||||||
capture_points: 5,
|
|
||||||
damage_dealt: 3201 * 50,
|
|
||||||
damage_received: 1093 * 50,
|
|
||||||
dropped_capture_points: 40,
|
|
||||||
frags: 99,
|
|
||||||
frags8p: 0,
|
|
||||||
hits: 50 * 13,
|
|
||||||
losses: 20,
|
|
||||||
max_frags: 7,
|
|
||||||
max_xp: 1203,
|
|
||||||
shots: 50 * 14,
|
|
||||||
spotted: 50 * 1.5,
|
|
||||||
survived_battles: 32,
|
|
||||||
win_and_survived: 28,
|
|
||||||
wins: 30,
|
|
||||||
xp: 1230 * 50,
|
|
||||||
},
|
|
||||||
averageDefinitions.averages[7297].mu!
|
|
||||||
);
|
|
||||||
|
|
||||||
export function BreakdownPreview() {
|
|
||||||
const tanks = Object.values(tankDefinitions.tanks);
|
|
||||||
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<BreakdownEmbedWrapper>
|
|
||||||
{useEmbedState("show_total") && (
|
|
||||||
<BreakdownEmbedCard composite={fakeCompositeStats} tank={null} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{tanks.slice(0, useEmbedState("list_max_tanks")).map((tank) => (
|
|
||||||
<BreakdownEmbedCard
|
|
||||||
composite={fakeCompositeStats}
|
|
||||||
key={tank.id}
|
|
||||||
tank={tank}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</BreakdownEmbedWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function BreakdownRenderer() {
|
|
||||||
const strings = useStrings();
|
const strings = useStrings();
|
||||||
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
@@ -98,9 +33,9 @@ export function BreakdownRenderer() {
|
|||||||
const diff = useMemo(
|
const diff = useMemo(
|
||||||
() =>
|
() =>
|
||||||
deltaTankStats(tankStatsA, tankStatsB).sort(
|
deltaTankStats(tankStatsA, tankStatsB).sort(
|
||||||
(a, b) => b.last_battle_time - a.last_battle_time
|
(a, b) => b.last_battle_time - a.last_battle_time,
|
||||||
),
|
),
|
||||||
[tankStatsB]
|
[tankStatsB],
|
||||||
);
|
);
|
||||||
const compositeStats = diff
|
const compositeStats = diff
|
||||||
.map((diff) => {
|
.map((diff) => {
|
||||||
@@ -110,14 +45,14 @@ export function BreakdownRenderer() {
|
|||||||
|
|
||||||
const compositeStats = calculateCompositeStats(
|
const compositeStats = calculateCompositeStats(
|
||||||
{ battle_life_time: diff.battle_life_time, ...diff.all },
|
{ battle_life_time: diff.battle_life_time, ...diff.all },
|
||||||
average.mu!
|
average.mu!,
|
||||||
);
|
);
|
||||||
|
|
||||||
return { id: diff.tank_id, compositeStats };
|
return { id: diff.tank_id, compositeStats };
|
||||||
})
|
})
|
||||||
.filter((stats) => stats !== null);
|
.filter((stats) => stats !== null);
|
||||||
const sum = sumCompositeStats(
|
const sum = sumCompositeStats(
|
||||||
compositeStats.map(({ compositeStats }) => compositeStats)
|
compositeStats.map(({ compositeStats }) => compositeStats),
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
+5
-5
@@ -1,14 +1,14 @@
|
|||||||
import { RangeSlider } from "./RangeSlider";
|
import { EmbedRangeSlider } from "../EmbedRangeSlider";
|
||||||
|
|
||||||
interface ColorControllerRawProps {
|
interface EmbedColorInputProps {
|
||||||
value: string;
|
value: string;
|
||||||
onValueChange: (value: string) => void;
|
onValueChange: (value: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ColorControllerRaw({
|
export function EmbedColorInput({
|
||||||
value,
|
value,
|
||||||
onValueChange,
|
onValueChange,
|
||||||
}: ColorControllerRawProps) {
|
}: EmbedColorInputProps) {
|
||||||
const tintString = value.slice(0, 7);
|
const tintString = value.slice(0, 7);
|
||||||
const alphaString = value.slice(7, 9);
|
const alphaString = value.slice(7, 9);
|
||||||
const alpha = alphaString.length === 0 ? 255 : parseInt(alphaString, 16);
|
const alpha = alphaString.length === 0 ? 255 : parseInt(alphaString, 16);
|
||||||
@@ -24,7 +24,7 @@ export function ColorControllerRaw({
|
|||||||
onValueChange(`${event.target.value}${alpha}`);
|
onValueChange(`${event.target.value}${alpha}`);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<RangeSlider
|
<EmbedRangeSlider
|
||||||
min={0}
|
min={0}
|
||||||
max={255}
|
max={255}
|
||||||
value={alpha}
|
value={alpha}
|
||||||
+3
-1
@@ -2,7 +2,9 @@ import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]
|
|||||||
import { EmbedState } from "../../stores/embedState";
|
import { EmbedState } from "../../stores/embedState";
|
||||||
import { Switch } from "../Switch";
|
import { Switch } from "../Switch";
|
||||||
|
|
||||||
export function Boolean({ configKey }: EmbedPreviewControllerProps) {
|
export function EmbedControlBoolean({
|
||||||
|
configKey,
|
||||||
|
}: EmbedPreviewControllerProps) {
|
||||||
return (
|
return (
|
||||||
<Switch
|
<Switch
|
||||||
checked={EmbedState.use((state) => state[configKey] as boolean)}
|
checked={EmbedState.use((state) => state[configKey] as boolean)}
|
||||||
+3
-3
@@ -1,12 +1,12 @@
|
|||||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||||
import { EmbedState } from "../../stores/embedState";
|
import { EmbedState } from "../../stores/embedState";
|
||||||
import { ColorControllerRaw } from "./ColorControllerRaw";
|
import { EmbedColorInput } from "../EmbedColorInput";
|
||||||
|
|
||||||
export function Color({ configKey }: EmbedPreviewControllerProps) {
|
export function EmbedControlColor({ configKey }: EmbedPreviewControllerProps) {
|
||||||
const color = EmbedState.use((state) => state[configKey] as string);
|
const color = EmbedState.use((state) => state[configKey] as string);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ColorControllerRaw
|
<EmbedColorInput
|
||||||
value={color}
|
value={color}
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
EmbedState.mutate((draft) => {
|
EmbedState.mutate((draft) => {
|
||||||
+1
-1
@@ -8,7 +8,7 @@ import type {
|
|||||||
} from "../../stores/embedState/constants";
|
} from "../../stores/embedState/constants";
|
||||||
import { Select } from "../Select";
|
import { Select } from "../Select";
|
||||||
|
|
||||||
export function Enum({
|
export function EmbedControlEnum({
|
||||||
configKey,
|
configKey,
|
||||||
config,
|
config,
|
||||||
}: EmbedPreviewControllerProps & {
|
}: EmbedPreviewControllerProps & {
|
||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||||
import { EmbedState } from "../../stores/embedState";
|
import { EmbedState } from "../../stores/embedState";
|
||||||
import type { Radius } from "../../types/styles";
|
import type { Radius } from "../../types/styles";
|
||||||
import { RangeSlider } from "./RangeSlider";
|
import { EmbedRangeSlider } from "../EmbedRangeSlider";
|
||||||
|
|
||||||
export function Radius({ configKey }: EmbedPreviewControllerProps) {
|
export function EmbedControlRadius({ configKey }: EmbedPreviewControllerProps) {
|
||||||
return (
|
return (
|
||||||
<RangeSlider
|
<EmbedRangeSlider
|
||||||
min={0}
|
min={0}
|
||||||
max={10}
|
max={10}
|
||||||
value={EmbedState.use((state) => {
|
value={EmbedState.use((state) => {
|
||||||
File renamed without changes.
+14
-13
@@ -1,27 +1,29 @@
|
|||||||
import { FontBoldIcon, FontSizeIcon } from "@radix-ui/react-icons";
|
import { FontBoldIcon, FontSizeIcon } from "@radix-ui/react-icons";
|
||||||
import type { EmbedPreviewControllerProps } from "../../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||||
import { weights } from "../../../config/styles";
|
import { weights } from "../../config/styles";
|
||||||
import { EmbedState } from "../../../stores/embedState";
|
import { EmbedState } from "../../stores/embedState";
|
||||||
import type {
|
import type {
|
||||||
EmbedConfigItemType,
|
EmbedConfigItemType,
|
||||||
EmbedItemType,
|
EmbedItemType,
|
||||||
} from "../../../stores/embedState/constants";
|
} from "../../stores/embedState/constants";
|
||||||
import type { SpaceWithout0, Weight } from "../../../types/styles";
|
import type { SpaceWithout0, Weight } from "../../types/styles";
|
||||||
import { ColorControllerRaw } from "../ColorControllerRaw";
|
import { EmbedColorInput } from "../EmbedColorInput";
|
||||||
import { RangeSlider } from "../RangeSlider";
|
import { EmbedRangeSlider } from "../EmbedRangeSlider";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
const weightNames = Object.keys(weights) as Weight[];
|
const weightNames = Object.keys(weights) as Weight[];
|
||||||
|
|
||||||
type RichTextState = EmbedConfigItemType<EmbedItemType.RichText>["default"];
|
type RichTextState = EmbedConfigItemType<EmbedItemType.RichText>["default"];
|
||||||
|
|
||||||
export function RichText({ configKey }: EmbedPreviewControllerProps) {
|
export function EmbedControlRichText({
|
||||||
|
configKey,
|
||||||
|
}: EmbedPreviewControllerProps) {
|
||||||
const state = EmbedState.use((state) => state[configKey] as RichTextState);
|
const state = EmbedState.use((state) => state[configKey] as RichTextState);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["rich-text"]}>
|
<div className={styles["rich-text"]}>
|
||||||
<div className={styles.row}>
|
<div className={styles.row}>
|
||||||
<ColorControllerRaw
|
<EmbedColorInput
|
||||||
value={state.color}
|
value={state.color}
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
EmbedState.mutate((draft) => {
|
EmbedState.mutate((draft) => {
|
||||||
@@ -33,7 +35,7 @@ export function RichText({ configKey }: EmbedPreviewControllerProps) {
|
|||||||
|
|
||||||
<div className={styles.row} data-padded>
|
<div className={styles.row} data-padded>
|
||||||
<FontSizeIcon className={styles.icon} />
|
<FontSizeIcon className={styles.icon} />
|
||||||
<RangeSlider
|
<EmbedRangeSlider
|
||||||
min={1}
|
min={1}
|
||||||
max={9}
|
max={9}
|
||||||
value={Number(state.size)}
|
value={Number(state.size)}
|
||||||
@@ -48,14 +50,13 @@ export function RichText({ configKey }: EmbedPreviewControllerProps) {
|
|||||||
|
|
||||||
<div className={styles.row} data-padded>
|
<div className={styles.row} data-padded>
|
||||||
<FontBoldIcon className={styles.icon} />
|
<FontBoldIcon className={styles.icon} />
|
||||||
<RangeSlider
|
<EmbedRangeSlider
|
||||||
min={0}
|
min={0}
|
||||||
max={weightNames.length - 1}
|
max={weightNames.length - 1}
|
||||||
value={weightNames.indexOf(state.weight)}
|
value={weightNames.indexOf(state.weight)}
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
EmbedState.mutate((draft) => {
|
EmbedState.mutate((draft) => {
|
||||||
(draft[configKey] as RichTextState).weight =
|
(draft[configKey] as RichTextState).weight = weightNames[value];
|
||||||
weightNames[value];
|
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||||
import { EmbedState } from "../../stores/embedState";
|
import { EmbedState } from "../../stores/embedState";
|
||||||
import type { Space } from "../../types/styles";
|
import type { Space } from "../../types/styles";
|
||||||
import { RangeSlider } from "./RangeSlider";
|
import { EmbedRangeSlider } from "../EmbedRangeSlider";
|
||||||
|
|
||||||
export function Size({ configKey }: EmbedPreviewControllerProps) {
|
export function EmbedControlSize({ configKey }: EmbedPreviewControllerProps) {
|
||||||
return (
|
return (
|
||||||
<RangeSlider
|
<EmbedRangeSlider
|
||||||
min={0}
|
min={0}
|
||||||
max={9}
|
max={9}
|
||||||
value={EmbedState.use((state) => parseInt(state[configKey] as Space))}
|
value={EmbedState.use((state) => parseInt(state[configKey] as Space))}
|
||||||
+5
-3
@@ -1,11 +1,13 @@
|
|||||||
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||||
import { EmbedState } from "../../stores/embedState";
|
import { EmbedState } from "../../stores/embedState";
|
||||||
import type { SpaceWithout0 } from "../../types/styles";
|
import type { SpaceWithout0 } from "../../types/styles";
|
||||||
import { RangeSlider } from "./RangeSlider";
|
import { EmbedRangeSlider } from "../EmbedRangeSlider";
|
||||||
|
|
||||||
export function SizeWithout0({ configKey }: EmbedPreviewControllerProps) {
|
export function EmbedControlSizeWithout0({
|
||||||
|
configKey,
|
||||||
|
}: EmbedPreviewControllerProps) {
|
||||||
return (
|
return (
|
||||||
<RangeSlider
|
<EmbedRangeSlider
|
||||||
min={1}
|
min={1}
|
||||||
max={9}
|
max={9}
|
||||||
value={EmbedState.use((state) =>
|
value={EmbedState.use((state) =>
|
||||||
+3
-3
@@ -4,16 +4,16 @@ import type {
|
|||||||
EmbedConfigItemType,
|
EmbedConfigItemType,
|
||||||
EmbedItemType,
|
EmbedItemType,
|
||||||
} from "../../stores/embedState/constants";
|
} from "../../stores/embedState/constants";
|
||||||
import { RangeSlider } from "./RangeSlider";
|
import { EmbedRangeSlider } from "../EmbedRangeSlider";
|
||||||
|
|
||||||
export function Slider({
|
export function EmbedControlSlider({
|
||||||
configKey,
|
configKey,
|
||||||
config,
|
config,
|
||||||
}: EmbedPreviewControllerProps & {
|
}: EmbedPreviewControllerProps & {
|
||||||
config: EmbedConfigItemType<EmbedItemType.Slider>;
|
config: EmbedConfigItemType<EmbedItemType.Slider>;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<RangeSlider
|
<EmbedRangeSlider
|
||||||
min={config.min}
|
min={config.min}
|
||||||
max={config.max}
|
max={config.max}
|
||||||
value={EmbedState.use((state) => Number(state[configKey]))}
|
value={EmbedState.use((state) => Number(state[configKey]))}
|
||||||
File renamed without changes.
+4
-4
@@ -1,9 +1,9 @@
|
|||||||
import type { EmbedPreviewControllerProps } from "../../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
import type { EmbedPreviewControllerProps } from "../../pages/[...chunk_default]/[...locale]/embed/[embed]/_index";
|
||||||
import { EmbedState } from "../../../stores/embedState";
|
import { EmbedState } from "../../stores/embedState";
|
||||||
import { TextField } from "../../TextField";
|
import { TextField } from "../TextField";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
export function TextController({ configKey }: EmbedPreviewControllerProps) {
|
export function EmbedControlText({ configKey }: EmbedPreviewControllerProps) {
|
||||||
return (
|
return (
|
||||||
<TextField
|
<TextField
|
||||||
className={styles.field}
|
className={styles.field}
|
||||||
File renamed without changes.
+12
-12
@@ -8,23 +8,23 @@ import { CaretLeftIcon, Link2Icon, PersonIcon } from "@radix-ui/react-icons";
|
|||||||
import { debounce } from "lodash-es";
|
import { debounce } from "lodash-es";
|
||||||
import { useCallback, useRef, useState } from "react";
|
import { useCallback, useRef, useState } from "react";
|
||||||
import { stringify } from "urlon";
|
import { stringify } from "urlon";
|
||||||
import type { embedConfigurations } from "../../../config/embeds";
|
import type { embedConfigurations } from "../../config/embeds";
|
||||||
import { useStrings } from "../../../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
import { EmbedState, type EmbedStateStore } from "../../../stores/embedState";
|
import { EmbedState, type EmbedStateStore } from "../../stores/embedState";
|
||||||
import { Button } from "../../Button";
|
import { Button } from "../Button";
|
||||||
import { CopyButton } from "../../CopyButton";
|
import { CopyButton } from "../CopyButton";
|
||||||
import { Dialog } from "../../Dialog";
|
import { Dialog } from "../Dialog";
|
||||||
import { SearchResults } from "../../SearchResults";
|
import { SearchResults } from "../SearchResults";
|
||||||
import { Spinner } from "../../Spinner";
|
import { Spinner } from "../Spinner";
|
||||||
import { Text } from "../../Text";
|
import { Text } from "../Text";
|
||||||
import { TextField } from "../../TextField";
|
import { TextField } from "../TextField";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
interface GenerateURLProps {
|
interface EmbedGenerateURLProps {
|
||||||
embed: keyof typeof embedConfigurations;
|
embed: keyof typeof embedConfigurations;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GenerateURL({ embed }: GenerateURLProps) {
|
export function EmbedGenerateURL({ embed }: EmbedGenerateURLProps) {
|
||||||
const [searchDialogOpen, setSearchDialogOpen] = useState(false);
|
const [searchDialogOpen, setSearchDialogOpen] = useState(false);
|
||||||
const [copyDialogOpen, setCopyDialogOpen] = useState(false);
|
const [copyDialogOpen, setCopyDialogOpen] = useState(false);
|
||||||
const [copyUser, setCopyUser] = useState<AccountListItem | null>(null);
|
const [copyUser, setCopyUser] = useState<AccountListItem | null>(null);
|
||||||
File renamed without changes.
+9
-9
@@ -1,16 +1,16 @@
|
|||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { parse } from "urlon";
|
import { parse } from "urlon";
|
||||||
import { useStrings } from "../../../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
import { EmbedState } from "../../../stores/embedState";
|
import { EmbedState } from "../../stores/embedState";
|
||||||
import { AlertDialog } from "../../AlertDialog";
|
import { AlertDialog } from "../AlertDialog";
|
||||||
import { Button } from "../../Button";
|
import { Button } from "../Button";
|
||||||
import { Heading } from "../../Heading";
|
import { Heading } from "../Heading";
|
||||||
import { Text } from "../../Text";
|
import { Text } from "../Text";
|
||||||
import { TextField } from "../../TextField";
|
import { TextField } from "../TextField";
|
||||||
import { Tooltip } from "../../Tooltip";
|
import { Tooltip } from "../Tooltip";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
export function Import() {
|
export function EmbedImport() {
|
||||||
const importInput = useRef<HTMLInputElement>(null);
|
const importInput = useRef<HTMLInputElement>(null);
|
||||||
const [showInvalidURLPrompt, setShowInvalidURLPrompt] = useState(false);
|
const [showInvalidURLPrompt, setShowInvalidURLPrompt] = useState(false);
|
||||||
const [showConfirmation, setConfirmation] = useState(false);
|
const [showConfirmation, setConfirmation] = useState(false);
|
||||||
File renamed without changes.
+5
-5
@@ -1,15 +1,15 @@
|
|||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { embedPreviews } from "../../../config/embeds";
|
import { embedPreviews } from "../../config/embeds";
|
||||||
import { classNames } from "../../../ui/classNames";
|
import { classNames } from "../../ui/classNames";
|
||||||
import { useEmbedStateCurry } from "../../../stores/embedState/utilities";
|
import { useEmbedStateCurry } from "../../stores/embedState/utilities";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
interface PreviewWrapperProps {
|
interface EmbedPreviewProps {
|
||||||
name: keyof typeof embedPreviews;
|
name: keyof typeof embedPreviews;
|
||||||
naked?: boolean;
|
naked?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PreviewWrapper({ name, naked }: PreviewWrapperProps) {
|
export function EmbedPreview({ name, naked }: EmbedPreviewProps) {
|
||||||
const { useEmbedState } = useEmbedStateCurry();
|
const { useEmbedState } = useEmbedStateCurry();
|
||||||
|
|
||||||
const width = useEmbedState("width");
|
const width = useEmbedState("width");
|
||||||
File renamed without changes.
+4
-4
@@ -1,19 +1,19 @@
|
|||||||
import { Slider } from "../../Slider";
|
import { Slider } from "../Slider";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
interface RangeSliderProps {
|
interface EmbedRangeSliderProps {
|
||||||
min: number;
|
min: number;
|
||||||
max: number;
|
max: number;
|
||||||
value: number;
|
value: number;
|
||||||
onValueChange(value: number): void;
|
onValueChange(value: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RangeSlider({
|
export function EmbedRangeSlider({
|
||||||
min,
|
min,
|
||||||
max,
|
max,
|
||||||
value,
|
value,
|
||||||
onValueChange,
|
onValueChange,
|
||||||
}: RangeSliderProps) {
|
}: EmbedRangeSliderProps) {
|
||||||
return (
|
return (
|
||||||
<Slider.Root
|
<Slider.Root
|
||||||
className={styles.root}
|
className={styles.root}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
import { literals } from "@blitzkit/i18n/src/literals";
|
import { literals } from "@blitzkit/i18n/src/literals";
|
||||||
import { EyeOpenIcon } from "@radix-ui/react-icons";
|
import { EyeOpenIcon } from "@radix-ui/react-icons";
|
||||||
import { Box, Flex, Heading, Text } from "@radix-ui/themes";
|
import { Box, Flex, Heading, Text } from "@radix-ui/themes";
|
||||||
import { api } from "../api/dynamic";
|
import { api } from "../../api/dynamic";
|
||||||
import { awaitablePopularTanks } from "../core/awaitables/popularTanks";
|
import { awaitablePopularTanks } from "../../core/awaitables/popularTanks";
|
||||||
import {
|
import {
|
||||||
LocaleProvider,
|
LocaleProvider,
|
||||||
useLocale,
|
useLocale,
|
||||||
type LocaleAcceptorProps,
|
type LocaleAcceptorProps,
|
||||||
} from "../hooks/useLocale";
|
} from "../../hooks/useLocale";
|
||||||
import { TankCard } from "./TankCard";
|
import { TankCard } from "../TankCard";
|
||||||
|
|
||||||
const [tankDefinitions, popularTanks] = await Promise.all([
|
const [tankDefinitions, popularTanks] = await Promise.all([
|
||||||
api.tanks(),
|
api.tanks(),
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { times } from "lodash-es";
|
import { times } from "lodash-es";
|
||||||
import { useCallback, useEffect, useState, type ReactNode } from "react";
|
import { useCallback, useEffect, useState, type ReactNode } from "react";
|
||||||
import type { MaybeSkeletonComponentProps } from "../types/maybeSkeletonComponentProps";
|
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
||||||
|
|
||||||
export interface IncrementalLoaderProps<Props extends { key: string }> {
|
export interface IncrementalLoaderProps<Props extends { key: string }> {
|
||||||
initial: number;
|
initial: number;
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { degToRad } from "three/src/math/MathUtils.js";
|
import { degToRad } from "three/src/math/MathUtils.js";
|
||||||
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
import { applyPitchYawLimits } from "../../core/blitz/applyPitchYawLimits";
|
||||||
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
import { modelTransformEvent } from "../../core/blitzkit/modelTransform";
|
||||||
import { useDuelModels } from "../hooks/useDuelModels";
|
import { useDuelModels } from "../../hooks/useDuelModels";
|
||||||
|
|
||||||
export function InitialCameraAligner() {
|
export function InitialCameraAligner() {
|
||||||
const { turret, gun } = useDuelModels("protagonist");
|
const { turret, gun } = useDuelModels("protagonist");
|
||||||
+6
-6
@@ -11,12 +11,12 @@ import {
|
|||||||
} from "react";
|
} from "react";
|
||||||
import { HemisphereLight, SpotLight, type Group } from "three";
|
import { HemisphereLight, SpotLight, type Group } from "three";
|
||||||
import { degToRad, lerp } from "three/src/math/MathUtils.js";
|
import { degToRad, lerp } from "three/src/math/MathUtils.js";
|
||||||
import { sceneChangeEvent } from "../core/three/sceneChange";
|
import { sceneChangeEvent } from "../../core/three/sceneChange";
|
||||||
import { useShadowsOnDemand } from "../hooks/useShadowsOnDemand";
|
import { useShadowsOnDemand } from "../../hooks/useShadowsOnDemand";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { TankopediaPersistent } from "../stores/tankopediaPersistent";
|
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
||||||
import { TankopediaDisplay } from "../stores/tankopediaPersistent/constants";
|
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
||||||
import { TankopediaContactShadows } from "./TankopediaContactShadows";
|
import { TankopediaContactShadows } from "../TankopediaContactShadows";
|
||||||
|
|
||||||
const ANGLE = degToRad(15);
|
const ANGLE = degToRad(15);
|
||||||
const REVEAL_ANIMATION_TIME = 3;
|
const REVEAL_ANIMATION_TIME = 3;
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import locales from "@blitzkit/i18n/locales.json";
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
import { Link, type LinkProps } from "./Link";
|
import { Link, type LinkProps } from "../Link";
|
||||||
|
|
||||||
export interface LinkI18n extends LinkProps {
|
export interface LinkI18n extends LinkProps {
|
||||||
locale: string;
|
locale: string;
|
||||||
+2
-2
@@ -5,8 +5,8 @@ import {
|
|||||||
} from "@blitzkit/i18n";
|
} from "@blitzkit/i18n";
|
||||||
import locales from "@blitzkit/i18n/locales.json";
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
import { Select } from "@radix-ui/themes";
|
import { Select } from "@radix-ui/themes";
|
||||||
import type { LocaleAcceptorProps } from "../hooks/useLocale";
|
import type { LocaleAcceptorProps } from "../../hooks/useLocale";
|
||||||
import { BlitzKitTheme } from "./BlitzKitTheme";
|
import { BlitzKitTheme } from "../BlitzKitTheme";
|
||||||
|
|
||||||
export function LocaleSwitcherThemeWrapper({ locale }: LocaleAcceptorProps) {
|
export function LocaleSwitcherThemeWrapper({ locale }: LocaleAcceptorProps) {
|
||||||
return (
|
return (
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
import { Link, Table } from '@radix-ui/themes';
|
import { Link, Table } from '@radix-ui/themes';
|
||||||
import MarkdownToJSX from 'markdown-to-jsx';
|
import MarkdownToJSX from 'markdown-to-jsx';
|
||||||
import type { ComponentProps } from 'react';
|
import type { ComponentProps } from 'react';
|
||||||
import { docImageUrl, isExternalImage } from '../core/blitzkit/docImages';
|
import { docImageUrl, isExternalImage } from '../../core/blitzkit/docImages';
|
||||||
import { LazyImage } from './LazyImage';
|
import { LazyImage } from '../LazyImage';
|
||||||
|
|
||||||
interface MarkdownProps {
|
interface MarkdownProps {
|
||||||
children: string;
|
children: string;
|
||||||
File renamed without changes.
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
import { fisherYates } from "@blitzkit/core";
|
import { fisherYates } from "@blitzkit/core";
|
||||||
import { CaretDownIcon } from "@radix-ui/react-icons";
|
import { CaretDownIcon } from "@radix-ui/react-icons";
|
||||||
import { Button, DropdownMenu, Flex, Spinner } from "@radix-ui/themes";
|
import { Button, DropdownMenu, Flex, Spinner } from "@radix-ui/themes";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { App } from "../stores/app";
|
import { App } from "../../stores/app";
|
||||||
import { Playlist } from "../stores/playlist";
|
import { Playlist } from "../../stores/playlist";
|
||||||
|
|
||||||
export function PlaylistActions() {
|
export function PlaylistActions() {
|
||||||
const { strings } = useLocale();
|
const { strings } = useLocale();
|
||||||
+9
-9
@@ -12,15 +12,15 @@ import {
|
|||||||
} from "@radix-ui/themes";
|
} from "@radix-ui/themes";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import usePromise from "react-promise-suspense";
|
import usePromise from "react-promise-suspense";
|
||||||
import { api } from "../api/dynamic";
|
import { api } from "../../api/dynamic";
|
||||||
import { filterTanks } from "../core/blitzkit/filterTanks";
|
import { filterTanks } from "../../core/blitzkit/filterTanks";
|
||||||
import { generatePlaylist } from "../core/blitzkit/generatePlaylist";
|
import { generatePlaylist } from "../../core/blitzkit/generatePlaylist";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { App } from "../stores/app";
|
import { App } from "../../stores/app";
|
||||||
import { TankFilters } from "../stores/tankFilters";
|
import { TankFilters } from "../../stores/tankFilters";
|
||||||
import type { MaybeSkeletonComponentProps } from "../types/maybeSkeletonComponentProps";
|
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
||||||
import { LinkI18n } from "./LinkI18n";
|
import { LinkI18n } from "../LinkI18n";
|
||||||
import { TankSearchFilters } from "./TankSearchFilters";
|
import { TankSearchFilters } from "../TankSearchFilters";
|
||||||
|
|
||||||
const tankDefinitions = await api.tanks();
|
const tankDefinitions = await api.tanks();
|
||||||
|
|
||||||
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
import { Box, Flex } from "@radix-ui/themes";
|
import { Box, Flex } from "@radix-ui/themes";
|
||||||
import { CurrentlyPlaying } from "./CurrentlyPlaying";
|
import { CurrentlyPlaying } from "../CurrentlyPlaying";
|
||||||
import { PlaylistActions } from "./PlaylistActions";
|
import { PlaylistActions } from "../PlaylistActions";
|
||||||
import { PlaylistTable } from "./PlaylistTable";
|
import { PlaylistTable } from "../PlaylistTable";
|
||||||
import { PlaylistTracking } from "./PlaylistTracking";
|
import { PlaylistTracking } from "../PlaylistTracking";
|
||||||
|
|
||||||
export function PlaylistOrder() {
|
export function PlaylistOrder() {
|
||||||
return (
|
return (
|
||||||
+5
-5
@@ -1,9 +1,9 @@
|
|||||||
import { Table, Text } from "@radix-ui/themes";
|
import { Table, Text } from "@radix-ui/themes";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { Playlist } from "../stores/playlist";
|
import { Playlist } from "../../stores/playlist";
|
||||||
import { PlaylistTankEntry } from "./PlaylistTankEntry";
|
import { PlaylistTankEntry } from "../PlaylistTankEntry";
|
||||||
import { StickyColumnHeaderCell } from "./StickyColumnHeaderCell";
|
import { StickyColumnHeaderCell } from "../StickyColumnHeaderCell";
|
||||||
import { StickyTableRoot } from "./StickyTableRoot";
|
import { StickyTableRoot } from "../StickyTableRoot";
|
||||||
|
|
||||||
export function PlaylistTable() {
|
export function PlaylistTable() {
|
||||||
const { strings } = useLocale();
|
const { strings } = useLocale();
|
||||||
+4
-4
@@ -5,10 +5,10 @@ import {
|
|||||||
} from "@radix-ui/react-icons";
|
} from "@radix-ui/react-icons";
|
||||||
import { Checkbox, Flex, IconButton, Table, Text } from "@radix-ui/themes";
|
import { Checkbox, Flex, IconButton, Table, Text } from "@radix-ui/themes";
|
||||||
import { memo } from "react";
|
import { memo } from "react";
|
||||||
import { api } from "../api/dynamic";
|
import { api } from "../../api/dynamic";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { Playlist, type PlaylistEntry } from "../stores/playlist";
|
import { Playlist, type PlaylistEntry } from "../../stores/playlist";
|
||||||
import { TankRowHeaderCell } from "./TankRowHeaderCell";
|
import { TankRowHeaderCell } from "../TankRowHeaderCell";
|
||||||
|
|
||||||
interface Props extends PlaylistEntry {
|
interface Props extends PlaylistEntry {
|
||||||
index: number;
|
index: number;
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { updatePlaylist } from "../core/blitzkit/updatePlaylist";
|
import { updatePlaylist } from "../../core/blitzkit/updatePlaylist";
|
||||||
|
|
||||||
export function PlaylistTracking() {
|
export function PlaylistTracking() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
File renamed without changes.
+7
-7
@@ -1,12 +1,12 @@
|
|||||||
import { memo, useRef } from "react";
|
import { memo, useRef } from "react";
|
||||||
import { Group } from "three";
|
import { Group } from "three";
|
||||||
import { useArmorPlates } from "../hooks/useArmorPlates";
|
import { useArmorPlates } from "../../hooks/useArmorPlates";
|
||||||
import { useConsumable } from "../hooks/useConsumable";
|
import { useConsumable } from "../../hooks/useConsumable";
|
||||||
import { useDuelModels } from "../hooks/useDuelModels";
|
import { useDuelModels } from "../../hooks/useDuelModels";
|
||||||
import { useDuelModules } from "../hooks/useDuelModules";
|
import { useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { useTankTransform } from "../hooks/useTankTransform";
|
import { useTankTransform } from "../../hooks/useTankTransform";
|
||||||
import { toThreeVector } from "../three/toThreeVector";
|
import { toThreeVector } from "../../three/toThreeVector";
|
||||||
import { PrimaryArmorSceneComponent } from "./PrimaryArmorSceneComponent";
|
import { PrimaryArmorSceneComponent } from "../PrimaryArmorSceneComponent";
|
||||||
|
|
||||||
export const PrimaryArmorScene = memo(() => {
|
export const PrimaryArmorScene = memo(() => {
|
||||||
const turretContainer = useRef<Group>(null!);
|
const turretContainer = useRef<Group>(null!);
|
||||||
@@ -11,7 +11,7 @@ import { ScrollerCurtains } from "../ScrollerCurtains";
|
|||||||
import { Section } from "../Section";
|
import { Section } from "../Section";
|
||||||
import { TankCard } from "../TankCard";
|
import { TankCard } from "../TankCard";
|
||||||
import { TankCardSkeleton } from "../TankCardSkeleton";
|
import { TankCardSkeleton } from "../TankCardSkeleton";
|
||||||
import { MAX_RECENTLY_VIEWED } from "../TankSearchResults/constants";
|
import { MAX_RECENTLY_VIEWED } from "../../config/recentlyViewed";
|
||||||
import { Text } from "../Text";
|
import { Text } from "../Text";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import { alias } from "@blitzkit/core";
|
import { alias } from "@blitzkit/core";
|
||||||
import { LazyImage } from "./LazyImage";
|
import { LazyImage } from "../LazyImage";
|
||||||
|
|
||||||
interface SmallTankIconProps {
|
interface SmallTankIconProps {
|
||||||
id: number;
|
id: number;
|
||||||
+11
-11
@@ -1,19 +1,19 @@
|
|||||||
import { memo, useMemo, useRef } from "react";
|
import { memo, useMemo, useRef } from "react";
|
||||||
import { Group, Plane, Scene, Vector3, type Object3D } from "three";
|
import { Group, Plane, Scene, Vector3, type Object3D } from "three";
|
||||||
import { type ArmorPlate, useArmorPlates } from "../hooks/useArmorPlates";
|
import { type ArmorPlate, useArmorPlates } from "../../hooks/useArmorPlates";
|
||||||
import { useConsumable } from "../hooks/useConsumable";
|
import { useConsumable } from "../../hooks/useConsumable";
|
||||||
import { useDuelModels } from "../hooks/useDuelModels";
|
import { useDuelModels } from "../../hooks/useDuelModels";
|
||||||
import { useDuelModules } from "../hooks/useDuelModules";
|
import { useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { useModelNodes } from "../hooks/useModelNodes";
|
import { useModelNodes } from "../../hooks/useModelNodes";
|
||||||
import { useTankTransform } from "../hooks/useTankTransform";
|
import { useTankTransform } from "../../hooks/useTankTransform";
|
||||||
import { toThreeVector } from "../three/toThreeVector";
|
import { toThreeVector } from "../../three/toThreeVector";
|
||||||
import {
|
import {
|
||||||
SpacedArmorSceneComponent,
|
SpacedArmorSceneComponent,
|
||||||
type ExternalModuleVariant,
|
type ExternalModuleVariant,
|
||||||
} from "./SpacedArmorSceneComponent";
|
} from "../SpacedArmorSceneComponent";
|
||||||
import { SpacedArmorSubExternal } from "./SpacedArmorSubExternal";
|
import { SpacedArmorSubExternal } from "../SpacedArmorSubExternal";
|
||||||
import { SpacedArmorSubPrimary } from "./SpacedArmorSubPrimary";
|
import { SpacedArmorSubPrimary } from "../SpacedArmorSubPrimary";
|
||||||
import { SpacedArmorSubSpaced } from "./SpacedArmorSubSpaced";
|
import { SpacedArmorSubSpaced } from "../SpacedArmorSubSpaced";
|
||||||
|
|
||||||
export enum ArmorType {
|
export enum ArmorType {
|
||||||
Primary,
|
Primary,
|
||||||
+8
-8
@@ -13,22 +13,22 @@ import {
|
|||||||
Vector3,
|
Vector3,
|
||||||
} from "three";
|
} from "three";
|
||||||
import { degToRad } from "three/src/math/MathUtils.js";
|
import { degToRad } from "three/src/math/MathUtils.js";
|
||||||
import { defaultEqualizer } from "../config/equalizer";
|
import { defaultEqualizer } from "../../config/equalizer";
|
||||||
import { jsxTree } from "../core/blitzkit/jsxTree";
|
import { jsxTree } from "../../core/blitzkit/jsxTree";
|
||||||
import {
|
import {
|
||||||
SPALL_LINER_HE_DAMAGE_DELTA,
|
SPALL_LINER_HE_DAMAGE_DELTA,
|
||||||
SPALL_LINER_PROVISION_ID,
|
SPALL_LINER_PROVISION_ID,
|
||||||
} from "../core/blitzkit/spallLiner";
|
} from "../../core/blitzkit/spallLiner";
|
||||||
import { discardClippingPlane } from "../core/three/discardClippingPlane";
|
import { discardClippingPlane } from "../../core/three/discardClippingPlane";
|
||||||
import { getDuelModules } from "../hooks/useDuelModules";
|
import { getDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { hasEquipment } from "../hooks/useEquipment";
|
import { hasEquipment } from "../../hooks/useEquipment";
|
||||||
import {
|
import {
|
||||||
type Shot,
|
type Shot,
|
||||||
type ShotLayerBase,
|
type ShotLayerBase,
|
||||||
type ShotLayerNonExternal,
|
type ShotLayerNonExternal,
|
||||||
Tankopedia,
|
Tankopedia,
|
||||||
} from "../stores/tankopedia";
|
} from "../../stores/tankopedia";
|
||||||
import { ArmorType } from "./SpacedArmorScene";
|
import { ArmorType } from "../SpacedArmorScene";
|
||||||
|
|
||||||
type SpacedArmorSceneComponentProps = {
|
type SpacedArmorSceneComponentProps = {
|
||||||
node: Object3D;
|
node: Object3D;
|
||||||
File renamed without changes.
+13
-13
@@ -16,25 +16,25 @@ import {
|
|||||||
Quaternion,
|
Quaternion,
|
||||||
Vector3,
|
Vector3,
|
||||||
} from "three";
|
} from "three";
|
||||||
import { defaultEqualizer } from "../config/equalizer";
|
import { defaultEqualizer } from "../../config/equalizer";
|
||||||
import { unrotateDavaVector } from "../core/blitz/unrotateDavaVector";
|
import { unrotateDavaVector } from "../../core/blitz/unrotateDavaVector";
|
||||||
import { jsxTree } from "../core/blitzkit/jsxTree";
|
import { jsxTree } from "../../core/blitzkit/jsxTree";
|
||||||
import {
|
import {
|
||||||
modelTransformEvent,
|
modelTransformEvent,
|
||||||
type ModelTransformEventData,
|
type ModelTransformEventData,
|
||||||
} from "../core/blitzkit/modelTransform";
|
} from "../../core/blitzkit/modelTransform";
|
||||||
import { discardClippingPlane } from "../core/three/discardClippingPlane";
|
import { discardClippingPlane } from "../../core/three/discardClippingPlane";
|
||||||
import { sceneChangeEvent } from "../core/three/sceneChange";
|
import { sceneChangeEvent } from "../../core/three/sceneChange";
|
||||||
import { useDuelModules } from "../hooks/useDuelModules";
|
import { useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { useEquipment } from "../hooks/useEquipment";
|
import { useEquipment } from "../../hooks/useEquipment";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { transitionEvent } from "./Lighting";
|
import { transitionEvent } from "../Lighting";
|
||||||
import { ArmorType } from "./SpacedArmorScene";
|
import { ArmorType } from "../SpacedArmorScene";
|
||||||
import type {
|
import type {
|
||||||
ArmorUserData,
|
ArmorUserData,
|
||||||
ExternalModuleVariant,
|
ExternalModuleVariant,
|
||||||
} from "./SpacedArmorSceneComponent";
|
} from "../SpacedArmorSceneComponent";
|
||||||
import type { ThicknessRange } from "./TankStaticArmor";
|
import type { ThicknessRange } from "../TankStaticArmor";
|
||||||
|
|
||||||
type StaticArmorSceneComponentProps = {
|
type StaticArmorSceneComponentProps = {
|
||||||
name: string;
|
name: string;
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -11,7 +11,7 @@ import { ClassIcon } from "../ClassIcon";
|
|||||||
import { LazyImage } from "../LazyImage";
|
import { LazyImage } from "../LazyImage";
|
||||||
import { LinkI18nWrapper } from "../LinkI18nWrapper";
|
import { LinkI18nWrapper } from "../LinkI18nWrapper";
|
||||||
import { TankCardSkeleton } from "../TankCardSkeleton";
|
import { TankCardSkeleton } from "../TankCardSkeleton";
|
||||||
import { MAX_RECENTLY_VIEWED } from "../TankSearchResults/constants";
|
import { MAX_RECENTLY_VIEWED } from "../../config/recentlyViewed";
|
||||||
import { Text, type TextProps } from "../Text";
|
import { Text, type TextProps } from "../Text";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
import { createPortal, useFrame, useThree } from "@react-three/fiber";
|
import { createPortal, useFrame, useThree } from "@react-three/fiber";
|
||||||
import { memo, useState } from "react";
|
import { memo, useState } from "react";
|
||||||
import { DepthTexture, Scene, Vector2 } from "three";
|
import { DepthTexture, Scene, Vector2 } from "three";
|
||||||
import { spacedArmorRenderTarget } from "./PrimaryArmorRenderTarget";
|
import { spacedArmorRenderTarget } from "../PrimaryArmorRenderTarget";
|
||||||
import { PrimaryArmorScene } from "./PrimaryArmorScene";
|
import { PrimaryArmorScene } from "../PrimaryArmorScene";
|
||||||
import { SpacedArmorScene } from "./SpacedArmorScene";
|
import { SpacedArmorScene } from "../SpacedArmorScene";
|
||||||
|
|
||||||
export const TankDynamicArmor = memo(() => {
|
export const TankDynamicArmor = memo(() => {
|
||||||
const rootScene = useThree((state) => state.scene);
|
const rootScene = useThree((state) => state.scene);
|
||||||
+15
-15
@@ -2,21 +2,21 @@ import { invalidate, useThree, type ThreeEvent } from "@react-three/fiber";
|
|||||||
import { useMemo, useRef } from "react";
|
import { useMemo, useRef } from "react";
|
||||||
import type { Object3D, Texture } from "three";
|
import type { Object3D, Texture } from "three";
|
||||||
import { Group, Mesh, MeshStandardMaterial, Vector2 } from "three";
|
import { Group, Mesh, MeshStandardMaterial, Vector2 } from "three";
|
||||||
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
import { applyPitchYawLimits } from "../../core/blitz/applyPitchYawLimits";
|
||||||
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
import { modelTransformEvent } from "../../core/blitzkit/modelTransform";
|
||||||
import { controlsEnabledEvent } from "../core/controlsEnabled";
|
import { controlsEnabledEvent } from "../../core/controlsEnabled";
|
||||||
import { useBatchGroups } from "../hooks/useBatchGroups";
|
import { useBatchGroups } from "../../hooks/useBatchGroups";
|
||||||
import { useDuelModels } from "../hooks/useDuelModels";
|
import { useDuelModels } from "../../hooks/useDuelModels";
|
||||||
import { getDuelModules, useDuelModules } from "../hooks/useDuelModules";
|
import { getDuelModules, useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { hasEquipment } from "../hooks/useEquipment";
|
import { hasEquipment } from "../../hooks/useEquipment";
|
||||||
import { useModelNodes } from "../hooks/useModelNodes";
|
import { useModelNodes } from "../../hooks/useModelNodes";
|
||||||
import { useSilhouette } from "../hooks/useSilhouette";
|
import { useSilhouette } from "../../hooks/useSilhouette";
|
||||||
import { useSkin, type Skin } from "../hooks/useSkin";
|
import { useSkin, type Skin } from "../../hooks/useSkin";
|
||||||
import { useSkinAnimation } from "../hooks/useSkinAnimation";
|
import { useSkinAnimation } from "../../hooks/useSkinAnimation";
|
||||||
import { useTankTransform } from "../hooks/useTankTransform";
|
import { useTankTransform } from "../../hooks/useTankTransform";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { TankopediaDisplay } from "../stores/tankopediaPersistent/constants";
|
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
||||||
import { Batch } from "./Batch";
|
import { Batch } from "../Batch";
|
||||||
|
|
||||||
interface SectionProps {
|
interface SectionProps {
|
||||||
nodes: Object3D[];
|
nodes: Object3D[];
|
||||||
+5
-5
@@ -1,11 +1,11 @@
|
|||||||
import { tankIcon } from "@blitzkit/core";
|
import { tankIcon } from "@blitzkit/core";
|
||||||
import { type TankDefinition, TankType } from "@blitzkit/protos";
|
import { type TankDefinition, TankType } from "@blitzkit/protos";
|
||||||
import { Box, Flex } from "@radix-ui/themes";
|
import { Box, Flex } from "@radix-ui/themes";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { classIcons } from "./ClassIcon";
|
import { classIcons } from "../ClassIcon";
|
||||||
import { ExperimentIcon } from "./ExperimentIcon";
|
import { ExperimentIcon } from "../ExperimentIcon";
|
||||||
import { LinkI18n } from "./LinkI18n";
|
import { LinkI18n } from "../LinkI18n";
|
||||||
import { StickyRowHeaderCell } from "./StickyRowHeaderCell";
|
import { StickyRowHeaderCell } from "../StickyRowHeaderCell";
|
||||||
|
|
||||||
interface TankRowHeaderCellProps {
|
interface TankRowHeaderCellProps {
|
||||||
tank: TankDefinition;
|
tank: TankDefinition;
|
||||||
@@ -36,7 +36,7 @@ import { TankCard } from "../TankCard";
|
|||||||
import { TankCardWrapper } from "../TankCardWrapper";
|
import { TankCardWrapper } from "../TankCardWrapper";
|
||||||
import { TankSearchNoResults } from "../TankSearchNoResults";
|
import { TankSearchNoResults } from "../TankSearchNoResults";
|
||||||
import { Text } from "../Text";
|
import { Text } from "../Text";
|
||||||
import { MAX_RECENTLY_VIEWED } from "./constants";
|
import { MAX_RECENTLY_VIEWED } from "../../config/recentlyViewed";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
export type TankSearchResultsProps = {
|
export type TankSearchResultsProps = {
|
||||||
|
|||||||
+8
-8
@@ -3,14 +3,14 @@ import {
|
|||||||
CaretRightIcon,
|
CaretRightIcon,
|
||||||
DotFilledIcon,
|
DotFilledIcon,
|
||||||
} from "@radix-ui/react-icons";
|
} from "@radix-ui/react-icons";
|
||||||
import { characteristicsGroups } from "../config/characteristicsGroups";
|
import { characteristicsGroups } from "../../config/characteristicsGroups";
|
||||||
import { useStrings } from "../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
import { SortDirection } from "../stores/tankopediaPersistent";
|
import { SortDirection } from "../../stores/tankopediaPersistent";
|
||||||
import { TankSort } from "../stores/tankopediaSort";
|
import { TankSort } from "../../stores/tankopediaSort";
|
||||||
import { sortableCharacteristics } from "../tankopedia/sortableCharacteristics";
|
import { sortableCharacteristics } from "../../tankopedia/sortableCharacteristics";
|
||||||
import type { RenderedCharacteristicName } from "../types/characteristics";
|
import type { RenderedCharacteristicName } from "../../types/characteristics";
|
||||||
import { Button } from "./Button";
|
import { Button } from "../Button";
|
||||||
import { DropdownMenu } from "./DropdownMenu";
|
import { DropdownMenu } from "../DropdownMenu";
|
||||||
|
|
||||||
interface ItemProps {
|
interface ItemProps {
|
||||||
by: RenderedCharacteristicName;
|
by: RenderedCharacteristicName;
|
||||||
+17
-17
@@ -1,23 +1,23 @@
|
|||||||
import { useThree, type ThreeEvent } from "@react-three/fiber";
|
import { useThree, type ThreeEvent } from "@react-three/fiber";
|
||||||
import { memo, useRef } from "react";
|
import { memo, useRef } from "react";
|
||||||
import { Group, Plane, Vector2, Vector3 } from "three";
|
import { Group, Plane, Vector2, Vector3 } from "three";
|
||||||
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
import { applyPitchYawLimits } from "../../core/blitz/applyPitchYawLimits";
|
||||||
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
import { modelTransformEvent } from "../../core/blitzkit/modelTransform";
|
||||||
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
import { nameToArmorId } from "../../core/blitzkit/nameToArmorId";
|
||||||
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
import { resolveArmor } from "../../core/blitzkit/resolveThickness";
|
||||||
import { controlsEnabledEvent } from "../core/controlsEnabled";
|
import { controlsEnabledEvent } from "../../core/controlsEnabled";
|
||||||
import { useArmor } from "../hooks/useArmor";
|
import { useArmor } from "../../hooks/useArmor";
|
||||||
import { useConsumable } from "../hooks/useConsumable";
|
import { useConsumable } from "../../hooks/useConsumable";
|
||||||
import { useDuelModels } from "../hooks/useDuelModels";
|
import { useDuelModels } from "../../hooks/useDuelModels";
|
||||||
import { getDuelModules, useDuelModules } from "../hooks/useDuelModules";
|
import { getDuelModules, useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { hasEquipment } from "../hooks/useEquipment";
|
import { hasEquipment } from "../../hooks/useEquipment";
|
||||||
import { useModel } from "../hooks/useModel";
|
import { useModel } from "../../hooks/useModel";
|
||||||
import { useTankTransform } from "../hooks/useTankTransform";
|
import { useTankTransform } from "../../hooks/useTankTransform";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { TankopediaPersistent } from "../stores/tankopediaPersistent";
|
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
||||||
import { toThreeVector } from "../three/toThreeVector";
|
import { toThreeVector } from "../../three/toThreeVector";
|
||||||
import { ArmorType } from "./SpacedArmorScene";
|
import { ArmorType } from "../SpacedArmorScene";
|
||||||
import { StaticArmorSceneComponent } from "./StaticArmorSceneComponent";
|
import { StaticArmorSceneComponent } from "../StaticArmorSceneComponent";
|
||||||
|
|
||||||
interface ArmorSceneProps {
|
interface ArmorSceneProps {
|
||||||
thicknessRange: ThicknessRange;
|
thicknessRange: ThicknessRange;
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
import { assertSecret } from "@blitzkit/core";
|
|
||||||
import { MinusCircledIcon } from "@radix-ui/react-icons";
|
|
||||||
import { Callout, Flex } from "@radix-ui/themes";
|
|
||||||
import { uniq } from "lodash-es";
|
|
||||||
import { useEffect } from "react";
|
|
||||||
import { api } from "../../api/dynamic";
|
|
||||||
import { Duel } from "../../stores/duel";
|
|
||||||
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
|
||||||
import { AesonPlug } from "../AesonPlug";
|
|
||||||
import { ExperimentIcon } from "../ExperimentIcon";
|
|
||||||
import { MAX_RECENTLY_VIEWED } from "../TankSearchResults/constants";
|
|
||||||
|
|
||||||
const tankDefinitions = await api.tanks();
|
|
||||||
|
|
||||||
export function CalloutsSection() {
|
|
||||||
const tank = Duel.use((state) => state.protagonist.tank);
|
|
||||||
const promoteAeson =
|
|
||||||
assertSecret(import.meta.env.PUBLIC_ENVIRONMENT) === "preview";
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
TankopediaPersistent.mutate((draft) => {
|
|
||||||
draft.recentlyViewed = uniq([tank.id, ...draft.recentlyViewed])
|
|
||||||
.filter((id) => id in tankDefinitions.tanks)
|
|
||||||
.slice(0, MAX_RECENTLY_VIEWED);
|
|
||||||
});
|
|
||||||
}, [tank]);
|
|
||||||
|
|
||||||
if (!tank.testing && !tank.deprecated && !promoteAeson) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Flex direction="column" align="center" gap="2" mb="4" px="4">
|
|
||||||
{promoteAeson && <AesonPlug />}
|
|
||||||
|
|
||||||
{tank.deprecated && (
|
|
||||||
<Callout.Root color="red">
|
|
||||||
<Callout.Icon>
|
|
||||||
<MinusCircledIcon />
|
|
||||||
</Callout.Icon>
|
|
||||||
<Callout.Text>
|
|
||||||
Deprecated tanks may display undefined behavior.
|
|
||||||
</Callout.Text>
|
|
||||||
</Callout.Root>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{tank.testing && (
|
|
||||||
<Callout.Root color="red">
|
|
||||||
<Callout.Icon>
|
|
||||||
<ExperimentIcon style={{ width: "1em", height: "1em" }} />
|
|
||||||
</Callout.Icon>
|
|
||||||
<Callout.Text>
|
|
||||||
Tanks in testing are subject to change and may not represent the
|
|
||||||
final product.
|
|
||||||
</Callout.Text>
|
|
||||||
</Callout.Root>
|
|
||||||
)}
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
#assault-cursor {
|
|
||||||
cursor: grab;
|
|
||||||
}
|
|
||||||
|
|
||||||
#assault-cursor:active {
|
|
||||||
cursor: grabbing;
|
|
||||||
}
|
|
||||||
-122
@@ -1,122 +0,0 @@
|
|||||||
import { DragHandleDots2Icon } from "@radix-ui/react-icons";
|
|
||||||
import { Box, Flex, Text } from "@radix-ui/themes";
|
|
||||||
import { useEffect, useRef, useState } from "react";
|
|
||||||
import { clamp } from "three/src/math/MathUtils.js";
|
|
||||||
import {
|
|
||||||
fakeLogSquishyHigh,
|
|
||||||
fakeLogSquishyHighInverse,
|
|
||||||
} from "../../../../../../../../../core/blitzkit/fakeLog";
|
|
||||||
import { Var } from "../../../../../../../../../core/radix/var";
|
|
||||||
import { Duel } from "../../../../../../../../../stores/duel";
|
|
||||||
import "./index.css";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
maxDistance: number;
|
|
||||||
maxFakeDistance: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AssaultCursor({ maxDistance, maxFakeDistance }: Props) {
|
|
||||||
const assaultDistance = Duel.use(
|
|
||||||
(state) => state.protagonist.assaultDistance
|
|
||||||
);
|
|
||||||
const [x, setX] = useState(fakeLogSquishyHigh(assaultDistance / maxDistance));
|
|
||||||
const cursor = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let localX = x;
|
|
||||||
let lastX = 0;
|
|
||||||
|
|
||||||
function handlePointerDown(event: PointerEvent) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
lastX = event.clientX;
|
|
||||||
|
|
||||||
window.addEventListener("pointermove", handlePointerMove);
|
|
||||||
window.addEventListener("pointerup", handlePointerUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePointerMove(event: PointerEvent) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
const parent = cursor.current?.parentElement;
|
|
||||||
|
|
||||||
if (!parent) return;
|
|
||||||
|
|
||||||
const width = parent.clientWidth;
|
|
||||||
const movementX = event.clientX - lastX;
|
|
||||||
lastX = event.clientX;
|
|
||||||
|
|
||||||
setX((state) => {
|
|
||||||
localX = clamp(state + movementX / width, 0, 1);
|
|
||||||
return localX;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePointerUp() {
|
|
||||||
Duel.mutate((draft) => {
|
|
||||||
draft.protagonist.assaultDistance =
|
|
||||||
fakeLogSquishyHighInverse(localX * maxFakeDistance) * maxDistance;
|
|
||||||
});
|
|
||||||
|
|
||||||
window.removeEventListener("pointermove", handlePointerMove);
|
|
||||||
window.removeEventListener("pointerup", handlePointerUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor.current?.addEventListener("pointerdown", handlePointerDown);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cursor.current?.removeEventListener("pointerdown", handlePointerDown);
|
|
||||||
window.removeEventListener("pointermove", handlePointerMove);
|
|
||||||
window.removeEventListener("pointerup", handlePointerUp);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
ref={cursor}
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left={`${x * 100}%`}
|
|
||||||
height="100%"
|
|
||||||
width="2pt"
|
|
||||||
id="assault-cursor"
|
|
||||||
style={{
|
|
||||||
touchAction: "none",
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
backgroundColor: Var("accent-11"),
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Flex
|
|
||||||
align="center"
|
|
||||||
direction="column"
|
|
||||||
position="absolute"
|
|
||||||
left="50%"
|
|
||||||
bottom="100%"
|
|
||||||
style={{ transform: "translateX(-50%)" }}
|
|
||||||
>
|
|
||||||
<Flex
|
|
||||||
align="center"
|
|
||||||
justify="center"
|
|
||||||
style={{
|
|
||||||
width: "1.5rem",
|
|
||||||
height: "1.5rem",
|
|
||||||
backgroundColor: Var("accent-9"),
|
|
||||||
borderRadius: `50% 50% ${Var("radius-1")} ${Var("radius-1")}`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={{ display: "flex" }} highContrast color="purple">
|
|
||||||
<DragHandleDots2Icon />
|
|
||||||
</Text>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
height="0.5rem"
|
|
||||||
width="2pt"
|
|
||||||
style={{
|
|
||||||
backgroundColor: Var("accent-11"),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-160
@@ -1,160 +0,0 @@
|
|||||||
import { literals } from "@blitzkit/i18n";
|
|
||||||
import type { AssaultRanges } from "@blitzkit/protos";
|
|
||||||
import { Box, Flex, Text } from "@radix-ui/themes";
|
|
||||||
import { clamp } from "three/src/math/MathUtils.js";
|
|
||||||
import {
|
|
||||||
fakeLogSquishyHigh,
|
|
||||||
fakeLogSquishyLow,
|
|
||||||
} from "../../../../../../../core/blitzkit/fakeLog";
|
|
||||||
import type { TankCharacteristics } from "../../../../../../../core/blitzkit/tankCharacteristics";
|
|
||||||
import { Var } from "../../../../../../../core/radix/var";
|
|
||||||
import { useLocale } from "../../../../../../../hooks/useLocale";
|
|
||||||
import { VisualizerCard } from "../VisualizerCard";
|
|
||||||
import { AssaultCursor } from "./components/Cursor";
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
ranges: AssaultRanges;
|
|
||||||
stats: TankCharacteristics;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AssaultRangesVisualizer({ ranges: _ranges, stats }: Props) {
|
|
||||||
const maxDistance = _ranges.ranges.at(-1)!.distance;
|
|
||||||
const ranges = _ranges.ranges.map((range) => ({
|
|
||||||
factor: range.factor,
|
|
||||||
distance: range.distance,
|
|
||||||
fakeDistance: fakeLogSquishyHigh(range.distance / maxDistance),
|
|
||||||
}));
|
|
||||||
const maxFakeDistance = ranges.at(-1)!.fakeDistance;
|
|
||||||
const maxFactor = ranges[0].factor;
|
|
||||||
|
|
||||||
const { strings } = useLocale();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<VisualizerCard>
|
|
||||||
<Flex
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
direction="column"
|
|
||||||
>
|
|
||||||
<Text m="3" size="2" color="gray">
|
|
||||||
{strings.website.tools.tankopedia.visualizers.assault.title}
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
direction="column"
|
|
||||||
p="3"
|
|
||||||
pt="8"
|
|
||||||
pr="5"
|
|
||||||
style={{ backgroundColor: Var("gray-1") }}
|
|
||||||
flexGrow="1"
|
|
||||||
>
|
|
||||||
<Flex flexGrow="1">
|
|
||||||
<Box position="relative" width={Var("space-8")}>
|
|
||||||
{ranges.map((range, index) => (
|
|
||||||
<Text
|
|
||||||
key={index}
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
left: 0,
|
|
||||||
bottom: `${fakeLogSquishyLow(range.factor / maxFactor) * 100}%`,
|
|
||||||
transform: "translateY(50%)",
|
|
||||||
}}
|
|
||||||
color="gray"
|
|
||||||
size="1"
|
|
||||||
wrap="nowrap"
|
|
||||||
>
|
|
||||||
{literals(strings.common.units.hp, {
|
|
||||||
value: Math.round(
|
|
||||||
stats.damageWithoutAssault * range.factor,
|
|
||||||
),
|
|
||||||
})}
|
|
||||||
</Text>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Flex flexGrow="1" align="end" position="relative">
|
|
||||||
{ranges.map((range, index) => {
|
|
||||||
const mix =
|
|
||||||
clamp(2 * (range.factor / maxFactor - 1) + 1, 0, 1) * 100;
|
|
||||||
const color0 = `color-mix(in hsl, ${Var("tomato-9")}, ${Var("jade-9")} ${mix}%)`;
|
|
||||||
const color1 = `color-mix(in hsl, ${Var("tomato-7")}, ${Var("jade-7")} ${mix}%)`;
|
|
||||||
const last = ranges[index - 1];
|
|
||||||
const lastFakeDistance = last?.fakeDistance ?? 0;
|
|
||||||
const fakeWidth = range.fakeDistance - lastFakeDistance;
|
|
||||||
const fraction = fakeWidth / ranges.at(-1)!.fakeDistance;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
width={`${fraction * 100}%`}
|
|
||||||
height={`${fakeLogSquishyLow(range.factor / maxFactor) * 100}%`}
|
|
||||||
style={{
|
|
||||||
background: `linear-gradient(45deg, ${color1}, ${color0})`,
|
|
||||||
}}
|
|
||||||
key={index}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
{ranges.map((range, index) => (
|
|
||||||
<Box
|
|
||||||
key={index}
|
|
||||||
position="absolute"
|
|
||||||
left="0"
|
|
||||||
bottom={`${fakeLogSquishyLow(range.factor / maxFactor) * 100}%`}
|
|
||||||
width="100%"
|
|
||||||
height="1pt"
|
|
||||||
style={{
|
|
||||||
transform: "translateY(50%)",
|
|
||||||
backgroundColor: Var("gray-11"),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<AssaultCursor
|
|
||||||
maxDistance={maxDistance}
|
|
||||||
maxFakeDistance={maxFakeDistance}
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Flex ml="8" height={Var("space-7")}>
|
|
||||||
{ranges.map((range, index) => {
|
|
||||||
const last = ranges[index - 1];
|
|
||||||
const lastFakeDistance = last?.fakeDistance ?? 0;
|
|
||||||
const fakeWidth = range.fakeDistance - lastFakeDistance;
|
|
||||||
const fraction = fakeWidth / ranges.at(-1)!.fakeDistance;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
position="relative"
|
|
||||||
key={index}
|
|
||||||
width={`${fraction * 100}%`}
|
|
||||||
height="100%"
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
size="1"
|
|
||||||
color="gray"
|
|
||||||
mt="2"
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
right: 0,
|
|
||||||
transform: "translateX(50%)",
|
|
||||||
writingMode: "vertical-rl",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{literals(strings.common.units.m, {
|
|
||||||
value: Math.round(range.distance),
|
|
||||||
})}
|
|
||||||
</Text>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
</VisualizerCard>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-112
@@ -1,112 +0,0 @@
|
|||||||
import { CREW_MEMBER_NAMES } from "@blitzkit/core";
|
|
||||||
import { literals } from "@blitzkit/i18n";
|
|
||||||
import { CrewType } from "@blitzkit/protos";
|
|
||||||
import { AccessibilityIcon, InfoCircledIcon } from "@radix-ui/react-icons";
|
|
||||||
import { Flex, Heading, IconButton, Popover, Text } from "@radix-ui/themes";
|
|
||||||
import { Fragment } from "react/jsx-runtime";
|
|
||||||
import { api } from "../../../../../../api/dynamic";
|
|
||||||
import { useEquipment } from "../../../../../../hooks/useEquipment";
|
|
||||||
import { useLocale } from "../../../../../../hooks/useLocale";
|
|
||||||
import { Duel } from "../../../../../../stores/duel";
|
|
||||||
import { InfoWithDelta } from "./InfoWithDelta";
|
|
||||||
import { StatsTableWrapper } from "./StatsTableWrapper";
|
|
||||||
import type { StatsAcceptorProps } from "./TraverseVisualizer";
|
|
||||||
|
|
||||||
const provisionDefinitions = await api.provisions();
|
|
||||||
|
|
||||||
export function Crew({ stats }: StatsAcceptorProps) {
|
|
||||||
const tank = Duel.use((state) => state.protagonist.tank);
|
|
||||||
const { strings } = useLocale();
|
|
||||||
const provisions = Duel.use((state) => state.protagonist.provisions);
|
|
||||||
const hasImprovedVentilation = useEquipment("protagonist", 102);
|
|
||||||
const provisionCrewBonus =
|
|
||||||
provisions.reduce(
|
|
||||||
(total, provision) =>
|
|
||||||
provisionDefinitions.provisions[provision].crew
|
|
||||||
? total + provisionDefinitions.provisions[provision].crew! / 100
|
|
||||||
: total,
|
|
||||||
0,
|
|
||||||
) + (hasImprovedVentilation ? 0.08 : 0);
|
|
||||||
const commanderMastery = 1 + provisionCrewBonus;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StatsTableWrapper>
|
|
||||||
<Flex gap="2" align="center">
|
|
||||||
<Heading size="5">
|
|
||||||
{strings.website.tools.tankopedia.crew.title}
|
|
||||||
</Heading>
|
|
||||||
|
|
||||||
<Popover.Root>
|
|
||||||
<Popover.Trigger>
|
|
||||||
<IconButton variant="ghost">
|
|
||||||
<InfoCircledIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Popover.Trigger>
|
|
||||||
|
|
||||||
<Popover.Content>
|
|
||||||
<Flex gap="1" align="center">
|
|
||||||
<AccessibilityIcon />
|
|
||||||
<Text>{strings.website.tools.tankopedia.crew.info}</Text>
|
|
||||||
</Flex>
|
|
||||||
</Popover.Content>
|
|
||||||
</Popover.Root>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<InfoWithDelta value="crewCount" stats={stats} decimals={0} />
|
|
||||||
|
|
||||||
{tank.crew.map((member) => {
|
|
||||||
return (
|
|
||||||
<Fragment key={member.type}>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
key={`${member.type}-root`}
|
|
||||||
name={`${
|
|
||||||
strings.website.tools.tankopedia.crew[
|
|
||||||
CREW_MEMBER_NAMES[member.type]
|
|
||||||
]
|
|
||||||
}${
|
|
||||||
member.count > 1
|
|
||||||
? ` ${literals(strings.common.units.x, { value: member.count })}`
|
|
||||||
: ""
|
|
||||||
}`}
|
|
||||||
decimals={0}
|
|
||||||
noRanking
|
|
||||||
value={() =>
|
|
||||||
(member.type === CrewType.CREW_TYPE_COMMANDER
|
|
||||||
? commanderMastery
|
|
||||||
: commanderMastery * 1.1) * 100
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{member.substitute.length > 0 && (
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
key={`${member.type}-substitute`}
|
|
||||||
decimals={0}
|
|
||||||
indent
|
|
||||||
name={
|
|
||||||
<>
|
|
||||||
<Flex align="center" gap="1" display="inline-flex">
|
|
||||||
<AccessibilityIcon />
|
|
||||||
{member.substitute
|
|
||||||
.map((sub, index) =>
|
|
||||||
index === 0
|
|
||||||
? strings.website.tools.tankopedia.crew[
|
|
||||||
CREW_MEMBER_NAMES[sub]
|
|
||||||
]
|
|
||||||
: sub,
|
|
||||||
)
|
|
||||||
.join(", ")}
|
|
||||||
</Flex>
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
noRanking
|
|
||||||
value={() => commanderMastery * 1.05 * 100}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Fragment>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</StatsTableWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-346
@@ -1,346 +0,0 @@
|
|||||||
import { alias, isExplosive } from "@blitzkit/core";
|
|
||||||
import { literals } from "@blitzkit/i18n";
|
|
||||||
import { InfoCircledIcon } from "@radix-ui/react-icons";
|
|
||||||
import {
|
|
||||||
Flex,
|
|
||||||
Heading,
|
|
||||||
IconButton,
|
|
||||||
Popover,
|
|
||||||
Text,
|
|
||||||
Tooltip,
|
|
||||||
} from "@radix-ui/themes";
|
|
||||||
import { useLocale } from "../../../../../../hooks/useLocale";
|
|
||||||
import { useTankModelDefinition } from "../../../../../../hooks/useTankModelDefinition";
|
|
||||||
import { Duel } from "../../../../../../stores/duel";
|
|
||||||
import type { MaybeSkeletonComponentProps } from "../../../../../../types/maybeSkeletonComponentProps";
|
|
||||||
import { LazyImage } from "../../../../../LazyImage";
|
|
||||||
import { AssaultRangesVisualizer } from "./AssaultRangesVisualizer";
|
|
||||||
import { GunFlexibilityVisualizer } from "./GunFlexibilityVisualizer";
|
|
||||||
import { Info } from "./Info";
|
|
||||||
import { InfoWithDelta } from "./InfoWithDelta";
|
|
||||||
import { RELOAD_PRECISION, ReloadVisualizer } from "./ReloadVisualizer";
|
|
||||||
import { RicochetVisualizer } from "./RicochetVisualizer";
|
|
||||||
import { StatsTableWrapper } from "./StatsTableWrapper";
|
|
||||||
import type { StatsAcceptorProps } from "./TraverseVisualizer";
|
|
||||||
|
|
||||||
export function Firepower({
|
|
||||||
stats,
|
|
||||||
skeleton,
|
|
||||||
}: StatsAcceptorProps & MaybeSkeletonComponentProps) {
|
|
||||||
const { strings, unwrap } = useLocale();
|
|
||||||
const turret = Duel.use((state) => state.protagonist.turret);
|
|
||||||
const gun = Duel.use((state) => state.protagonist.gun);
|
|
||||||
const shell = Duel.use((state) => state.protagonist.shell);
|
|
||||||
const tankModelDefinition = useTankModelDefinition();
|
|
||||||
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
|
||||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StatsTableWrapper>
|
|
||||||
<Flex align="center" gap="4">
|
|
||||||
<Heading size="5">
|
|
||||||
{strings.website.tools.tankopedia.firepower.title}
|
|
||||||
</Heading>
|
|
||||||
|
|
||||||
<Flex>
|
|
||||||
{gun.shells.map((thisShell, shellIndex) => {
|
|
||||||
const selected = thisShell.id === shell.id;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tooltip content={unwrap(thisShell.name!)} key={thisShell.id}>
|
|
||||||
<IconButton
|
|
||||||
color={selected ? undefined : "gray"}
|
|
||||||
variant={selected ? "solid" : "soft"}
|
|
||||||
highContrast={selected}
|
|
||||||
style={{
|
|
||||||
borderTopLeftRadius: shellIndex === 0 ? undefined : 0,
|
|
||||||
borderBottomLeftRadius: shellIndex === 0 ? undefined : 0,
|
|
||||||
borderTopRightRadius:
|
|
||||||
shellIndex === gun.shells.length - 1 ? undefined : 0,
|
|
||||||
borderBottomRightRadius:
|
|
||||||
shellIndex === gun.shells.length - 1 ? undefined : 0,
|
|
||||||
marginLeft: shellIndex === 0 ? 0 : -1,
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
Duel.mutate((draft) => {
|
|
||||||
draft.protagonist.shell = thisShell;
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<LazyImage
|
|
||||||
alt={unwrap(thisShell.name!)}
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
src={alias("api", `icons/shells/${thisShell.icon}.webp`)}
|
|
||||||
/>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Info
|
|
||||||
name={strings.website.tools.tankopedia.characteristics.values.gunType}
|
|
||||||
>
|
|
||||||
{strings.common.gun_types[gun.gun_type!.$case]}
|
|
||||||
</Info>
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} value="dpm" />
|
|
||||||
{gun.gun_type!.$case === "regular" && (
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
indent
|
|
||||||
decimals={0}
|
|
||||||
noRanking
|
|
||||||
name={
|
|
||||||
<Flex align="center" gap="1" display="inline-flex">
|
|
||||||
{
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.peekabooDpm
|
|
||||||
}
|
|
||||||
|
|
||||||
<Popover.Root>
|
|
||||||
<Popover.Trigger>
|
|
||||||
<IconButton variant="ghost" size="1">
|
|
||||||
<InfoCircledIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Popover.Trigger>
|
|
||||||
|
|
||||||
<Popover.Content style={{ maxWidth: 280 }}>
|
|
||||||
<Text size="2">
|
|
||||||
{
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.peekabooDpmInfo
|
|
||||||
}
|
|
||||||
</Text>
|
|
||||||
</Popover.Content>
|
|
||||||
</Popover.Root>
|
|
||||||
</Flex>
|
|
||||||
}
|
|
||||||
value={(tank) => tank.peekabooDpm}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} value="damage" />
|
|
||||||
{gun.gun_type!.$case !== "regular" && (
|
|
||||||
<InfoWithDelta stats={stats} indent decimals={0} value="clipDamage" />
|
|
||||||
)}
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} value="moduleDamage" />
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} value="penetration" />
|
|
||||||
|
|
||||||
{gun.assault_ranges?.types.includes(shell.type) && (
|
|
||||||
<AssaultRangesVisualizer stats={stats} ranges={gun.assault_ranges} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{gun.gun_type!.$case === "auto_reloader" && (
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} indent value="dpmEffective" />
|
|
||||||
)}
|
|
||||||
{gun.gun_type!.$case !== "regular" && (
|
|
||||||
<InfoWithDelta stats={stats} value="shells" />
|
|
||||||
)}
|
|
||||||
{gun.gun_type!.$case === "auto_reloader" ? (
|
|
||||||
<>
|
|
||||||
<Info
|
|
||||||
indent
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.mostOptimalShellIndex
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{stats.mostOptimalShellIndex! + 1}
|
|
||||||
</Info>
|
|
||||||
<Info
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.shellReloads
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{stats.shellReloads!.map((reload, index) => (
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
key={index}
|
|
||||||
indent
|
|
||||||
name={literals(
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.shell_index,
|
|
||||||
{ index: index + 1 },
|
|
||||||
)}
|
|
||||||
decimals={RELOAD_PRECISION}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
noRanking
|
|
||||||
value={() => reload}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={RELOAD_PRECISION}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="shellReload"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{(gun.gun_type!.$case === "auto_loader" ||
|
|
||||||
gun.gun_type!.$case === "auto_reloader") && (
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
indent
|
|
||||||
decimals={RELOAD_PRECISION}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="intraClip"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<ReloadVisualizer stats={stats} />
|
|
||||||
|
|
||||||
{isExplosive(shell.type) && (
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
noRanking
|
|
||||||
decimals={0}
|
|
||||||
value="explosionRadius"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} value="caliber" />
|
|
||||||
|
|
||||||
{!isExplosive(shell.type) && (
|
|
||||||
<>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={0}
|
|
||||||
noRanking
|
|
||||||
value="shellNormalization"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
noRanking
|
|
||||||
decimals={0}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="shellRicochet"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<RicochetVisualizer stats={stats} />
|
|
||||||
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} value="shellVelocity" />
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} value="shellRange" />
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} value="shellCapacity" />
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={2}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="aimTime"
|
|
||||||
/>
|
|
||||||
<Info
|
|
||||||
name={literals(
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.dispersion_at_distance,
|
|
||||||
{ distance: 100 },
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={3}
|
|
||||||
indent
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="dispersion"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
prefix="+"
|
|
||||||
decimals={3}
|
|
||||||
indent
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="dispersionMoving"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={3}
|
|
||||||
prefix="+"
|
|
||||||
indent
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="dispersionHullTraversing"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={3}
|
|
||||||
prefix="+"
|
|
||||||
indent
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="dispersionTurretTraversing"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={3}
|
|
||||||
prefix="+"
|
|
||||||
indent
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="dispersionShooting"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
prefix="x"
|
|
||||||
indent
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="dispersionGunDamaged"
|
|
||||||
/>
|
|
||||||
<Info
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.gun_flexibility
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta value="gunDepression" stats={stats} decimals={1} indent />
|
|
||||||
<InfoWithDelta stats={stats} decimals={1} indent value="gunElevation" />
|
|
||||||
{gunModelDefinition.pitch!.front && (
|
|
||||||
<>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="gunFrontalDepression"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="gunFrontalElevation"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{gunModelDefinition.pitch!.back && (
|
|
||||||
<>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="gunRearDepression"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="gunRearElevation"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{turretModelDefinition.yaw && (
|
|
||||||
<>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="azimuthLeft"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="azimuthRight"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<GunFlexibilityVisualizer skeleton={skeleton} />
|
|
||||||
</StatsTableWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
import { useFrame } from "@react-three/fiber";
|
|
||||||
|
|
||||||
export const zoom = 60;
|
|
||||||
|
|
||||||
export function CameraPositioner() {
|
|
||||||
useFrame(({ camera, gl: { domElement } }) => {
|
|
||||||
const { width } = domElement.getBoundingClientRect();
|
|
||||||
const physicalWidth = width / zoom;
|
|
||||||
|
|
||||||
camera.position.set(10, 0, -physicalWidth / 6);
|
|
||||||
});
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
-70
@@ -1,70 +0,0 @@
|
|||||||
import type { QuicklimeEvent } from "quicklime";
|
|
||||||
import { useEffect, useRef } from "react";
|
|
||||||
import type { Group } from "three";
|
|
||||||
import { api } from "../../../../../../../../api/dynamic";
|
|
||||||
import {
|
|
||||||
modelTransformEvent,
|
|
||||||
type ModelTransformEventData,
|
|
||||||
} from "../../../../../../../../core/blitzkit/modelTransform";
|
|
||||||
import { ModelChunk } from "./ModelChunk";
|
|
||||||
|
|
||||||
const modelDefinitions = await api.models();
|
|
||||||
|
|
||||||
export function CanvasContent() {
|
|
||||||
const hullWrapper = useRef<Group>(null);
|
|
||||||
const gunWrapper = useRef<Group>(null);
|
|
||||||
|
|
||||||
const tank = Duel.use((state) => state.protagonist.tank);
|
|
||||||
const turret = Duel.use((state) => state.protagonist.turret);
|
|
||||||
|
|
||||||
const tankModel = modelDefinitions.models[tank.id];
|
|
||||||
const turretModel = tankModel.turrets[turret.id];
|
|
||||||
|
|
||||||
// baked-in turret mount tilt (e.g. Minotauro sits pitched 3deg forward);
|
|
||||||
// applied as a static base rotation so the live gun pitch composes on top
|
|
||||||
// of it, mirroring useTankTransform.ts's turretContainer/gunContainer nesting
|
|
||||||
const initialTurretPitch = -degToRad(
|
|
||||||
tankModel.initial_turret_rotation?.pitch ?? 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
function handleModelTransformEvent(
|
|
||||||
event: QuicklimeEvent<ModelTransformEventData>,
|
|
||||||
) {
|
|
||||||
if (!gunWrapper.current || !hullWrapper.current) return;
|
|
||||||
|
|
||||||
gunWrapper.current.rotation.x = event.data.pitch;
|
|
||||||
if (event.data.yaw) hullWrapper.current.rotation.y = event.data.yaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
modelTransformEvent.on(handleModelTransformEvent);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
modelTransformEvent.off(handleModelTransformEvent);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<group ref={hullWrapper} position={[0, 0, turretModel.gun_origin!.z]}>
|
|
||||||
<group position={[0, 0, -turretModel.gun_origin!.z]}>
|
|
||||||
<ModelChunk only="body" />
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
|
|
||||||
<group
|
|
||||||
position={[0, turretModel.gun_origin!.y, turretModel.gun_origin!.z]}
|
|
||||||
rotation={[initialTurretPitch, 0, 0]}
|
|
||||||
>
|
|
||||||
<group
|
|
||||||
position={[0, -turretModel.gun_origin!.y, -turretModel.gun_origin!.z]}
|
|
||||||
>
|
|
||||||
<ModelChunk only="turret" />
|
|
||||||
|
|
||||||
<group ref={gunWrapper}>
|
|
||||||
<ModelChunk only="gun" />
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
import { SmartCanvas } from '../../../../../../../SmartCanvas';
|
|
||||||
import { CameraPositioner, zoom } from './CameraPositioner';
|
|
||||||
import { CanvasContent } from './CanvasContent';
|
|
||||||
|
|
||||||
export function FlexibilityCanvas() {
|
|
||||||
return (
|
|
||||||
<SmartCanvas orthographic camera={{ zoom, rotation: [0, Math.PI / 2, 0] }}>
|
|
||||||
<CanvasContent />
|
|
||||||
<CameraPositioner />
|
|
||||||
</SmartCanvas>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-105
@@ -1,105 +0,0 @@
|
|||||||
import { mauveDark } from "@radix-ui/colors";
|
|
||||||
import { LineBasicMaterial, MeshBasicMaterial } from "three";
|
|
||||||
import { api } from "../../../../../../../../api/dynamic";
|
|
||||||
import { jsxTree } from "../../../../../../../../core/blitzkit/jsxTree";
|
|
||||||
import { useModel } from "../../../../../../../../hooks/useModel";
|
|
||||||
import { Duel } from "../../../../../../../../stores/duel";
|
|
||||||
|
|
||||||
const modelDefinitions = await api.models();
|
|
||||||
|
|
||||||
const surfaceMaterial: Record<Props["only"], MeshBasicMaterial> = {
|
|
||||||
gun: new MeshBasicMaterial({
|
|
||||||
color: mauveDark.mauve8,
|
|
||||||
toneMapped: false,
|
|
||||||
}),
|
|
||||||
turret: new MeshBasicMaterial({
|
|
||||||
color: mauveDark.mauve6,
|
|
||||||
toneMapped: false,
|
|
||||||
}),
|
|
||||||
body: new MeshBasicMaterial({
|
|
||||||
color: mauveDark.mauve6,
|
|
||||||
toneMapped: false,
|
|
||||||
transparent: true,
|
|
||||||
opacity: 0.5,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
const outlineMaterial: Record<Props["only"], LineBasicMaterial> = {
|
|
||||||
gun: new LineBasicMaterial({
|
|
||||||
color: mauveDark.mauve11,
|
|
||||||
toneMapped: false,
|
|
||||||
}),
|
|
||||||
turret: new LineBasicMaterial({
|
|
||||||
color: mauveDark.mauve8,
|
|
||||||
toneMapped: false,
|
|
||||||
}),
|
|
||||||
body: new LineBasicMaterial({
|
|
||||||
color: mauveDark.mauve8,
|
|
||||||
toneMapped: false,
|
|
||||||
transparent: true,
|
|
||||||
opacity: 0.5,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
only: "gun" | "turret" | "body";
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ModelChunk({ only }: Props) {
|
|
||||||
const tank = Duel.use((state) => state.protagonist.tank);
|
|
||||||
const turret = Duel.use((state) => state.protagonist.turret);
|
|
||||||
const gun = Duel.use((state) => state.protagonist.gun);
|
|
||||||
|
|
||||||
const tankModel = modelDefinitions.models[tank.id];
|
|
||||||
const turretModel = tankModel.turrets[turret.id];
|
|
||||||
const gunModel = turretModel.guns[gun.id];
|
|
||||||
|
|
||||||
const originZ = tankModel.turret_origin!.z + turretModel.gun_origin!.z;
|
|
||||||
const originY = tankModel.turret_origin!.y + turretModel.gun_origin!.y;
|
|
||||||
|
|
||||||
const { gltf } = useModel(tank.id);
|
|
||||||
const nodes = Object.values(gltf.nodes);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<group position={[0, -originY, originZ]} rotation={[-Math.PI / 2, 0, 0]}>
|
|
||||||
{nodes.map((node) => {
|
|
||||||
const isCurrentMantlet =
|
|
||||||
node.name ===
|
|
||||||
`gun_${gunModel.model_id.toString().padStart(2, "0")}_mask`;
|
|
||||||
const isCurrentGun =
|
|
||||||
node.name === `gun_${gunModel.model_id.toString().padStart(2, "0")}`;
|
|
||||||
const isGun = isCurrentGun || isCurrentMantlet;
|
|
||||||
|
|
||||||
const isCurrentTurret =
|
|
||||||
node.name ===
|
|
||||||
`turret_${turretModel.model_id.toString().padStart(2, "0")}`;
|
|
||||||
const isTurret = isCurrentTurret;
|
|
||||||
|
|
||||||
const isHull = node.name === "hull";
|
|
||||||
const isWheel = node.name.startsWith("chassis_wheel_");
|
|
||||||
const isTrack = node.name.startsWith("chassis_track_");
|
|
||||||
const isBody = isHull || isWheel || isTrack;
|
|
||||||
|
|
||||||
if (
|
|
||||||
(only === "gun" && !isGun) ||
|
|
||||||
(only === "turret" && !isTurret) ||
|
|
||||||
(only === "body" && !isBody)
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsxTree(node, {
|
|
||||||
mesh(mesh, props, key) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<mesh key={key} {...props} material={surfaceMaterial[only]} />
|
|
||||||
<lineSegments material={outlineMaterial[only]}>
|
|
||||||
<edgesGeometry args={[mesh.geometry, 29]} />
|
|
||||||
</lineSegments>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
</group>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-412
@@ -1,412 +0,0 @@
|
|||||||
import { literals } from "@blitzkit/i18n";
|
|
||||||
import { Box, Card, Flex } from "@radix-ui/themes";
|
|
||||||
import { clamp } from "lodash-es";
|
|
||||||
import { useRef, useState } from "react";
|
|
||||||
import { degToRad, radToDeg } from "three/src/math/MathUtils.js";
|
|
||||||
import { api } from "../../../../../../../api/dynamic";
|
|
||||||
import {
|
|
||||||
DEFAULT_PITCH_TRANSITION,
|
|
||||||
applyPitchYawLimits,
|
|
||||||
} from "../../../../../../../core/blitz/applyPitchYawLimits";
|
|
||||||
import { hasEquipment } from "../../../../../../../core/blitzkit/hasEquipment";
|
|
||||||
import { modelTransformEvent } from "../../../../../../../core/blitzkit/modelTransform";
|
|
||||||
import { Var } from "../../../../../../../core/radix/var";
|
|
||||||
import { useLocale } from "../../../../../../../hooks/useLocale";
|
|
||||||
import { Duel } from "../../../../../../../stores/duel";
|
|
||||||
import { Tankopedia } from "../../../../../../../stores/tankopedia";
|
|
||||||
import type { MaybeSkeletonComponentProps } from "../../../../../../../types/maybeSkeletonComponentProps";
|
|
||||||
import { VisualizerCard } from "../VisualizerCard";
|
|
||||||
import { VisualizerCornerStat } from "../VisualizerCornerStat";
|
|
||||||
import { FlexibilityCanvas } from "./components/FlexibilityCanvas";
|
|
||||||
|
|
||||||
const ANGLE_COEFFICIENT = 1 / 10;
|
|
||||||
|
|
||||||
const modelDefinition = await api.models();
|
|
||||||
|
|
||||||
function mag(x: number) {
|
|
||||||
return (1 / Math.PI) * Math.atan(ANGLE_COEFFICIENT * x) + 1 / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
function magInverse(y: number): number {
|
|
||||||
return (1 / ANGLE_COEFFICIENT) * Math.tan(Math.PI * y - Math.PI / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
function c(thetaDeg: number, m = 1) {
|
|
||||||
const theta = thetaDeg * (Math.PI / 180);
|
|
||||||
return `${m * Math.cos(theta)} ${-m * Math.sin(theta)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function GunFlexibilityVisualizer({
|
|
||||||
skeleton,
|
|
||||||
}: MaybeSkeletonComponentProps) {
|
|
||||||
const { strings } = useLocale();
|
|
||||||
|
|
||||||
const tank = Duel.use((state) => state.protagonist.tank);
|
|
||||||
const turret = Duel.use((state) => state.protagonist.turret);
|
|
||||||
const gun = Duel.use((state) => state.protagonist.gun);
|
|
||||||
const modelRequested = Tankopedia.use(
|
|
||||||
(state) => state.loaders.model.requested,
|
|
||||||
);
|
|
||||||
|
|
||||||
const tankModel = modelDefinition.models[tank.id];
|
|
||||||
const turretModel = tankModel.turrets[turret.id];
|
|
||||||
const gunModel = turretModel.guns[gun.id];
|
|
||||||
|
|
||||||
// turret's own baked-in mount tilt (e.g. Minotauro's turret sits pitched
|
|
||||||
// 3deg forward on the hull); must be folded into displayed pitch values
|
|
||||||
// the same way tankCharacteristics.ts and QuickInputs do
|
|
||||||
const initialTurretPitch = degToRad(
|
|
||||||
tankModel.initial_turret_rotation?.pitch ?? 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
// radial map is in the tilt-compensated frame so the neutrality circle sits
|
|
||||||
// at the displayed 0deg
|
|
||||||
const tiltDeg = radToDeg(initialTurretPitch);
|
|
||||||
const magTilted = (deg: number) => mag(deg + tiltDeg);
|
|
||||||
|
|
||||||
const [yaw, setYaw] = useState(0);
|
|
||||||
const [pitch, setPitch] = useState(0);
|
|
||||||
const [minPitch, setMinPitch] = useState(
|
|
||||||
-degToRad(gunModel.pitch!.front?.max ?? gunModel.pitch!.max) -
|
|
||||||
initialTurretPitch,
|
|
||||||
);
|
|
||||||
const [maxPitch, setMaxPitch] = useState(
|
|
||||||
-degToRad(gunModel.pitch!.front?.min ?? gunModel.pitch!.min) -
|
|
||||||
initialTurretPitch,
|
|
||||||
);
|
|
||||||
|
|
||||||
const container = useRef<HTMLDivElement>(null);
|
|
||||||
const highlighter = useRef<HTMLDivElement>(null);
|
|
||||||
const pointer = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
const p = gunModel.pitch!;
|
|
||||||
const y = turretModel.yaw;
|
|
||||||
const f = p.front;
|
|
||||||
const b = p.back;
|
|
||||||
const t = gunModel.pitch!.transition ?? DEFAULT_PITCH_TRANSITION;
|
|
||||||
|
|
||||||
let d = "";
|
|
||||||
|
|
||||||
// right
|
|
||||||
const mo = magTilted(p.max);
|
|
||||||
if (y) {
|
|
||||||
d += `M 0 0`;
|
|
||||||
d += `L ${c(90 - y.max, mo)}`;
|
|
||||||
} else if (b) {
|
|
||||||
d += `M ${c(-90 + b.range / 2 + t, mo)}`;
|
|
||||||
} else {
|
|
||||||
d += `M ${c(-90, mo)}`;
|
|
||||||
}
|
|
||||||
if (f) {
|
|
||||||
d += `A ${mo} ${mo} 0 0 0 ${c(90 - f.range / 2 - t, mo)}`;
|
|
||||||
} else {
|
|
||||||
d += `A ${mo} ${mo} 0 0 0 ${c(90, mo)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// front
|
|
||||||
if (f) {
|
|
||||||
const m = magTilted(f.max);
|
|
||||||
d += `L ${c(90 - f.range / 2, m)}`;
|
|
||||||
d += `A ${m} ${m} 0 0 0 ${c(90 + f.range / 2, m)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// left
|
|
||||||
if (f) {
|
|
||||||
d += `L ${c(90 + f.range / 2 + t, mo)}`;
|
|
||||||
} else {
|
|
||||||
d += `L ${c(90, mo)}`;
|
|
||||||
}
|
|
||||||
if (y) {
|
|
||||||
d += `A ${mo} ${mo} 0 0 0 ${c(90 - y.min, mo)}`;
|
|
||||||
} else if (b) {
|
|
||||||
d += `A ${mo} ${mo} 0 0 0 ${c(-90 - b.range / 2 - t, mo)}`;
|
|
||||||
} else {
|
|
||||||
d += `A ${mo} ${mo} 0 0 0 ${c(-90, mo)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// back
|
|
||||||
if (!y && b) {
|
|
||||||
const m = magTilted(b.max);
|
|
||||||
d += `L ${c(-90 - b.range / 2, m)}`;
|
|
||||||
d += `A ${m} ${m} 0 0 0 ${c(-90 + b.range / 2, m)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
d += `Z`;
|
|
||||||
|
|
||||||
// right
|
|
||||||
const mi = magTilted(p.min);
|
|
||||||
if (y) {
|
|
||||||
d += `M 0 0`;
|
|
||||||
d += `L ${c(90 - y.max, mi)}`;
|
|
||||||
} else if (b) {
|
|
||||||
d += `M ${c(-90 + b.range / 2 + t, mi)}`;
|
|
||||||
} else {
|
|
||||||
d += `M ${c(-90, mi)}`;
|
|
||||||
}
|
|
||||||
if (f) {
|
|
||||||
d += `A ${mi} ${mi} 0 0 0 ${c(90 - f.range / 2 - t, mi)}`;
|
|
||||||
} else {
|
|
||||||
d += `A ${mi} ${mi} 0 0 0 ${c(90, mi)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// front
|
|
||||||
if (f) {
|
|
||||||
const m = magTilted(f.min);
|
|
||||||
d += `L ${c(90 - f.range / 2, m)}`;
|
|
||||||
d += `A ${m} ${m} 0 0 0 ${c(90 + f.range / 2, m)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// left
|
|
||||||
if (f) {
|
|
||||||
d += `L ${c(90 + f.range / 2 + t, mi)}`;
|
|
||||||
} else {
|
|
||||||
d += `L ${c(90, mi)}`;
|
|
||||||
}
|
|
||||||
if (y) {
|
|
||||||
d += `A ${mi} ${mi} 0 0 0 ${c(90 - y.min, mi)}`;
|
|
||||||
} else if (b) {
|
|
||||||
d += `A ${mi} ${mi} 0 0 0 ${c(-90 - b.range / 2 - t, mi)}`;
|
|
||||||
} else {
|
|
||||||
d += `A ${mi} ${mi} 0 0 0 ${c(-90, mi)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// back
|
|
||||||
if (!y && b) {
|
|
||||||
const m = magTilted(b.min);
|
|
||||||
d += `L ${c(-90 - b.range / 2, m)}`;
|
|
||||||
d += `A ${m} ${m} 0 0 0 ${c(-90 + b.range / 2, m)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
d += `Z`;
|
|
||||||
|
|
||||||
const r = mag(radToDeg(-(pitch - initialTurretPitch)));
|
|
||||||
const dotX = r * Math.sin(yaw);
|
|
||||||
const dotY = r * Math.cos(yaw);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Flex direction="column-reverse" gap="0">
|
|
||||||
<Box mt="-3" px="2">
|
|
||||||
<Card variant="classic" style={{ height: "10rem" }}>
|
|
||||||
<Box
|
|
||||||
style={{
|
|
||||||
background: "linear-gradient(var(--gray-1), var(--gray-3))",
|
|
||||||
}}
|
|
||||||
position="absolute"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
>
|
|
||||||
{!skeleton && modelRequested && <FlexibilityCanvas />}
|
|
||||||
|
|
||||||
<Box
|
|
||||||
position="absolute"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
top="0"
|
|
||||||
left="33%"
|
|
||||||
style={{
|
|
||||||
background: `conic-gradient(
|
|
||||||
at 0 50%,
|
|
||||||
|
|
||||||
transparent,
|
|
||||||
transparent ${Math.PI / 2 - maxPitch}rad,
|
|
||||||
|
|
||||||
${Var("cyan-a4")} ${Math.PI / 2 - maxPitch}rad,
|
|
||||||
${Var("jade-a4")} ${Math.PI / 2 - minPitch}rad,
|
|
||||||
|
|
||||||
transparent ${Math.PI / 2 - minPitch}rad,
|
|
||||||
transparent 180deg
|
|
||||||
)`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</Card>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<VisualizerCard
|
|
||||||
ref={container}
|
|
||||||
style={{ touchAction: "none" }}
|
|
||||||
onPointerMove={(event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
if (!container.current || !highlighter.current || !pointer.current)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const rect = container.current.getBoundingClientRect();
|
|
||||||
const u = event.clientX - rect.left - rect.width / 2;
|
|
||||||
const v = event.clientY - rect.top - rect.height / 2;
|
|
||||||
let yaw = Math.atan2(u, -v);
|
|
||||||
|
|
||||||
const hasImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
122,
|
|
||||||
Duel.state.protagonist.tank.equipment_preset,
|
|
||||||
Duel.state.protagonist.equipmentMatrix,
|
|
||||||
);
|
|
||||||
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
124,
|
|
||||||
Duel.state.protagonist.tank.equipment_preset,
|
|
||||||
Duel.state.protagonist.equipmentMatrix,
|
|
||||||
);
|
|
||||||
|
|
||||||
const min = applyPitchYawLimits(
|
|
||||||
-Math.PI,
|
|
||||||
yaw,
|
|
||||||
p,
|
|
||||||
y,
|
|
||||||
hasImprovedVerticalStabilizer,
|
|
||||||
hasDownImprovedVerticalStabilizer,
|
|
||||||
);
|
|
||||||
const max = applyPitchYawLimits(
|
|
||||||
Math.PI,
|
|
||||||
yaw,
|
|
||||||
p,
|
|
||||||
y,
|
|
||||||
hasImprovedVerticalStabilizer,
|
|
||||||
hasDownImprovedVerticalStabilizer,
|
|
||||||
);
|
|
||||||
|
|
||||||
yaw = min[1];
|
|
||||||
let t = 2 * Math.sqrt((u / rect.width) ** 2 + (v / rect.height) ** 2);
|
|
||||||
t = clamp(t, 0, 1);
|
|
||||||
let pitch = degToRad(magInverse(-t)) + initialTurretPitch;
|
|
||||||
pitch = clamp(pitch, min[0], max[0]);
|
|
||||||
|
|
||||||
setPitch(pitch);
|
|
||||||
setYaw(yaw);
|
|
||||||
setMinPitch(min[0] - initialTurretPitch);
|
|
||||||
setMaxPitch(max[0] - initialTurretPitch);
|
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
|
||||||
}}
|
|
||||||
mb="0"
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
ref={highlighter}
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
style={{
|
|
||||||
borderRadius: Var("radius-2"),
|
|
||||||
overflow: "hidden",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
style={{
|
|
||||||
opacity: 2 ** -3,
|
|
||||||
backgroundImage: `url(/media/toys/armor-hash.png)`,
|
|
||||||
boxShadow: "inset 0 0 4rem 1rem black",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<svg
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
width: "calc(100%)",
|
|
||||||
height: "calc(100%)",
|
|
||||||
}}
|
|
||||||
viewBox="-1 -1 2 2"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fillRule="evenodd"
|
|
||||||
fill="var(--gray-5)"
|
|
||||||
stroke="var(--gray-8)"
|
|
||||||
strokeWidth="1px"
|
|
||||||
vectorEffect="non-scaling-stroke"
|
|
||||||
d={d}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<path
|
|
||||||
stroke="var(--gray-10)"
|
|
||||||
fill="transparent"
|
|
||||||
strokeWidth="1px"
|
|
||||||
strokeDasharray="0.5rem 0.5rem"
|
|
||||||
vectorEffect="non-scaling-stroke"
|
|
||||||
d={`
|
|
||||||
M 0.5 0
|
|
||||||
A 0.5 0.5 0 1 1 -0.5 0
|
|
||||||
A 0.5 0.5 0 1 1 0.5 0
|
|
||||||
Z
|
|
||||||
`}
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
ref={pointer}
|
|
||||||
position="absolute"
|
|
||||||
top="50%"
|
|
||||||
left="50%"
|
|
||||||
width="0"
|
|
||||||
height="0"
|
|
||||||
style={{
|
|
||||||
transform: `translate(-50%, -50%) rotate(${yaw + Math.PI}rad)`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
width="1pt"
|
|
||||||
height="14rem"
|
|
||||||
style={{
|
|
||||||
borderRadius: Var("radius-1"),
|
|
||||||
background: `linear-gradient(${Var("gray-a11")}, ${Var("gray-a6")})`,
|
|
||||||
boxShadow:
|
|
||||||
"var(--white-a12) -0.25rem 0 1rem, var(--black-a12) 0.25rem 0 1rem",
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
position="absolute"
|
|
||||||
left={`${50 * (dotX + 1)}%`}
|
|
||||||
bottom={`${50 * (dotY + 1)}%`}
|
|
||||||
width="0.25rem"
|
|
||||||
height="0.25rem"
|
|
||||||
style={{
|
|
||||||
borderRadius: "50%",
|
|
||||||
backgroundColor: Var("gray-12"),
|
|
||||||
transform: "translate(-50%, 50%)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<VisualizerCornerStat
|
|
||||||
label={strings.website.tools.tankopedia.visualizers.flexibility.max}
|
|
||||||
value={literals(strings.common.units.deg, {
|
|
||||||
value: radToDeg(maxPitch).toFixed(0),
|
|
||||||
})}
|
|
||||||
side="bottom-left"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<VisualizerCornerStat
|
|
||||||
label={strings.website.tools.tankopedia.visualizers.flexibility.min}
|
|
||||||
value={literals(strings.common.units.deg, {
|
|
||||||
value: radToDeg(minPitch).toFixed(0),
|
|
||||||
})}
|
|
||||||
side="bottom-right"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<VisualizerCornerStat
|
|
||||||
label={strings.website.tools.tankopedia.visualizers.flexibility.pitch}
|
|
||||||
value={literals(strings.common.units.deg, {
|
|
||||||
value: radToDeg(pitch - initialTurretPitch).toFixed(0),
|
|
||||||
})}
|
|
||||||
side="top-left"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<VisualizerCornerStat
|
|
||||||
label={strings.website.tools.tankopedia.visualizers.flexibility.yaw}
|
|
||||||
value={literals(strings.common.units.deg, {
|
|
||||||
value: radToDeg(yaw).toFixed(0),
|
|
||||||
})}
|
|
||||||
side="top-right"
|
|
||||||
/>
|
|
||||||
</VisualizerCard>
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-116
@@ -1,116 +0,0 @@
|
|||||||
import { CaretDownIcon, CaretUpIcon } from "@radix-ui/react-icons";
|
|
||||||
import { Box, Flex, Text } from "@radix-ui/themes";
|
|
||||||
import fuzzysort from "fuzzysort";
|
|
||||||
import { Quicklime } from "quicklime";
|
|
||||||
import { useEffect, useRef, type ReactNode } from "react";
|
|
||||||
import { Tankopedia } from "../../../../../../stores/tankopedia";
|
|
||||||
import { Mark } from "../../../../../Mark";
|
|
||||||
|
|
||||||
export const highlightedRows = new Set<HTMLDivElement>();
|
|
||||||
export const highlightedRowsUpdate = new Quicklime();
|
|
||||||
|
|
||||||
export interface InfoProps {
|
|
||||||
name: ReactNode;
|
|
||||||
children?: ReactNode;
|
|
||||||
indent?: boolean;
|
|
||||||
delta?: number;
|
|
||||||
decimals?: number;
|
|
||||||
prefix?: string;
|
|
||||||
deltaType?: "higherIsBetter" | "lowerIsBetter";
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Info({
|
|
||||||
name,
|
|
||||||
children,
|
|
||||||
indent = false,
|
|
||||||
delta,
|
|
||||||
decimals,
|
|
||||||
prefix,
|
|
||||||
deltaType = "higherIsBetter",
|
|
||||||
}: InfoProps) {
|
|
||||||
const statSearch = Tankopedia.use((state) => state.statSearch);
|
|
||||||
const container = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
let label = name;
|
|
||||||
let highlighted = false;
|
|
||||||
|
|
||||||
if (statSearch !== undefined && typeof name === "string") {
|
|
||||||
const result = fuzzysort.single(statSearch, name);
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
label = result.highlight((match, index) => (
|
|
||||||
<Mark key={index}>{match}</Mark>
|
|
||||||
));
|
|
||||||
highlighted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!container.current) return;
|
|
||||||
|
|
||||||
if (highlighted) {
|
|
||||||
highlightedRows.add(container.current);
|
|
||||||
highlightedRowsUpdate.dispatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
highlightedRows.delete(container.current!);
|
|
||||||
highlightedRowsUpdate.dispatch();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Flex
|
|
||||||
align="center"
|
|
||||||
pl={indent ? "2" : "0"}
|
|
||||||
width="100%"
|
|
||||||
gap="4"
|
|
||||||
ref={container}
|
|
||||||
>
|
|
||||||
<Text color="gray">{label}</Text>
|
|
||||||
|
|
||||||
<Box flexGrow="1" />
|
|
||||||
|
|
||||||
{children !== undefined && (
|
|
||||||
<Flex align="center" gap="1">
|
|
||||||
{delta !== undefined && delta !== 0 && !isNaN(delta) && (
|
|
||||||
<>
|
|
||||||
<Text
|
|
||||||
color={
|
|
||||||
delta * (deltaType === "lowerIsBetter" ? -1 : 1) > 0
|
|
||||||
? "green"
|
|
||||||
: "tomato"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{decimals !== undefined
|
|
||||||
? Math.abs(delta).toFixed(decimals)
|
|
||||||
: Math.abs(delta)}
|
|
||||||
</Text>
|
|
||||||
<Text
|
|
||||||
color={
|
|
||||||
delta * (deltaType === "lowerIsBetter" ? -1 : 1) > 0
|
|
||||||
? "green"
|
|
||||||
: "tomato"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{delta > 0 ? <CaretUpIcon /> : <CaretDownIcon />}
|
|
||||||
</Text>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Text>
|
|
||||||
{prefix !== undefined && (
|
|
||||||
<Text color="gray" size="1">
|
|
||||||
{prefix}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{decimals !== undefined && typeof children === "number"
|
|
||||||
? children.toFixed(decimals)
|
|
||||||
: children}
|
|
||||||
</Text>
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-136
@@ -1,136 +0,0 @@
|
|||||||
import { Heading } from '@radix-ui/themes';
|
|
||||||
import { useLocale } from '../../../../../../hooks/useLocale';
|
|
||||||
import { Info } from './Info';
|
|
||||||
import { InfoWithDelta } from './InfoWithDelta';
|
|
||||||
import { StatsTableWrapper } from './StatsTableWrapper';
|
|
||||||
import {
|
|
||||||
TraverseVisualizer,
|
|
||||||
type StatsAcceptorProps,
|
|
||||||
} from './TraverseVisualizer';
|
|
||||||
|
|
||||||
export function Maneuverability({ stats }: StatsAcceptorProps) {
|
|
||||||
const { strings } = useLocale();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StatsTableWrapper>
|
|
||||||
<Heading size="5">
|
|
||||||
{strings.website.tools.tankopedia.maneuverability.title}
|
|
||||||
</Heading>
|
|
||||||
<Info
|
|
||||||
name={strings.website.tools.tankopedia.characteristics.values.speed}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta value="speedForwards" stats={stats} decimals={0} indent />
|
|
||||||
<InfoWithDelta value="speedBackwards" stats={stats} decimals={0} indent />
|
|
||||||
<InfoWithDelta stats={stats} decimals={0} value="enginePower" />
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="weight"
|
|
||||||
/>
|
|
||||||
<Info
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.terrain_coefficients
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
value="hardTerrainCoefficient"
|
|
||||||
stats={stats}
|
|
||||||
decimals={0}
|
|
||||||
indent
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={0}
|
|
||||||
indent
|
|
||||||
value="mediumTerrainCoefficient"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
value="softTerrainCoefficient"
|
|
||||||
stats={stats}
|
|
||||||
decimals={0}
|
|
||||||
indent
|
|
||||||
/>
|
|
||||||
<Info
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.raw_terrain_coefficients
|
|
||||||
}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
value="hardTerrainCoefficientRaw"
|
|
||||||
stats={stats}
|
|
||||||
decimals={2}
|
|
||||||
indent
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={2}
|
|
||||||
indent
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="mediumTerrainCoefficientRaw"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={2}
|
|
||||||
indent
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
value="softTerrainCoefficientRaw"
|
|
||||||
/>
|
|
||||||
<Info
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.power_to_weight_ratio
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="powerToWeightRatioHardTerrain"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="powerToWeightRatioMediumTerrain"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="powerToWeightRatioSoftTerrain"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta stats={stats} decimals={1} value="turretTraverseSpeed" />
|
|
||||||
<Info
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.hull_traverse_speed
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="hullTraverseHardTerrain"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="hullTraverseMediumTerrain"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
decimals={1}
|
|
||||||
indent
|
|
||||||
value="hullTraverseSoftTerrain"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TraverseVisualizer stats={stats} />
|
|
||||||
</StatsTableWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-89
@@ -1,89 +0,0 @@
|
|||||||
import { Box, Flex } from '@radix-ui/themes';
|
|
||||||
import type { QuicklimeCallback } from 'quicklime';
|
|
||||||
import { useEffect, useRef } from 'react';
|
|
||||||
import { reloadUpdate, type ReloadUpdateData } from '..';
|
|
||||||
import { Var } from '../../../../../../../../core/radix/var';
|
|
||||||
import type { StatsAcceptorProps } from '../../TraverseVisualizer';
|
|
||||||
import { ShellBorder } from './ShellBorder';
|
|
||||||
|
|
||||||
interface ShellProps {
|
|
||||||
index: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Shell({ index, stats }: ShellProps & StatsAcceptorProps) {
|
|
||||||
const bar = useRef<HTMLDivElement>(null!);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleReloadUpdate: QuicklimeCallback<ReloadUpdateData> = ({
|
|
||||||
data,
|
|
||||||
}) => {
|
|
||||||
bar.current.style.width = `${data.shells[index] * 100}%`;
|
|
||||||
};
|
|
||||||
|
|
||||||
reloadUpdate.on(handleReloadUpdate);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
reloadUpdate.off(handleReloadUpdate);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
position: 'absolute',
|
|
||||||
top: '50%',
|
|
||||||
left: '50%',
|
|
||||||
transform: `translate(-50%, -50%) rotate(${135 - 7 * (index - (stats.shells - 1) / 2)}deg)`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
left="50%"
|
|
||||||
position="absolute"
|
|
||||||
ml="40%"
|
|
||||||
width="1.25rem"
|
|
||||||
height="1.25rem"
|
|
||||||
style={{
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ShellBorder
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
color: Var('jade-8'),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
justify="end"
|
|
||||||
style={{
|
|
||||||
borderRadius: '0.25rem',
|
|
||||||
overflow: 'hidden',
|
|
||||||
maskImage:
|
|
||||||
'url(/media/toys/shell.png)',
|
|
||||||
maskSize: 'contain',
|
|
||||||
maskRepeat: 'no-repeat',
|
|
||||||
maskPosition: 'center',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
ref={bar}
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
background: Var('jade-9'),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
import { Box } from '@radix-ui/themes';
|
|
||||||
|
|
||||||
export function Target() {
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
style={{
|
|
||||||
background:
|
|
||||||
'url(/media/toys/background.jpg)',
|
|
||||||
backgroundSize: '25rem',
|
|
||||||
backgroundPosition: 'center',
|
|
||||||
position: 'absolute',
|
|
||||||
top: '50%',
|
|
||||||
left: '50%',
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
objectFit: 'cover',
|
|
||||||
filter: 'blur(0.2rem) contrast(1.2) brightness(0.5) saturate(0.8)',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
#reload-visualizer-flash {
|
|
||||||
background: transparent;
|
|
||||||
transition-duration: 200ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
#reload-visualizer-flash.go {
|
|
||||||
background: var(--white-a3);
|
|
||||||
transition: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reload {
|
|
||||||
width: 65%;
|
|
||||||
height: 65%;
|
|
||||||
transition-duration: 200ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reload.go {
|
|
||||||
width: 70%;
|
|
||||||
height: 70%;
|
|
||||||
transition: none;
|
|
||||||
}
|
|
||||||
-319
@@ -1,319 +0,0 @@
|
|||||||
import { DoubleArrowRightIcon } from '@radix-ui/react-icons';
|
|
||||||
import { Box, Button, Code } from '@radix-ui/themes';
|
|
||||||
import { times } from 'lodash-es';
|
|
||||||
import { Quicklime, type QuicklimeCallback } from 'quicklime';
|
|
||||||
import { useCallback, useEffect, useRef } from 'react';
|
|
||||||
import { Var } from '../../../../../../../core/radix/var';
|
|
||||||
import { useLocale } from '../../../../../../../hooks/useLocale';
|
|
||||||
import { LazyImage } from '../../../../../../LazyImage';
|
|
||||||
import type { StatsAcceptorProps } from '../TraverseVisualizer';
|
|
||||||
import { VisualizerCard } from '../VisualizerCard';
|
|
||||||
import { Shell } from './components/Shell';
|
|
||||||
import { Target } from './components/Target';
|
|
||||||
import './index.css';
|
|
||||||
|
|
||||||
export const RELOAD_PRECISION = 1;
|
|
||||||
|
|
||||||
export interface ReloadUpdateData {
|
|
||||||
reload: number;
|
|
||||||
shells: number[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const reloadUpdate = new Quicklime<ReloadUpdateData>();
|
|
||||||
|
|
||||||
export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
|
|
||||||
const { strings } = useLocale();
|
|
||||||
|
|
||||||
const reloadCircle = useRef<HTMLDivElement>(null);
|
|
||||||
const reloadCore = useRef<HTMLDivElement>(null);
|
|
||||||
const reloadGlow = useRef<HTMLDivElement>(null);
|
|
||||||
const totalTime = useRef<HTMLSpanElement>(null);
|
|
||||||
const progressTime = useRef<HTMLSpanElement>(null);
|
|
||||||
const flash = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
const state = useRef(0);
|
|
||||||
|
|
||||||
const shoot = useCallback(() => {
|
|
||||||
flash.current?.classList.add('go');
|
|
||||||
reloadCircle.current?.classList.add('go');
|
|
||||||
reloadGlow.current?.classList.add('go');
|
|
||||||
|
|
||||||
void flash.current?.offsetWidth;
|
|
||||||
void reloadCircle.current?.offsetWidth;
|
|
||||||
void reloadGlow.current?.offsetWidth;
|
|
||||||
|
|
||||||
flash.current?.classList.remove('go');
|
|
||||||
reloadCircle.current?.classList.remove('go');
|
|
||||||
reloadGlow.current?.classList.remove('go');
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let cancel = false;
|
|
||||||
let lastT = Date.now() / 1000;
|
|
||||||
let lastState = state.current;
|
|
||||||
const shellArray = new Array(stats.shells);
|
|
||||||
|
|
||||||
function frame() {
|
|
||||||
if (!totalTime.current || !progressTime.current) return;
|
|
||||||
|
|
||||||
const reloadThreshold = stats.shellReloads
|
|
||||||
? stats.shellReloads.length
|
|
||||||
: 1;
|
|
||||||
const now = Date.now() / 1000;
|
|
||||||
const dt = now - lastT;
|
|
||||||
let reload;
|
|
||||||
let shells;
|
|
||||||
|
|
||||||
if (state.current < reloadThreshold) {
|
|
||||||
const shellReload =
|
|
||||||
reloadThreshold === 1
|
|
||||||
? stats.shellReload!
|
|
||||||
: stats.shellReloads![Math.floor(state.current)];
|
|
||||||
|
|
||||||
state.current = Math.min(
|
|
||||||
reloadThreshold,
|
|
||||||
state.current + dt / shellReload,
|
|
||||||
);
|
|
||||||
reload = state.current % 1;
|
|
||||||
shells = shellArray.fill(reload);
|
|
||||||
|
|
||||||
if (reloadThreshold > 1) {
|
|
||||||
shells = shells.map((_, index) =>
|
|
||||||
Math.max(0, state.current - shellArray.length + index + 1),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
totalTime.current.innerHTML = shellReload.toFixed(RELOAD_PRECISION);
|
|
||||||
progressTime.current.innerHTML = ((1 - reload) * shellReload).toFixed(
|
|
||||||
RELOAD_PRECISION,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (state.current >= reloadThreshold) shoot();
|
|
||||||
} else if (state.current < stats.shells + reloadThreshold - 1) {
|
|
||||||
let interval;
|
|
||||||
|
|
||||||
if (
|
|
||||||
stats.burstShells === 1 ||
|
|
||||||
Math.floor(state.current) % stats.burstShells === 0
|
|
||||||
) {
|
|
||||||
interval = stats.intraClip!;
|
|
||||||
} else {
|
|
||||||
interval = stats.burstInterShell!;
|
|
||||||
}
|
|
||||||
|
|
||||||
state.current = Math.min(
|
|
||||||
stats.shells + reloadThreshold,
|
|
||||||
state.current + dt / interval,
|
|
||||||
);
|
|
||||||
reload = state.current % 1;
|
|
||||||
|
|
||||||
if (reloadThreshold > 1) {
|
|
||||||
shells = shellArray.map((_, index) =>
|
|
||||||
Math.max(
|
|
||||||
0,
|
|
||||||
Math.floor(index + 1 + reloadThreshold - state.current),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
shells = times(stats.shells, (index) => index > state.current - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
totalTime.current.innerHTML = interval.toFixed(RELOAD_PRECISION);
|
|
||||||
progressTime.current.innerHTML = ((1 - reload) * interval).toFixed(
|
|
||||||
RELOAD_PRECISION,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (lastState % 1 > state.current % 1) shoot();
|
|
||||||
} else {
|
|
||||||
state.current = 0;
|
|
||||||
reload = 0;
|
|
||||||
shells = shellArray.fill(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
reloadUpdate.dispatch({ reload, shells });
|
|
||||||
|
|
||||||
if (!cancel) requestAnimationFrame(frame);
|
|
||||||
|
|
||||||
lastT = now;
|
|
||||||
lastState = state.current;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame();
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cancel = true;
|
|
||||||
};
|
|
||||||
}, [stats]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleReloadUpdate: QuicklimeCallback<ReloadUpdateData> = ({
|
|
||||||
data,
|
|
||||||
}) => {
|
|
||||||
if (!reloadCircle.current || !reloadCore.current || !reloadGlow.current)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const reloadAngle = data.reload * 2 * Math.PI;
|
|
||||||
|
|
||||||
reloadCircle.current.style.background = `conic-gradient(${Var('amber-9')} 0 ${reloadAngle}rad, ${Var('orange-7')} ${reloadAngle}rad)`;
|
|
||||||
reloadCore.current.style.background = `conic-gradient(${Var('amber-6')} 0 ${reloadAngle}rad, ${Var('orange-3')} ${reloadAngle}rad)`;
|
|
||||||
reloadGlow.current.style.background = `conic-gradient(${Var('amber-9')} 0 ${reloadAngle}rad, transparent ${reloadAngle}rad)`;
|
|
||||||
};
|
|
||||||
|
|
||||||
reloadUpdate.on(handleReloadUpdate);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
reloadUpdate.off(handleReloadUpdate);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<VisualizerCard>
|
|
||||||
<Box position="absolute" top="0" left="0" width="100%" height="100%">
|
|
||||||
<Target />
|
|
||||||
|
|
||||||
<Box
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
style={{
|
|
||||||
background: `radial-gradient(transparent 50%, ${Var('black-a8')} 100%)`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
p="1"
|
|
||||||
position="absolute"
|
|
||||||
top="50%"
|
|
||||||
left="50%"
|
|
||||||
className="reload"
|
|
||||||
ref={reloadGlow}
|
|
||||||
style={{
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
borderRadius: '50%',
|
|
||||||
filter: 'blur(0.5rem)',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
p="1"
|
|
||||||
position="absolute"
|
|
||||||
top="50%"
|
|
||||||
left="50%"
|
|
||||||
className="reload"
|
|
||||||
ref={reloadCircle}
|
|
||||||
style={{
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
borderRadius: '50%',
|
|
||||||
background: Var('orange-7'),
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
style={{
|
|
||||||
borderRadius: '50%',
|
|
||||||
background: 'black',
|
|
||||||
overflow: 'hidden',
|
|
||||||
}}
|
|
||||||
position="relative"
|
|
||||||
>
|
|
||||||
<Target />
|
|
||||||
|
|
||||||
<Box
|
|
||||||
ref={reloadCore}
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
style={{
|
|
||||||
borderRadius: '50%',
|
|
||||||
maskImage: 'radial-gradient(transparent 25%, black 100%)',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<LazyImage
|
|
||||||
src="/assets/images/tankopedia/visualizers/reload/caret.png"
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: '50%',
|
|
||||||
left: '50%',
|
|
||||||
transform: 'translateX(-50%)',
|
|
||||||
width: '10%',
|
|
||||||
height: '10%',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Code
|
|
||||||
ref={progressTime}
|
|
||||||
size="2"
|
|
||||||
variant="ghost"
|
|
||||||
weight="bold"
|
|
||||||
color="gray"
|
|
||||||
highContrast
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: '50%',
|
|
||||||
right: 'calc(50% + var(--space-8))',
|
|
||||||
transform: 'translate(50%, -50%)',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{(0).toFixed(RELOAD_PRECISION)}
|
|
||||||
</Code>
|
|
||||||
<Code
|
|
||||||
ref={totalTime}
|
|
||||||
size="2"
|
|
||||||
variant="ghost"
|
|
||||||
weight="bold"
|
|
||||||
color="gray"
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: '50%',
|
|
||||||
left: 'calc(50% + var(--space-8))',
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{(0).toFixed(RELOAD_PRECISION)}
|
|
||||||
</Code>
|
|
||||||
|
|
||||||
{stats.shells > 1 &&
|
|
||||||
times(stats.shells, (index) => (
|
|
||||||
<Shell stats={stats} index={index} key={index} />
|
|
||||||
))}
|
|
||||||
|
|
||||||
<Box
|
|
||||||
id="reload-visualizer-flash"
|
|
||||||
ref={flash}
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
size="1"
|
|
||||||
variant="outline"
|
|
||||||
color="gray"
|
|
||||||
highContrast
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: '68%',
|
|
||||||
left: '50%',
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
state.current = Math.floor(state.current + 1);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{strings.website.tools.tankopedia.visualizers.reload.skip}
|
|
||||||
<DoubleArrowRightIcon />
|
|
||||||
</Button>
|
|
||||||
</VisualizerCard>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-50
@@ -1,50 +0,0 @@
|
|||||||
import { alias } from "@blitzkit/core";
|
|
||||||
import { Flex, IconButton, Tooltip } from "@radix-ui/themes";
|
|
||||||
import { useLocale } from "../../../../../../../../hooks/useLocale";
|
|
||||||
import { Duel } from "../../../../../../../../stores/duel";
|
|
||||||
import { LazyImage } from "../../../../../../../LazyImage";
|
|
||||||
|
|
||||||
export function ShellSwitcher() {
|
|
||||||
const gun = Duel.use((state) => state.protagonist.gun);
|
|
||||||
const shell = Duel.use((state) => state.protagonist.shell);
|
|
||||||
|
|
||||||
const { unwrap } = useLocale();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Flex>
|
|
||||||
{gun.shells.map((thisShell, shellIndex) => {
|
|
||||||
const selected = thisShell.id === shell.id;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tooltip content={unwrap(thisShell.name!)} key={thisShell.id}>
|
|
||||||
<IconButton
|
|
||||||
size="3"
|
|
||||||
color={selected ? undefined : "gray"}
|
|
||||||
variant={selected ? "solid" : "soft"}
|
|
||||||
highContrast={selected}
|
|
||||||
style={{
|
|
||||||
borderTopLeftRadius: 0,
|
|
||||||
borderBottomLeftRadius: shellIndex === 0 ? "50%" : 0,
|
|
||||||
borderTopRightRadius: 0,
|
|
||||||
borderBottomRightRadius:
|
|
||||||
shellIndex === gun.shells.length - 1 ? "50%" : 0,
|
|
||||||
marginLeft: shellIndex === 0 ? 0 : -1,
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
Duel.mutate((draft) => {
|
|
||||||
draft.protagonist.shell = thisShell;
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<LazyImage
|
|
||||||
alt={unwrap(thisShell.name!)}
|
|
||||||
style={{ width: "1.125rem", height: "1.125rem" }}
|
|
||||||
src={alias("api", `icons/shells/${thisShell.icon}.webp`)}
|
|
||||||
/>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-239
@@ -1,239 +0,0 @@
|
|||||||
import { alias, isExplosive } from "@blitzkit/core";
|
|
||||||
import { literals } from "@blitzkit/i18n";
|
|
||||||
import { Box, Flex, Text } from "@radix-ui/themes";
|
|
||||||
import { useRef, useState } from "react";
|
|
||||||
import { clamp, degToRad, radToDeg } from "three/src/math/MathUtils.js";
|
|
||||||
import { Var } from "../../../../../../../core/radix/var";
|
|
||||||
import { useLocale } from "../../../../../../../hooks/useLocale";
|
|
||||||
import { Duel } from "../../../../../../../stores/duel";
|
|
||||||
import { LazyImage } from "../../../../../../LazyImage";
|
|
||||||
import type { StatsAcceptorProps } from "../TraverseVisualizer";
|
|
||||||
import { VisualizerCard } from "../VisualizerCard";
|
|
||||||
import { VisualizerCornerStat } from "../VisualizerCornerStat";
|
|
||||||
import { ShellSwitcher } from "./components/ShellSwitcher";
|
|
||||||
|
|
||||||
export function RicochetVisualizer({ stats }: StatsAcceptorProps) {
|
|
||||||
const shell = Duel.use((state) => state.protagonist.shell);
|
|
||||||
const container = useRef<HTMLDivElement>(null);
|
|
||||||
const normalization = degToRad(stats.shellNormalization);
|
|
||||||
const ricochet = degToRad(stats.shellRicochet ?? 90);
|
|
||||||
const [rawAngle, setAngle] = useState(degToRad(-25));
|
|
||||||
const explodes = isExplosive(shell.type);
|
|
||||||
const angle = explodes ? degToRad(-70) : rawAngle;
|
|
||||||
const doesRicochet = Math.abs(angle) >= ricochet;
|
|
||||||
const effectiveAngle = doesRicochet
|
|
||||||
? -angle + Math.PI
|
|
||||||
: Math.sign(angle) * Math.max(0, Math.abs(angle) - normalization);
|
|
||||||
const { strings } = useLocale();
|
|
||||||
const armorPercentage = Math.min(999, 100 / Math.cos(effectiveAngle));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Flex direction="column" mb="6" align="center">
|
|
||||||
<VisualizerCard
|
|
||||||
mb="0"
|
|
||||||
style={{ width: "100%", touchAction: "none" }}
|
|
||||||
ref={container}
|
|
||||||
onPointerMove={(event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
if (!container.current || explodes) return;
|
|
||||||
|
|
||||||
const rect = container.current.getBoundingClientRect();
|
|
||||||
const x = event.clientX - rect.left - rect.width / 3;
|
|
||||||
const y = event.clientY - rect.top - rect.height / 2;
|
|
||||||
const angle = clamp(Math.atan2(-y, x), -Math.PI / 2, Math.PI / 2);
|
|
||||||
|
|
||||||
setAngle(angle);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
width="33%"
|
|
||||||
height="100%"
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
style={{
|
|
||||||
background: `linear-gradient(to right, transparent, ${Var("gray-a4")})`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
style={{
|
|
||||||
opacity: 2 ** -3,
|
|
||||||
backgroundImage: `url(/media/toys/armor-hash.png)`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
left="33%"
|
|
||||||
top="0"
|
|
||||||
width="67%"
|
|
||||||
height="100%"
|
|
||||||
position="absolute"
|
|
||||||
style={{
|
|
||||||
background: `conic-gradient(
|
|
||||||
at 0 50%,
|
|
||||||
|
|
||||||
${Var("ruby-a2")},
|
|
||||||
${Var("ruby-a1")} ${Math.PI / 2 - ricochet}rad,
|
|
||||||
|
|
||||||
${Var("jade-a2")} ${Math.PI / 2 - ricochet}rad,
|
|
||||||
${Var("jade-a4")} ${Math.PI / 2 - normalization}rad,
|
|
||||||
|
|
||||||
${Var("cyan-a5")} ${Math.PI / 2 - normalization}rad,
|
|
||||||
${Var("cyan-a3")} ${Math.PI / 2 + normalization}rad,
|
|
||||||
|
|
||||||
${Var("jade-a2")} ${Math.PI / 2 + normalization}rad,
|
|
||||||
${Var("jade-a4")} ${Math.PI / 2 + ricochet}rad,
|
|
||||||
|
|
||||||
${Var("ruby-a1")} ${Math.PI / 2 + ricochet}rad,
|
|
||||||
${Var("ruby-a2")} 180deg
|
|
||||||
`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
position="absolute"
|
|
||||||
left="33%"
|
|
||||||
top="50%"
|
|
||||||
height="18rem"
|
|
||||||
style={{
|
|
||||||
transformOrigin: "top center",
|
|
||||||
transform: `translateX(-50%) rotate(${-Math.PI / 2 - angle}rad)`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
position="absolute"
|
|
||||||
width="1px"
|
|
||||||
height="100%"
|
|
||||||
bottom="100%"
|
|
||||||
style={{
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
backgroundColor: Var("gray-a8"),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Box
|
|
||||||
position="absolute"
|
|
||||||
width="3px"
|
|
||||||
height="100%"
|
|
||||||
style={{
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
background: `linear-gradient(${Var("gray-a11")}, ${Var("gray-a4")})`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<LazyImage
|
|
||||||
src={alias("api", `icons/shells/${shell.icon}.webp`)}
|
|
||||||
style={{
|
|
||||||
objectFit: "contain",
|
|
||||||
transform: "translate(-50%, -50%) rotate(-45deg)",
|
|
||||||
position: "absolute",
|
|
||||||
width: "2rem",
|
|
||||||
height: "2rem",
|
|
||||||
top: "6rem",
|
|
||||||
left: 0,
|
|
||||||
filter: "drop-shadow(0px 0px 0.25rem black)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
position="absolute"
|
|
||||||
left="33%"
|
|
||||||
top="50%"
|
|
||||||
height="16rem"
|
|
||||||
style={{
|
|
||||||
transformOrigin: "top center",
|
|
||||||
transform: `translateX(-50%) rotate(${-Math.PI / 2 - effectiveAngle}rad)`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
position="absolute"
|
|
||||||
width="3px"
|
|
||||||
height="100%"
|
|
||||||
top="-100%"
|
|
||||||
style={{
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
background: `linear-gradient(${Var("gray-a4")}, ${Var("gray-a11")})`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<VisualizerCornerStat
|
|
||||||
label={strings.website.tools.tankopedia.visualizers.ricochet.angle}
|
|
||||||
value={literals(strings.common.units.deg, {
|
|
||||||
value: radToDeg(Math.abs(angle)).toFixed(0),
|
|
||||||
})}
|
|
||||||
side="top-left"
|
|
||||||
/>
|
|
||||||
<VisualizerCornerStat
|
|
||||||
label={
|
|
||||||
strings.website.tools.tankopedia.visualizers.ricochet.normalization
|
|
||||||
}
|
|
||||||
value={
|
|
||||||
doesRicochet
|
|
||||||
? "-"
|
|
||||||
: literals(strings.common.units.deg, {
|
|
||||||
value: radToDeg(
|
|
||||||
Math.min(normalization, Math.abs(angle)),
|
|
||||||
).toFixed(0),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
side="top-right"
|
|
||||||
/>
|
|
||||||
<VisualizerCornerStat
|
|
||||||
label={
|
|
||||||
strings.website.tools.tankopedia.visualizers.ricochet
|
|
||||||
.effective_angle
|
|
||||||
}
|
|
||||||
value={
|
|
||||||
doesRicochet
|
|
||||||
? "-"
|
|
||||||
: literals(strings.common.units.deg, {
|
|
||||||
value: radToDeg(Math.abs(effectiveAngle)).toFixed(0),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
side="bottom-left"
|
|
||||||
/>
|
|
||||||
<VisualizerCornerStat
|
|
||||||
label={strings.website.tools.tankopedia.visualizers.ricochet.armor}
|
|
||||||
value={
|
|
||||||
doesRicochet
|
|
||||||
? "-"
|
|
||||||
: literals(strings.common.units.percentage, {
|
|
||||||
value: armorPercentage.toFixed(0),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
side="bottom-right"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{explodes && (
|
|
||||||
<Flex
|
|
||||||
p="3"
|
|
||||||
justify="center"
|
|
||||||
align="center"
|
|
||||||
height="100%"
|
|
||||||
width="100%"
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
style={{
|
|
||||||
background: `radial-gradient(${Var("black-a7")}, ${Var("black-a11")})`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text color="gray" align="center">
|
|
||||||
{
|
|
||||||
strings.website.tools.tankopedia.visualizers.ricochet
|
|
||||||
.no_ricochet
|
|
||||||
}
|
|
||||||
</Text>
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
</VisualizerCard>
|
|
||||||
|
|
||||||
<ShellSwitcher />
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-91
@@ -1,91 +0,0 @@
|
|||||||
import { memo, useEffect, useMemo, useRef } from "react";
|
|
||||||
|
|
||||||
const RESOLUTION = 1000;
|
|
||||||
const HEIGHT = 8;
|
|
||||||
const DENSE_TICKS = 100;
|
|
||||||
|
|
||||||
interface StatScaleProps {
|
|
||||||
values: number[];
|
|
||||||
value: number;
|
|
||||||
lowerIsBetter?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const StatScale = memo<StatScaleProps>(
|
|
||||||
({ values, value, lowerIsBetter }) => {
|
|
||||||
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
||||||
const ticks = useMemo(() => {
|
|
||||||
const min = Math.min(value, ...values);
|
|
||||||
const max = Math.max(value, ...values);
|
|
||||||
const range = max - min;
|
|
||||||
const positions = new Set<number>();
|
|
||||||
|
|
||||||
for (const other of values) {
|
|
||||||
const raw = range === 0 ? 0.5 : (other - min) / range;
|
|
||||||
const x = Math.round((lowerIsBetter ? 1 - raw : raw) * RESOLUTION);
|
|
||||||
|
|
||||||
if (x === 0 || x === RESOLUTION) continue;
|
|
||||||
|
|
||||||
positions.add(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Array.from(positions, (x) => ({ x }));
|
|
||||||
}, [values, value, lowerIsBetter]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const canvas = canvasRef.current;
|
|
||||||
if (!canvas) return;
|
|
||||||
|
|
||||||
const draw = () => {
|
|
||||||
const { width } = canvas.getBoundingClientRect();
|
|
||||||
const pixelRatio = window.devicePixelRatio || 1;
|
|
||||||
const canvasWidth = Math.ceil(width * pixelRatio);
|
|
||||||
const canvasHeight = Math.ceil(HEIGHT * pixelRatio);
|
|
||||||
|
|
||||||
if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
|
|
||||||
canvas.width = canvasWidth;
|
|
||||||
canvas.height = canvasHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
const context = canvas.getContext("2d");
|
|
||||||
if (!context) return;
|
|
||||||
|
|
||||||
context.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
|
|
||||||
context.clearRect(0, 0, width, HEIGHT);
|
|
||||||
|
|
||||||
const styles = getComputedStyle(canvas);
|
|
||||||
for (const { x } of ticks) {
|
|
||||||
context.fillStyle = styles.getPropertyValue("--gray-a6").trim();
|
|
||||||
context.fillRect((x / RESOLUTION) * width, 0, 1, HEIGHT);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const observer = new ResizeObserver(draw);
|
|
||||||
observer.observe(canvas);
|
|
||||||
window.addEventListener("resize", draw);
|
|
||||||
draw();
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
observer.disconnect();
|
|
||||||
window.removeEventListener("resize", draw);
|
|
||||||
};
|
|
||||||
}, [ticks]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<canvas
|
|
||||||
ref={canvasRef}
|
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: 0,
|
|
||||||
bottom: 0,
|
|
||||||
left: 0,
|
|
||||||
width: "100%",
|
|
||||||
height: HEIGHT,
|
|
||||||
margin: "auto 0",
|
|
||||||
opacity: Math.min(1, Math.sqrt(DENSE_TICKS / ticks.length)),
|
|
||||||
pointerEvents: "none",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
-103
@@ -1,103 +0,0 @@
|
|||||||
import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
|
|
||||||
import { Flex, Spinner, TextField, type FlexProps } from "@radix-ui/themes";
|
|
||||||
import { debounce } from "lodash-es";
|
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
|
||||||
import { useLocale } from "../../../../../../hooks/useLocale";
|
|
||||||
import { Tankopedia } from "../../../../../../stores/tankopedia";
|
|
||||||
import { highlightedRows, highlightedRowsUpdate } from "./Info";
|
|
||||||
|
|
||||||
export function StatSearch(props: FlexProps) {
|
|
||||||
const { strings } = useLocale();
|
|
||||||
const [searching, setSearching] = useState(false);
|
|
||||||
const input = useRef<HTMLInputElement>(null);
|
|
||||||
const count = useRef<HTMLDivElement>(null);
|
|
||||||
const [index, setIndex] = useState(0);
|
|
||||||
const search = useCallback(() => {
|
|
||||||
if (!input.current || !count.current) return;
|
|
||||||
|
|
||||||
if (input.current.value.length > 0) {
|
|
||||||
setSearching(true);
|
|
||||||
} else {
|
|
||||||
setSearching(false);
|
|
||||||
count.current.textContent = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
requestUpdate();
|
|
||||||
setIndex(0);
|
|
||||||
}, []);
|
|
||||||
const requestUpdate = useCallback(
|
|
||||||
debounce(() => {
|
|
||||||
if (!input.current || !count.current) return;
|
|
||||||
|
|
||||||
if (input.current.value.length === 0) {
|
|
||||||
count.current.textContent = "";
|
|
||||||
|
|
||||||
setSearching(false);
|
|
||||||
Tankopedia.mutate((draft) => {
|
|
||||||
draft.statSearch = undefined;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setSearching(false);
|
|
||||||
Tankopedia.mutate((draft) => {
|
|
||||||
draft.statSearch = input.current!.value;
|
|
||||||
});
|
|
||||||
}, 500),
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleHighlightedRowsUpdate = () => {
|
|
||||||
if (!count.current || !input.current) return;
|
|
||||||
|
|
||||||
count.current.textContent =
|
|
||||||
input.current.value.length === 0 ? "" : `0 / ${highlightedRows.size}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
highlightedRowsUpdate.on(handleHighlightedRowsUpdate);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
highlightedRowsUpdate.off(handleHighlightedRowsUpdate);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Flex flexGrow="1" maxWidth="20rem" width="100%" {...props}>
|
|
||||||
<TextField.Root
|
|
||||||
ref={input}
|
|
||||||
placeholder={strings.website.tools.tankopedia.search}
|
|
||||||
variant="classic"
|
|
||||||
style={{ width: "100%" }}
|
|
||||||
onChange={search}
|
|
||||||
onKeyDown={(event) => {
|
|
||||||
if (!count.current) return;
|
|
||||||
|
|
||||||
if (event.key === "Enter") {
|
|
||||||
const newIndex = (index + 1) % highlightedRows.size;
|
|
||||||
count.current.textContent = `${newIndex + 1} / ${highlightedRows.size}`;
|
|
||||||
const array = [...highlightedRows];
|
|
||||||
|
|
||||||
array.forEach((element) => element.classList.remove("focused"));
|
|
||||||
|
|
||||||
if (array[newIndex]) {
|
|
||||||
array[newIndex].classList.add("focused");
|
|
||||||
array[newIndex].scrollIntoView({
|
|
||||||
block: "center",
|
|
||||||
inline: "center",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setIndex((index) => index + 1);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TextField.Slot>
|
|
||||||
{searching ? <Spinner /> : <MagnifyingGlassIcon />}
|
|
||||||
</TextField.Slot>
|
|
||||||
|
|
||||||
<TextField.Slot ref={count} />
|
|
||||||
</TextField.Root>
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
import { Flex, type FlexProps } from '@radix-ui/themes';
|
|
||||||
|
|
||||||
export function StatsTableWrapper(props: FlexProps) {
|
|
||||||
return (
|
|
||||||
<Flex
|
|
||||||
direction="column"
|
|
||||||
gap="2"
|
|
||||||
maxWidth="25rem"
|
|
||||||
width={{ initial: '100%', md: '16rem', xl: '20rem' }}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-118
@@ -1,118 +0,0 @@
|
|||||||
import { Heading } from '@radix-ui/themes';
|
|
||||||
import { useLocale } from '../../../../../../hooks/useLocale';
|
|
||||||
import { Info } from './Info';
|
|
||||||
import { InfoWithDelta } from './InfoWithDelta';
|
|
||||||
import { StatsTableWrapper } from './StatsTableWrapper';
|
|
||||||
import type { StatsAcceptorProps } from './TraverseVisualizer';
|
|
||||||
import { ViewRangeVisualizer } from './ViewRangeVisualizer';
|
|
||||||
|
|
||||||
export function Survivability({ stats }: StatsAcceptorProps) {
|
|
||||||
const { strings } = useLocale();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StatsTableWrapper>
|
|
||||||
<Heading size="5">
|
|
||||||
{strings.website.tools.tankopedia.survivability.title}
|
|
||||||
</Heading>
|
|
||||||
<InfoWithDelta value="health" stats={stats} decimals={0} />
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values.fireChance
|
|
||||||
}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
decimals={0}
|
|
||||||
value={(stats) => stats.fireChance * 100}
|
|
||||||
/>
|
|
||||||
{stats.trackRepairTime !== undefined && (
|
|
||||||
<InfoWithDelta
|
|
||||||
value="trackRepairTime"
|
|
||||||
stats={stats}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
decimals={2}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<InfoWithDelta value="viewRange" stats={stats} decimals={0} />
|
|
||||||
<ViewRangeVisualizer stats={stats} />
|
|
||||||
<Info
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values.camouflage
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
value={(stats) => stats.camouflageStill * 100}
|
|
||||||
stats={stats}
|
|
||||||
indent
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.camouflageStill
|
|
||||||
}
|
|
||||||
decimals={2}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
value={(stats) => stats.camouflageMoving * 100}
|
|
||||||
stats={stats}
|
|
||||||
indent
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.camouflageMoving
|
|
||||||
}
|
|
||||||
decimals={2}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
indent
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.camouflageShootingStill
|
|
||||||
}
|
|
||||||
decimals={2}
|
|
||||||
value={(stats) => stats.camouflageShootingStill * 100}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
indent
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.camouflageShootingMoving
|
|
||||||
}
|
|
||||||
decimals={2}
|
|
||||||
value={(stats) => stats.camouflageShootingMoving * 100}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
stats={stats}
|
|
||||||
indent
|
|
||||||
name={
|
|
||||||
strings.website.tools.tankopedia.characteristics.values
|
|
||||||
.camouflageCaughtOnFire
|
|
||||||
}
|
|
||||||
decimals={2}
|
|
||||||
value={(stats) => stats.camouflageCaughtOnFire * 100}
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
decimals={2}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
stats={stats}
|
|
||||||
value="width"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
decimals={2}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
stats={stats}
|
|
||||||
value="height"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
decimals={2}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
stats={stats}
|
|
||||||
value="length"
|
|
||||||
/>
|
|
||||||
<InfoWithDelta
|
|
||||||
decimals={2}
|
|
||||||
deltaType="lowerIsBetter"
|
|
||||||
stats={stats}
|
|
||||||
value="volume"
|
|
||||||
/>
|
|
||||||
</StatsTableWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-195
@@ -1,195 +0,0 @@
|
|||||||
import { literals } from "@blitzkit/i18n";
|
|
||||||
import { Checkbox, Code, Flex, Tabs, Text } from "@radix-ui/themes";
|
|
||||||
import { useEffect, useRef, useState } from "react";
|
|
||||||
import type { TankCharacteristics } from "../../../../../../../core/blitzkit/tankCharacteristics";
|
|
||||||
import { useLocale } from "../../../../../../../hooks/useLocale";
|
|
||||||
import { LazyImage } from "../../../../../../LazyImage";
|
|
||||||
import { VisualizerCard } from "../VisualizerCard";
|
|
||||||
|
|
||||||
export interface StatsAcceptorProps {
|
|
||||||
stats: TankCharacteristics;
|
|
||||||
}
|
|
||||||
|
|
||||||
type Terrain = "Hard" | "Medium" | "Soft";
|
|
||||||
|
|
||||||
export function TraverseVisualizer({ stats }: StatsAcceptorProps) {
|
|
||||||
const hull = useRef<HTMLDivElement>(null);
|
|
||||||
const turret = useRef<HTMLImageElement>(null);
|
|
||||||
const [terrain, setTerrain] = useState<Terrain>("Hard");
|
|
||||||
const [rotateHull, setRotateHull] = useState(true);
|
|
||||||
const [rotateTurret, setRotateTurret] = useState(true);
|
|
||||||
const { strings } = useLocale();
|
|
||||||
const isTurretless =
|
|
||||||
stats.azimuthLeft !== undefined || stats.azimuthRight !== undefined;
|
|
||||||
const turretAngle = useRef(0);
|
|
||||||
const hullAngle = useRef(0);
|
|
||||||
const turretSpeedDeg = rotateTurret ? stats.turretTraverseSpeed : 0;
|
|
||||||
const hullSpeedDeg = rotateHull ? stats[`hullTraverse${terrain}Terrain`] : 0;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let cancel = false;
|
|
||||||
const turretSpeedRad = turretSpeedDeg * (Math.PI / 180);
|
|
||||||
const hullTraverseRad = hullSpeedDeg * (Math.PI / 180);
|
|
||||||
let lastT = Date.now() / 1000;
|
|
||||||
|
|
||||||
function frame() {
|
|
||||||
const t = Date.now() / 1000;
|
|
||||||
const dt = t - lastT;
|
|
||||||
lastT = t;
|
|
||||||
|
|
||||||
if (turret.current) {
|
|
||||||
turretAngle.current =
|
|
||||||
(turretAngle.current + turretSpeedRad * dt) % (2 * Math.PI);
|
|
||||||
turret.current.style.transform = `translate(-50%, -50%) rotate(${-turretAngle.current}rad)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hull.current) {
|
|
||||||
hullAngle.current =
|
|
||||||
(hullAngle.current + hullTraverseRad * dt) % (2 * Math.PI);
|
|
||||||
hull.current.style.transform = `translate(-50%, -50%) rotate(${-hullAngle.current}rad)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cancel) requestAnimationFrame(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
frame();
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cancel = true;
|
|
||||||
};
|
|
||||||
}, [terrain, turretSpeedDeg, hullSpeedDeg]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<VisualizerCard>
|
|
||||||
<div
|
|
||||||
ref={hull}
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
animationDuration: `${
|
|
||||||
rotateHull ? 360 / stats[`hullTraverse${terrain}Terrain`] : 0
|
|
||||||
}s`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<LazyImage
|
|
||||||
draggable="false"
|
|
||||||
style={{
|
|
||||||
width: isTurretless ? "22rem" : "12rem",
|
|
||||||
height: isTurretless ? "22rem" : "12rem",
|
|
||||||
objectFit: "contain",
|
|
||||||
filter: "drop-shadow(0px 0px 4px black)",
|
|
||||||
}}
|
|
||||||
src={`/assets/images/tankopedia/visualizers/hull-traverse/hull${isTurretless ? "-only" : ""}.png`}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{!isTurretless && (
|
|
||||||
<LazyImage
|
|
||||||
draggable="false"
|
|
||||||
ref={turret}
|
|
||||||
style={{
|
|
||||||
width: "27rem",
|
|
||||||
height: "27rem",
|
|
||||||
objectFit: "contain",
|
|
||||||
position: "absolute",
|
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
filter: "drop-shadow(0px 0px 4px black)",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
animationDuration: `${
|
|
||||||
rotateTurret ? 360 / stats.turretTraverseSpeed : 0
|
|
||||||
}s`,
|
|
||||||
}}
|
|
||||||
src="/assets/images/tankopedia/visualizers/hull-traverse/turret.png"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
position="absolute"
|
|
||||||
bottom="0"
|
|
||||||
left="50%"
|
|
||||||
style={{
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Tabs.Root
|
|
||||||
value={terrain}
|
|
||||||
onValueChange={(terrain) => setTerrain(terrain as Terrain)}
|
|
||||||
>
|
|
||||||
<Tabs.List>
|
|
||||||
<Tabs.Trigger value="Hard">
|
|
||||||
{strings.website.tools.tankopedia.visualizers.rotator.hard}
|
|
||||||
</Tabs.Trigger>
|
|
||||||
<Tabs.Trigger value="Medium">
|
|
||||||
{strings.website.tools.tankopedia.visualizers.rotator.medium}
|
|
||||||
</Tabs.Trigger>
|
|
||||||
<Tabs.Trigger value="Soft">
|
|
||||||
{strings.website.tools.tankopedia.visualizers.rotator.soft}
|
|
||||||
</Tabs.Trigger>
|
|
||||||
</Tabs.List>
|
|
||||||
</Tabs.Root>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
gap="2"
|
|
||||||
position="absolute"
|
|
||||||
left="50%"
|
|
||||||
bottom="7"
|
|
||||||
style={{
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text color="gray" size="1">
|
|
||||||
{strings.website.tools.tankopedia.visualizers.rotator.effective}
|
|
||||||
</Text>
|
|
||||||
<Code size="1" variant="ghost">
|
|
||||||
{literals(strings.common.units.deg_s, {
|
|
||||||
value: (turretSpeedDeg + hullSpeedDeg).toFixed(1),
|
|
||||||
})}
|
|
||||||
</Code>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
{!isTurretless && (
|
|
||||||
<Flex
|
|
||||||
position="absolute"
|
|
||||||
top="4"
|
|
||||||
left="50%"
|
|
||||||
width="100%"
|
|
||||||
px="5"
|
|
||||||
gap="5"
|
|
||||||
justify="center"
|
|
||||||
style={{
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
userSelect: "none",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Flex
|
|
||||||
align="center"
|
|
||||||
gap="2"
|
|
||||||
onClick={() => setRotateHull((state) => !state)}
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
>
|
|
||||||
<Checkbox variant="classic" checked={rotateHull} />
|
|
||||||
<Text size="2">
|
|
||||||
{strings.website.tools.tankopedia.visualizers.rotator.hull}
|
|
||||||
</Text>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
align="center"
|
|
||||||
gap="2"
|
|
||||||
onClick={() => setRotateTurret((state) => !state)}
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
>
|
|
||||||
<Checkbox variant="classic" checked={rotateTurret} />
|
|
||||||
<Text size="2">
|
|
||||||
{strings.website.tools.tankopedia.visualizers.rotator.turret}
|
|
||||||
</Text>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
</VisualizerCard>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-161
@@ -1,161 +0,0 @@
|
|||||||
import { literals } from "@blitzkit/i18n";
|
|
||||||
import { EyeOpenIcon } from "@radix-ui/react-icons";
|
|
||||||
import { Box, Card, Code, Flex, Slider, Tabs, Text } from "@radix-ui/themes";
|
|
||||||
import { useRef, useState } from "react";
|
|
||||||
import { Var } from "../../../../../../core/radix/var";
|
|
||||||
import { useLocale } from "../../../../../../hooks/useLocale";
|
|
||||||
import type { StatsAcceptorProps } from "./TraverseVisualizer";
|
|
||||||
|
|
||||||
const maps = [
|
|
||||||
{
|
|
||||||
id: "ghost-factory",
|
|
||||||
string: "ghost_factory",
|
|
||||||
size: 512,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "dead-rail",
|
|
||||||
string: "dead_rail",
|
|
||||||
size: 512,
|
|
||||||
},
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export function ViewRangeVisualizer({ stats }: StatsAcceptorProps) {
|
|
||||||
const [mapIndex, setMapIndex] = useState(0);
|
|
||||||
const [camouflage, setCamouflage] = useState(0);
|
|
||||||
const map = maps[mapIndex];
|
|
||||||
const resolvedViewRange = stats.viewRange * (1 - camouflage);
|
|
||||||
const fraction = resolvedViewRange / map.size;
|
|
||||||
const fractionPercentage = `${fraction * 100}%`;
|
|
||||||
const { strings } = useLocale();
|
|
||||||
const container = useRef<HTMLDivElement>(null);
|
|
||||||
const range = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
style={{ aspectRatio: "1 / 1", touchAction: "none" }}
|
|
||||||
mb="6"
|
|
||||||
variant="classic"
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
ref={container}
|
|
||||||
onPointerMove={(event) => {
|
|
||||||
if (!container.current || !range.current) return;
|
|
||||||
|
|
||||||
const rect = container.current.getBoundingClientRect();
|
|
||||||
range.current.style.left = `${event.clientX - rect.left}px`;
|
|
||||||
range.current.style.top = `${event.clientY - rect.top - 16}px`;
|
|
||||||
}}
|
|
||||||
flexGrow="1"
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
style={{
|
|
||||||
backgroundImage: `url(/assets/images/tankopedia/visualizers/range/${map.id}.png)`,
|
|
||||||
filter: `grayscale(0.5) brightness(0.8) contrast(1.2)`,
|
|
||||||
backgroundSize: "cover",
|
|
||||||
backgroundPosition: "center",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
ref={range}
|
|
||||||
position="absolute"
|
|
||||||
top="50%"
|
|
||||||
left="50%"
|
|
||||||
width={fractionPercentage}
|
|
||||||
align="center"
|
|
||||||
justify="center"
|
|
||||||
style={{
|
|
||||||
aspectRatio: "1 / 1",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
background: `radial-gradient(${Var("black-a6")}, ${Var("gray-a12")})`,
|
|
||||||
borderRadius: "50%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={{ userSelect: "none" }}>
|
|
||||||
<Flex align="center" gap="1">
|
|
||||||
<EyeOpenIcon width="1.25rem" height="1.25rem" />
|
|
||||||
{literals(strings.common.units.m, {
|
|
||||||
value: resolvedViewRange.toFixed(0),
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
</Text>
|
|
||||||
</Flex>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
position="absolute"
|
|
||||||
top="0"
|
|
||||||
left="0"
|
|
||||||
width="100%"
|
|
||||||
py="2"
|
|
||||||
px="3"
|
|
||||||
gap="3"
|
|
||||||
align="center"
|
|
||||||
style={{
|
|
||||||
backgroundColor: Var("black-a7"),
|
|
||||||
backdropFilter: "blur(4rem)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text size="2">
|
|
||||||
{strings.website.tools.tankopedia.visualizers.view_range.camo}
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Slider
|
|
||||||
size="1"
|
|
||||||
variant="classic"
|
|
||||||
value={[camouflage]}
|
|
||||||
min={0}
|
|
||||||
max={0.5}
|
|
||||||
step={Number.EPSILON}
|
|
||||||
onValueChange={([value]) => setCamouflage(value)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Code size="1" color="gray" variant="ghost">
|
|
||||||
<Flex justify="center" width="2em">
|
|
||||||
{literals(strings.common.units.percentage, {
|
|
||||||
value: `${Math.round(camouflage * 100)}`.padStart(3, " "),
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
</Code>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
justify="center"
|
|
||||||
position="absolute"
|
|
||||||
bottom="0"
|
|
||||||
left="0"
|
|
||||||
width="100%"
|
|
||||||
style={{
|
|
||||||
background: `radial-gradient(at 50% 100%, ${Var("gray-1")}, transparent 70%)`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Tabs.Root
|
|
||||||
value={`${mapIndex}`}
|
|
||||||
onValueChange={(index) => setMapIndex(Number(index))}
|
|
||||||
>
|
|
||||||
<Tabs.List>
|
|
||||||
{maps.map((map) => (
|
|
||||||
<Tabs.Trigger key={map.id} value={`${maps.indexOf(map)}`}>
|
|
||||||
{
|
|
||||||
strings.website.tools.tankopedia.visualizers.view_range[
|
|
||||||
map.string
|
|
||||||
]
|
|
||||||
}
|
|
||||||
</Tabs.Trigger>
|
|
||||||
))}
|
|
||||||
</Tabs.List>
|
|
||||||
</Tabs.Root>
|
|
||||||
</Flex>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Loaded 100 of 150 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user