mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b00a63a9f8 | ||
|
|
8ec7fcb90a | ||
|
|
830e1597e7 | ||
|
|
3131217600 | ||
|
|
0b740e3f60 | ||
|
|
1416d64e34 |
No files matched your search
@@ -0,0 +1,11 @@
|
|||||||
|
import { SkillDefinitions } from "@blitzkit/protos";
|
||||||
|
import { createDefaultSkills } from "./createDefaultSkills";
|
||||||
|
import { TankEnvironment } from "./tankEnvironment";
|
||||||
|
|
||||||
|
export function createDefaultEnvironment(skills: SkillDefinitions) {
|
||||||
|
return {
|
||||||
|
equalize: false,
|
||||||
|
distance: 0,
|
||||||
|
skills: createDefaultSkills(skills),
|
||||||
|
} satisfies TankEnvironment;
|
||||||
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
import { SkillDefinitions } from "..";
|
import { SkillDefinitions } from "@blitzkit/protos";
|
||||||
import { permanentSkills } from "../blitz/permanentSkills";
|
import { permanentSkills } from "../blitz/permanentSkills";
|
||||||
|
import { MAX_SKILL_LEVEL } from "../config/skills";
|
||||||
|
|
||||||
export function createDefaultSkills(skillDefinitions: SkillDefinitions) {
|
export function createDefaultSkills(skillDefinitions: SkillDefinitions) {
|
||||||
const skills: Record<string, number> = {};
|
const skills: Record<string, number> = {};
|
||||||
|
|
||||||
Object.values(skillDefinitions.classes).forEach((tankSkills) => {
|
Object.values(skillDefinitions.classes).forEach((tankSkills) => {
|
||||||
tankSkills.skills.forEach((skill) => {
|
tankSkills.skills.forEach((skill) => {
|
||||||
skills[skill] = permanentSkills.includes(skill) ? 7 : 0;
|
skills[skill] = permanentSkills.includes(skill) ? MAX_SKILL_LEVEL : 0;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export * from "./api";
|
|||||||
export * from "./assertSecret";
|
export * from "./assertSecret";
|
||||||
export * from "./availableProvisions";
|
export * from "./availableProvisions";
|
||||||
export * from "./coefficient";
|
export * from "./coefficient";
|
||||||
|
export * from "./createDefaultEnvironment";
|
||||||
export * from "./createDefaultProvisions";
|
export * from "./createDefaultProvisions";
|
||||||
export * from "./createDefaultSkills";
|
export * from "./createDefaultSkills";
|
||||||
export * from "./degressiveStat";
|
export * from "./degressiveStat";
|
||||||
@@ -24,6 +25,7 @@ export * from "./sluggify";
|
|||||||
export * from "./staticAsset";
|
export * from "./staticAsset";
|
||||||
export * from "./sum";
|
export * from "./sum";
|
||||||
export * from "./tankDefinitions";
|
export * from "./tankDefinitions";
|
||||||
|
export * from "./tankEnvironment";
|
||||||
export * from "./tankIcon";
|
export * from "./tankIcon";
|
||||||
export * from "./tankNames";
|
export * from "./tankNames";
|
||||||
export * from "./unionBoundingBox";
|
export * from "./unionBoundingBox";
|
||||||
|
|||||||
@@ -43,19 +43,6 @@ export const TANK_ICONS_COLLECTOR: Record<TankClass, string> = {
|
|||||||
[TankClass.TANK_CLASS_HEAVY]: "https://i.imgur.com/8xRf3nc.png",
|
[TankClass.TANK_CLASS_HEAVY]: "https://i.imgur.com/8xRf3nc.png",
|
||||||
};
|
};
|
||||||
export const TIERS = times(10, (index) => index + 1);
|
export const TIERS = times(10, (index) => index + 1);
|
||||||
export const TIER_ROMAN_NUMERALS: Record<number, string> = {
|
|
||||||
1: "I",
|
|
||||||
2: "II",
|
|
||||||
3: "III",
|
|
||||||
4: "IV",
|
|
||||||
5: "V",
|
|
||||||
6: "VI",
|
|
||||||
7: "VII",
|
|
||||||
8: "VIII",
|
|
||||||
9: "IX",
|
|
||||||
10: "X",
|
|
||||||
11: "XI",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const flags: Record<string, string> = {
|
export const flags: Record<string, string> = {
|
||||||
ussr: "<:ussr:1218421042033197197>",
|
ussr: "<:ussr:1218421042033197197>",
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export interface TankEnvironment {
|
||||||
|
equalize: boolean;
|
||||||
|
distance: number;
|
||||||
|
skills: Record<string, number>;
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
export * from "./gunTypeOrder";
|
export * from "./gunTypeOrder";
|
||||||
|
export * from "./skills";
|
||||||
export * from "./tankClassOrder";
|
export * from "./tankClassOrder";
|
||||||
export * from "./treeTypeOrder";
|
export * from "./treeTypeOrder";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export const MAX_SKILL_LEVEL = 7;
|
||||||
@@ -143,6 +143,9 @@
|
|||||||
"modules": "Modules",
|
"modules": "Modules",
|
||||||
"equipment": "Equipment",
|
"equipment": "Equipment",
|
||||||
"shells": "Shells",
|
"shells": "Shells",
|
||||||
|
"clear": "Clear",
|
||||||
|
"maximize": "Maximize",
|
||||||
|
"skills": "Crew skills",
|
||||||
"alternative": "Alt"
|
"alternative": "Alt"
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -481,53 +484,15 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"sort": {
|
"sort": {
|
||||||
"meta.none": "none",
|
|
||||||
"survivability.health": "health",
|
|
||||||
"survivability.viewRange": "view range",
|
|
||||||
"survivability.camouflageStill": "camouflage still",
|
|
||||||
"survivability.camouflageMoving": "camouflage moving",
|
|
||||||
"survivability.camouflageShooting": "camouflage shooting",
|
|
||||||
"survivability.volume": "volume",
|
|
||||||
"survivability.length": "length",
|
|
||||||
"fire.dpm": "standard DPM",
|
|
||||||
"fire.dpmPremium": "premium DPM",
|
|
||||||
"fire.reload": "reload",
|
|
||||||
"fire.caliber": "caliber",
|
|
||||||
"fire.standardPenetration": "standard penetration",
|
|
||||||
"fire.premiumPenetration": "premium penetration",
|
|
||||||
"fire.tertiaryPenetration": "tertiary penetration",
|
|
||||||
"fire.damage": "damage",
|
|
||||||
"fire.moduleDamage": "module damage",
|
|
||||||
"fire.shellVelocity": "shell velocity",
|
|
||||||
"fire.shellRange": "shell range",
|
|
||||||
"fire.shellCapacity": "shell capacity",
|
|
||||||
"fire.aimTime": "aim time",
|
|
||||||
"fire.dispersionStill": "dispersion still",
|
|
||||||
"fire.dispersionMoving": "dispersion moving",
|
|
||||||
"fire.gunDepression": "gun depression",
|
|
||||||
"fire.gunElevation": "gun elevation",
|
|
||||||
"maneuverability.forwardsSpeed": "forwards speed",
|
|
||||||
"maneuverability.backwardsSpeed": "backwards speed",
|
|
||||||
"maneuverability.power": "power",
|
|
||||||
"maneuverability.powerToWeight": "power to weight",
|
|
||||||
"maneuverability.weight": "weight",
|
|
||||||
"maneuverability.traverseSpeed": "traverse speed"
|
|
||||||
},
|
|
||||||
"sort_dropdown": {
|
|
||||||
"label": "Sort",
|
"label": "Sort",
|
||||||
"groups": {
|
|
||||||
"sort": {
|
"none": "None",
|
||||||
"no_sort": "No sort",
|
"by": "Sort by",
|
||||||
"label": "Sort by",
|
|
||||||
"fire": "Fire",
|
"direction": {
|
||||||
"maneuverability": "Maneuverability",
|
"label": "Direction",
|
||||||
"survivability": "Survivability"
|
"ascending": "Ascending",
|
||||||
},
|
"descending": "Descending"
|
||||||
"direction": {
|
|
||||||
"label": "Direction",
|
|
||||||
"ascending": "Ascending",
|
|
||||||
"descending": "Descending"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { alias, availableProvisions, permanentSkills } from "@blitzkit/core";
|
import {
|
||||||
|
alias,
|
||||||
|
availableProvisions,
|
||||||
|
MAX_SKILL_LEVEL,
|
||||||
|
permanentSkills,
|
||||||
|
} from "@blitzkit/core";
|
||||||
import { checkConsumableProvisionInclusivity } from "@blitzkit/core/src/blitzkit/checkConsumableProvisionInclusivity";
|
import { checkConsumableProvisionInclusivity } from "@blitzkit/core/src/blitzkit/checkConsumableProvisionInclusivity";
|
||||||
import { ComponentPlaceholderIcon } from "@radix-ui/react-icons";
|
import { ComponentPlaceholderIcon } from "@radix-ui/react-icons";
|
||||||
import {
|
import {
|
||||||
@@ -153,7 +158,7 @@ export function CompareTable({ stats }: CompareTableProps) {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
CompareEphemeral.mutate((draft) => {
|
CompareEphemeral.mutate((draft) => {
|
||||||
Object.keys(draft.crewSkills).forEach((skill) => {
|
Object.keys(draft.crewSkills).forEach((skill) => {
|
||||||
draft.crewSkills[skill] = 7;
|
draft.crewSkills[skill] = MAX_SKILL_LEVEL;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { alias, permanentSkills, romanize } from "@blitzkit/core";
|
import {
|
||||||
|
alias,
|
||||||
|
MAX_SKILL_LEVEL,
|
||||||
|
permanentSkills,
|
||||||
|
romanize,
|
||||||
|
} from "@blitzkit/core";
|
||||||
import { Flex } from "@radix-ui/themes";
|
import { Flex } from "@radix-ui/themes";
|
||||||
import { api } from "../api/dynamic";
|
import { api } from "../api/dynamic";
|
||||||
import { GenericTankComponentButton } from "./ModuleButtons/GenericTankComponentButton";
|
import { GenericTankComponentButton } from "./ModuleButtons/GenericTankComponentButton";
|
||||||
@@ -34,10 +39,10 @@ export function CrewSkillManager({
|
|||||||
const draft = { ...skillLevels };
|
const draft = { ...skillLevels };
|
||||||
|
|
||||||
if (event.shiftKey) {
|
if (event.shiftKey) {
|
||||||
draft[skill] = draft[skill] === 0 ? 7 : 0;
|
draft[skill] = draft[skill] === 0 ? MAX_SKILL_LEVEL : 0;
|
||||||
} else {
|
} else {
|
||||||
draft[skill] = level - 1;
|
draft[skill] = level - 1;
|
||||||
if (draft[skill] < 0) draft[skill] = 7;
|
if (draft[skill] < 0) draft[skill] = MAX_SKILL_LEVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(draft);
|
onChange(draft);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { alias, SEARCH_KEYS, TIER_ROMAN_NUMERALS } from "@blitzkit/core";
|
import { alias, romanize, SEARCH_KEYS } from "@blitzkit/core";
|
||||||
import { literals } from "@blitzkit/i18n";
|
import { literals } from "@blitzkit/i18n";
|
||||||
import { TankDefinition } from "@blitzkit/protos";
|
import { TankDefinition } from "@blitzkit/protos";
|
||||||
import {
|
import {
|
||||||
@@ -163,7 +163,7 @@ export function Guesser() {
|
|||||||
justify="center"
|
justify="center"
|
||||||
>
|
>
|
||||||
<Icon width="1em" height="1em" />
|
<Icon width="1em" height="1em" />
|
||||||
{TIER_ROMAN_NUMERALS[result.tier]}
|
{romanize(result.tier)}
|
||||||
</Flex>
|
</Flex>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -215,7 +215,7 @@ export function Guesser() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{literals(strings.website.tools.guess.tier, {
|
{literals(strings.website.tools.guess.tier, {
|
||||||
tier: TIER_ROMAN_NUMERALS[tier],
|
tier: romanize(tier),
|
||||||
})}
|
})}
|
||||||
</DropdownMenu.CheckboxItem>
|
</DropdownMenu.CheckboxItem>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { TIER_ROMAN_NUMERALS } from "@blitzkit/core";
|
import { romanize } from "@blitzkit/core";
|
||||||
import type {
|
import type {
|
||||||
EngineDefinition,
|
EngineDefinition,
|
||||||
GunDefinition,
|
GunDefinition,
|
||||||
@@ -42,7 +42,7 @@ export function ModuleManager({
|
|||||||
<Flex gap="1" wrap="wrap">
|
<Flex gap="1" wrap="wrap">
|
||||||
<ModuleButton
|
<ModuleButton
|
||||||
module="turret"
|
module="turret"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[modules.turret.tier]}
|
discriminator={romanize(modules.turret.tier)}
|
||||||
onClick={() => setTurretMenuOpen(true)}
|
onClick={() => setTurretMenuOpen(true)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ export function ModuleManager({
|
|||||||
<ModuleButton
|
<ModuleButton
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
module="turret"
|
module="turret"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[turret.tier]}
|
discriminator={romanize(turret.tier)}
|
||||||
/>{" "}
|
/>{" "}
|
||||||
{unwrap(turret.name!)}
|
{unwrap(turret.name!)}
|
||||||
</DropdownMenu.RadioItem>
|
</DropdownMenu.RadioItem>
|
||||||
@@ -83,7 +83,7 @@ export function ModuleManager({
|
|||||||
|
|
||||||
<ModuleButton
|
<ModuleButton
|
||||||
module="gun"
|
module="gun"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[modules.gun.tier]}
|
discriminator={romanize(modules.gun.tier)}
|
||||||
onClick={() => setGunMenuOpen(true)}
|
onClick={() => setGunMenuOpen(true)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ export function ModuleManager({
|
|||||||
<ModuleButton
|
<ModuleButton
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
module="gun"
|
module="gun"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[gun.tier]}
|
discriminator={romanize(gun.tier)}
|
||||||
/>{" "}
|
/>{" "}
|
||||||
{unwrap(gun.name!)}
|
{unwrap(gun.name!)}
|
||||||
</DropdownMenu.RadioItem>
|
</DropdownMenu.RadioItem>
|
||||||
@@ -123,7 +123,7 @@ export function ModuleManager({
|
|||||||
|
|
||||||
<ModuleButton
|
<ModuleButton
|
||||||
module="engine"
|
module="engine"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[modules.engine.tier]}
|
discriminator={romanize(modules.engine.tier)}
|
||||||
onClick={() => setEngineMenuOpen(true)}
|
onClick={() => setEngineMenuOpen(true)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ export function ModuleManager({
|
|||||||
<ModuleButton
|
<ModuleButton
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
module="engine"
|
module="engine"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[engine.tier]}
|
discriminator={romanize(engine.tier)}
|
||||||
/>{" "}
|
/>{" "}
|
||||||
{unwrap(engine.name!)}
|
{unwrap(engine.name!)}
|
||||||
</DropdownMenu.RadioItem>
|
</DropdownMenu.RadioItem>
|
||||||
@@ -162,7 +162,7 @@ export function ModuleManager({
|
|||||||
|
|
||||||
<ModuleButton
|
<ModuleButton
|
||||||
module="chassis"
|
module="chassis"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[modules.track.tier]}
|
discriminator={romanize(modules.track.tier)}
|
||||||
onClick={() => setTrackMenuOpen(true)}
|
onClick={() => setTrackMenuOpen(true)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ export function ModuleManager({
|
|||||||
<ModuleButton
|
<ModuleButton
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
module="chassis"
|
module="chassis"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[track.tier]}
|
discriminator={romanize(track.tier)}
|
||||||
/>{" "}
|
/>{" "}
|
||||||
{unwrap(track.name!)}
|
{unwrap(track.name!)}
|
||||||
</DropdownMenu.RadioItem>
|
</DropdownMenu.RadioItem>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export function RecentlyViewedTanks() {
|
|||||||
const strings = useStrings();
|
const strings = useStrings();
|
||||||
const by = TankSort.use((state) => state.by);
|
const by = TankSort.use((state) => state.by);
|
||||||
|
|
||||||
if (recentlyViewed.length === 0 || by !== "meta.none" || hasFilters) {
|
if (recentlyViewed.length === 0 || by !== null || hasFilters) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
.scroller {
|
||||||
|
--scroller-curtain-color: var(--gray-1);
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-3);
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.content {
|
||||||
|
overflow: auto;
|
||||||
|
|
||||||
|
padding-bottom: var(--space-4);
|
||||||
|
|
||||||
|
transition: scrollbar-color var(--duration-brief);
|
||||||
|
scrollbar-color: transparent transparent;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
scrollbar-color: var(--gray-7) var(--gray-3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus-within {
|
||||||
|
.bar-wrapper {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-orientation="horizontal"] {
|
||||||
|
.curtain {
|
||||||
|
width: min(25%, var(--space-7));
|
||||||
|
height: calc(100% - var(--space-3) - 2 * var(--space-1));
|
||||||
|
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
&[data-side="start"] {
|
||||||
|
left: 0;
|
||||||
|
background: linear-gradient(
|
||||||
|
90deg,
|
||||||
|
var(--scroller-curtain-color),
|
||||||
|
transparent
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-side="end"] {
|
||||||
|
right: 0;
|
||||||
|
background: linear-gradient(
|
||||||
|
90deg,
|
||||||
|
transparent,
|
||||||
|
var(--scroller-curtain-color)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-orientation="vertical"] {
|
||||||
|
min-height: 0;
|
||||||
|
|
||||||
|
.content {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.curtain {
|
||||||
|
width: calc(100% - var(--space-3) - 2 * var(--space-1));
|
||||||
|
height: min(25%, var(--space-7));
|
||||||
|
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
&[data-side="start"] {
|
||||||
|
top: 0;
|
||||||
|
background: linear-gradient(
|
||||||
|
180deg,
|
||||||
|
var(--scroller-curtain-color),
|
||||||
|
transparent
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-side="end"] {
|
||||||
|
bottom: 0;
|
||||||
|
background: linear-gradient(
|
||||||
|
180deg,
|
||||||
|
transparent,
|
||||||
|
var(--scroller-curtain-color)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.curtain {
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import { useEffect, useRef, type ComponentProps } from "react";
|
||||||
|
import { clamp } from "three/src/math/MathUtils.js";
|
||||||
|
import { classNames } from "../../ui/classNames";
|
||||||
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
|
interface ScrollerProps extends ComponentProps<"div"> {
|
||||||
|
orientation?: "horizontal" | "vertical";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Scroller({
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
orientation = "horizontal",
|
||||||
|
...props
|
||||||
|
}: ScrollerProps) {
|
||||||
|
const content = useRef<HTMLDivElement>(null!);
|
||||||
|
const curtainStart = useRef<HTMLDivElement>(null!);
|
||||||
|
const curtainEnd = useRef<HTMLDivElement>(null!);
|
||||||
|
|
||||||
|
const isHorizontal = orientation === "horizontal";
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function syncCurtains() {
|
||||||
|
const maxScroll = isHorizontal
|
||||||
|
? content.current.scrollWidth - content.current.clientWidth
|
||||||
|
: content.current.scrollHeight - content.current.clientHeight;
|
||||||
|
const scrollPosition = isHorizontal
|
||||||
|
? content.current.scrollLeft
|
||||||
|
: content.current.scrollTop;
|
||||||
|
|
||||||
|
if (maxScroll <= 0) {
|
||||||
|
curtainStart.current.style.opacity = "0";
|
||||||
|
curtainEnd.current.style.opacity = "0";
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dimension = isHorizontal
|
||||||
|
? content.current.clientWidth
|
||||||
|
: content.current.clientHeight;
|
||||||
|
const fadeDistance = Math.min(60, dimension * 0.15);
|
||||||
|
const startOpacity = clamp(scrollPosition / fadeDistance, 0, 1);
|
||||||
|
const endOpacity = clamp(
|
||||||
|
(maxScroll - scrollPosition) / fadeDistance,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
|
||||||
|
curtainStart.current.style.opacity = `${startOpacity}`;
|
||||||
|
curtainEnd.current.style.opacity = `${endOpacity}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
syncCurtains();
|
||||||
|
|
||||||
|
window.addEventListener("resize", syncCurtains);
|
||||||
|
content.current.addEventListener("scroll", syncCurtains);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("resize", syncCurtains);
|
||||||
|
content.current.removeEventListener("scroll", syncCurtains);
|
||||||
|
};
|
||||||
|
}, [orientation]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={classNames(styles.scroller, className)}
|
||||||
|
{...props}
|
||||||
|
data-orientation={orientation}
|
||||||
|
>
|
||||||
|
<div className={styles.content} ref={content}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ref={curtainStart} data-side="start" className={styles.curtain} />
|
||||||
|
<div ref={curtainEnd} data-side="end" className={styles.curtain} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
.section {
|
.section {
|
||||||
|
padding: var(--space-5);
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
|
|||||||
@@ -40,4 +40,10 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.discriminator {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: var(--space-2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ export const TankCard = (props: MaybeSkeletonComponentProps<TankCardProps>) => {
|
|||||||
|
|
||||||
{props.discriminator && (
|
{props.discriminator && (
|
||||||
<Text lowContrast align="center">
|
<Text lowContrast align="center">
|
||||||
{props.discriminator}
|
<div className={styles.discriminator}>{props.discriminator}</div>
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@@ -1,145 +0,0 @@
|
|||||||
import {
|
|
||||||
normalizeBoundingBox,
|
|
||||||
resolveDpm,
|
|
||||||
unionBoundingBox,
|
|
||||||
} from "@blitzkit/core";
|
|
||||||
import type { TankDefinition } from "@blitzkit/protos";
|
|
||||||
import { useMemo } from "react";
|
|
||||||
import { api } from "../../../api/dynamic";
|
|
||||||
import { resolveReload } from "../../../core/blitzkit/resolveReload";
|
|
||||||
import { TankSort } from "../../../stores/tankopediaSort";
|
|
||||||
import { TankCard } from "../../TankCard";
|
|
||||||
|
|
||||||
interface TankSearchCardProps {
|
|
||||||
tank: TankDefinition;
|
|
||||||
onSelect?: (tank: TankDefinition) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const modelDefinitions = await api.models();
|
|
||||||
|
|
||||||
export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) {
|
|
||||||
const by = TankSort.use((state) => state.by);
|
|
||||||
const discriminator = useMemo(() => {
|
|
||||||
if (by.startsWith("meta")) return undefined;
|
|
||||||
|
|
||||||
const turret = tank.turrets.at(-1)!;
|
|
||||||
const gun = turret.guns.at(-1)!;
|
|
||||||
const shell0 = gun.shells[0];
|
|
||||||
const shell1 = gun.shells[1];
|
|
||||||
const shell2 = gun.shells[2];
|
|
||||||
const tracks = tank.tracks.at(-1)!;
|
|
||||||
const engine = tank.engines.at(-1)!;
|
|
||||||
const tankModelDefinition = modelDefinitions.models[tank.id];
|
|
||||||
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
|
||||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
|
||||||
|
|
||||||
switch (by) {
|
|
||||||
case "fire.aimTime":
|
|
||||||
return gun.aim_time.toFixed(2);
|
|
||||||
case "fire.caliber":
|
|
||||||
return shell0.caliber.toFixed(0);
|
|
||||||
case "fire.damage":
|
|
||||||
return shell0.armor_damage.toFixed(0);
|
|
||||||
case "fire.moduleDamage":
|
|
||||||
return shell0.module_damage.toFixed(0);
|
|
||||||
case "fire.dispersionMoving":
|
|
||||||
return tracks.dispersion_move.toFixed(3);
|
|
||||||
case "fire.dispersionStill":
|
|
||||||
return gun.dispersion_base.toFixed(3);
|
|
||||||
case "fire.dpm":
|
|
||||||
return resolveDpm(gun, shell0).toFixed(0);
|
|
||||||
case "fire.dpmPremium":
|
|
||||||
return shell1 ? resolveDpm(gun, shell1).toFixed(0) : "--";
|
|
||||||
case "fire.reload":
|
|
||||||
return resolveReload(gun).toFixed(2);
|
|
||||||
case "fire.standardPenetration":
|
|
||||||
return shell0?.penetration!.near.toFixed(0);
|
|
||||||
case "fire.premiumPenetration":
|
|
||||||
return shell1 ? shell1?.penetration!.near.toFixed(0) : "--";
|
|
||||||
case "fire.tertiaryPenetration":
|
|
||||||
return shell1 ? shell2?.penetration!.near.toFixed(0) : "--";
|
|
||||||
case "fire.shellVelocity":
|
|
||||||
return shell0.velocity.toFixed(0);
|
|
||||||
case "fire.shellCapacity":
|
|
||||||
return gun.shell_capacity.toFixed(0);
|
|
||||||
case "fire.shellRange":
|
|
||||||
return shell0.range.toFixed(0);
|
|
||||||
case "fire.gunDepression":
|
|
||||||
return (
|
|
||||||
gunModelDefinition.pitch!.max +
|
|
||||||
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
|
||||||
).toFixed(1);
|
|
||||||
case "fire.gunElevation":
|
|
||||||
return (
|
|
||||||
-gunModelDefinition.pitch!.min -
|
|
||||||
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
|
||||||
).toFixed(1);
|
|
||||||
case "maneuverability.forwardsSpeed":
|
|
||||||
return tank.speed_forwards.toFixed(0);
|
|
||||||
case "maneuverability.backwardsSpeed":
|
|
||||||
return tank.speed_backwards.toFixed(0);
|
|
||||||
case "maneuverability.power":
|
|
||||||
return engine.power.toFixed(0);
|
|
||||||
case "maneuverability.powerToWeight":
|
|
||||||
return (
|
|
||||||
(1000 * engine.power) /
|
|
||||||
(tank.weight +
|
|
||||||
engine.weight +
|
|
||||||
tracks.weight +
|
|
||||||
turret.weight +
|
|
||||||
gun.weight)
|
|
||||||
).toFixed(1);
|
|
||||||
case "maneuverability.weight":
|
|
||||||
return (
|
|
||||||
(tank.weight +
|
|
||||||
engine.weight +
|
|
||||||
tracks.weight +
|
|
||||||
turret.weight +
|
|
||||||
gun.weight) /
|
|
||||||
1000
|
|
||||||
).toFixed(1);
|
|
||||||
case "maneuverability.traverseSpeed":
|
|
||||||
return tracks.traverse_speed.toFixed(1);
|
|
||||||
case "survivability.health":
|
|
||||||
return (tank.health + turret.health).toFixed(0);
|
|
||||||
case "survivability.viewRange":
|
|
||||||
return turret.view_range.toFixed(0);
|
|
||||||
case "survivability.camouflageStill":
|
|
||||||
return (tank.camouflage_still * 100).toFixed(0);
|
|
||||||
case "survivability.camouflageMoving":
|
|
||||||
return (tank.camouflage_moving * 100).toFixed(0);
|
|
||||||
case "survivability.camouflageShooting":
|
|
||||||
return (tank.camouflage_still * gun.camouflage_loss * 100).toFixed(0);
|
|
||||||
case "survivability.volume": {
|
|
||||||
const dimensions = normalizeBoundingBox(
|
|
||||||
unionBoundingBox(
|
|
||||||
tankModelDefinition.bounding_box!,
|
|
||||||
turretModelDefinition.bounding_box!,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return (dimensions.x * dimensions.y * dimensions.z).toFixed(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
case "survivability.length": {
|
|
||||||
const bounds = normalizeBoundingBox(
|
|
||||||
unionBoundingBox(
|
|
||||||
tankModelDefinition.bounding_box!,
|
|
||||||
turretModelDefinition.bounding_box!,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return Math.max(bounds.x, bounds.y, bounds.z).toFixed(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [by]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TankCard
|
|
||||||
key={tank.id}
|
|
||||||
onTankSelect={onSelect}
|
|
||||||
tank={tank}
|
|
||||||
discriminator={discriminator}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,40 +1,37 @@
|
|||||||
import { CaretDownIcon } from "@radix-ui/react-icons";
|
import { CaretDownIcon } from "@radix-ui/react-icons";
|
||||||
|
import { characteristicsGroups } from "../../../config/characteristicsGroups";
|
||||||
import { useStrings } from "../../../hooks/useStrings";
|
import { useStrings } from "../../../hooks/useStrings";
|
||||||
import type {
|
import { TankopediaSortDirection } from "../../../stores/tankopediaPersistent";
|
||||||
TankopediaSortBy,
|
|
||||||
TankopediaSortDirection,
|
|
||||||
} from "../../../stores/tankopediaPersistent";
|
|
||||||
import { TankSort } from "../../../stores/tankopediaSort";
|
import { TankSort } from "../../../stores/tankopediaSort";
|
||||||
|
import { sortableCharacteristics } from "../../../tankopedia/sortableCharacteristics";
|
||||||
|
import type { CharacteristicName } from "../../../types/characteristics";
|
||||||
import { Button } from "../../Button";
|
import { Button } from "../../Button";
|
||||||
import { DropdownMenu } from "../../DropdownMenu";
|
import { DropdownMenu } from "../../DropdownMenu";
|
||||||
|
|
||||||
interface ItemProps {
|
interface ItemProps {
|
||||||
by: TankopediaSortBy;
|
by: CharacteristicName;
|
||||||
}
|
|
||||||
|
|
||||||
interface ItemProps {
|
|
||||||
by: TankopediaSortBy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Item({ by }: ItemProps) {
|
function Item({ by }: ItemProps) {
|
||||||
const strings = useStrings();
|
const strings = useStrings();
|
||||||
const _by = TankSort.use((state) => state.by);
|
const selectedBy = TankSort.use((state) => state.by);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu.CheckboxItem
|
<DropdownMenu.CheckboxItem
|
||||||
checked={_by === by}
|
checked={selectedBy === by}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
TankSort.mutate((draft) => {
|
TankSort.mutate((draft) => {
|
||||||
draft.by = by;
|
draft.by = by;
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{strings.website.common.tank_search.sort[by]}
|
{strings.tanks.characteristics.items[by]}
|
||||||
</DropdownMenu.CheckboxItem>
|
</DropdownMenu.CheckboxItem>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Sort() {
|
export function Sort() {
|
||||||
|
const by = TankSort.use((state) => state.by);
|
||||||
const direction = TankSort.use((state) => state.direction);
|
const direction = TankSort.use((state) => state.direction);
|
||||||
const strings = useStrings();
|
const strings = useStrings();
|
||||||
|
|
||||||
@@ -42,103 +39,79 @@ export function Sort() {
|
|||||||
<DropdownMenu.Root>
|
<DropdownMenu.Root>
|
||||||
<DropdownMenu.Trigger asChild>
|
<DropdownMenu.Trigger asChild>
|
||||||
<Button variant="surface" color="gray">
|
<Button variant="surface" color="gray">
|
||||||
{strings.website.common.tank_search.sort_dropdown.label}
|
{strings.website.common.tank_search.sort.label}
|
||||||
<CaretDownIcon />
|
<CaretDownIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenu.Trigger>
|
</DropdownMenu.Trigger>
|
||||||
|
|
||||||
<DropdownMenu.Content align="end">
|
<DropdownMenu.Content align="end">
|
||||||
<DropdownMenu.Label>
|
<DropdownMenu.Label>
|
||||||
{strings.website.common.tank_search.sort_dropdown.groups.sort.label}
|
{strings.website.common.tank_search.sort.direction.label}
|
||||||
</DropdownMenu.Label>
|
</DropdownMenu.Label>
|
||||||
|
|
||||||
<Item by="meta.none" />
|
<DropdownMenu.CheckboxItem
|
||||||
|
checked={by === null || !sortableCharacteristics.has(by)}
|
||||||
|
onClick={() => {
|
||||||
|
TankSort.mutate((draft) => {
|
||||||
|
draft.by = null;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{strings.website.common.tank_search.sort.none}
|
||||||
|
</DropdownMenu.CheckboxItem>
|
||||||
|
|
||||||
<DropdownMenu.Sub>
|
{characteristicsGroups.map((group) => {
|
||||||
<DropdownMenu.SubTrigger>
|
const items = group.order.filter(
|
||||||
{strings.website.common.tank_search.sort_dropdown.groups.sort.fire}
|
(item) => "name" in item && sortableCharacteristics.has(item.name),
|
||||||
</DropdownMenu.SubTrigger>
|
);
|
||||||
<DropdownMenu.SubContent>
|
|
||||||
<Item by="fire.dpm" />
|
|
||||||
<Item by="fire.dpmPremium" />
|
|
||||||
<Item by="fire.reload" />
|
|
||||||
<Item by="fire.caliber" />
|
|
||||||
<Item by="fire.standardPenetration" />
|
|
||||||
<Item by="fire.premiumPenetration" />
|
|
||||||
<Item by="fire.tertiaryPenetration" />
|
|
||||||
<Item by="fire.damage" />
|
|
||||||
<Item by="fire.moduleDamage" />
|
|
||||||
<Item by="fire.shellVelocity" />
|
|
||||||
<Item by="fire.shellRange" />
|
|
||||||
<Item by="fire.shellCapacity" />
|
|
||||||
<Item by="fire.aimTime" />
|
|
||||||
<Item by="fire.dispersionStill" />
|
|
||||||
<Item by="fire.dispersionMoving" />
|
|
||||||
<Item by="fire.gunDepression" />
|
|
||||||
<Item by="fire.gunElevation" />
|
|
||||||
</DropdownMenu.SubContent>
|
|
||||||
</DropdownMenu.Sub>
|
|
||||||
|
|
||||||
<DropdownMenu.Sub>
|
return (
|
||||||
<DropdownMenu.SubTrigger>
|
<DropdownMenu.Sub key={group.name}>
|
||||||
{
|
<DropdownMenu.SubTrigger>
|
||||||
strings.website.common.tank_search.sort_dropdown.groups.sort
|
{
|
||||||
.maneuverability
|
(
|
||||||
}
|
strings.tanks.characteristics.titles as Record<
|
||||||
</DropdownMenu.SubTrigger>
|
string,
|
||||||
<DropdownMenu.SubContent>
|
string
|
||||||
<Item by="maneuverability.forwardsSpeed" />
|
>
|
||||||
<Item by="maneuverability.backwardsSpeed" />
|
)[group.name]
|
||||||
<Item by="maneuverability.power" />
|
}
|
||||||
<Item by="maneuverability.powerToWeight" />
|
</DropdownMenu.SubTrigger>
|
||||||
<Item by="maneuverability.weight" />
|
|
||||||
<Item by="maneuverability.traverseSpeed" />
|
|
||||||
</DropdownMenu.SubContent>
|
|
||||||
</DropdownMenu.Sub>
|
|
||||||
|
|
||||||
<DropdownMenu.Sub>
|
<DropdownMenu.SubContent>
|
||||||
<DropdownMenu.SubTrigger>
|
{items.map((item) => {
|
||||||
{
|
if (!("name" in item)) return null;
|
||||||
strings.website.common.tank_search.sort_dropdown.groups.sort
|
|
||||||
.survivability
|
return <Item key={item.name} by={item.name} />;
|
||||||
}
|
})}
|
||||||
</DropdownMenu.SubTrigger>
|
</DropdownMenu.SubContent>
|
||||||
<DropdownMenu.SubContent>
|
</DropdownMenu.Sub>
|
||||||
<Item by="survivability.health" />
|
);
|
||||||
<Item by="survivability.viewRange" />
|
})}
|
||||||
<Item by="survivability.camouflageStill" />
|
|
||||||
<Item by="survivability.camouflageMoving" />
|
|
||||||
<Item by="survivability.camouflageShooting" />
|
|
||||||
<Item by="survivability.volume" />
|
|
||||||
<Item by="survivability.length" />
|
|
||||||
</DropdownMenu.SubContent>
|
|
||||||
</DropdownMenu.Sub>
|
|
||||||
|
|
||||||
<DropdownMenu.Label>
|
<DropdownMenu.Label>
|
||||||
{
|
{strings.website.common.tank_search.sort.direction.label}
|
||||||
strings.website.common.tank_search.sort_dropdown.groups.direction
|
|
||||||
.label
|
|
||||||
}
|
|
||||||
</DropdownMenu.Label>
|
</DropdownMenu.Label>
|
||||||
<DropdownMenu.RadioGroup
|
<DropdownMenu.RadioGroup
|
||||||
value={direction}
|
value={direction}
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
|
if (
|
||||||
|
value !== TankopediaSortDirection.Ascending &&
|
||||||
|
value !== TankopediaSortDirection.Descending
|
||||||
|
) {
|
||||||
|
throw new Error(`Unknown tankopedia sort direction: ${value}`);
|
||||||
|
}
|
||||||
|
|
||||||
TankSort.mutate((draft) => {
|
TankSort.mutate((draft) => {
|
||||||
draft.direction = value as TankopediaSortDirection;
|
draft.direction = value;
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DropdownMenu.RadioItem value="ascending">
|
<DropdownMenu.RadioItem value={TankopediaSortDirection.Ascending}>
|
||||||
{
|
{strings.website.common.tank_search.sort.direction.ascending}
|
||||||
strings.website.common.tank_search.sort_dropdown.groups.direction
|
|
||||||
.ascending
|
|
||||||
}
|
|
||||||
</DropdownMenu.RadioItem>
|
</DropdownMenu.RadioItem>
|
||||||
<DropdownMenu.RadioItem value="descending">
|
<DropdownMenu.RadioItem value={TankopediaSortDirection.Descending}>
|
||||||
{
|
{strings.website.common.tank_search.sort.direction.descending}
|
||||||
strings.website.common.tank_search.sort_dropdown.groups.direction
|
|
||||||
.descending
|
|
||||||
}
|
|
||||||
</DropdownMenu.RadioItem>
|
</DropdownMenu.RadioItem>
|
||||||
</DropdownMenu.RadioGroup>
|
</DropdownMenu.RadioGroup>
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { TIER_ROMAN_NUMERALS } from "@blitzkit/core";
|
import { romanize } from "@blitzkit/core";
|
||||||
import { Flex, IconButton, Text } from "@radix-ui/themes";
|
import { Flex, IconButton, Text } from "@radix-ui/themes";
|
||||||
import { memo } from "react";
|
import { memo } from "react";
|
||||||
import { awaitableTiers } from "../../../core/awaitables/tiers";
|
import { awaitableTiers } from "../../../core/awaitables/tiers";
|
||||||
@@ -12,7 +12,9 @@ export const TierFilter = memo(() => {
|
|||||||
const search = TankFilters.use((state) => state.search);
|
const search = TankFilters.use((state) => state.search);
|
||||||
const tiers = TankFilters.use((state) => state.tiers);
|
const tiers = TankFilters.use((state) => state.tiers);
|
||||||
|
|
||||||
if (by !== "meta.none" || search) return null;
|
if (by !== null || search) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex justify="center">
|
<Flex justify="center">
|
||||||
@@ -41,7 +43,7 @@ export const TierFilter = memo(() => {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text size="2">{TIER_ROMAN_NUMERALS[tier]}</Text>
|
<Text size="2">{romanize(tier)}</Text>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
import {
|
import { metaSortTank, SEARCH_KEYS } from "@blitzkit/core";
|
||||||
metaSortTank,
|
|
||||||
normalizeBoundingBox,
|
|
||||||
resolveDpm,
|
|
||||||
SEARCH_KEYS,
|
|
||||||
unionBoundingBox,
|
|
||||||
} from "@blitzkit/core";
|
|
||||||
import { literals } from "@blitzkit/i18n/src/literals";
|
import { literals } from "@blitzkit/i18n/src/literals";
|
||||||
import type { TankDefinition } from "@blitzkit/protos";
|
import type { TankDefinition } from "@blitzkit/protos";
|
||||||
import fuzzysort from "fuzzysort";
|
import fuzzysort from "fuzzysort";
|
||||||
@@ -12,16 +6,26 @@ import { uniq } from "lodash-es";
|
|||||||
import { memo, useMemo } from "react";
|
import { memo, useMemo } 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 { characteristics } from "../../config/characteristics";
|
||||||
|
import { characteristicRenderConfigs } from "../../config/characteristicsGroups";
|
||||||
import { awaitableTankNames } from "../../core/awaitables/tankNames";
|
import { awaitableTankNames } from "../../core/awaitables/tankNames";
|
||||||
import { filterTanks } from "../../core/blitzkit/filterTanks";
|
import { filterTanks } from "../../core/blitzkit/filterTanks";
|
||||||
import { resolveReload } from "../../core/blitzkit/resolveReload";
|
import { useCharacteristicRenderer } from "../../hooks/useCharacteristicRenderer";
|
||||||
|
import { computeDefaultCharacteristics } from "../../hooks/useCharacteristics";
|
||||||
import { useLocale } from "../../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
import { App } from "../../stores/app";
|
import { App } from "../../stores/app";
|
||||||
import { TankFilters } from "../../stores/tankFilters";
|
import { TankFilters } from "../../stores/tankFilters";
|
||||||
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
import {
|
||||||
import { SORT_UNITS } from "../../stores/tankopediaPersistent/constants";
|
TankopediaPersistent,
|
||||||
|
TankopediaSortDirection,
|
||||||
|
} from "../../stores/tankopediaPersistent";
|
||||||
import { TankSort } from "../../stores/tankopediaSort";
|
import { TankSort } from "../../stores/tankopediaSort";
|
||||||
|
import { sortableCharacteristics } from "../../tankopedia/sortableCharacteristics";
|
||||||
|
import {
|
||||||
|
CharacteristicType,
|
||||||
|
type ComputedCharacteristics,
|
||||||
|
} from "../../types/characteristics";
|
||||||
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
||||||
import { Callout } from "../Callout";
|
import { Callout } from "../Callout";
|
||||||
import { ExperimentIcon } from "../ExperimentIcon";
|
import { ExperimentIcon } from "../ExperimentIcon";
|
||||||
@@ -44,386 +48,170 @@ export type TankSearchProps = MaybeSkeletonComponentProps & {
|
|||||||
onSelectAll?: (tanks: TankDefinition[]) => void;
|
onSelectAll?: (tanks: TankDefinition[]) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const [gameDefinitions, modelDefinitions, tankDefinitions, tankNames] =
|
const [gameDefinitions, tankDefinitions, tankNames] = await Promise.all([
|
||||||
await Promise.all([
|
api.game(),
|
||||||
api.game(),
|
api.tanks(),
|
||||||
api.models(),
|
awaitableTankNames,
|
||||||
api.tanks(),
|
]);
|
||||||
awaitableTankNames,
|
const tankDefinitionsArray = Object.values(tankDefinitions.tanks);
|
||||||
]);
|
|
||||||
|
|
||||||
export const TankSearch = memo<TankSearchProps>(
|
export const TankSearch = memo<TankSearchProps>(
|
||||||
({ compact, onSelect, onSelectAll, skeleton }) => {
|
({ compact, onSelect, onSelectAll, skeleton }) => {
|
||||||
const strings = useStrings();
|
const strings = useStrings();
|
||||||
const locale = useLocale();
|
const locale = useLocale();
|
||||||
|
|
||||||
const wargaming = App.use((state) => state.logins.wargaming);
|
const wargaming = App.use((state) => state.logins.wargaming);
|
||||||
const awaitedTanksDefinitionsArray = Object.values(tankDefinitions.tanks);
|
|
||||||
const tankopediaSort = TankSort.use();
|
const tankopediaSort = TankSort.use();
|
||||||
const tankFilters = TankFilters.use();
|
const tankFilters = TankFilters.use();
|
||||||
|
|
||||||
|
const defaultCharacteristics = useMemo(() => {
|
||||||
|
const computed = new Map<number, ComputedCharacteristics>();
|
||||||
|
|
||||||
|
for (const tank of tankDefinitionsArray) {
|
||||||
|
computed.set(tank.id, computeDefaultCharacteristics(tank));
|
||||||
|
}
|
||||||
|
|
||||||
|
return computed;
|
||||||
|
}, []);
|
||||||
|
|
||||||
const filtered = usePromise(
|
const filtered = usePromise(
|
||||||
() => {
|
async () => {
|
||||||
if (tankFilters.search === null) {
|
let filtered = tankDefinitionsArray;
|
||||||
return filterTanks(
|
|
||||||
tankFilters,
|
console.log("A");
|
||||||
awaitedTanksDefinitionsArray,
|
|
||||||
wargaming?.id,
|
if (tankopediaSort.by !== null) {
|
||||||
);
|
console.log("B", filtered.length);
|
||||||
} else {
|
|
||||||
return Promise.resolve(
|
filtered = filtered.filter((tank) =>
|
||||||
fuzzysort
|
defaultCharacteristics.get(tank.id)!.has(tankopediaSort.by!),
|
||||||
.go(tankFilters.search, tankNames, { keys: SEARCH_KEYS })
|
|
||||||
.map((result) => tankDefinitions.tanks[result.obj.id]),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log("C", filtered.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tankFilters.search === null) {
|
||||||
|
filtered = await filterTanks(tankFilters, filtered, wargaming?.id);
|
||||||
|
} else {
|
||||||
|
filtered = fuzzysort
|
||||||
|
.go(tankFilters.search, tankNames, { keys: SEARCH_KEYS })
|
||||||
|
.map((result) => tankDefinitions.tanks[result.obj.id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filtered;
|
||||||
},
|
},
|
||||||
// react-promise-suspense has awful type annotations
|
// react-promise-suspense has awful type annotations
|
||||||
[tankFilters] as any,
|
[tankFilters, tankopediaSort.by] as any,
|
||||||
);
|
);
|
||||||
|
|
||||||
const sorted = useMemo(() => {
|
const sorted = useMemo(() => {
|
||||||
if (tankFilters.search === null) {
|
if (tankFilters.search !== null) return filtered;
|
||||||
let sorted: TankDefinition[];
|
|
||||||
|
|
||||||
switch (tankopediaSort.by) {
|
if (
|
||||||
case "meta.none":
|
tankopediaSort.by === null ||
|
||||||
sorted = metaSortTank(filtered, gameDefinitions);
|
!sortableCharacteristics.has(tankopediaSort.by)
|
||||||
break;
|
) {
|
||||||
|
const byMeta = metaSortTank([...filtered], gameDefinitions);
|
||||||
|
|
||||||
case "survivability.health": {
|
return tankopediaSort.direction === TankopediaSortDirection.Ascending
|
||||||
sorted = filtered.sort((a, b) => {
|
? byMeta
|
||||||
const aHealth = a.health + a.turrets.at(-1)!.health;
|
: byMeta.reverse();
|
||||||
const bHealth = b.health + b.turrets.at(-1)!.health;
|
}
|
||||||
|
|
||||||
|
const values = new Map<number, number | undefined>();
|
||||||
|
const by = tankopediaSort.by;
|
||||||
|
const characteristic = characteristics[by];
|
||||||
|
|
||||||
|
for (const tank of filtered) {
|
||||||
|
const computedCharacteristics = defaultCharacteristics.get(tank.id)!;
|
||||||
|
if (!computedCharacteristics.has(by)) {
|
||||||
|
values.set(tank.id, undefined);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = computedCharacteristics.get(by);
|
||||||
|
|
||||||
|
let sortValue: number | undefined;
|
||||||
|
|
||||||
|
switch (characteristic.type) {
|
||||||
|
case CharacteristicType.Number: {
|
||||||
|
sortValue = value as number;
|
||||||
|
|
||||||
return aHealth - bHealth;
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "survivability.viewRange":
|
case CharacteristicType.NumberList: {
|
||||||
sorted = filtered.sort(
|
const values = value as number[];
|
||||||
(a, b) =>
|
if (values.length === 0) {
|
||||||
a.turrets.at(-1)!.view_range - b.turrets.at(-1)!.view_range,
|
sortValue = undefined;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let sum = 0;
|
||||||
|
|
||||||
|
for (const item of values) {
|
||||||
|
sum += item;
|
||||||
|
}
|
||||||
|
|
||||||
|
sortValue = sum / values.length;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error(
|
||||||
|
`Unsortable characteristic type ${characteristic.type}`,
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
|
|
||||||
case "survivability.camouflageStill":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) => a.camouflage_still - b.camouflage_still,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "survivability.camouflageMoving":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) => a.camouflage_moving - b.camouflage_moving,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "survivability.camouflageShooting":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.camouflage_still *
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.camouflage_loss -
|
|
||||||
b.camouflage_still *
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.camouflage_loss,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "survivability.volume":
|
|
||||||
sorted = filtered.sort((a, b) => {
|
|
||||||
const aTankModelDefinition = modelDefinitions.models[a.id];
|
|
||||||
const bTankModelDefinition = modelDefinitions.models[b.id];
|
|
||||||
const aTurretModelDefinition =
|
|
||||||
aTankModelDefinition.turrets[a.turrets.at(-1)!.id];
|
|
||||||
const bTurretModelDefinition =
|
|
||||||
bTankModelDefinition.turrets[b.turrets.at(-1)!.id];
|
|
||||||
const aSize = normalizeBoundingBox(
|
|
||||||
unionBoundingBox(
|
|
||||||
aTankModelDefinition.bounding_box!,
|
|
||||||
aTurretModelDefinition.bounding_box!,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const bSize = normalizeBoundingBox(
|
|
||||||
unionBoundingBox(
|
|
||||||
bTankModelDefinition.bounding_box!,
|
|
||||||
bTurretModelDefinition.bounding_box!,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const aVolume = aSize.x * aSize.y * aSize.z;
|
|
||||||
const bVolume = bSize.x * bSize.y * bSize.z;
|
|
||||||
|
|
||||||
return aVolume - bVolume;
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "survivability.length":
|
|
||||||
sorted = filtered.sort((a, b) => {
|
|
||||||
const aTankModelDefinition = modelDefinitions.models[a.id];
|
|
||||||
const bTankModelDefinition = modelDefinitions.models[b.id];
|
|
||||||
const aTurretModelDefinition =
|
|
||||||
aTankModelDefinition.turrets[a.turrets.at(-1)!.id];
|
|
||||||
const bTurretModelDefinition =
|
|
||||||
bTankModelDefinition.turrets[b.turrets.at(-1)!.id];
|
|
||||||
const aSize = normalizeBoundingBox(
|
|
||||||
unionBoundingBox(
|
|
||||||
aTankModelDefinition.bounding_box!,
|
|
||||||
aTurretModelDefinition.bounding_box!,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const bSize = normalizeBoundingBox(
|
|
||||||
unionBoundingBox(
|
|
||||||
bTankModelDefinition.bounding_box!,
|
|
||||||
bTurretModelDefinition.bounding_box!,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const aLength = Math.max(aSize.x, aSize.y, aSize.z);
|
|
||||||
const bLength = Math.max(bSize.x, bSize.y, bSize.z);
|
|
||||||
|
|
||||||
return aLength - bLength;
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.dpm":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
resolveDpm(
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!,
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0],
|
|
||||||
) -
|
|
||||||
resolveDpm(
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!,
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.dpmPremium":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
(a.turrets.at(-1)!.guns.at(-1)!.shells[1]
|
|
||||||
? resolveDpm(
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!,
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.shells[1],
|
|
||||||
)
|
|
||||||
: 0) -
|
|
||||||
(b.turrets.at(-1)!.guns.at(-1)!.shells[1]
|
|
||||||
? resolveDpm(
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!,
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.shells[1],
|
|
||||||
)
|
|
||||||
: 0),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.reload":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
resolveReload(a.turrets.at(-1)!.guns.at(-1)!) -
|
|
||||||
resolveReload(b.turrets.at(-1)!.guns.at(-1)!),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.caliber":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].caliber -
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].caliber,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.standardPenetration":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near -
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.premiumPenetration":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
(a.turrets.at(-1)!.guns.at(-1)!.shells[1]?.penetration!.near ??
|
|
||||||
0) -
|
|
||||||
(b.turrets.at(-1)!.guns.at(-1)!.shells[1]?.penetration!.near ??
|
|
||||||
0),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.tertiaryPenetration":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
(a.turrets.at(-1)!.guns.at(-1)!.shells[2]?.penetration!.near ??
|
|
||||||
0) -
|
|
||||||
(b.turrets.at(-1)!.guns.at(-1)!.shells[2]?.penetration!.near ??
|
|
||||||
0),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.damage":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].armor_damage -
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].armor_damage,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.moduleDamage":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].module_damage -
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].module_damage,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.shellVelocity":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].velocity -
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].velocity,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.shellRange":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].range -
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].range,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.shellCapacity":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.shell_capacity -
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.shell_capacity,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.aimTime":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.aim_time -
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.aim_time,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.dispersionStill":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.dispersion_base -
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.dispersion_base,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.dispersionMoving":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.tracks.at(-1)!.dispersion_move -
|
|
||||||
b.tracks.at(-1)!.dispersion_move,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.gunDepression":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id]
|
|
||||||
.guns[a.turrets.at(-1)!.guns.at(-1)!.id].pitch!.max +
|
|
||||||
(modelDefinitions.models[a.id].initial_turret_rotation?.pitch ??
|
|
||||||
0) -
|
|
||||||
modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id]
|
|
||||||
.guns[b.turrets.at(-1)!.guns.at(-1)!.id].pitch!.max -
|
|
||||||
(modelDefinitions.models[b.id].initial_turret_rotation?.pitch ??
|
|
||||||
0),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fire.gunElevation":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id]
|
|
||||||
.guns[b.turrets.at(-1)!.guns.at(-1)!.id].pitch!.min +
|
|
||||||
(modelDefinitions.models[b.id].initial_turret_rotation?.pitch ??
|
|
||||||
0) -
|
|
||||||
modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id]
|
|
||||||
.guns[a.turrets.at(-1)!.guns.at(-1)!.id].pitch!.min -
|
|
||||||
(modelDefinitions.models[a.id].initial_turret_rotation?.pitch ??
|
|
||||||
0),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "maneuverability.forwardsSpeed":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) => a.speed_forwards - b.speed_forwards,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "maneuverability.backwardsSpeed":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) => a.speed_backwards - b.speed_backwards,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "maneuverability.power":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) => a.engines.at(-1)!.power - b.engines.at(-1)!.power,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "maneuverability.powerToWeight":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.engines.at(-1)!.power /
|
|
||||||
(a.weight +
|
|
||||||
a.engines.at(-1)!.weight +
|
|
||||||
a.tracks.at(-1)!.weight +
|
|
||||||
a.turrets.at(-1)!.weight +
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.weight) -
|
|
||||||
b.engines.at(-1)!.power /
|
|
||||||
(b.weight +
|
|
||||||
b.engines.at(-1)!.weight +
|
|
||||||
b.tracks.at(-1)!.weight +
|
|
||||||
b.turrets.at(-1)!.weight +
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.weight),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "maneuverability.weight":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.weight +
|
|
||||||
a.engines.at(-1)!.weight +
|
|
||||||
a.tracks.at(-1)!.weight +
|
|
||||||
a.turrets.at(-1)!.weight +
|
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.weight -
|
|
||||||
(b.weight +
|
|
||||||
b.engines.at(-1)!.weight +
|
|
||||||
b.tracks.at(-1)!.weight +
|
|
||||||
b.turrets.at(-1)!.weight +
|
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.weight),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "maneuverability.traverseSpeed":
|
|
||||||
sorted = filtered.sort(
|
|
||||||
(a, b) =>
|
|
||||||
a.tracks.at(-1)!.traverse_speed -
|
|
||||||
b.tracks.at(-1)!.traverse_speed,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tankopediaSort.direction === "ascending"
|
values.set(tank.id, sortValue);
|
||||||
? sorted
|
|
||||||
: sorted.reverse();
|
|
||||||
} else {
|
|
||||||
return filtered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const direction =
|
||||||
|
tankopediaSort.direction === TankopediaSortDirection.Ascending ? 1 : -1;
|
||||||
|
|
||||||
|
return [...filtered].sort((a, b) => {
|
||||||
|
const aValue = values.get(a.id);
|
||||||
|
const bValue = values.get(b.id);
|
||||||
|
|
||||||
|
if (aValue === undefined) return bValue === undefined ? 0 : 1;
|
||||||
|
if (bValue === undefined) return -1;
|
||||||
|
|
||||||
|
if (aValue === bValue) return 0;
|
||||||
|
|
||||||
|
return (aValue < bValue ? -1 : 1) * direction;
|
||||||
|
});
|
||||||
}, [tankFilters, tankopediaSort]);
|
}, [tankFilters, tankopediaSort]);
|
||||||
|
|
||||||
const data = sorted.map((tank) => ({
|
console.log("V", sorted.length);
|
||||||
key: `${tank.id}`,
|
|
||||||
tank,
|
const sortConfig =
|
||||||
onTankSelect: onSelect,
|
tankopediaSort.by !== null &&
|
||||||
}));
|
sortableCharacteristics.has(tankopediaSort.by)
|
||||||
|
? tankopediaSort.by
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const renderCharacteristic = useCharacteristicRenderer();
|
||||||
|
|
||||||
|
const data = sorted.map((tank) => {
|
||||||
|
const tankDefaultCharacteristics = defaultCharacteristics.get(tank.id)!;
|
||||||
|
const shouldRenderDiscriminator =
|
||||||
|
tankopediaSort.by !== null &&
|
||||||
|
tankDefaultCharacteristics.has(tankopediaSort.by);
|
||||||
|
|
||||||
|
return {
|
||||||
|
key: `${tank.id}`,
|
||||||
|
tank,
|
||||||
|
discriminator: shouldRenderDiscriminator
|
||||||
|
? renderCharacteristic(
|
||||||
|
tankDefaultCharacteristics.get(tankopediaSort.by!)!,
|
||||||
|
characteristicRenderConfigs.get(tankopediaSort.by!)!,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
onTankSelect: onSelect,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex className={styles.container} column gap="4">
|
<Flex className={styles.container} column gap="4">
|
||||||
@@ -470,16 +258,16 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{tankopediaSort.by !== "meta.none" && (
|
{sortConfig && (
|
||||||
<Text color="gray">
|
<Text color="gray">
|
||||||
{literals(strings.website.common.tank_search.sorting_by, {
|
{literals(strings.website.common.tank_search.sorting_by, {
|
||||||
name: strings.website.common.tank_search.sort[
|
name: (
|
||||||
tankopediaSort.by
|
strings.tanks.characteristics.items as Record<
|
||||||
],
|
string,
|
||||||
|
string
|
||||||
|
>
|
||||||
|
)[sortConfig],
|
||||||
})}
|
})}
|
||||||
{SORT_UNITS[tankopediaSort.by] === undefined
|
|
||||||
? ""
|
|
||||||
: ` (${SORT_UNITS[tankopediaSort.by]})`}
|
|
||||||
, {tankopediaSort.direction}
|
, {tankopediaSort.direction}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { alias, gunTypeOrder, romanize, treeTypeOrder } from "@blitzkit/core";
|
||||||
alias,
|
|
||||||
gunTypeOrder,
|
|
||||||
TIER_ROMAN_NUMERALS,
|
|
||||||
treeTypeOrder,
|
|
||||||
} from "@blitzkit/core";
|
|
||||||
import { tankClassOrder } from "@blitzkit/core/src/config/tankClassOrder";
|
import { tankClassOrder } from "@blitzkit/core/src/config/tankClassOrder";
|
||||||
import { literals } from "@blitzkit/i18n";
|
import { literals } from "@blitzkit/i18n";
|
||||||
import locales from "@blitzkit/i18n/locales.json";
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
@@ -203,7 +198,7 @@ function TiersFilter() {
|
|||||||
<Flex gap="1">
|
<Flex gap="1">
|
||||||
{tiers.slice(0, MAX_ICONS).map((tier) => (
|
{tiers.slice(0, MAX_ICONS).map((tier) => (
|
||||||
<Text size="minor" key={tier}>
|
<Text size="minor" key={tier}>
|
||||||
{TIER_ROMAN_NUMERALS[tier]}
|
{romanize(tier)}
|
||||||
</Text>
|
</Text>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
@@ -239,7 +234,7 @@ function TiersFilter() {
|
|||||||
key={tier}
|
key={tier}
|
||||||
>
|
>
|
||||||
{literals(strings.website.common.tank_search.tier, {
|
{literals(strings.website.common.tank_search.tier, {
|
||||||
tier: TIER_ROMAN_NUMERALS[tier],
|
tier: romanize(tier),
|
||||||
})}
|
})}
|
||||||
</DropdownMenu.CheckboxItem>
|
</DropdownMenu.CheckboxItem>
|
||||||
);
|
);
|
||||||
@@ -620,13 +615,7 @@ function IndividualShellFilter({
|
|||||||
return (
|
return (
|
||||||
<DropdownMenu.Root modal={false}>
|
<DropdownMenu.Root modal={false}>
|
||||||
<DropdownMenu.Trigger asChild>
|
<DropdownMenu.Trigger asChild>
|
||||||
<IconButton
|
<IconButton listChild size="minor" variant="surface" color="gray">
|
||||||
listChild
|
|
||||||
size="minor"
|
|
||||||
variant="surface"
|
|
||||||
color="gray"
|
|
||||||
highContrast
|
|
||||||
>
|
|
||||||
{shells[index] === null && (
|
{shells[index] === null && (
|
||||||
<Text lowContrast className={styles["shell-icon"]}>
|
<Text lowContrast className={styles["shell-icon"]}>
|
||||||
<MissingShellIcon width="1em" height="1em" />
|
<MissingShellIcon width="1em" height="1em" />
|
||||||
@@ -739,10 +728,10 @@ function OwnershipFilterInternal() {
|
|||||||
borderTopRightRadius: 0,
|
borderTopRightRadius: 0,
|
||||||
borderBottomRightRadius: 0,
|
borderBottomRightRadius: 0,
|
||||||
}}
|
}}
|
||||||
|
listChild
|
||||||
disabled={!wargaming}
|
disabled={!wargaming}
|
||||||
variant={showOwned ? "solid" : "surface"}
|
variant={showOwned ? "solid" : "surface"}
|
||||||
color={showOwned ? undefined : "gray"}
|
color={showOwned ? undefined : "gray"}
|
||||||
highContrast
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
TankFilters.mutate((draft) => {
|
TankFilters.mutate((draft) => {
|
||||||
draft.showOwned = !draft.showOwned;
|
draft.showOwned = !draft.showOwned;
|
||||||
@@ -759,10 +748,10 @@ function OwnershipFilterInternal() {
|
|||||||
borderBottomLeftRadius: 0,
|
borderBottomLeftRadius: 0,
|
||||||
marginLeft: "-1px",
|
marginLeft: "-1px",
|
||||||
}}
|
}}
|
||||||
|
listChild
|
||||||
disabled={!wargaming}
|
disabled={!wargaming}
|
||||||
variant={showUnowned ? "solid" : "surface"}
|
variant={showUnowned ? "solid" : "surface"}
|
||||||
color={showUnowned ? undefined : "gray"}
|
color={showUnowned ? undefined : "gray"}
|
||||||
highContrast
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
TankFilters.mutate((draft) => {
|
TankFilters.mutate((draft) => {
|
||||||
draft.showUnowned = !draft.showUnowned;
|
draft.showUnowned = !draft.showUnowned;
|
||||||
@@ -789,7 +778,7 @@ function TestFilter() {
|
|||||||
}}
|
}}
|
||||||
variant={showNonTesting ? "solid" : "surface"}
|
variant={showNonTesting ? "solid" : "surface"}
|
||||||
color={showNonTesting ? undefined : "gray"}
|
color={showNonTesting ? undefined : "gray"}
|
||||||
highContrast
|
listChild
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
TankFilters.mutate((draft) => {
|
TankFilters.mutate((draft) => {
|
||||||
draft.showNonTesting = !draft.showNonTesting;
|
draft.showNonTesting = !draft.showNonTesting;
|
||||||
@@ -810,7 +799,7 @@ function TestFilter() {
|
|||||||
}}
|
}}
|
||||||
variant={showTesting ? "solid" : "surface"}
|
variant={showTesting ? "solid" : "surface"}
|
||||||
color={showTesting ? undefined : "gray"}
|
color={showTesting ? undefined : "gray"}
|
||||||
highContrast
|
listChild
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
TankFilters.mutate((draft) => {
|
TankFilters.mutate((draft) => {
|
||||||
draft.showTesting = !draft.showTesting;
|
draft.showTesting = !draft.showTesting;
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@ import {
|
|||||||
alias,
|
alias,
|
||||||
formatCompact,
|
formatCompact,
|
||||||
tankIcon,
|
tankIcon,
|
||||||
TIER_ROMAN_NUMERALS,
|
romanize,
|
||||||
} from "@blitzkit/core";
|
} from "@blitzkit/core";
|
||||||
import {
|
import {
|
||||||
EngineDefinition,
|
EngineDefinition,
|
||||||
@@ -93,7 +93,7 @@ function ModuleButton({
|
|||||||
top: isTank ? 8 : 4,
|
top: isTank ? 8 : 4,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{TIER_ROMAN_NUMERALS[tier]}
|
{romanize(tier)}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{unlock.cost!.value > 0 && (
|
{unlock.cost!.value > 0 && (
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import { MAX_SKILL_LEVEL } from "@blitzkit/core";
|
||||||
import { InfoCircledIcon } from "@radix-ui/react-icons";
|
import { InfoCircledIcon } from "@radix-ui/react-icons";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -59,7 +60,7 @@ export function Skills() {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
Object.keys(draft.skills).forEach((skill) => {
|
Object.keys(draft.skills).forEach((skill) => {
|
||||||
draft.skills[skill] = 7;
|
draft.skills[skill] = MAX_SKILL_LEVEL;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
alias,
|
alias,
|
||||||
resolvePenetrationCoefficient,
|
resolvePenetrationCoefficient,
|
||||||
TIER_ROMAN_NUMERALS,
|
romanize,
|
||||||
uniqueGuns,
|
uniqueGuns,
|
||||||
} from "@blitzkit/core";
|
} from "@blitzkit/core";
|
||||||
import { literals } from "@blitzkit/i18n/src/literals";
|
import { literals } from "@blitzkit/i18n/src/literals";
|
||||||
@@ -137,7 +137,7 @@ export function Options({ thicknessRange, canvas, skeleton }: OptionsProps) {
|
|||||||
mr="2"
|
mr="2"
|
||||||
mb="1"
|
mb="1"
|
||||||
>
|
>
|
||||||
{TIER_ROMAN_NUMERALS[antagonistGun.tier]}
|
{romanize(antagonistGun.tier)}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
@@ -166,7 +166,7 @@ export function Options({ thicknessRange, canvas, skeleton }: OptionsProps) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
selected={gun.id === antagonistGun.id}
|
selected={gun.id === antagonistGun.id}
|
||||||
discriminator={TIER_ROMAN_NUMERALS[gun.tier]}
|
discriminator={romanize(gun.tier)}
|
||||||
secondaryDiscriminator={
|
secondaryDiscriminator={
|
||||||
<Text style={{ fontSize: "0.75em" }}>
|
<Text style={{ fontSize: "0.75em" }}>
|
||||||
{literals(strings.common.units.mm, {
|
{literals(strings.common.units.mm, {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { alias, TIER_ROMAN_NUMERALS } from "@blitzkit/core";
|
import { alias, romanize } from "@blitzkit/core";
|
||||||
import { TankPriceType, TankType } from "@blitzkit/protos";
|
import { TankPriceType, TankType } from "@blitzkit/protos";
|
||||||
import { Box, Flex } from "@radix-ui/themes";
|
import { Box, Flex } from "@radix-ui/themes";
|
||||||
import { Var } from "../../../core/radix/var";
|
import { Var } from "../../../core/radix/var";
|
||||||
@@ -80,7 +80,7 @@ export function MetaSection() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Listing>
|
</Listing>
|
||||||
<Listing label={strings.website.tools.tankopedia.meta.tier}>
|
<Listing label={strings.website.tools.tankopedia.meta.tier}>
|
||||||
{TIER_ROMAN_NUMERALS[protagonist.tier]}
|
{romanize(protagonist.tier)}
|
||||||
</Listing>
|
</Listing>
|
||||||
<Listing
|
<Listing
|
||||||
label={strings.website.tools.tankopedia.meta.type}
|
label={strings.website.tools.tankopedia.meta.type}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { alias, formatCompact, TIER_ROMAN_NUMERALS } from "@blitzkit/core";
|
import { alias, formatCompact, romanize } from "@blitzkit/core";
|
||||||
import { literals } from "@blitzkit/i18n/src/literals";
|
import { literals } from "@blitzkit/i18n/src/literals";
|
||||||
import { Box, Flex, Skeleton, Text } from "@radix-ui/themes";
|
import { Box, Flex, Skeleton, Text } from "@radix-ui/themes";
|
||||||
import { api } from "../../../../api/dynamic";
|
import { api } from "../../../../api/dynamic";
|
||||||
@@ -90,7 +90,7 @@ export function Node({ id, highlight, nextIds, skeleton }: NodeProps) {
|
|||||||
<Flex direction="column" align="center">
|
<Flex direction="column" align="center">
|
||||||
<Flex gap="2" align="center">
|
<Flex gap="2" align="center">
|
||||||
<Text color="gray" size="1">
|
<Text color="gray" size="1">
|
||||||
{TIER_ROMAN_NUMERALS[tank.tier]}
|
{romanize(tank.tier)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text wrap="nowrap">{unwrap(tank.name!)}</Text>
|
<Text wrap="nowrap">{unwrap(tank.name!)}</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { TIER_ROMAN_NUMERALS } from "@blitzkit/core";
|
import { romanize } from "@blitzkit/core";
|
||||||
import { literals } from "@blitzkit/i18n/src/literals";
|
import { literals } from "@blitzkit/i18n/src/literals";
|
||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import { characteristicsGroups } from "../../config/characteristicsGroups";
|
import { characteristicsGroups } from "../../config/characteristicsGroups";
|
||||||
@@ -201,7 +201,7 @@ function CompareOptions() {
|
|||||||
value: `${TankopediaRelativeAgainst.ClassAndTier}`,
|
value: `${TankopediaRelativeAgainst.ClassAndTier}`,
|
||||||
relativeAgainst: TankopediaRelativeAgainst.ClassAndTier,
|
relativeAgainst: TankopediaRelativeAgainst.ClassAndTier,
|
||||||
label: literals(strings.tanks.characteristics.compare.class, {
|
label: literals(strings.tanks.characteristics.compare.class, {
|
||||||
tier: TIER_ROMAN_NUMERALS[tank.tier],
|
tier: romanize(tank.tier),
|
||||||
class: strings.common.tank_class_short_plural_lowercase[tank.class],
|
class: strings.common.tank_class_short_plural_lowercase[tank.class],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@@ -209,7 +209,7 @@ function CompareOptions() {
|
|||||||
value: `${TankopediaRelativeAgainst.Tier}`,
|
value: `${TankopediaRelativeAgainst.Tier}`,
|
||||||
relativeAgainst: TankopediaRelativeAgainst.Tier,
|
relativeAgainst: TankopediaRelativeAgainst.Tier,
|
||||||
label: literals(strings.tanks.characteristics.compare.tier, {
|
label: literals(strings.tanks.characteristics.compare.tier, {
|
||||||
tier: TIER_ROMAN_NUMERALS[tank.tier],
|
tier: romanize(tank.tier),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
.section {
|
.section {
|
||||||
max-width: 21rem;
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
@@ -13,6 +11,31 @@
|
|||||||
|
|
||||||
.upgrade-buttons {
|
.upgrade-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
gap: var(--space-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.crew-skills {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-3);
|
||||||
|
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
gap: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skill {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.level {
|
||||||
|
position: absolute;
|
||||||
|
|
||||||
|
right: var(--space-1);
|
||||||
|
bottom: var(--space-1);
|
||||||
|
|
||||||
|
font-size: var(--font-size-minor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +78,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.consumables {
|
.consumables {
|
||||||
display: flex;
|
display: grid;
|
||||||
flex-wrap: wrap;
|
grid-template-columns: repeat(3, max-content);
|
||||||
gap: var(--space-3);
|
gap: var(--space-3);
|
||||||
|
|
||||||
.consumable-wrapper {
|
.consumable-wrapper {
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
import { alias } from "@blitzkit/core";
|
import {
|
||||||
|
alias,
|
||||||
|
MAX_SKILL_LEVEL,
|
||||||
|
permanentSkills,
|
||||||
|
romanize,
|
||||||
|
} from "@blitzkit/core";
|
||||||
import type { Consumable, EquipmentSlot, Provision } from "@blitzkit/protos";
|
import type { Consumable, EquipmentSlot, Provision } from "@blitzkit/protos";
|
||||||
import { ClockIcon, ResetIcon, TrashIcon } from "@radix-ui/react-icons";
|
import {
|
||||||
|
ClockIcon,
|
||||||
|
DoubleArrowUpIcon,
|
||||||
|
ResetIcon,
|
||||||
|
TrashIcon,
|
||||||
|
} from "@radix-ui/react-icons";
|
||||||
import { chunk } from "lodash-es";
|
import { chunk } from "lodash-es";
|
||||||
import { api } from "../../api/dynamic";
|
import { api } from "../../api/dynamic";
|
||||||
import { equipmentColumns } from "../../config/equipment";
|
import { equipmentColumns } from "../../config/equipment";
|
||||||
@@ -23,13 +33,14 @@ import styles from "./index.module.css";
|
|||||||
const equipment = await api.equipment();
|
const equipment = await api.equipment();
|
||||||
const provisions = await api.provisions();
|
const provisions = await api.provisions();
|
||||||
const consumables = await api.consumables();
|
const consumables = await api.consumables();
|
||||||
|
const skills = await api.skills();
|
||||||
|
|
||||||
interface TankopediaLoadoutProps {
|
interface TankopediaLoadoutProps {
|
||||||
characteristics: ComputedCharacteristics;
|
characteristics: ComputedCharacteristics;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TankopediaLoadout({ characteristics }: TankopediaLoadoutProps) {
|
export function TankopediaLoadout({ characteristics }: TankopediaLoadoutProps) {
|
||||||
const tank = useDuel("protagonist", DuelModule.Tank);
|
// const tank = useDuel("protagonist", DuelModule.Tank);
|
||||||
// const showModules = hasUpgrades(tank);
|
// const showModules = hasUpgrades(tank);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -39,12 +50,103 @@ export function TankopediaLoadout({ characteristics }: TankopediaLoadoutProps) {
|
|||||||
<Equipment />
|
<Equipment />
|
||||||
<Provisions />
|
<Provisions />
|
||||||
<Consumables characteristics={characteristics} />
|
<Consumables characteristics={characteristics} />
|
||||||
|
<CrewSkills />
|
||||||
<State />
|
<State />
|
||||||
<Status />
|
<Status />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CrewSkills() {
|
||||||
|
const strings = useStrings();
|
||||||
|
const selectedSkills = Tankopedia.use((state) => state.environment.skills);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.section}>
|
||||||
|
<div className={styles.header}>
|
||||||
|
<Heading size="4">{strings.tanks.loadout.skills}</Heading>
|
||||||
|
|
||||||
|
<div className={styles["upgrade-buttons"]}>
|
||||||
|
<IconButton
|
||||||
|
color="red"
|
||||||
|
aria-label={`${strings.tanks.loadout.clear} ${strings.tanks.loadout.skills}`}
|
||||||
|
onClick={() => {
|
||||||
|
Tankopedia.mutate((draft) => {
|
||||||
|
Object.keys(draft.environment.skills).forEach((skill) => {
|
||||||
|
draft.environment.skills[skill] = 0;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TrashIcon />
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
color="gray"
|
||||||
|
highContrast
|
||||||
|
aria-label={`${strings.tanks.loadout.maximize} ${strings.tanks.loadout.skills}`}
|
||||||
|
onClick={() => {
|
||||||
|
Tankopedia.mutate((draft) => {
|
||||||
|
Object.keys(draft.environment.skills).forEach((skill) => {
|
||||||
|
draft.environment.skills[skill] = MAX_SKILL_LEVEL;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DoubleArrowUpIcon />
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles["crew-skills"]}>
|
||||||
|
{Object.entries(skills.classes).map(([tankClass, group]) => (
|
||||||
|
<div key={tankClass} className={styles.row}>
|
||||||
|
{group.skills.map((skill) => (
|
||||||
|
<CrewSkillEntry
|
||||||
|
key={skill}
|
||||||
|
id={skill}
|
||||||
|
level={selectedSkills[skill]}
|
||||||
|
permanent={permanentSkills.includes(skill)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CrewSkillEntryProps {
|
||||||
|
id: string;
|
||||||
|
level: number;
|
||||||
|
permanent: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function CrewSkillEntry({ id, level, permanent }: CrewSkillEntryProps) {
|
||||||
|
return (
|
||||||
|
<IconButton
|
||||||
|
size="major"
|
||||||
|
radius="1"
|
||||||
|
className={styles.skill}
|
||||||
|
color={level === 0 ? "gray" : permanent ? undefined : "amber"}
|
||||||
|
variant={level === 0 ? "soft" : "surface"}
|
||||||
|
onClick={(event) => {
|
||||||
|
Tankopedia.mutate((draft) => {
|
||||||
|
if (event.shiftKey) {
|
||||||
|
draft.environment.skills[id] = level === 0 ? MAX_SKILL_LEVEL : 0;
|
||||||
|
} else {
|
||||||
|
draft.environment.skills[id] =
|
||||||
|
level === 0 ? MAX_SKILL_LEVEL : level - 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img src={alias("api", `/icons/skills/${id}.webp`)} />
|
||||||
|
{level > 0 && <span className={styles.level}>{romanize(level)}</span>}
|
||||||
|
</IconButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function State() {
|
function State() {
|
||||||
const strings = useStrings();
|
const strings = useStrings();
|
||||||
|
|
||||||
@@ -58,6 +160,7 @@ function State() {
|
|||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
color="red"
|
color="red"
|
||||||
|
aria-label={`${strings.tanks.loadout.clear} ${strings.tanks.loadout.consumables}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
draft.protagonist.consumables = [];
|
draft.protagonist.consumables = [];
|
||||||
@@ -87,6 +190,7 @@ function Status() {
|
|||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
color="red"
|
color="red"
|
||||||
|
aria-label={`${strings.tanks.loadout.clear} ${strings.tanks.loadout.status}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
draft.protagonist.consumables = [];
|
draft.protagonist.consumables = [];
|
||||||
@@ -103,6 +207,8 @@ function Status() {
|
|||||||
{group.map((key) => (
|
{group.map((key) => (
|
||||||
<IconButton
|
<IconButton
|
||||||
key={key}
|
key={key}
|
||||||
|
aria-label={key.replaceAll("_", " ")}
|
||||||
|
aria-pressed={status[key]}
|
||||||
radius="1"
|
radius="1"
|
||||||
className={styles.state}
|
className={styles.state}
|
||||||
color={status[key] ? "amber" : "gray"}
|
color={status[key] ? "amber" : "gray"}
|
||||||
@@ -183,6 +289,7 @@ function Provisions() {
|
|||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
color="red"
|
color="red"
|
||||||
|
aria-label={`${strings.tanks.loadout.clear} ${strings.tanks.loadout.provisions}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
draft.protagonist.provisions = [];
|
draft.protagonist.provisions = [];
|
||||||
@@ -230,6 +337,7 @@ function ProvisionEntry({ id, provision }: ProvisionEntryProps) {
|
|||||||
return (
|
return (
|
||||||
<Tooltip tooltip={unwrap(provision.name)}>
|
<Tooltip tooltip={unwrap(provision.name)}>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
aria-label={unwrap(provision.name)}
|
||||||
size="major"
|
size="major"
|
||||||
radius="1"
|
radius="1"
|
||||||
variant={isSelected ? "surface" : "soft"}
|
variant={isSelected ? "surface" : "soft"}
|
||||||
@@ -275,6 +383,7 @@ function Consumables({ characteristics }: ConsumablesProps) {
|
|||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
color="red"
|
color="red"
|
||||||
|
aria-label={`${strings.tanks.loadout.clear} ${strings.tanks.loadout.consumables}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
draft.protagonist.consumables = [];
|
draft.protagonist.consumables = [];
|
||||||
@@ -325,6 +434,7 @@ function ConsumableEntry({ id, consumable }: ConsumableProps) {
|
|||||||
<div className={styles["consumable-wrapper"]}>
|
<div className={styles["consumable-wrapper"]}>
|
||||||
<Tooltip tooltip={unwrap(consumable.name)}>
|
<Tooltip tooltip={unwrap(consumable.name)}>
|
||||||
<Button
|
<Button
|
||||||
|
aria-label={unwrap(consumable.name)}
|
||||||
radius="1"
|
radius="1"
|
||||||
variant={isSelected ? "surface" : "soft"}
|
variant={isSelected ? "surface" : "soft"}
|
||||||
color={isSelected ? undefined : "gray"}
|
color={isSelected ? undefined : "gray"}
|
||||||
@@ -384,6 +494,7 @@ function Equipment() {
|
|||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
color="red"
|
color="red"
|
||||||
|
aria-label={`${strings.tanks.loadout.clear} ${strings.tanks.loadout.equipment}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
for (const key in draft.protagonist.equipment) {
|
for (const key in draft.protagonist.equipment) {
|
||||||
@@ -489,6 +600,7 @@ function EquipmentOption({
|
|||||||
return (
|
return (
|
||||||
<Tooltip tooltip={unwrap(specificEquipment.name)}>
|
<Tooltip tooltip={unwrap(specificEquipment.name)}>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
aria-label={unwrap(specificEquipment.name)}
|
||||||
size="major"
|
size="major"
|
||||||
color={isSelected ? undefined : "gray"}
|
color={isSelected ? undefined : "gray"}
|
||||||
variant={isSelected ? "surface" : "soft"}
|
variant={isSelected ? "surface" : "soft"}
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
import {
|
import { Suspense, useEffect, useRef } from "react";
|
||||||
forwardRef,
|
|
||||||
Suspense,
|
|
||||||
useEffect,
|
|
||||||
useImperativeHandle,
|
|
||||||
useRef,
|
|
||||||
} from "react";
|
|
||||||
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 { Pose, poseEvent } from "../../core/blitzkit/pose";
|
import { Pose, poseEvent } from "../../core/blitzkit/pose";
|
||||||
@@ -14,6 +8,7 @@ import { useModel } from "../../hooks/useModel";
|
|||||||
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 type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
||||||
import { ArmorPlateDisplay } from "../ArmorPlateDisplay";
|
import { ArmorPlateDisplay } from "../ArmorPlateDisplay";
|
||||||
import { CanvasAutoClear } from "../CanvasAutoClear";
|
import { CanvasAutoClear } from "../CanvasAutoClear";
|
||||||
import { CanvasControl } from "../CanvasControl";
|
import { CanvasControl } from "../CanvasControl";
|
||||||
@@ -27,19 +22,18 @@ import { StaticArmor, type ThicknessRange } from "../StaticArmor";
|
|||||||
import { TankModel } from "../TankModel";
|
import { TankModel } from "../TankModel";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
interface TankSandboxProps {
|
type TankSandboxProps = MaybeSkeletonComponentProps & {
|
||||||
thicknessRange: ThicknessRange;
|
thicknessRange: ThicknessRange;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const TankopediaSandbox = forwardRef<
|
export function TankopediaSandbox({
|
||||||
HTMLCanvasElement,
|
skeleton,
|
||||||
TankSandboxProps
|
thicknessRange,
|
||||||
>(({ thicknessRange }, ref) => {
|
}: TankSandboxProps) {
|
||||||
const canvas = useRef<HTMLCanvasElement>(null);
|
const canvas = useRef<HTMLCanvasElement>(null);
|
||||||
const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122);
|
const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122);
|
||||||
const hasDownImprovedVerticalStabilizer = useEquipment("protagonist", 124);
|
const hasDownImprovedVerticalStabilizer = useEquipment("protagonist", 124);
|
||||||
|
|
||||||
const tank = useDuel("protagonist", DuelModule.Tank);
|
|
||||||
const gun = useDuel("protagonist", DuelModule.Gun);
|
const gun = useDuel("protagonist", DuelModule.Gun);
|
||||||
const turret = useDuel("protagonist", DuelModule.Turret);
|
const turret = useDuel("protagonist", DuelModule.Turret);
|
||||||
|
|
||||||
@@ -47,13 +41,6 @@ export const TankopediaSandbox = forwardRef<
|
|||||||
const turretModelDefinition = model.turrets[turret.id];
|
const turretModelDefinition = model.turrets[turret.id];
|
||||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
const display = Tankopedia.use((state) => state.display);
|
const display = Tankopedia.use((state) => state.display);
|
||||||
const hideTankModelUnderArmor = TankopediaPersistent.use(
|
|
||||||
(state) => state.hideTankModelUnderArmor,
|
|
||||||
);
|
|
||||||
|
|
||||||
const { hasPbr } = useModel(tank.id);
|
|
||||||
|
|
||||||
useImperativeHandle(ref, () => canvas.current!, []);
|
|
||||||
|
|
||||||
function handlePointerDown() {
|
function handlePointerDown() {
|
||||||
window.addEventListener("pointermove", handlePointerMove);
|
window.addEventListener("pointermove", handlePointerMove);
|
||||||
@@ -169,29 +156,47 @@ export const TankopediaSandbox = forwardRef<
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Lighting hasPbr={hasPbr} />
|
{!skeleton && <Content thicknessRange={thicknessRange} />}
|
||||||
|
|
||||||
<SceneProps />
|
|
||||||
{(display === TankopediaDisplay.Model ||
|
|
||||||
(display === TankopediaDisplay.DynamicArmor &&
|
|
||||||
!hideTankModelUnderArmor)) && <TankModel />}
|
|
||||||
|
|
||||||
<ShotDisplay />
|
|
||||||
<ArmorPlateDisplay />
|
|
||||||
<CanvasAutoClear />
|
|
||||||
|
|
||||||
<Suspense>
|
|
||||||
{/* Controls within Suspense to allow for frame-perfect start of camera auto-rotate */}
|
|
||||||
<CanvasControl />
|
|
||||||
|
|
||||||
{display === TankopediaDisplay.DynamicArmor && <DynamicArmor />}
|
|
||||||
{display === TankopediaDisplay.StaticArmor && (
|
|
||||||
<StaticArmor thicknessRange={thicknessRange} />
|
|
||||||
)}
|
|
||||||
</Suspense>
|
|
||||||
|
|
||||||
<InitialCameraAligner />
|
|
||||||
</SmartCanvas>
|
</SmartCanvas>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
function Content({ thicknessRange }: { thicknessRange: ThicknessRange }) {
|
||||||
|
const display = Tankopedia.use((state) => state.display);
|
||||||
|
const tank = useDuel("protagonist", DuelModule.Tank);
|
||||||
|
|
||||||
|
const { hasPbr } = useModel(tank.id);
|
||||||
|
|
||||||
|
const hideTankModelUnderArmor = TankopediaPersistent.use(
|
||||||
|
(state) => state.hideTankModelUnderArmor,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Lighting hasPbr={hasPbr} />
|
||||||
|
|
||||||
|
<SceneProps />
|
||||||
|
|
||||||
|
{(display === TankopediaDisplay.Model ||
|
||||||
|
(display === TankopediaDisplay.DynamicArmor &&
|
||||||
|
!hideTankModelUnderArmor)) && <TankModel />}
|
||||||
|
|
||||||
|
<ShotDisplay />
|
||||||
|
<ArmorPlateDisplay />
|
||||||
|
<CanvasAutoClear />
|
||||||
|
|
||||||
|
<Suspense>
|
||||||
|
{/* Controls within Suspense to allow for frame-perfect start of camera auto-rotate */}
|
||||||
|
<CanvasControl />
|
||||||
|
|
||||||
|
{display === TankopediaDisplay.DynamicArmor && <DynamicArmor />}
|
||||||
|
{display === TankopediaDisplay.StaticArmor && (
|
||||||
|
<StaticArmor thicknessRange={thicknessRange} />
|
||||||
|
)}
|
||||||
|
</Suspense>
|
||||||
|
|
||||||
|
<InitialCameraAligner />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
import type { CaseType } from "@blitzkit/core";
|
import type { CaseType } from "@blitzkit/core";
|
||||||
import type { GunDefinition } from "@blitzkit/protos";
|
import type { GunDefinition } from "@blitzkit/protos";
|
||||||
import { CharacteristicRanking } from "../types/characteristics";
|
import {
|
||||||
import type { CharacteristicsGroup } from "../types/characteristics";
|
CharacteristicRanking,
|
||||||
|
type CharacteristicName,
|
||||||
|
type CharacteristicRenderConfig,
|
||||||
|
type CharacteristicsGroup,
|
||||||
|
} from "../types/characteristics";
|
||||||
|
|
||||||
export const characteristicsGroups: CharacteristicsGroup[] = [
|
export const characteristicsGroups: CharacteristicsGroup[] = [
|
||||||
// {
|
// {
|
||||||
@@ -299,3 +303,15 @@ export const characteristicsGroups: CharacteristicsGroup[] = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const characteristicRenderConfigs = new Map<
|
||||||
|
CharacteristicName,
|
||||||
|
CharacteristicRenderConfig
|
||||||
|
>();
|
||||||
|
|
||||||
|
for (const group of characteristicsGroups) {
|
||||||
|
for (const config of group.order) {
|
||||||
|
if (!("name" in config)) continue;
|
||||||
|
characteristicRenderConfigs.set(config.name, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,16 @@
|
|||||||
import { degressiveStat, progressiveStat } from "@blitzkit/core";
|
import {
|
||||||
|
createDefaultEnvironment,
|
||||||
|
degressiveStat,
|
||||||
|
progressiveStat,
|
||||||
|
type TankEnvironment,
|
||||||
|
} from "@blitzkit/core";
|
||||||
import type { BlitzEffectScript } from "@blitzkit/core/src/types/blitzEffectScript";
|
import type { BlitzEffectScript } from "@blitzkit/core/src/types/blitzEffectScript";
|
||||||
import { CrewType } from "@blitzkit/protos";
|
import { CrewType, type TankDefinition } from "@blitzkit/protos";
|
||||||
import { api } from "../api/dynamic";
|
import { api } from "../api/dynamic";
|
||||||
import { characteristics } from "../config/characteristics";
|
import { characteristics } from "../config/characteristics";
|
||||||
import { defaultEqualizer } from "../config/equalizer";
|
import { defaultEqualizer } from "../config/equalizer";
|
||||||
import { Tankopedia, type TankEnvironment } from "../stores/tankopedia";
|
import { Tankopedia } from "../stores/tankopedia";
|
||||||
|
import { createTankState } from "../tankopedia/createTankState";
|
||||||
import type { TankState } from "../tankopedia/tankState";
|
import type { TankState } from "../tankopedia/tankState";
|
||||||
import type {
|
import type {
|
||||||
CharacteristicContext,
|
CharacteristicContext,
|
||||||
@@ -16,14 +22,7 @@ import { duelSides, type DuelSide } from "./useEquipment";
|
|||||||
const tanks = await api.tanks();
|
const tanks = await api.tanks();
|
||||||
const scripts = await api.scripts();
|
const scripts = await api.scripts();
|
||||||
const equipment = await api.equipment();
|
const equipment = await api.equipment();
|
||||||
|
const skills = await api.skills();
|
||||||
export function useCharacteristics() {
|
|
||||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
|
||||||
const antagonist = Tankopedia.use((state) => state.antagonist);
|
|
||||||
const environment = Tankopedia.use((state) => state.environment);
|
|
||||||
|
|
||||||
return computeCharacteristics({ protagonist, antagonist }, environment);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function computeCharacteristics(
|
export function computeCharacteristics(
|
||||||
states: Record<DuelSide, TankState>,
|
states: Record<DuelSide, TankState>,
|
||||||
@@ -191,3 +190,20 @@ export function computeCharacteristics(
|
|||||||
|
|
||||||
return computed;
|
return computed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useCharacteristics() {
|
||||||
|
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||||
|
const antagonist = Tankopedia.use((state) => state.antagonist);
|
||||||
|
const environment = Tankopedia.use((state) => state.environment);
|
||||||
|
|
||||||
|
return computeCharacteristics({ protagonist, antagonist }, environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function computeDefaultCharacteristics(tank: TankDefinition) {
|
||||||
|
const state = createTankState(tank);
|
||||||
|
|
||||||
|
return computeCharacteristics(
|
||||||
|
{ protagonist: state, antagonist: state },
|
||||||
|
createDefaultEnvironment(skills),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
alias,
|
alias,
|
||||||
TIER_ROMAN_NUMERALS,
|
romanize,
|
||||||
} from "@blitzkit/core";
|
} from "@blitzkit/core";
|
||||||
import { literals } from "@blitzkit/i18n";
|
import { literals } from "@blitzkit/i18n";
|
||||||
import {
|
import {
|
||||||
@@ -161,7 +161,7 @@ function ModuleChooser({
|
|||||||
}
|
}
|
||||||
key={turret.id}
|
key={turret.id}
|
||||||
module="turret"
|
module="turret"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[turret.tier]}
|
discriminator={romanize(turret.tier)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onSelect?.(tankDefinition, turret);
|
onSelect?.(tankDefinition, turret);
|
||||||
}}
|
}}
|
||||||
@@ -179,7 +179,7 @@ function ModuleChooser({
|
|||||||
}
|
}
|
||||||
key={gun.id}
|
key={gun.id}
|
||||||
module="gun"
|
module="gun"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[gun.tier]}
|
discriminator={romanize(gun.tier)}
|
||||||
secondaryDiscriminator={
|
secondaryDiscriminator={
|
||||||
<Text style={{ fontSize: "0.75em" }}>
|
<Text style={{ fontSize: "0.75em" }}>
|
||||||
{literals(strings.common.units.mm, {
|
{literals(strings.common.units.mm, {
|
||||||
|
|||||||
+8
-5
@@ -13,11 +13,14 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
gap: var(--space-5);
|
|
||||||
padding: var(--space-5);
|
|
||||||
|
|
||||||
overflow-y: auto;
|
|
||||||
|
|
||||||
background-color: var(--gray-2);
|
background-color: var(--gray-2);
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: var(--space-5);
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { api } from "../../../../../api/dynamic";
|
import { api } from "../../../../../api/dynamic";
|
||||||
|
import { Scroller } from "../../../../../components/Scroller";
|
||||||
import type { ThicknessRange } from "../../../../../components/StaticArmor";
|
import type { ThicknessRange } from "../../../../../components/StaticArmor";
|
||||||
import { TankopediaCharacteristics } from "../../../../../components/TankopediaCharacteristics";
|
import { TankopediaCharacteristics } from "../../../../../components/TankopediaCharacteristics";
|
||||||
import { TankopediaGameModeAbilities } from "../../../../../components/TankopediaGameModeAbilities";
|
import { TankopediaGameModeAbilities } from "../../../../../components/TankopediaGameModeAbilities";
|
||||||
import { TankopediaLoadout } from "../../../../../components/TankopediaLoadout";
|
import { TankopediaLoadout } from "../../../../../components/TankopediaLoadout";
|
||||||
|
import { TankopediaSandbox } from "../../../../../components/TankopediaSandbox";
|
||||||
import { defaultEqualizer } from "../../../../../config/equalizer";
|
import { defaultEqualizer } from "../../../../../config/equalizer";
|
||||||
import { withErrorWrapper } from "../../../../../hocs/withErrorWrapper";
|
import { withErrorWrapper } from "../../../../../hocs/withErrorWrapper";
|
||||||
import { withLocale } from "../../../../../hocs/withLocale";
|
import { withLocale } from "../../../../../hocs/withLocale";
|
||||||
@@ -52,12 +54,17 @@ export const Page = withErrorWrapper(
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.page}>
|
<div className={styles.page}>
|
||||||
<div className={styles.loadout}>
|
<Scroller className={styles.loadout} orientation="vertical">
|
||||||
<TankopediaLoadout characteristics={characteristics} />
|
<div className={styles.content}>
|
||||||
</div>
|
<TankopediaLoadout characteristics={characteristics} />
|
||||||
|
</div>
|
||||||
|
</Scroller>
|
||||||
|
|
||||||
<div className={styles.sandbox}>
|
<div className={styles.sandbox}>
|
||||||
{/* {!skeleton && <TankopediaSandbox thicknessRange={thicknessRange} />} */}
|
<TankopediaSandbox
|
||||||
|
skeleton={skeleton}
|
||||||
|
thicknessRange={thicknessRange}
|
||||||
|
/>
|
||||||
<TankopediaCharacteristics characteristics={characteristics} />
|
<TankopediaCharacteristics characteristics={characteristics} />
|
||||||
<TankopediaGameModeAbilities />
|
<TankopediaGameModeAbilities />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createDefaultSkills } from "@blitzkit/core";
|
import { createDefaultEnvironment, type TankEnvironment } from "@blitzkit/core";
|
||||||
import type { ShellDefinition, TankDefinition } from "@blitzkit/protos";
|
import type { ShellDefinition, TankDefinition } from "@blitzkit/protos";
|
||||||
import { Soapstone } from "soapstone";
|
import { Soapstone } from "soapstone";
|
||||||
import type { Vector3 } from "three";
|
import type { Vector3 } from "three";
|
||||||
@@ -76,12 +76,6 @@ export enum TankopediaRelativeAgainst {
|
|||||||
All,
|
All,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TankEnvironment {
|
|
||||||
equalize: boolean;
|
|
||||||
distance: number;
|
|
||||||
skills: Record<string, number>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Tankopedia {
|
interface Tankopedia {
|
||||||
disturbed: boolean;
|
disturbed: boolean;
|
||||||
revealed: boolean;
|
revealed: boolean;
|
||||||
@@ -128,11 +122,7 @@ export const Tankopedia = new Soapstone<Tankopedia, [TankDefinition]>(
|
|||||||
antagonist: createTankState(tank),
|
antagonist: createTankState(tank),
|
||||||
model: models.models[tank.id],
|
model: models.models[tank.id],
|
||||||
|
|
||||||
environment: {
|
environment: createDefaultEnvironment(skills),
|
||||||
equalize: false,
|
|
||||||
distance: 0,
|
|
||||||
skills: createDefaultSkills(skills),
|
|
||||||
},
|
|
||||||
|
|
||||||
relative_against: TankopediaRelativeAgainst.ClassAndTier,
|
relative_against: TankopediaRelativeAgainst.ClassAndTier,
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +1,3 @@
|
|||||||
import type { TankopediaSortBy } from '.';
|
|
||||||
|
|
||||||
export const SORT_UNITS: Record<TankopediaSortBy, string | undefined> = {
|
|
||||||
'meta.none': undefined,
|
|
||||||
'survivability.health': 'hp',
|
|
||||||
'fire.aimTime': 's',
|
|
||||||
'fire.caliber': 'mm',
|
|
||||||
'fire.damage': 'hp',
|
|
||||||
'fire.moduleDamage': 'hp',
|
|
||||||
'fire.dispersionMoving': 'm',
|
|
||||||
'fire.dispersionStill': 'm',
|
|
||||||
'fire.dpm': undefined,
|
|
||||||
'fire.dpmPremium': undefined,
|
|
||||||
'fire.gunDepression': '°',
|
|
||||||
'fire.gunElevation': '°',
|
|
||||||
'fire.premiumPenetration': 'mm',
|
|
||||||
'fire.tertiaryPenetration': 'mm',
|
|
||||||
'fire.reload': 's',
|
|
||||||
'fire.shellVelocity': 'm/s',
|
|
||||||
'fire.shellRange': 'm',
|
|
||||||
'fire.shellCapacity': undefined,
|
|
||||||
'fire.standardPenetration': 'mm',
|
|
||||||
'maneuverability.backwardsSpeed': 'kph',
|
|
||||||
'maneuverability.forwardsSpeed': 'kph',
|
|
||||||
'maneuverability.power': 'hp',
|
|
||||||
'maneuverability.powerToWeight': 'hp/tn',
|
|
||||||
'maneuverability.traverseSpeed': '°/s',
|
|
||||||
'maneuverability.weight': 'tn',
|
|
||||||
'survivability.camouflageMoving': '%',
|
|
||||||
'survivability.camouflageShooting': '%',
|
|
||||||
'survivability.camouflageStill': '%',
|
|
||||||
'survivability.length': 'm',
|
|
||||||
'survivability.viewRange': 'm',
|
|
||||||
'survivability.volume': 'm^3',
|
|
||||||
};
|
|
||||||
|
|
||||||
export enum TankopediaDisplay {
|
export enum TankopediaDisplay {
|
||||||
Model,
|
Model,
|
||||||
DynamicArmor,
|
DynamicArmor,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import type en from "@blitzkit/i18n/strings/en.json";
|
|
||||||
import { Soapstone } from "soapstone";
|
import { Soapstone } from "soapstone";
|
||||||
|
|
||||||
export type TankopediaSortBy = keyof typeof en.website.common.tank_search.sort;
|
export enum TankopediaSortDirection {
|
||||||
export type TankopediaSortDirection = "ascending" | "descending";
|
Ascending,
|
||||||
export type TankopediaTestTankDisplay = "include" | "exclude" | "only";
|
Descending,
|
||||||
|
}
|
||||||
|
|
||||||
export interface TankopediaPersistent {
|
export interface TankopediaPersistent {
|
||||||
wireframe: boolean;
|
wireframe: boolean;
|
||||||
@@ -16,11 +16,6 @@ export interface TankopediaPersistent {
|
|||||||
recentlyViewed: number[];
|
recentlyViewed: number[];
|
||||||
hideTankModelUnderArmor: boolean;
|
hideTankModelUnderArmor: boolean;
|
||||||
highGraphics: boolean;
|
highGraphics: boolean;
|
||||||
|
|
||||||
sort: {
|
|
||||||
by: TankopediaSortBy;
|
|
||||||
direction: TankopediaSortDirection;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TankopediaPersistent = new Soapstone<TankopediaPersistent>(
|
export const TankopediaPersistent = new Soapstone<TankopediaPersistent>(
|
||||||
@@ -35,10 +30,6 @@ export const TankopediaPersistent = new Soapstone<TankopediaPersistent>(
|
|||||||
showPrimaryArmor: true,
|
showPrimaryArmor: true,
|
||||||
recentlyViewed: [],
|
recentlyViewed: [],
|
||||||
highGraphics: true,
|
highGraphics: true,
|
||||||
sort: {
|
|
||||||
by: "meta.none",
|
|
||||||
direction: "ascending",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"tankopedia-3",
|
"tankopedia-3",
|
||||||
);
|
);
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
import { Soapstone } from 'soapstone';
|
import { Soapstone } from "soapstone";
|
||||||
import {
|
import type { CharacteristicName } from "../types/characteristics";
|
||||||
type TankopediaSortBy,
|
import { TankopediaSortDirection } from "./tankopediaPersistent";
|
||||||
type TankopediaSortDirection,
|
|
||||||
} from './tankopediaPersistent';
|
|
||||||
|
|
||||||
export interface TankSort {
|
export interface TankSort {
|
||||||
by: TankopediaSortBy;
|
by: CharacteristicName | null;
|
||||||
direction: TankopediaSortDirection;
|
direction: TankopediaSortDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TankSort = new Soapstone<TankSort>({
|
export const TankSort = new Soapstone<TankSort>({
|
||||||
by: 'meta.none',
|
by: null,
|
||||||
direction: 'descending',
|
direction: TankopediaSortDirection.Descending,
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { characteristics } from "../config/characteristics";
|
||||||
|
import { characteristicsGroups } from "../config/characteristicsGroups";
|
||||||
|
import {
|
||||||
|
CharacteristicType,
|
||||||
|
type CharacteristicName,
|
||||||
|
} from "../types/characteristics";
|
||||||
|
|
||||||
|
const sortableCharacteristicTypes = new Set<CharacteristicType>([
|
||||||
|
CharacteristicType.Number,
|
||||||
|
CharacteristicType.NumberList,
|
||||||
|
]);
|
||||||
|
|
||||||
|
export const sortableCharacteristics = new Set<CharacteristicName>();
|
||||||
|
|
||||||
|
for (const group of characteristicsGroups) {
|
||||||
|
for (const config of group.order) {
|
||||||
|
if (!("name" in config)) continue;
|
||||||
|
|
||||||
|
// TODO: remove this when all characteristics are defined
|
||||||
|
if (!(config.name in characteristics)) continue;
|
||||||
|
|
||||||
|
const item = characteristics[config.name];
|
||||||
|
|
||||||
|
if (!sortableCharacteristicTypes.has(item.type)) continue;
|
||||||
|
|
||||||
|
sortableCharacteristics.add(config.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { TankEnvironment } from "@blitzkit/core";
|
||||||
import type { BlitzEffectScript } from "@blitzkit/core/src/types/blitzEffectScript";
|
import type { BlitzEffectScript } from "@blitzkit/core/src/types/blitzEffectScript";
|
||||||
import type { Strings } from "@blitzkit/i18n";
|
import type { Strings } from "@blitzkit/i18n";
|
||||||
import type {
|
import type {
|
||||||
@@ -13,7 +14,6 @@ import type { ReactNode } from "react";
|
|||||||
import type { characteristics } from "../config/characteristics";
|
import type { characteristics } from "../config/characteristics";
|
||||||
import type { toys } from "../config/toys";
|
import type { toys } from "../config/toys";
|
||||||
import type { DuelSide } from "../hooks/useEquipment";
|
import type { DuelSide } from "../hooks/useEquipment";
|
||||||
import type { TankEnvironment } from "../stores/tankopedia";
|
|
||||||
import type { TankState } from "../tankopedia/tankState";
|
import type { TankState } from "../tankopedia/tankState";
|
||||||
|
|
||||||
export type Characteristic = {
|
export type Characteristic = {
|
||||||
|
|||||||
Reference in new issue
Block a user