mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-28 12:23:24 +01:00
demote componnents
This commit is contained in:
18 files changed
+437
-441
No files matched your search
@@ -16,6 +16,7 @@ interface Props {
|
|||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move error screen to separate element and just make the fallback trigger that to handle duplicate hoc's
|
||||||
export function ErrorWrapper({ children }: Props) {
|
export function ErrorWrapper({ children }: Props) {
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary fallbackRender={(props) => <Fallback {...props} />}>
|
<ErrorBoundary fallbackRender={(props) => <Fallback {...props} />}>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { useStrings } from "../../hooks/useStrings";
|
|||||||
import { useUnwrapper } from "../../hooks/useUnwrapper";
|
import { useUnwrapper } from "../../hooks/useUnwrapper";
|
||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
||||||
import type { ComputedCharacteristics } from "../../types/characteristics";
|
|
||||||
import { CustomShellButton } from "../CustomShellButton";
|
import { CustomShellButton } from "../CustomShellButton";
|
||||||
import { EqualIcon } from "../EqualIcon";
|
import { EqualIcon } from "../EqualIcon";
|
||||||
import { IconButton } from "../IconButton";
|
import { IconButton } from "../IconButton";
|
||||||
@@ -20,21 +19,21 @@ import { Tooltip } from "../Tooltip";
|
|||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
interface TankopediaAntagonistControlProps {
|
interface TankopediaAntagonistControlProps {
|
||||||
antagonistCharacteristics: ComputedCharacteristics;
|
penetration: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TankopediaAntagonistControl({
|
export function TankopediaAntagonistControl({
|
||||||
antagonistCharacteristics,
|
penetration,
|
||||||
}: TankopediaAntagonistControlProps) {
|
}: TankopediaAntagonistControlProps) {
|
||||||
const strings = useStrings();
|
const strings = useStrings();
|
||||||
const unwrap = useUnwrapper();
|
const unwrap = useUnwrapper();
|
||||||
|
|
||||||
const showControls = Tankopedia.use((state) => state.showControls);
|
const showControls = Tankopedia.use((state) => state.showControls);
|
||||||
const isDynamicArmorDisplay = useAbsoluteDisplay(
|
const isDynamicArmorDisplay = useAbsoluteDisplay(
|
||||||
TankopediaDisplay.DynamicArmor,
|
TankopediaDisplay.DynamicArmor
|
||||||
);
|
);
|
||||||
const hasCustomShell = Tankopedia.use(
|
const hasCustomShell = Tankopedia.use(
|
||||||
(state) => state.customShell !== undefined,
|
(state) => state.customShell !== undefined
|
||||||
);
|
);
|
||||||
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ export function TankopediaAntagonistControl({
|
|||||||
|
|
||||||
const antagonistUniqueGuns = useMemo(
|
const antagonistUniqueGuns = useMemo(
|
||||||
() => uniqueGuns(protagonist.tank.turrets),
|
() => uniqueGuns(protagonist.tank.turrets),
|
||||||
[protagonist.tank.turrets],
|
[protagonist.tank.turrets]
|
||||||
);
|
);
|
||||||
|
|
||||||
const isVisible = showControls && isDynamicArmorDisplay;
|
const isVisible = showControls && isDynamicArmorDisplay;
|
||||||
@@ -54,9 +53,7 @@ export function TankopediaAntagonistControl({
|
|||||||
<div className={styles["antagonist-control"]} data-visible={isVisible}>
|
<div className={styles["antagonist-control"]} data-visible={isVisible}>
|
||||||
<Text lowContrast>
|
<Text lowContrast>
|
||||||
{literals(strings.common.units.mm, {
|
{literals(strings.common.units.mm, {
|
||||||
value: (
|
value: penetration.toFixed(0),
|
||||||
antagonistCharacteristics.get("penetration") as number
|
|
||||||
).toFixed(0),
|
|
||||||
})}
|
})}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ import { Fragment, useRef } from "react";
|
|||||||
import { characteristicsGroups } from "../../config/characteristicsGroups";
|
import { characteristicsGroups } from "../../config/characteristicsGroups";
|
||||||
import { RANKING_STEPS } from "../../config/rankings";
|
import { RANKING_STEPS } from "../../config/rankings";
|
||||||
import { toys } from "../../config/toys";
|
import { toys } from "../../config/toys";
|
||||||
|
import { withErrorWrapper } from "../../hocs/withErrorWrapper";
|
||||||
|
import { withLocale } from "../../hocs/withLocale";
|
||||||
|
import { useCharacteristics } from "../../hooks/useCharacteristics";
|
||||||
import { useDuelModules } from "../../hooks/useDuelModules";
|
import { useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { useRankings } from "../../hooks/useRankings";
|
import { useRankings } from "../../hooks/useRankings";
|
||||||
|
import { api } from "../../api/dynamic";
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
import { Tankopedia, TankopediaRelativeAgainst } from "../../stores/tankopedia";
|
import { Tankopedia, TankopediaRelativeAgainst } from "../../stores/tankopedia";
|
||||||
import type { CharacteristicRank } from "../../tankopedia/calculateRankings";
|
import type { CharacteristicRank } from "../../tankopedia/calculateRankings";
|
||||||
@@ -24,13 +28,20 @@ import { CharacteristicValue } from "../CharacteristicValue";
|
|||||||
import { Text } from "../Text";
|
import { Text } from "../Text";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
|
const tanks = await api.tanks();
|
||||||
|
|
||||||
interface TankopediaCharacteristicsProps {
|
interface TankopediaCharacteristicsProps {
|
||||||
characteristics: ComputedCharacteristics;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TankopediaCharacteristics({
|
export const TankopediaCharacteristics = withErrorWrapper(
|
||||||
characteristics,
|
withLocale<TankopediaCharacteristicsProps>(Content)
|
||||||
}: TankopediaCharacteristicsProps) {
|
);
|
||||||
|
|
||||||
|
function Content({ id }: TankopediaCharacteristicsProps) {
|
||||||
|
Tankopedia.useInitialization(() => tanks.tanks[id]);
|
||||||
|
|
||||||
|
const characteristics = useCharacteristics("protagonist");
|
||||||
const rankings = useRankings(characteristics);
|
const rankings = useRankings(characteristics);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -56,7 +67,7 @@ type GroupItem = CharacteristicsGroup["order"][number];
|
|||||||
// A toy that needs a characteristic only shows for the tanks that have it
|
// A toy that needs a characteristic only shows for the tanks that have it
|
||||||
function hasToy(
|
function hasToy(
|
||||||
{ requires }: ToyRenderConfig,
|
{ requires }: ToyRenderConfig,
|
||||||
characteristics: ComputedCharacteristics,
|
characteristics: ComputedCharacteristics
|
||||||
) {
|
) {
|
||||||
return requires === undefined || characteristics.has(requires);
|
return requires === undefined || characteristics.has(requires);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
---
|
||||||
|
import { alias } from "@blitzkit/core";
|
||||||
|
import { unwrapper } from "@blitzkit/i18n";
|
||||||
|
import { api } from "../api/dynamic";
|
||||||
|
import { Heading } from "./Heading";
|
||||||
|
import { Text } from "./Text";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
id: number;
|
||||||
|
locale: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { id, locale } = Astro.props;
|
||||||
|
const [gameDefinitions, consumableDefinitions, provisionDefinitions, tanks] =
|
||||||
|
await Promise.all([
|
||||||
|
api.game(),
|
||||||
|
api.consumables(),
|
||||||
|
api.provisions(),
|
||||||
|
api.tanks(),
|
||||||
|
]);
|
||||||
|
const strings = await api.strings(locale);
|
||||||
|
const unwrap = unwrapper(locale);
|
||||||
|
const tank = tanks.tanks[id];
|
||||||
|
const roles = Object.entries(tank.roles);
|
||||||
|
---
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.tankopedia-game-mode-abilities {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-5);
|
||||||
|
padding: var(--space-4);
|
||||||
|
|
||||||
|
.cards {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
gap: var(--space-4);
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.card {
|
||||||
|
width: 16rem;
|
||||||
|
height: 20rem;
|
||||||
|
display: flex;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: var(--space-3);
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
|
||||||
|
.banner {
|
||||||
|
flex: 1;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
display: flex;
|
||||||
|
min-height: 6.125rem;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: var(--space-2);
|
||||||
|
padding: var(--space-3);
|
||||||
|
backdrop-filter: blur(4rem);
|
||||||
|
-webkit-backdrop-filter: blur(4rem);
|
||||||
|
|
||||||
|
.abilities {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
|
||||||
|
.ability {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-1);
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
width: 1.5em;
|
||||||
|
height: 1.5em;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
{
|
||||||
|
roles.length > 0 && (
|
||||||
|
<section class="tankopedia-game-mode-abilities">
|
||||||
|
<Heading size="3">{strings.tanks.game_modes.title}</Heading>
|
||||||
|
|
||||||
|
<div class="cards">
|
||||||
|
{roles.map(([id, value]) => {
|
||||||
|
const gameMode = gameDefinitions.gameModes[id];
|
||||||
|
const role = gameDefinitions.roles[value];
|
||||||
|
const banner = alias("api", `/gamemodes/${id}/banner.webp`);
|
||||||
|
const provisions = role.provisions.map((id) => ({
|
||||||
|
icon: alias("api", `/icons/provisions/${id}.webp`),
|
||||||
|
name: unwrap(provisionDefinitions.provisions[id].name!),
|
||||||
|
}));
|
||||||
|
const consumables = role.consumables.map((id) => ({
|
||||||
|
icon: alias("api", `/icons/consumables/${id}.webp`),
|
||||||
|
name: unwrap(consumableDefinitions.consumables[id].name!),
|
||||||
|
}));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<article
|
||||||
|
class="card"
|
||||||
|
style={{ backgroundImage: `url(${banner})` }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="banner"
|
||||||
|
style={{ backgroundImage: `url(${banner})` }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="info">
|
||||||
|
<Text size="major" weight="bold" align="center">
|
||||||
|
{unwrap(gameMode.name!)}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<div class="abilities">
|
||||||
|
{[...provisions, ...consumables].map(({ icon, name }) => (
|
||||||
|
<span class="ability">
|
||||||
|
<img class="icon" src={icon} alt={name} loading="lazy" />
|
||||||
|
<Text lowContrast>{name}</Text>
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
.section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-5);
|
|
||||||
padding: var(--space-4);
|
|
||||||
|
|
||||||
.cards {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
gap: var(--space-4);
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
.card {
|
|
||||||
width: 16rem;
|
|
||||||
height: 20rem;
|
|
||||||
display: flex;
|
|
||||||
flex: 0 0 auto;
|
|
||||||
flex-direction: column;
|
|
||||||
overflow: hidden;
|
|
||||||
border-radius: var(--space-3);
|
|
||||||
background-size: cover;
|
|
||||||
background-position: center;
|
|
||||||
|
|
||||||
.banner {
|
|
||||||
flex: 1;
|
|
||||||
background-size: cover;
|
|
||||||
background-position: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info {
|
|
||||||
display: flex;
|
|
||||||
min-height: 6.125rem;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: var(--space-2);
|
|
||||||
padding: var(--space-3);
|
|
||||||
backdrop-filter: blur(4rem);
|
|
||||||
-webkit-backdrop-filter: blur(4rem);
|
|
||||||
|
|
||||||
.abilities {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
|
|
||||||
.ability {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-1);
|
|
||||||
white-space: nowrap;
|
|
||||||
|
|
||||||
img {
|
|
||||||
width: 1.5em;
|
|
||||||
height: 1.5em;
|
|
||||||
object-fit: contain;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
import { alias } from "@blitzkit/core";
|
|
||||||
import { api } from "../../api/dynamic";
|
|
||||||
import { useDuelModules } from "../../hooks/useDuelModules";
|
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
|
||||||
import { useUnwrapper } from "../../hooks/useUnwrapper";
|
|
||||||
import { Heading } from "../Heading";
|
|
||||||
import { LazyImage } from "../LazyImage";
|
|
||||||
import { Text } from "../Text";
|
|
||||||
import styles from "./index.module.css";
|
|
||||||
|
|
||||||
const [gameDefinitions, consumableDefinitions, provisionDefinitions, tanks] =
|
|
||||||
await Promise.all([
|
|
||||||
api.game(),
|
|
||||||
api.consumables(),
|
|
||||||
api.provisions(),
|
|
||||||
api.tanks(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
export function TankopediaGameModeAbilities() {
|
|
||||||
const unwrap = useUnwrapper();
|
|
||||||
const strings = useStrings();
|
|
||||||
const protagonist = useDuelModules("protagonist");
|
|
||||||
const roles = Object.entries(protagonist.tank.roles);
|
|
||||||
|
|
||||||
if (roles.length === 0) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className={styles.section}>
|
|
||||||
<Heading size="3">{strings.tanks.game_modes.title}</Heading>
|
|
||||||
|
|
||||||
<div className={styles.cards}>
|
|
||||||
{roles.map(([id, value]) => {
|
|
||||||
const gameMode = gameDefinitions.gameModes[id];
|
|
||||||
const role = gameDefinitions.roles[value];
|
|
||||||
const banner = alias("api", `/gamemodes/${id}/banner.webp`);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<article
|
|
||||||
key={id}
|
|
||||||
className={styles.card}
|
|
||||||
style={{ backgroundImage: `url(${banner})` }}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={styles.banner}
|
|
||||||
style={{ backgroundImage: `url(${banner})` }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className={styles.info}>
|
|
||||||
<Text size="major" weight="bold" align="center">
|
|
||||||
{unwrap(gameMode.name!)}
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<div className={styles.abilities}>
|
|
||||||
{role.provisions.map((id) => {
|
|
||||||
const provisions = provisionDefinitions.provisions[id];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Ability
|
|
||||||
key={`provision-${id}`}
|
|
||||||
icon={alias("api", `/icons/provisions/${id}.webp`)}
|
|
||||||
name={unwrap(provisions.name!)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
{role.consumables.map((id) => {
|
|
||||||
const consumable = consumableDefinitions.consumables[id];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Ability
|
|
||||||
key={`consumable-${id}`}
|
|
||||||
icon={alias("api", `/icons/consumables/${id}.webp`)}
|
|
||||||
name={unwrap(consumable.name!)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Ability({ icon, name }: { icon: string; name: string }) {
|
|
||||||
return (
|
|
||||||
<Text lowContrast className={styles.ability}>
|
|
||||||
<LazyImage src={icon} alt={name} />
|
|
||||||
{name}
|
|
||||||
</Text>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
+1
-16
@@ -1,15 +1,3 @@
|
|||||||
.sandbox {
|
|
||||||
flex-grow: 1;
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-4);
|
|
||||||
|
|
||||||
@media (pointer: fine) {
|
|
||||||
padding-top: var(--space-4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.loadout {
|
.loadout {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -25,11 +13,8 @@
|
|||||||
|
|
||||||
padding: var(--space-5);
|
padding: var(--space-5);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
|
||||||
|
|
||||||
@media (pointer: coarse) {
|
@media (pointer: coarse) {
|
||||||
.sandbox,
|
|
||||||
.loadout {
|
|
||||||
&[data-tabbed="false"] {
|
&[data-tabbed="false"] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
import { MAX_SKILL_LEVEL } from "@blitzkit/core";
|
import { MAX_SKILL_LEVEL } from "@blitzkit/core";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
|
import { api } from "../../api/dynamic";
|
||||||
|
import { withErrorWrapper } from "../../hocs/withErrorWrapper";
|
||||||
|
import { withLocale } from "../../hocs/withLocale";
|
||||||
import { useDuelModules } from "../../hooks/useDuelModules";
|
import { useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia, TankopediaTab } from "../../stores/tankopedia";
|
||||||
import { selectModule } from "../../tankopedia/selectModule";
|
|
||||||
import { createAugments, toggleAugment } from "../../tankopedia/augments";
|
import { createAugments, toggleAugment } from "../../tankopedia/augments";
|
||||||
|
import { selectModule } from "../../tankopedia/selectModule";
|
||||||
|
import { LoadoutAugments } from "../LoadoutAugments";
|
||||||
import { LoadoutConsumables } from "../LoadoutConsumables";
|
import { LoadoutConsumables } from "../LoadoutConsumables";
|
||||||
import { LoadoutEquipment } from "../LoadoutEquipment";
|
import { LoadoutEquipment } from "../LoadoutEquipment";
|
||||||
import { LoadoutModules } from "../LoadoutModules";
|
import { LoadoutModules } from "../LoadoutModules";
|
||||||
@@ -11,11 +15,28 @@ import { LoadoutProvisions } from "../LoadoutProvisions";
|
|||||||
import { LoadoutShells } from "../LoadoutShells";
|
import { LoadoutShells } from "../LoadoutShells";
|
||||||
import { LoadoutSkills } from "../LoadoutSkills";
|
import { LoadoutSkills } from "../LoadoutSkills";
|
||||||
import { LoadoutStatus } from "../LoadoutStatus";
|
import { LoadoutStatus } from "../LoadoutStatus";
|
||||||
import { LoadoutAugments } from "../LoadoutAugments";
|
import { ScrollerOrientation } from "../Scroller";
|
||||||
|
import { ScrollerCurtains } from "../ScrollerCurtains";
|
||||||
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
|
const tanks = await api.tanks();
|
||||||
|
|
||||||
|
interface TankopediaLoadoutProps {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TankopediaLoadout = withErrorWrapper(
|
||||||
|
withLocale<TankopediaLoadoutProps>(Content),
|
||||||
|
);
|
||||||
|
|
||||||
|
function Content({ id }: TankopediaLoadoutProps) {
|
||||||
|
Tankopedia.useInitialization(() => tanks.tanks[id]);
|
||||||
|
|
||||||
|
const tabbed = Tankopedia.use((state) => state.tab === TankopediaTab.Loadout);
|
||||||
|
|
||||||
export function TankopediaLoadout() {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className={styles.loadout} data-tabbed={tabbed}>
|
||||||
|
<ScrollerCurtains orientation={ScrollerOrientation.Vertical} />
|
||||||
<Modules />
|
<Modules />
|
||||||
<Augments />
|
<Augments />
|
||||||
<Shells />
|
<Shells />
|
||||||
@@ -24,7 +45,7 @@ export function TankopediaLoadout() {
|
|||||||
<Consumables />
|
<Consumables />
|
||||||
<CrewSkills />
|
<CrewSkills />
|
||||||
<Status />
|
<Status />
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import type { QuicklimeEvent } from "quicklime";
|
import type { QuicklimeEvent } from "quicklime";
|
||||||
import { Suspense, useEffect, useRef } from "react";
|
import { Suspense, useEffect, useMemo, useRef } from "react";
|
||||||
|
import { api } from "../../api/dynamic";
|
||||||
|
import { defaultEqualizer } from "../../config/equalizer";
|
||||||
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";
|
||||||
|
import { withErrorWrapper } from "../../hocs/withErrorWrapper";
|
||||||
|
import { withLocale } from "../../hocs/withLocale";
|
||||||
|
import { useCharacteristics } from "../../hooks/useCharacteristics";
|
||||||
import { useDuelModels } from "../../hooks/useDuelModels";
|
import { useDuelModels } from "../../hooks/useDuelModels";
|
||||||
import { useDuelModules } from "../../hooks/useDuelModules";
|
import { useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { useEquipment } from "../../hooks/useEquipment";
|
import { useEquipment } from "../../hooks/useEquipment";
|
||||||
@@ -11,7 +16,6 @@ import { useMounted } from "../../hooks/useMounted";
|
|||||||
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 { ComputedCharacteristics } from "../../types/characteristics";
|
|
||||||
import { ArmorPlateDisplay } from "../ArmorPlateDisplay";
|
import { ArmorPlateDisplay } from "../ArmorPlateDisplay";
|
||||||
import { CanvasAutoClear } from "../CanvasAutoClear";
|
import { CanvasAutoClear } from "../CanvasAutoClear";
|
||||||
import { CanvasControl } from "../CanvasControl";
|
import { CanvasControl } from "../CanvasControl";
|
||||||
@@ -31,15 +35,22 @@ import { TankStaticArmor, type ThicknessRange } from "../TankStaticArmor";
|
|||||||
import { Thicknesses } from "../Thicknesses";
|
import { Thicknesses } from "../Thicknesses";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
interface TankSandboxProps {
|
const tanks = await api.tanks();
|
||||||
thicknessRange: ThicknessRange;
|
|
||||||
antagonistCharacteristics: ComputedCharacteristics;
|
interface TankopediaSandboxProps {
|
||||||
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TankopediaSandbox({
|
export const TankopediaSandbox = withErrorWrapper(
|
||||||
thicknessRange,
|
withLocale<TankopediaSandboxProps>(Sandbox)
|
||||||
antagonistCharacteristics,
|
);
|
||||||
}: TankSandboxProps) {
|
|
||||||
|
function Sandbox({ id }: TankopediaSandboxProps) {
|
||||||
|
const protagonistTank = tanks.tanks[id];
|
||||||
|
|
||||||
|
Tankopedia.useInitialization(() => protagonistTank);
|
||||||
|
|
||||||
|
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
||||||
const mounted = useMounted();
|
const mounted = useMounted();
|
||||||
const wrapper = useRef<HTMLDivElement>(null);
|
const wrapper = useRef<HTMLDivElement>(null);
|
||||||
const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122);
|
const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122);
|
||||||
@@ -50,6 +61,31 @@ export function TankopediaSandbox({
|
|||||||
const { turret, gun } = useDuelModels("protagonist");
|
const { turret, gun } = useDuelModels("protagonist");
|
||||||
const display = Tankopedia.use((state) => state.loaders.display.loaded);
|
const display = Tankopedia.use((state) => state.loaders.display.loaded);
|
||||||
|
|
||||||
|
const antagonistCharacteristics = useCharacteristics("antagonist");
|
||||||
|
const antagonistPenetration = antagonistCharacteristics.get(
|
||||||
|
"penetration"
|
||||||
|
) as number;
|
||||||
|
|
||||||
|
const thicknessRange = useMemo(() => {
|
||||||
|
const entries = Object.values(tanks.tanks);
|
||||||
|
const filtered = entries.filter(
|
||||||
|
(thisTank) => thisTank.tier === protagonistTank.tier
|
||||||
|
);
|
||||||
|
const value =
|
||||||
|
(filtered.reduce((accumulator, thisTank) => {
|
||||||
|
return (
|
||||||
|
accumulator +
|
||||||
|
thisTank.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near *
|
||||||
|
((equalize ? thisTank.equalizer : undefined) ?? defaultEqualizer)
|
||||||
|
.penetration
|
||||||
|
);
|
||||||
|
}, 0) /
|
||||||
|
filtered.length) *
|
||||||
|
(3 / 4);
|
||||||
|
|
||||||
|
return { value } satisfies ThicknessRange;
|
||||||
|
}, [equalize]);
|
||||||
|
|
||||||
function handlePointerDown() {
|
function handlePointerDown() {
|
||||||
window.addEventListener("pointermove", handlePointerMove);
|
window.addEventListener("pointermove", handlePointerMove);
|
||||||
window.addEventListener("pointerup", handlePointerUp);
|
window.addEventListener("pointerup", handlePointerUp);
|
||||||
@@ -74,7 +110,7 @@ export function TankopediaSandbox({
|
|||||||
gun.pitch!,
|
gun.pitch!,
|
||||||
turret.yaw,
|
turret.yaw,
|
||||||
hasImprovedVerticalStabilizer,
|
hasImprovedVerticalStabilizer,
|
||||||
hasDownImprovedVerticalStabilizer,
|
hasDownImprovedVerticalStabilizer
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
@@ -88,7 +124,7 @@ export function TankopediaSandbox({
|
|||||||
0,
|
0,
|
||||||
gun.pitch!,
|
gun.pitch!,
|
||||||
turret.yaw,
|
turret.yaw,
|
||||||
hasImprovedVerticalStabilizer,
|
hasImprovedVerticalStabilizer
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
@@ -102,7 +138,7 @@ export function TankopediaSandbox({
|
|||||||
0,
|
0,
|
||||||
gun.pitch!,
|
gun.pitch!,
|
||||||
turret.yaw,
|
turret.yaw,
|
||||||
hasImprovedVerticalStabilizer,
|
hasImprovedVerticalStabilizer
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
@@ -130,7 +166,7 @@ export function TankopediaSandbox({
|
|||||||
modelTransformEvent.last!.yaw,
|
modelTransformEvent.last!.yaw,
|
||||||
gun.pitch!,
|
gun.pitch!,
|
||||||
turret.yaw,
|
turret.yaw,
|
||||||
hasImprovedVerticalStabilizer,
|
hasImprovedVerticalStabilizer
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
@@ -176,9 +212,7 @@ export function TankopediaSandbox({
|
|||||||
<TankopediaSkinSwitcher />
|
<TankopediaSkinSwitcher />
|
||||||
<TankopediaQuickInputs />
|
<TankopediaQuickInputs />
|
||||||
<Thicknesses thicknessRange={thicknessRange} />
|
<Thicknesses thicknessRange={thicknessRange} />
|
||||||
<TankopediaAntagonistControl
|
<TankopediaAntagonistControl penetration={antagonistPenetration} />
|
||||||
antagonistCharacteristics={antagonistCharacteristics}
|
|
||||||
/>
|
|
||||||
<TankopediaOptions />
|
<TankopediaOptions />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -194,7 +228,7 @@ function Content({ thicknessRange }: { thicknessRange: ThicknessRange }) {
|
|||||||
// this causes a re-render of the ENTIRE thing, maybe move this elsewhere?
|
// this causes a re-render of the ENTIRE thing, maybe move this elsewhere?
|
||||||
const revealed = Tankopedia.use((state) => state.revealed);
|
const revealed = Tankopedia.use((state) => state.revealed);
|
||||||
const hideTankModelUnderArmor = TankopediaPersistent.use(
|
const hideTankModelUnderArmor = TankopediaPersistent.use(
|
||||||
(state) => state.hideTankModelUnderArmor,
|
(state) => state.hideTankModelUnderArmor
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,8 +1,23 @@
|
|||||||
|
import { api } from "../../api/dynamic";
|
||||||
|
import { withErrorWrapper } from "../../hocs/withErrorWrapper";
|
||||||
|
import { withLocale } from "../../hocs/withLocale";
|
||||||
import { Tankopedia, TankopediaTab } from "../../stores/tankopedia";
|
import { Tankopedia, TankopediaTab } from "../../stores/tankopedia";
|
||||||
import { SegmentedControl } from "../SegmentedControl";
|
import { SegmentedControl } from "../SegmentedControl";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
export function TankopediaTabs() {
|
const tanks = await api.tanks();
|
||||||
|
|
||||||
|
interface TankopediaTabsProps {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TankopediaTabs = withErrorWrapper(
|
||||||
|
withLocale<TankopediaTabsProps>(Content)
|
||||||
|
);
|
||||||
|
|
||||||
|
function Content({ id }: TankopediaTabsProps) {
|
||||||
|
Tankopedia.useInitialization(() => tanks.tanks[id]);
|
||||||
|
|
||||||
const tab = Tankopedia.use((state) => state.tab);
|
const tab = Tankopedia.use((state) => state.tab);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
import { unwrapper } from "@blitzkit/i18n";
|
||||||
|
import { api } from "../api/dynamic";
|
||||||
|
import { Heading } from "./Heading";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
id: number;
|
||||||
|
locale: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { id, locale } = Astro.props;
|
||||||
|
const tanks = await api.tanks();
|
||||||
|
const tank = tanks.tanks[id];
|
||||||
|
const unwrap = unwrapper(locale);
|
||||||
|
---
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.tankopedia-title {
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: var(--space-4);
|
||||||
|
|
||||||
|
background: linear-gradient(90deg, var(--gray-1), transparent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="tankopedia-title"
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(/media/national-wallpapers/${tank.nation}.jpg)`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="content">
|
||||||
|
<Heading size="3">{unwrap(tank.name)}</Heading>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
.wrapper {
|
|
||||||
background-size: cover;
|
|
||||||
background-position: center;
|
|
||||||
|
|
||||||
.content {
|
|
||||||
padding: var(--space-4);
|
|
||||||
|
|
||||||
background: linear-gradient(90deg, var(--gray-1), transparent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import { useDuelModules } from "../../hooks/useDuelModules";
|
|
||||||
import { useUnwrapper } from "../../hooks/useUnwrapper";
|
|
||||||
import { Heading } from "../Heading";
|
|
||||||
import styles from "./index.module.css";
|
|
||||||
|
|
||||||
export function TankopediaTitle() {
|
|
||||||
const unwrap = useUnwrapper();
|
|
||||||
|
|
||||||
const protagonist = useDuelModules("protagonist");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={styles.wrapper}
|
|
||||||
style={{
|
|
||||||
backgroundImage: `url(/media/national-wallpapers/${protagonist.tank.nation}.jpg)`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className={styles.content}>
|
|
||||||
<Heading size="3">{unwrap(protagonist.tank.name)}</Heading>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
---
|
||||||
|
import { youtubers } from "@blitzkit/core";
|
||||||
|
import { api } from "../api/dynamic";
|
||||||
|
import { awaitableReviews } from "../core/awaitables/reviews";
|
||||||
|
import { Heading } from "./Heading";
|
||||||
|
import { Text } from "./Text";
|
||||||
|
import { VerifiedIcon } from "./VerifiedIcon";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
id: number;
|
||||||
|
locale: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { id, locale } = Astro.props;
|
||||||
|
const reviews = await awaitableReviews;
|
||||||
|
const strings = await api.strings(locale);
|
||||||
|
const videos = reviews.reviews[id]?.videos ?? [];
|
||||||
|
---
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.tankopedia-videos {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-5);
|
||||||
|
padding: var(--space-4);
|
||||||
|
|
||||||
|
.cards {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
gap: var(--space-4);
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.card {
|
||||||
|
display: flex;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: var(--space-3);
|
||||||
|
background-size: cover;
|
||||||
|
background-position: 0 18px;
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
.thumbnail {
|
||||||
|
width: 16rem;
|
||||||
|
aspect-ratio: 16 / 9;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: var(--space-1);
|
||||||
|
padding: var(--space-3);
|
||||||
|
backdrop-filter: blur(4rem);
|
||||||
|
-webkit-backdrop-filter: blur(4rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover .info {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
{
|
||||||
|
videos.length > 0 && (
|
||||||
|
<section class="tankopedia-videos">
|
||||||
|
<Heading size="3">{strings.tanks.videos.title}</Heading>
|
||||||
|
|
||||||
|
<div class="cards">
|
||||||
|
{videos.map((video) => {
|
||||||
|
const image = `https://i.ytimg.com/vi/${video.id}/hqdefault.jpg`;
|
||||||
|
const youtuber = youtubers.find(
|
||||||
|
(youtuber) => youtuber.id === video.author,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!youtuber) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
class="card"
|
||||||
|
style={{ backgroundImage: `url(${image})` }}
|
||||||
|
href={`https://www.youtube.com/watch?v=${video.id}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="thumbnail"
|
||||||
|
style={{ backgroundImage: `url(${image})` }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="info">
|
||||||
|
<Text>{youtuber.name}</Text>
|
||||||
|
<VerifiedIcon width="1em" height="1em" />
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
.section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-5);
|
|
||||||
padding: var(--space-4);
|
|
||||||
|
|
||||||
.cards {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
gap: var(--space-4);
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
.card {
|
|
||||||
display: flex;
|
|
||||||
flex: 0 0 auto;
|
|
||||||
flex-direction: column;
|
|
||||||
overflow: hidden;
|
|
||||||
border-radius: var(--space-3);
|
|
||||||
background-size: cover;
|
|
||||||
background-position: 0 18px;
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: none;
|
|
||||||
|
|
||||||
.thumbnail {
|
|
||||||
width: 16rem;
|
|
||||||
aspect-ratio: 16 / 9;
|
|
||||||
background-size: cover;
|
|
||||||
background-position: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: var(--space-1);
|
|
||||||
padding: var(--space-3);
|
|
||||||
backdrop-filter: blur(4rem);
|
|
||||||
-webkit-backdrop-filter: blur(4rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover .info {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
import { youtubers } from "@blitzkit/core";
|
|
||||||
import { awaitableReviews } from "../../core/awaitables/reviews";
|
|
||||||
import { useDuelModules } from "../../hooks/useDuelModules";
|
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
|
||||||
import { Heading } from "../Heading";
|
|
||||||
import { Text } from "../Text";
|
|
||||||
import { VerifiedIcon } from "../VerifiedIcon";
|
|
||||||
import styles from "./index.module.css";
|
|
||||||
|
|
||||||
const reviews = await awaitableReviews;
|
|
||||||
|
|
||||||
export function TankopediaVideos() {
|
|
||||||
const strings = useStrings();
|
|
||||||
const protagonist = useDuelModules("protagonist");
|
|
||||||
const videos = reviews.reviews[protagonist.tank.id]?.videos;
|
|
||||||
|
|
||||||
if (videos === undefined || videos.length === 0) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className={styles.section}>
|
|
||||||
<Heading size="3">{strings.tanks.videos.title}</Heading>
|
|
||||||
|
|
||||||
<div className={styles.cards}>
|
|
||||||
{videos.map((video) => {
|
|
||||||
const image = `https://i.ytimg.com/vi/${video.id}/hqdefault.jpg`;
|
|
||||||
const youtuber = youtubers.find(
|
|
||||||
(youtuber) => youtuber.id === video.author,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!youtuber) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<a
|
|
||||||
key={video.id}
|
|
||||||
className={styles.card}
|
|
||||||
style={{ backgroundImage: `url(${image})` }}
|
|
||||||
href={`https://www.youtube.com/watch?v=${video.id}`}
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={styles.thumbnail}
|
|
||||||
style={{ backgroundImage: `url(${image})` }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className={styles.info}>
|
|
||||||
<Text>{youtuber.name}</Text>
|
|
||||||
<VerifiedIcon width="1em" height="1em" />
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
import { useMemo } from "react";
|
|
||||||
import { api } from "../../../../../api/dynamic";
|
|
||||||
import { ScrollerOrientation } from "../../../../../components/Scroller";
|
|
||||||
import { ScrollerCurtains } from "../../../../../components/ScrollerCurtains";
|
|
||||||
import type { ThicknessRange } from "../../../../../components/TankStaticArmor";
|
|
||||||
import { TankopediaCharacteristics } from "../../../../../components/TankopediaCharacteristics";
|
|
||||||
import { TankopediaGameModeAbilities } from "../../../../../components/TankopediaGameModeAbilities";
|
|
||||||
import { TankopediaLoadout } from "../../../../../components/TankopediaLoadout";
|
|
||||||
import { TankopediaSandbox } from "../../../../../components/TankopediaSandbox";
|
|
||||||
import { TankopediaTabs } from "../../../../../components/TankopediaTabs";
|
|
||||||
import { TankopediaTitle } from "../../../../../components/TankopediaTitle";
|
|
||||||
import { TankopediaVideos } from "../../../../../components/TankopediaVideos";
|
|
||||||
import { defaultEqualizer } from "../../../../../config/equalizer";
|
|
||||||
import { withErrorWrapper } from "../../../../../hocs/withErrorWrapper";
|
|
||||||
import { withLocale } from "../../../../../hocs/withLocale";
|
|
||||||
import { useCharacteristics } from "../../../../../hooks/useCharacteristics";
|
|
||||||
import { Tankopedia, TankopediaTab } from "../../../../../stores/tankopedia";
|
|
||||||
import styles from "./_index.module.css";
|
|
||||||
|
|
||||||
interface TankProps {
|
|
||||||
id: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const tanks = await api.tanks();
|
|
||||||
|
|
||||||
export const Sandbox = withErrorWrapper(
|
|
||||||
withLocale<TankProps>(({ id }) => {
|
|
||||||
const protagonistTank = tanks.tanks[id];
|
|
||||||
|
|
||||||
Tankopedia.useInitialization(() => protagonistTank);
|
|
||||||
|
|
||||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
|
||||||
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
|
||||||
|
|
||||||
const characteristics = useCharacteristics("protagonist");
|
|
||||||
const antagonistCharacteristics = useCharacteristics("antagonist");
|
|
||||||
|
|
||||||
const thicknessRange = useMemo(() => {
|
|
||||||
const entries = Object.values(tanks.tanks);
|
|
||||||
const filtered = entries.filter(
|
|
||||||
(thisTank) => thisTank.tier === protagonistTank.tier,
|
|
||||||
);
|
|
||||||
const value =
|
|
||||||
(filtered.reduce((accumulator, thisTank) => {
|
|
||||||
return (
|
|
||||||
accumulator +
|
|
||||||
thisTank.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near *
|
|
||||||
((equalize ? thisTank.equalizer : undefined) ?? defaultEqualizer)
|
|
||||||
.penetration
|
|
||||||
);
|
|
||||||
}, 0) /
|
|
||||||
filtered.length) *
|
|
||||||
(3 / 4);
|
|
||||||
|
|
||||||
return { value } satisfies ThicknessRange;
|
|
||||||
}, [protagonist, equalize]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.sandbox}>
|
|
||||||
<TankopediaTitle />
|
|
||||||
<TankopediaSandbox
|
|
||||||
antagonistCharacteristics={antagonistCharacteristics}
|
|
||||||
thicknessRange={thicknessRange}
|
|
||||||
/>
|
|
||||||
<TankopediaCharacteristics characteristics={characteristics} />
|
|
||||||
<TankopediaGameModeAbilities />
|
|
||||||
<TankopediaVideos />
|
|
||||||
<TankopediaTabs />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
export const Loadout = withErrorWrapper(
|
|
||||||
withLocale<TankProps>(({ id }) => {
|
|
||||||
Tankopedia.useInitialization(() => tanks.tanks[id]);
|
|
||||||
|
|
||||||
const tabbed = Tankopedia.use(
|
|
||||||
(state) => state.tab === TankopediaTab.Loadout,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.loadout} data-tabbed={tabbed}>
|
|
||||||
<ScrollerCurtains orientation={ScrollerOrientation.Vertical} />
|
|
||||||
<TankopediaLoadout />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
@@ -3,10 +3,16 @@ import { api } from "../../../../../api/dynamic";
|
|||||||
import { mixStaticPaths } from "../../../../../astro/mixStaticPaths";
|
import { mixStaticPaths } from "../../../../../astro/mixStaticPaths";
|
||||||
import ColorRanks from "../../../../../components/ColorRanks.astro";
|
import ColorRanks from "../../../../../components/ColorRanks.astro";
|
||||||
import ColorScale from "../../../../../components/ColorScale.astro";
|
import ColorScale from "../../../../../components/ColorScale.astro";
|
||||||
|
import { TankopediaCharacteristics } from "../../../../../components/TankopediaCharacteristics";
|
||||||
|
import TankopediaGameModeAbilities from "../../../../../components/TankopediaGameModeAbilities.astro";
|
||||||
|
import { TankopediaLoadout } from "../../../../../components/TankopediaLoadout";
|
||||||
|
import { TankopediaSandbox } from "../../../../../components/TankopediaSandbox";
|
||||||
|
import { TankopediaTabs } from "../../../../../components/TankopediaTabs";
|
||||||
|
import TankopediaTitle from "../../../../../components/TankopediaTitle.astro";
|
||||||
|
import TankopediaVideos from "../../../../../components/TankopediaVideos.astro";
|
||||||
import { tools } from "../../../../../config/tools";
|
import { tools } from "../../../../../config/tools";
|
||||||
import BaseLayout from "../../../../../layouts/BaseLayout.astro";
|
import BaseLayout from "../../../../../layouts/BaseLayout.astro";
|
||||||
import { getStaticPaths as _getStaticPaths } from "../index.astro";
|
import { getStaticPaths as _getStaticPaths } from "../index.astro";
|
||||||
import { Loadout, Sandbox } from "./_index";
|
|
||||||
|
|
||||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||||
const tanks = await api.tanks();
|
const tanks = await api.tanks();
|
||||||
@@ -31,12 +37,32 @@ const { id, locale } = Astro.props;
|
|||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
gap: var(--space-4);
|
gap: var(--space-4);
|
||||||
|
|
||||||
|
.sandbox {
|
||||||
|
flex-grow: 1;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-4);
|
||||||
|
|
||||||
|
@media (pointer: fine) {
|
||||||
|
padding-top: var(--space-4);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<BaseLayout tool={tools.tanks} {locale} accent="violet">
|
<BaseLayout tool={tools.tanks} {locale} accent="violet">
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<Sandbox {id} {locale} client:load />
|
<div class="sandbox">
|
||||||
<Loadout {id} {locale} client:load />
|
<TankopediaTitle {id} {locale} />
|
||||||
|
<TankopediaSandbox {id} {locale} client:load />
|
||||||
|
<TankopediaCharacteristics {id} {locale} client:load />
|
||||||
|
<TankopediaGameModeAbilities {id} {locale} />
|
||||||
|
<TankopediaVideos {id} {locale} />
|
||||||
|
<TankopediaTabs {id} {locale} client:load />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TankopediaLoadout {id} {locale} client:load />
|
||||||
</div>
|
</div>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
Reference in new issue
Block a user