mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 12:24:55 +01:00
migrate mixer
This commit is contained in:
49 files changed
+659
-859
No files matched your search
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: commit-message
|
||||
description: Read the git diff and write a commit message in the repo's existing style. Use when the user asks for a commit message or runs /commit-message. Only prints the message; never stages, commits, or pushes.
|
||||
disable-model-invocation: true
|
||||
allowed-tools: Bash(git diff:*), Bash(git log:*), Bash(git status:*)
|
||||
---
|
||||
|
||||
# Commit message
|
||||
|
||||
Write a commit message for the current changes. Do not stage, commit, or push anything; the user does that themselves.
|
||||
|
||||
## Context
|
||||
|
||||
- Recent commits: !`git log --format=%s -20`
|
||||
- Staged stat: !`git diff --cached --stat`
|
||||
- Unstaged stat: !`git diff --stat`
|
||||
|
||||
## Steps
|
||||
|
||||
1. Use the staged diff (`git diff --cached`) if anything is staged; otherwise use the unstaged diff (`git diff`). Read the actual hunks for anything the stat doesn't explain. Skim large deletions and pure-formatting churn rather than reading them line by line.
|
||||
2. Find the one main thing the change does. Renames, moves into the flat `Name/index.tsx` layout, CSS tweaks, and formatting churn are usually side effects of that, not separate items.
|
||||
3. Match the style of the recent commits: one line, all lowercase, no trailing period, no conventional-commit prefix, no body, usually 2–6 words (e.g. `migrate 404 page`, `no internal css`, `fix embed redirector`).
|
||||
4. Reply with only the message in a code block. No preamble, no summary, no bullet list, no suggestions.
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"language_servers": ["!eslint", "..."]
|
||||
}
|
||||
@@ -127,35 +127,35 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
.then((files) => files.filter((nation) => nation !== "common"));
|
||||
|
||||
this.optionalDevices = await this.vfs.xml<{ root: OptionalDevices }>(
|
||||
"Data/XML/item_defs/vehicles/common/optional_devices.xml",
|
||||
"Data/XML/item_defs/vehicles/common/optional_devices.xml"
|
||||
);
|
||||
this.optionalDeviceSlots = await this.vfs.xml<{
|
||||
root: OptionalDeviceSlots;
|
||||
}>("Data/XML/item_defs/vehicles/common/optional_device_slots.xml");
|
||||
this.tankmenAvatar = await this.vfs.xml<{ root: TankmenAvatar }>(
|
||||
"Data/XML/item_defs/tankmen/avatar.xml",
|
||||
"Data/XML/item_defs/tankmen/avatar.xml"
|
||||
);
|
||||
this.mapsYaml = await this.vfs.yaml<MapsYaml>("Data/maps.yaml");
|
||||
this.camouflagesXml = await this.vfs.xml<{ root: CamouflagesXml }>(
|
||||
"Data/XML/item_defs/vehicles/common/camouflages.xml",
|
||||
"Data/XML/item_defs/vehicles/common/camouflages.xml"
|
||||
);
|
||||
this.camouflagesYaml = await this.vfs.yaml<CamouflagesYaml>(
|
||||
"Data/camouflages.yaml",
|
||||
"Data/camouflages.yaml"
|
||||
);
|
||||
this.squadBattleTypeStyles = await this.vfs.yaml<SquadBattleTypeStylesYaml>(
|
||||
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`,
|
||||
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`
|
||||
);
|
||||
this.gameTypeSelectorStyles =
|
||||
await this.vfs.yaml<SquadBattleTypeStylesYaml>(
|
||||
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`,
|
||||
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`
|
||||
);
|
||||
this.combatRoles = await this.vfs.yaml<CombatRolesYaml>(
|
||||
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`,
|
||||
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`
|
||||
);
|
||||
this.tierEqualizer = await this.vfs.csv(
|
||||
// spell:disable-next-line
|
||||
`Data/XML/item_defs/vehicles/common/tier_equializer.csv`,
|
||||
{ delimiter: ";" },
|
||||
{ delimiter: ";" }
|
||||
);
|
||||
|
||||
this.version = (await this.vfs.text("Data/version.txt")).split(" ")[0];
|
||||
@@ -163,46 +163,49 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
console.log("Fetching game localizations...");
|
||||
|
||||
await Promise.all(
|
||||
locales.supported.map(async ({ locale }) => {
|
||||
locales.supported.map(async (supported) => {
|
||||
const root = `../../temp/game-strings/${this.version}`;
|
||||
const cachePath = `${root}/${locale}.json`;
|
||||
const cachePath = `${root}/${supported.locale}.json`;
|
||||
|
||||
if (existsSync(cachePath)) {
|
||||
console.log(` Cache hit for ${locale}`);
|
||||
console.log(` Cache hit for ${supported.locale}`);
|
||||
|
||||
const content = await readFile(cachePath, "utf-8");
|
||||
this.stringsI18n[locale] = JSON.parse(content) as BlitzStrings;
|
||||
this.stringsI18n[supported.locale] = JSON.parse(
|
||||
content
|
||||
) as BlitzStrings;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(` Cache miss for ${locale} (this will take a while...)`);
|
||||
console.log(
|
||||
` Cache miss for ${supported.locale} (this will take a while...)`
|
||||
);
|
||||
|
||||
const blitzLocale = locales.supported.find(
|
||||
(l) => l.locale === locale,
|
||||
)!.variant_blitz_local;
|
||||
const localLocale = supported.variant_blitz_local ?? supported.locale;
|
||||
const cdnLocale = supported.variant_blitz_cdn ?? supported.locale;
|
||||
const networkStrings = (await fetch(
|
||||
`https://stufficons.wgcdn.co/localizations/${blitzLocale}.yaml`,
|
||||
`https://stufficons.wgcdn.co/localizations/${cdnLocale}.yaml`
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then(parseYaml)) as BlitzStrings;
|
||||
const localStrings = await this.vfs.yaml<BlitzStrings>(
|
||||
`Data/Strings/${blitzLocale}.yaml`,
|
||||
`Data/Strings/${localLocale}.yaml`
|
||||
);
|
||||
const combined = { ...networkStrings, ...localStrings };
|
||||
|
||||
await mkdir(root, { recursive: true });
|
||||
await writeFile(cachePath, JSON.stringify(combined));
|
||||
|
||||
this.stringsI18n[locale] = combined;
|
||||
}),
|
||||
this.stringsI18n[supported.locale] = combined;
|
||||
})
|
||||
);
|
||||
|
||||
console.log("Fetching consumable and provision data...");
|
||||
|
||||
for (const match of (
|
||||
await this.vfs.text(
|
||||
`Data/XML/item_defs/vehicles/common/consumables/list.xml`,
|
||||
`Data/XML/item_defs/vehicles/common/consumables/list.xml`
|
||||
)
|
||||
).matchAll(/<items path="(.+)\.xml"\/>/g)) {
|
||||
if (match[1] === "prototypes") continue;
|
||||
@@ -211,15 +214,15 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
this.consumablesCommon,
|
||||
(
|
||||
await this.vfs.xml<{ root: ConsumablesCommon }>(
|
||||
`Data/XML/item_defs/vehicles/common/consumables/${match[1]}.xml`,
|
||||
`Data/XML/item_defs/vehicles/common/consumables/${match[1]}.xml`
|
||||
)
|
||||
).root,
|
||||
).root
|
||||
);
|
||||
}
|
||||
|
||||
for (const match of (
|
||||
await this.vfs.text(
|
||||
`Data/XML/item_defs/vehicles/common/provisions/list.xml`,
|
||||
`Data/XML/item_defs/vehicles/common/provisions/list.xml`
|
||||
)
|
||||
).matchAll(/<items path="(.+)\.xml"\/>/g)) {
|
||||
if (match[1] === "prototypes") continue;
|
||||
@@ -228,15 +231,15 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
this.provisionsCommon,
|
||||
(
|
||||
await this.vfs.xml<{ root: ConsumablesCommon }>(
|
||||
`Data/XML/item_defs/vehicles/common/provisions/${match[1]}.xml`,
|
||||
`Data/XML/item_defs/vehicles/common/provisions/${match[1]}.xml`
|
||||
)
|
||||
).root,
|
||||
).root
|
||||
);
|
||||
}
|
||||
|
||||
for (const nation of this.nationsDir!) {
|
||||
const tankList = await this.vfs.xml<{ root: VehicleDefinitionList }>(
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`
|
||||
);
|
||||
|
||||
for (const tankKey in tankList.root) {
|
||||
@@ -255,7 +258,7 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
protected getTankFilterIds(
|
||||
name: string,
|
||||
definitionKey: string,
|
||||
filter: "include" | "exclude",
|
||||
filter: "include" | "exclude"
|
||||
) {
|
||||
const keys = name.trim().split(/\s+/).filter(Boolean);
|
||||
|
||||
@@ -264,7 +267,7 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
||||
|
||||
if (id === undefined) {
|
||||
console.warn(
|
||||
`Skipping unavailable tank "${key}" in ${filter} vehicle filter for "${definitionKey}"`,
|
||||
`Skipping unavailable tank "${key}" in ${filter} vehicle filter for "${definitionKey}"`
|
||||
);
|
||||
return [];
|
||||
}
|
||||
@@ -301,7 +304,7 @@ export function Cache(disableInDev = false) {
|
||||
const cache = new WeakMap<object, Map<string, Promise<unknown>>>();
|
||||
|
||||
return function <This, Arguments extends any[], Return>(
|
||||
target: (this: This, ...args: Arguments) => Promise<Return>,
|
||||
target: (this: This, ...args: Arguments) => Promise<Return>
|
||||
// TODO: evaluate if we need context to make the error trace easier
|
||||
// context: ClassMethodDecoratorContext<
|
||||
// This,
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
"settings": "Settings"
|
||||
},
|
||||
|
||||
"mixer": {
|
||||
"screenshot": "Screenshot",
|
||||
"randomize": "Randomize"
|
||||
},
|
||||
|
||||
"guesser": {
|
||||
"help": {
|
||||
"title": "Partially reveal tank?",
|
||||
@@ -545,6 +550,14 @@
|
||||
"common": {
|
||||
"name": "BlitzKit",
|
||||
|
||||
"screenshot": {
|
||||
"title": "Screenshot",
|
||||
"description": "Screenshot the tank with a transparent background.",
|
||||
"cancel": "Cancel",
|
||||
"download": "Download",
|
||||
"copy": "Copy"
|
||||
},
|
||||
|
||||
"search": {
|
||||
"hint_players": "Search players...",
|
||||
"hint_tanks": "Search tanks...",
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
gap: var(--space-4);
|
||||
|
||||
box-sizing: border-box;
|
||||
width: calc(100dvw - 2 * var(--space-4));
|
||||
max-width: 40rem;
|
||||
max-width: min(40rem, calc(100dvw - 2 * var(--space-4)));
|
||||
max-height: calc(100dvh - 2 * var(--space-4));
|
||||
padding: var(--space-4);
|
||||
overflow: hidden;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.progress {
|
||||
width: 10rem;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Html } from "@react-three/drei";
|
||||
import { useStableProgress } from "../../hooks/useStableProgress";
|
||||
import { Progress } from "../Progress";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export function MixerFallback() {
|
||||
const progress = useStableProgress();
|
||||
|
||||
return (
|
||||
<Html center>
|
||||
<Progress className={styles.progress} value={progress} />
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
+28
-23
@@ -2,19 +2,20 @@ import { useThree, type ThreeEvent } from "@react-three/fiber";
|
||||
import type { QuicklimeEvent } from "quicklime";
|
||||
import { useCallback, useEffect, useRef } from "react";
|
||||
import { Group, Vector2 } from "three";
|
||||
import { api } from "../../../api/dynamic";
|
||||
import { jsxTree } from "../../../core/blitzkit/jsxTree";
|
||||
import { api } from "../../api/dynamic";
|
||||
import { jsxTree } from "../../core/blitzkit/jsxTree";
|
||||
import {
|
||||
modelTransformEvent,
|
||||
type ModelTransformEventData,
|
||||
} from "../../../core/blitzkit/modelTransform";
|
||||
import { controlsEnabledEvent } from "../../../core/controlsEnabled";
|
||||
import { useModel } from "../../../hooks/useModel";
|
||||
import { Mixer } from "../../../stores/mixer";
|
||||
} from "../../core/blitzkit/modelTransform";
|
||||
import { controlsEnabledEvent } from "../../core/controlsEnabled";
|
||||
import { useModel } from "../../hooks/useModel";
|
||||
import { Mixer } from "../../stores/mixer";
|
||||
|
||||
const modelDefinitions = await api.models();
|
||||
|
||||
export function Model() {
|
||||
// TODO: combine this and others with tank model or at least find a mutual way to handle tank assembly
|
||||
export function MixerModel() {
|
||||
const canvas = useThree((state) => state.gl.domElement);
|
||||
|
||||
const turretGroup = useRef<Group>(null!);
|
||||
@@ -86,7 +87,7 @@ export function Model() {
|
||||
function handleModelTransform(
|
||||
event: QuicklimeEvent<ModelTransformEventData>,
|
||||
) {
|
||||
turretGroup.current.rotation.z = event.data.yaw;
|
||||
turretGroup.current.rotation.y = event.data.yaw;
|
||||
gunGroup.current.rotation.x = event.data.pitch;
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ export function Model() {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<group rotation={[-Math.PI / 2, 0, 0]}>
|
||||
<>
|
||||
{hullNodes.map((node) => {
|
||||
const isHull = node.name === "hull";
|
||||
const isWheel = node.name.startsWith("chassis_wheel_");
|
||||
@@ -116,18 +117,18 @@ export function Model() {
|
||||
|
||||
<group
|
||||
ref={turretGroup}
|
||||
rotation={[0, 0, modelTransformEvent.last!.yaw]}
|
||||
rotation={[0, modelTransformEvent.last!.yaw, 0]}
|
||||
position={[
|
||||
tankModel.turret_origin!.x + trackModel.origin!.x,
|
||||
tankModel.turret_origin!.z + trackModel.origin!.z,
|
||||
tankModel.turret_origin!.y + trackModel.origin!.y,
|
||||
tankModel.turret_origin!.z + trackModel.origin!.z,
|
||||
]}
|
||||
>
|
||||
<group
|
||||
position={[
|
||||
-turretTankModel.turret_origin!.x - turretTrackModel.origin!.x,
|
||||
-turretTankModel.turret_origin!.z - turretTrackModel.origin!.z,
|
||||
-turretTankModel.turret_origin!.y - turretTrackModel.origin!.y,
|
||||
-turretTankModel.turret_origin!.z - turretTrackModel.origin!.z,
|
||||
]}
|
||||
>
|
||||
{turretNodes.map((node) => {
|
||||
@@ -163,12 +164,12 @@ export function Model() {
|
||||
turretTankModel.turret_origin!.x +
|
||||
turretTrackModel.origin!.x +
|
||||
turretModel.gun_origin!.x,
|
||||
turretTankModel.turret_origin!.z +
|
||||
turretTrackModel.origin!.z +
|
||||
turretModel.gun_origin!.z,
|
||||
turretTankModel.turret_origin!.y +
|
||||
turretTrackModel.origin!.y +
|
||||
turretModel.gun_origin!.y,
|
||||
turretTankModel.turret_origin!.z +
|
||||
turretTrackModel.origin!.z +
|
||||
turretModel.gun_origin!.z,
|
||||
]}
|
||||
>
|
||||
<group
|
||||
@@ -176,18 +177,22 @@ export function Model() {
|
||||
-turretTankModel.turret_origin!.x -
|
||||
turretTrackModel.origin!.x -
|
||||
turretModel.gun_origin!.x,
|
||||
-turretTankModel.turret_origin!.z -
|
||||
turretTrackModel.origin!.z -
|
||||
turretModel.gun_origin!.z,
|
||||
-turretTankModel.turret_origin!.y -
|
||||
turretTrackModel.origin!.y -
|
||||
turretModel.gun_origin!.y,
|
||||
-turretTankModel.turret_origin!.z -
|
||||
turretTrackModel.origin!.z -
|
||||
turretModel.gun_origin!.z,
|
||||
]}
|
||||
>
|
||||
{turretNodes.map((node) => {
|
||||
const isCurrentMantlet =
|
||||
node.name ===
|
||||
`gun_${turretModel.guns[turret.turret.guns.at(-1)!.id].model_id.toString().padStart(2, "0")}_mask`;
|
||||
`gun_${turretModel.guns[
|
||||
turret.turret.guns.at(-1)!.id
|
||||
].model_id
|
||||
.toString()
|
||||
.padStart(2, "0")}_mask`;
|
||||
// const isCurrentGun =
|
||||
// node.name ===
|
||||
// `gun_${gunModel.model_id.toString().padStart(2, "0")}`;
|
||||
@@ -219,12 +224,12 @@ export function Model() {
|
||||
-gunTankModel.turret_origin!.x -
|
||||
gunTrackModel.origin!.x -
|
||||
gunTurretModel.gun_origin!.x,
|
||||
-gunTankModel.turret_origin!.z -
|
||||
gunTrackModel.origin!.z -
|
||||
gunTurretModel.gun_origin!.z,
|
||||
-gunTankModel.turret_origin!.y -
|
||||
gunTrackModel.origin!.y -
|
||||
gunTurretModel.gun_origin!.y,
|
||||
-gunTankModel.turret_origin!.z -
|
||||
gunTrackModel.origin!.z -
|
||||
gunTurretModel.gun_origin!.z,
|
||||
]}
|
||||
>
|
||||
{gunNodes.map((node) => {
|
||||
@@ -259,6 +264,6 @@ export function Model() {
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
.mixer-module-chooser {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.trigger {
|
||||
position: relative;
|
||||
overflow: clip;
|
||||
}
|
||||
|
||||
.sizer {
|
||||
width: var(--space-6);
|
||||
height: var(--space-5);
|
||||
}
|
||||
|
||||
.tank-image,
|
||||
.skeleton {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
|
||||
.tank-image {
|
||||
background-size: auto 125%;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.module-button {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.popover-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.popover-row {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
import { alias, romanize } from "@blitzkit/core";
|
||||
import type {
|
||||
GunDefinition,
|
||||
TankDefinition,
|
||||
TurretDefinition,
|
||||
} from "@blitzkit/protos";
|
||||
import { CaretUpIcon } from "@radix-ui/react-icons";
|
||||
import { useState } from "react";
|
||||
import { api } from "../../api/dynamic";
|
||||
import { useStrings } from "../../hooks/useStrings";
|
||||
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
||||
import { Button } from "../Button";
|
||||
import { Dialog } from "../Dialog";
|
||||
import { Discriminator } from "../Discriminator";
|
||||
import { IconButton } from "../IconButton";
|
||||
import { Popover } from "../Popover";
|
||||
import { Skeleton } from "../Skeleton";
|
||||
import { TankSearch } from "../TankSearch";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
const tankDefinitions = await api.tanks();
|
||||
|
||||
type MixerModuleChooserProps = MaybeSkeletonComponentProps & {
|
||||
tank: number;
|
||||
onSelect: (
|
||||
tank: TankDefinition,
|
||||
turret?: TurretDefinition,
|
||||
gun?: GunDefinition
|
||||
) => void;
|
||||
turret?: number;
|
||||
gun?: number;
|
||||
};
|
||||
|
||||
export function MixerModuleChooser({
|
||||
skeleton,
|
||||
tank,
|
||||
onSelect,
|
||||
turret,
|
||||
gun,
|
||||
}: MixerModuleChooserProps) {
|
||||
const strings = useStrings();
|
||||
const [open, setOpen] = useState(false);
|
||||
const tankDefinition = tankDefinitions.tanks[tank];
|
||||
const turretDefinition = tankDefinition.turrets.find((t) => t.id === turret);
|
||||
const gunDefinition = turretDefinition?.guns.find((g) => g.id === gun);
|
||||
const topTurret = tankDefinition.turrets.at(-1)!;
|
||||
const subSelector =
|
||||
turret !== undefined &&
|
||||
(tankDefinition.turrets.length > 1 ||
|
||||
(gun !== undefined && turretDefinition!.guns.length > 1));
|
||||
|
||||
return (
|
||||
<div className={styles["mixer-module-chooser"]}>
|
||||
<Dialog.Root open={open} onOpenChange={setOpen}>
|
||||
<Dialog.Trigger asChild>
|
||||
<Button
|
||||
variant="surface"
|
||||
listChild="horizontal"
|
||||
className={styles.trigger}
|
||||
>
|
||||
<div className={styles.sizer} />
|
||||
|
||||
{skeleton ? (
|
||||
<Skeleton className={styles.skeleton} />
|
||||
) : (
|
||||
<div
|
||||
className={styles["tank-image"]}
|
||||
style={{
|
||||
backgroundImage: `url(${alias(
|
||||
"api",
|
||||
`/tanks/${tank}/icons/big.webp`
|
||||
)})`,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Button>
|
||||
</Dialog.Trigger>
|
||||
|
||||
<Dialog.Portal>
|
||||
<Dialog.Overlay />
|
||||
<Dialog.Content>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>
|
||||
{strings.website.common.tank_search.select_dialog_title}
|
||||
</Dialog.Title>
|
||||
</Dialog.Header>
|
||||
|
||||
<Dialog.Body>
|
||||
<TankSearch
|
||||
compact
|
||||
onSelect={(tank) => {
|
||||
onSelect?.(tank);
|
||||
setOpen(false);
|
||||
}}
|
||||
/>
|
||||
</Dialog.Body>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
|
||||
{subSelector && (
|
||||
<Popover.Root>
|
||||
<Popover.Trigger asChild>
|
||||
<IconButton variant="surface" listChild="horizontal">
|
||||
<CaretUpIcon />
|
||||
</IconButton>
|
||||
</Popover.Trigger>
|
||||
|
||||
<Popover.Content>
|
||||
<div className={styles["popover-list"]}>
|
||||
{tankDefinition.turrets.length > 1 && (
|
||||
<div className={styles["popover-row"]}>
|
||||
{tankDefinition.turrets.map((turret) => (
|
||||
<IconButton
|
||||
key={turret.id}
|
||||
radius="1"
|
||||
size="major"
|
||||
variant={
|
||||
turret.id === turretDefinition?.id ? "surface" : "soft"
|
||||
}
|
||||
color={
|
||||
turret.id === turretDefinition?.id
|
||||
? turret.id === topTurret.id
|
||||
? "amber"
|
||||
: undefined
|
||||
: "gray"
|
||||
}
|
||||
className={styles["module-button"]}
|
||||
onClick={() => {
|
||||
onSelect?.(tankDefinition, turret);
|
||||
}}
|
||||
>
|
||||
<img
|
||||
alt="turret"
|
||||
src={alias("api", "/icons/modules/turret.webp")}
|
||||
/>
|
||||
|
||||
<Discriminator corner="top-left">
|
||||
{romanize(turret.tier)}
|
||||
</Discriminator>
|
||||
</IconButton>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{turretDefinition && turretDefinition.guns.length > 1 && (
|
||||
<div className={styles["popover-row"]}>
|
||||
{turretDefinition.guns.map((gun) => (
|
||||
<IconButton
|
||||
key={gun.id}
|
||||
radius="1"
|
||||
size="major"
|
||||
variant={
|
||||
gun.id === gunDefinition?.id ? "surface" : "soft"
|
||||
}
|
||||
color={
|
||||
gun.id === gunDefinition?.id
|
||||
? gun.id === topTurret.guns.at(-1)!.id
|
||||
? "amber"
|
||||
: undefined
|
||||
: "gray"
|
||||
}
|
||||
className={styles["module-button"]}
|
||||
onClick={() => {
|
||||
onSelect?.(tankDefinition, turretDefinition, gun);
|
||||
}}
|
||||
>
|
||||
<img
|
||||
alt="gun"
|
||||
src={alias("api", "/icons/modules/gun.webp")}
|
||||
/>
|
||||
|
||||
<Discriminator corner="top-left">
|
||||
{romanize(gun.tier)}
|
||||
</Discriminator>
|
||||
</IconButton>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Popover.Content>
|
||||
</Popover.Root>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
.mixer-module-separator {
|
||||
display: flex;
|
||||
color: var(--gray-11);
|
||||
font-size: var(--font-size-regular);
|
||||
|
||||
svg {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { CaretRightIcon } from "@radix-ui/react-icons";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export function MixerModuleSeparator() {
|
||||
return (
|
||||
<span className={styles["mixer-module-separator"]}>
|
||||
<CaretRightIcon />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Progress } from "@radix-ui/themes";
|
||||
import { Html } from "@react-three/drei";
|
||||
import { useStableProgress } from "../../../hooks/useStableProgress";
|
||||
|
||||
export function MixerFallback() {
|
||||
const progress = useStableProgress();
|
||||
|
||||
return (
|
||||
<Html center>
|
||||
<Progress value={progress} style={{ width: "10rem" }} />
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { Box, Flex, Text } from "@radix-ui/themes";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
interface Props {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function Selector({ children }: Props) {
|
||||
return (
|
||||
<Flex align="center">
|
||||
<Box
|
||||
width="16rem"
|
||||
height="1px"
|
||||
style={{ backgroundColor: "var(--gray-12)" }}
|
||||
/>
|
||||
<Box
|
||||
style={{
|
||||
padding: "var(--space-3)",
|
||||
backgroundColor: "var(--gray-3)",
|
||||
borderRadius: "var(--radius-3)",
|
||||
boxShadow: "var(--shadow-3)",
|
||||
}}
|
||||
>
|
||||
<Text style={{ whiteSpace: "nowrap" }}>{children}</Text>
|
||||
</Box>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
@@ -5,9 +5,9 @@ import { forwardRef, Suspense, useEffect, useRef } from "react";
|
||||
import type { OrbitControls as OrbitControlsClass } from "three-stdlib";
|
||||
import { controlsEnabledEvent } from "../../core/controlsEnabled";
|
||||
import { Lighting } from "../Lighting";
|
||||
import { MixerFallback } from "../MixerFallback";
|
||||
import { MixerModel } from "../MixerModel";
|
||||
import { SceneProps } from "../SceneProps";
|
||||
import { MixerFallback } from "./components/MixerFallback";
|
||||
import { Model } from "./components/Model";
|
||||
|
||||
export const MixerScene = forwardRef<HTMLCanvasElement>((_, ref) => {
|
||||
const controls = useRef<OrbitControlsClass>(null!);
|
||||
@@ -29,11 +29,7 @@ export const MixerScene = forwardRef<HTMLCanvasElement>((_, ref) => {
|
||||
<Canvas
|
||||
ref={ref}
|
||||
shadows="soft"
|
||||
style={{ background: "black" }}
|
||||
camera={{
|
||||
fov: 45,
|
||||
position: [-4, 4, -7],
|
||||
}}
|
||||
camera={{ fov: 45, position: [-4, 4, -7] }}
|
||||
>
|
||||
<OrbitControls
|
||||
ref={controls}
|
||||
@@ -47,7 +43,7 @@ export const MixerScene = forwardRef<HTMLCanvasElement>((_, ref) => {
|
||||
<SceneProps />
|
||||
|
||||
<Suspense fallback={<MixerFallback />}>
|
||||
<Model />
|
||||
<MixerModel />
|
||||
</Suspense>
|
||||
</Canvas>
|
||||
);
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
import { alias } from "@blitzkit/core";
|
||||
import { ClockIcon, ReloadIcon } from "@radix-ui/react-icons";
|
||||
import { Flex, Text } from "@radix-ui/themes";
|
||||
import { api } from "../../api/dynamic";
|
||||
import { useDelta } from "../../hooks/useDelta";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
import { GenericTankComponentButton } from "./GenericTankComponentButton";
|
||||
import type { TankComponentButtonProps } from "./TankComponentButton";
|
||||
|
||||
interface ConsumableButtonProps extends TankComponentButtonProps {
|
||||
consumable: number;
|
||||
duration?: number;
|
||||
cooldown?: number;
|
||||
}
|
||||
|
||||
const consumableDefinitions = await api.consumables();
|
||||
|
||||
export function ConsumableButton({
|
||||
consumable,
|
||||
cooldown,
|
||||
duration,
|
||||
...props
|
||||
}: ConsumableButtonProps) {
|
||||
const cooldownDelta = useDelta(cooldown ?? 0);
|
||||
const durationDelta = useDelta(duration ?? 0);
|
||||
const { unwrap } = useLocale();
|
||||
|
||||
return (
|
||||
<GenericTankComponentButton
|
||||
style={{ width: "6rem" }}
|
||||
tooltip={unwrap(consumableDefinitions.consumables[consumable].name!)}
|
||||
icon={alias("api", `/icons/consumables/${consumable}.webp`)}
|
||||
{...props}
|
||||
>
|
||||
{(cooldown || duration) && (
|
||||
<Flex direction="column" gap="1" ml="-2" mr="2">
|
||||
{duration && (
|
||||
<Text
|
||||
size="1"
|
||||
color={
|
||||
durationDelta > 0
|
||||
? "green"
|
||||
: durationDelta < 0
|
||||
? "tomato"
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<Flex align="center" gap="1" style={{ marginBottom: -4 }}>
|
||||
<ClockIcon width={12} height={12} />
|
||||
{Math.round(duration)}s
|
||||
</Flex>
|
||||
</Text>
|
||||
)}
|
||||
{cooldown && (
|
||||
<Text
|
||||
size="1"
|
||||
color={
|
||||
cooldownDelta < 0
|
||||
? "green"
|
||||
: cooldownDelta > 0
|
||||
? "tomato"
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<Flex align="center" gap="1">
|
||||
<ReloadIcon width={12} height={12} />
|
||||
{Math.round(cooldown)}s
|
||||
</Flex>
|
||||
</Text>
|
||||
)}
|
||||
</Flex>
|
||||
)}
|
||||
</GenericTankComponentButton>
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { alias } from "@blitzkit/core";
|
||||
import { api } from "../../api/dynamic";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
import { GenericTankComponentButton } from "./GenericTankComponentButton";
|
||||
import type { TankComponentButtonProps } from "./TankComponentButton";
|
||||
|
||||
interface EquipmentButtonProps extends TankComponentButtonProps {
|
||||
equipment: number;
|
||||
}
|
||||
|
||||
const equipmentDefinitions = await api.equipment();
|
||||
|
||||
export function EquipmentButton({ equipment, ...props }: EquipmentButtonProps) {
|
||||
const { unwrap } = useLocale();
|
||||
|
||||
return (
|
||||
<GenericTankComponentButton
|
||||
tooltip={unwrap(equipmentDefinitions.equipments[equipment].name!)}
|
||||
icon={alias("api", `/icons/equipment/${equipment}.webp`)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import {
|
||||
TankComponentButton,
|
||||
type TankComponentButtonProps,
|
||||
} from './TankComponentButton';
|
||||
|
||||
interface GenericTankComponentButtonProps extends TankComponentButtonProps {
|
||||
icon: string;
|
||||
iconStyles?: HTMLAttributes<HTMLImageElement>['style'];
|
||||
}
|
||||
|
||||
export function GenericTankComponentButton({
|
||||
icon,
|
||||
iconStyles,
|
||||
children,
|
||||
...props
|
||||
}: GenericTankComponentButtonProps) {
|
||||
return (
|
||||
<TankComponentButton {...props}>
|
||||
<div
|
||||
style={{
|
||||
width: 48,
|
||||
height: 40,
|
||||
position: 'relative',
|
||||
}}
|
||||
>
|
||||
<img
|
||||
alt={icon}
|
||||
draggable={false}
|
||||
src={icon}
|
||||
style={{
|
||||
objectFit: 'contain',
|
||||
width: 32,
|
||||
height: 32,
|
||||
position: 'absolute',
|
||||
opacity: props.disabled ? 0.5 : 1,
|
||||
transform: 'translate(-50%, -50%) scale(0.75)',
|
||||
top: '50%',
|
||||
left: '50%',
|
||||
...iconStyles,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{children}
|
||||
</TankComponentButton>
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { alias } from "@blitzkit/core";
|
||||
import { GenericTankComponentButton } from "./GenericTankComponentButton";
|
||||
import type { TankComponentButtonProps } from "./TankComponentButton";
|
||||
|
||||
interface ModuleProps extends TankComponentButtonProps {
|
||||
module: string;
|
||||
}
|
||||
|
||||
export function ModuleButton({ module, ...props }: ModuleProps) {
|
||||
return (
|
||||
<GenericTankComponentButton
|
||||
icon={alias("api", `/icons/modules/${module}.webp`)}
|
||||
iconStyles={{
|
||||
top: "50%",
|
||||
left: "50%",
|
||||
transform: "translate(calc(-50% + 2px), calc(-50% + 2px))",
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { alias } from "@blitzkit/core";
|
||||
import { api } from "../../api/dynamic";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
import { GenericTankComponentButton } from "./GenericTankComponentButton";
|
||||
import type { TankComponentButtonProps } from "./TankComponentButton";
|
||||
|
||||
interface ProvisionButtonProps extends TankComponentButtonProps {
|
||||
provision: number;
|
||||
}
|
||||
|
||||
const provisionDefinitions = await api.provisions();
|
||||
|
||||
export function ProvisionButton({ provision, ...props }: ProvisionButtonProps) {
|
||||
const { unwrap } = useLocale();
|
||||
|
||||
return (
|
||||
<GenericTankComponentButton
|
||||
tooltip={unwrap(provisionDefinitions.provisions[provision].name!)}
|
||||
icon={alias("api", `/icons/provisions/${provision}.webp`)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import { alias } from "@blitzkit/core";
|
||||
import { GenericTankComponentButton } from "./GenericTankComponentButton";
|
||||
import type { TankComponentButtonProps } from "./TankComponentButton";
|
||||
|
||||
interface ShellButtonProps extends TankComponentButtonProps {
|
||||
shell: string;
|
||||
}
|
||||
|
||||
export function ShellButton({ shell, ...props }: ShellButtonProps) {
|
||||
return (
|
||||
<GenericTankComponentButton
|
||||
icon={alias("api", `/icons/shells/${shell}.webp`)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
import { Button, Tooltip } from '@radix-ui/themes';
|
||||
import type { ComponentProps, ReactNode } from 'react';
|
||||
import { Discriminator } from '../Discriminator';
|
||||
|
||||
export interface TankComponentButtonProps
|
||||
extends ComponentProps<typeof Button> {
|
||||
selected?: boolean;
|
||||
children?: ReactNode;
|
||||
discriminator?: ReactNode;
|
||||
secondaryDiscriminator?: ReactNode;
|
||||
disabled?: boolean;
|
||||
banner?: string;
|
||||
special?: boolean;
|
||||
tooltip?: string;
|
||||
}
|
||||
|
||||
export function TankComponentButton({
|
||||
variant,
|
||||
selected,
|
||||
discriminator,
|
||||
secondaryDiscriminator,
|
||||
special,
|
||||
children,
|
||||
banner,
|
||||
disabled,
|
||||
style,
|
||||
tooltip,
|
||||
...props
|
||||
}: TankComponentButtonProps) {
|
||||
const button = (
|
||||
<Button
|
||||
radius="medium"
|
||||
color={selected ? (special ? 'amber' : undefined) : 'gray'}
|
||||
variant={variant ?? (selected ? 'surface' : 'soft')}
|
||||
style={{
|
||||
padding: 0,
|
||||
minWidth: 48,
|
||||
height: 40,
|
||||
position: 'relative',
|
||||
overflow: 'hidden',
|
||||
cursor: 'unset',
|
||||
pointerEvents: variant === 'ghost' ? 'none' : undefined,
|
||||
...style,
|
||||
}}
|
||||
disabled={variant === 'ghost' || disabled}
|
||||
{...props}
|
||||
>
|
||||
{banner !== undefined && (
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
width: '200%',
|
||||
height: 12,
|
||||
backgroundColor: banner,
|
||||
top: '50%',
|
||||
left: '-50%',
|
||||
transform: 'translateY(-50%) rotate(-22.5deg)',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{children}
|
||||
|
||||
{discriminator !== undefined && (
|
||||
<Discriminator>{discriminator}</Discriminator>
|
||||
)}
|
||||
|
||||
{secondaryDiscriminator !== undefined && (
|
||||
<Discriminator>
|
||||
{secondaryDiscriminator}
|
||||
</Discriminator>
|
||||
)}
|
||||
</Button>
|
||||
);
|
||||
|
||||
if (tooltip) return <Tooltip content={tooltip}>{button}</Tooltip>;
|
||||
return button;
|
||||
}
|
||||
@@ -20,10 +20,24 @@ const strings = await api.strings(locale);
|
||||
---
|
||||
|
||||
<style>
|
||||
#navbar-mobile {
|
||||
#navbar-mobile,
|
||||
#navbar-mobile-spacer {
|
||||
--icon-size: 1.5rem;
|
||||
--padding: var(--space-4);
|
||||
}
|
||||
|
||||
#navbar-mobile-spacer {
|
||||
display: none;
|
||||
flex-shrink: 0;
|
||||
|
||||
height: calc(var(--icon-size) + 2 * var(--padding));
|
||||
|
||||
@media screen and (max-width: 80rem) {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
#navbar-mobile {
|
||||
position: fixed;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -190,7 +204,12 @@ const strings = await api.strings(locale);
|
||||
});
|
||||
</script>
|
||||
|
||||
<nav id="navbar-mobile" data-visible="true" data-expanded="false">
|
||||
<nav
|
||||
id="navbar-mobile"
|
||||
data-visible="true"
|
||||
data-expanded="false"
|
||||
data-solid={solid}
|
||||
>
|
||||
<Scroller
|
||||
client:load
|
||||
orientation={ScrollerOrientation.Vertical}
|
||||
@@ -246,4 +265,6 @@ const strings = await api.strings(locale);
|
||||
|
||||
<div id="navbar-mobile-overlay" />
|
||||
|
||||
{solid && <div id="navbar-mobile-spacer" />}
|
||||
|
||||
{!solid && <NavbarMobileAutoHide />}
|
||||
@@ -0,0 +1,15 @@
|
||||
.progress {
|
||||
width: 100%;
|
||||
height: var(--space-2);
|
||||
overflow: hidden;
|
||||
|
||||
background-color: var(--gray-a3);
|
||||
border-radius: var(--radius-max);
|
||||
|
||||
.bar {
|
||||
height: 100%;
|
||||
|
||||
background-color: var(--accent-9);
|
||||
transition-duration: var(--duration-brief);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { ComponentProps } from "react";
|
||||
import { classNames } from "../../ui/classNames";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
interface ProgressProps extends ComponentProps<"div"> {
|
||||
value: number;
|
||||
}
|
||||
|
||||
export function Progress({ value, className, ...props }: ProgressProps) {
|
||||
return (
|
||||
<div {...props} className={classNames(styles.progress, className)}>
|
||||
<div className={styles.bar} style={{ width: `${value}%` }} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
import { CameraIcon, CopyIcon, DownloadIcon } from "@radix-ui/react-icons";
|
||||
import {
|
||||
Button,
|
||||
Flex,
|
||||
IconButton,
|
||||
Popover,
|
||||
type ButtonProps,
|
||||
} from "@radix-ui/themes";
|
||||
import { Jimp } from "jimp";
|
||||
import { useCallback, type RefObject } from "react";
|
||||
import { useLocale } from "../hooks/useLocale";
|
||||
import { screenshotReadyEvent } from "./SceneProps";
|
||||
|
||||
interface Props extends ButtonProps {
|
||||
canvas: RefObject<HTMLCanvasElement>;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function ScreenshotButton({ canvas, name, children, ...props }: Props) {
|
||||
const { strings } = useLocale();
|
||||
|
||||
const screenshot = useCallback(async () => {
|
||||
if (!canvas.current) {
|
||||
throw new Error("Canvas not found");
|
||||
}
|
||||
|
||||
screenshotReadyEvent.dispatch(true);
|
||||
|
||||
const blob = await new Promise<Blob>((resolve, reject) => {
|
||||
requestAnimationFrame(() => {
|
||||
canvas.current.toBlob((blob) => {
|
||||
screenshotReadyEvent.dispatch(false);
|
||||
|
||||
if (!blob) {
|
||||
reject(new Error("Failed to capture screenshot"));
|
||||
} else {
|
||||
resolve(blob);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const buffer = await blob.arrayBuffer();
|
||||
const image = await Jimp.fromBuffer(buffer);
|
||||
|
||||
image.autocrop();
|
||||
|
||||
return image;
|
||||
}, [canvas]);
|
||||
|
||||
return (
|
||||
<Popover.Root>
|
||||
<Popover.Trigger>
|
||||
{children ? (
|
||||
<Button {...props}>
|
||||
<CameraIcon />
|
||||
{children}
|
||||
</Button>
|
||||
) : (
|
||||
<IconButton {...props}>
|
||||
<CameraIcon />
|
||||
</IconButton>
|
||||
)}
|
||||
</Popover.Trigger>
|
||||
|
||||
<Popover.Content>
|
||||
<Flex direction="column" gap="2">
|
||||
<Popover.Close>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
const image = await screenshot();
|
||||
const anchor = document.createElement("a");
|
||||
|
||||
anchor.setAttribute("download", `${name}.png`);
|
||||
anchor.setAttribute("href", await image.getBase64("image/png"));
|
||||
anchor.click();
|
||||
}}
|
||||
>
|
||||
<DownloadIcon />
|
||||
{strings.website.tools.tankopedia.sandbox.screenshot.download}
|
||||
</Button>
|
||||
</Popover.Close>
|
||||
<Popover.Close>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={async () => {
|
||||
const image = await screenshot();
|
||||
const buffer = await image.getBuffer("image/png");
|
||||
const blob = new Blob([buffer as unknown as ArrayBuffer], {
|
||||
type: "image/png",
|
||||
});
|
||||
|
||||
navigator.clipboard.write([
|
||||
new ClipboardItem({ "image/png": blob }),
|
||||
]);
|
||||
}}
|
||||
>
|
||||
<CopyIcon />
|
||||
{strings.website.tools.tankopedia.sandbox.screenshot.copy}
|
||||
</Button>
|
||||
</Popover.Close>
|
||||
</Flex>
|
||||
</Popover.Content>
|
||||
</Popover.Root>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
import { CameraIcon, CopyIcon, DownloadIcon } from "@radix-ui/react-icons";
|
||||
import { Jimp } from "jimp";
|
||||
import { useCallback, type RefObject } from "react";
|
||||
import { useStrings } from "../../hooks/useStrings";
|
||||
import { AlertDialog } from "../AlertDialog";
|
||||
import { Button, type ButtonProps } from "../Button";
|
||||
import { Dialog } from "../Dialog";
|
||||
import { IconButton } from "../IconButton";
|
||||
import { screenshotReadyEvent } from "../SceneProps";
|
||||
|
||||
interface Props extends ButtonProps {
|
||||
canvas: RefObject<HTMLCanvasElement>;
|
||||
name: string;
|
||||
}
|
||||
|
||||
// TODO: crop breaks when tank is clipping into the edge of the screen
|
||||
export function ScreenshotButton({ canvas, name, children, ...props }: Props) {
|
||||
const strings = useStrings();
|
||||
|
||||
const screenshot = useCallback(async () => {
|
||||
if (!canvas.current) {
|
||||
throw new Error("Canvas not found");
|
||||
}
|
||||
|
||||
screenshotReadyEvent.dispatch(true);
|
||||
|
||||
const blob = await new Promise<Blob>((resolve, reject) => {
|
||||
requestAnimationFrame(() => {
|
||||
canvas.current.toBlob((blob) => {
|
||||
screenshotReadyEvent.dispatch(false);
|
||||
|
||||
if (!blob) {
|
||||
reject(new Error("Failed to capture screenshot"));
|
||||
} else {
|
||||
resolve(blob);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const buffer = await blob.arrayBuffer();
|
||||
const image = await Jimp.fromBuffer(buffer);
|
||||
|
||||
image.autocrop();
|
||||
|
||||
return image;
|
||||
}, [canvas]);
|
||||
|
||||
return (
|
||||
<Dialog.Root>
|
||||
<Dialog.Trigger asChild>
|
||||
{children ? (
|
||||
<Button {...props}>
|
||||
<CameraIcon />
|
||||
{children}
|
||||
</Button>
|
||||
) : (
|
||||
<IconButton {...props}>
|
||||
<CameraIcon />
|
||||
</IconButton>
|
||||
)}
|
||||
</Dialog.Trigger>
|
||||
|
||||
<Dialog.Portal>
|
||||
<Dialog.Overlay />
|
||||
<Dialog.Content>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>{strings.common.screenshot.title}</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
{strings.common.screenshot.description}
|
||||
</Dialog.Description>
|
||||
</Dialog.Header>
|
||||
|
||||
<AlertDialog.Actions>
|
||||
<Dialog.Close asChild>
|
||||
<Button color="red" variant="outline">
|
||||
{strings.common.screenshot.cancel}
|
||||
</Button>
|
||||
</Dialog.Close>
|
||||
|
||||
<Dialog.Close asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={async () => {
|
||||
const image = await screenshot();
|
||||
const buffer = await image.getBuffer("image/png");
|
||||
const blob = new Blob([buffer as unknown as ArrayBuffer], {
|
||||
type: "image/png",
|
||||
});
|
||||
|
||||
navigator.clipboard.write([
|
||||
new ClipboardItem({ "image/png": blob }),
|
||||
]);
|
||||
}}
|
||||
>
|
||||
<CopyIcon />
|
||||
{strings.common.screenshot.copy}
|
||||
</Button>
|
||||
</Dialog.Close>
|
||||
|
||||
<Dialog.Close asChild>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
const image = await screenshot();
|
||||
const anchor = document.createElement("a");
|
||||
|
||||
anchor.setAttribute("download", `${name}.png`);
|
||||
anchor.setAttribute(
|
||||
"href",
|
||||
await image.getBase64("image/png"),
|
||||
);
|
||||
anchor.click();
|
||||
}}
|
||||
>
|
||||
<DownloadIcon />
|
||||
{strings.common.screenshot.download}
|
||||
</Button>
|
||||
</Dialog.Close>
|
||||
</AlertDialog.Actions>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
);
|
||||
}
|
||||
@@ -113,7 +113,7 @@
|
||||
position: absolute;
|
||||
|
||||
opacity: 0;
|
||||
transition: opacity var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
&[data-hidden="true"] {
|
||||
display: none;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
outline: var(--outline-focus);
|
||||
border-radius: var(--radius-max);
|
||||
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
}
|
||||
|
||||
&[data-variant="solid"] {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
background-color: var(--gray-a5);
|
||||
|
||||
cursor: pointer;
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
&[data-state="checked"] {
|
||||
background-color: var(--accent-8);
|
||||
@@ -43,7 +43,7 @@
|
||||
background-color: var(--white-a12);
|
||||
box-shadow: var(--shadow-subtle);
|
||||
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
&[data-state="checked"] {
|
||||
transform: translateX(calc(var(--switch-thumb-size) * 1.25));
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
opacity: 1;
|
||||
filter: blur(0);
|
||||
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
&[data-visible="false"] {
|
||||
transition: var(--duration-subtle);
|
||||
transition-duration: var(--duration-subtle);
|
||||
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
@@ -28,19 +28,4 @@
|
||||
.icon {
|
||||
height: 25%;
|
||||
}
|
||||
|
||||
.progress {
|
||||
height: var(--space-2);
|
||||
width: 100%;
|
||||
|
||||
background-color: var(--gray-3);
|
||||
|
||||
border-radius: calc(var(--space-2) / 2);
|
||||
overflow: hidden;
|
||||
|
||||
.bar {
|
||||
height: 100%;
|
||||
background-color: var(--accent-9);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { alias } from "@blitzkit/core";
|
||||
import { useProgress } from "@react-three/drei";
|
||||
import { Tankopedia } from "../../stores/tankopedia";
|
||||
import { Progress } from "../Progress";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export function TankSandboxLoader() {
|
||||
@@ -21,15 +22,3 @@ export function TankSandboxLoader() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface ProgressProps {
|
||||
value: number;
|
||||
}
|
||||
|
||||
function Progress({ value }: ProgressProps) {
|
||||
return (
|
||||
<div className={styles.progress}>
|
||||
<div className={styles.bar} style={{ width: `${value}%` }} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import type { TankDefinition } from "@blitzkit/protos";
|
||||
import { CaretRightIcon } from "@radix-ui/react-icons";
|
||||
import { useLocale } from "../../../hooks/useLocale";
|
||||
import { TankFilters } from "../../../stores/tankFilters";
|
||||
import { LinkI18n } from "../../LinkI18n";
|
||||
|
||||
interface QuickLinkProps {
|
||||
topResult?: TankDefinition;
|
||||
}
|
||||
|
||||
export function QuickLink({ topResult }: QuickLinkProps) {
|
||||
const { locale, unwrap } = useLocale();
|
||||
const search = TankFilters.use((state) => state.search);
|
||||
const searching = TankFilters.use((state) => state.searching);
|
||||
|
||||
if (!search || !topResult || searching) return null;
|
||||
|
||||
return (
|
||||
<TextField.Slot>
|
||||
<LinkI18n locale={locale} href={`/tanks/${topResult.slug}`}>
|
||||
<Button variant="ghost">
|
||||
{unwrap(topResult.name!)}
|
||||
<CaretRightIcon />
|
||||
</Button>
|
||||
</LinkI18n>
|
||||
</TextField.Slot>
|
||||
);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
import { romanize } from "@blitzkit/core";
|
||||
import { Flex, IconButton, Text } from "@radix-ui/themes";
|
||||
import { memo } from "react";
|
||||
import { awaitableTiers } from "../../../core/awaitables/tiers";
|
||||
import { TankFilters } from "../../../stores/tankFilters";
|
||||
import { TankSort } from "../../../stores/tankopediaSort";
|
||||
|
||||
const TIERS = await awaitableTiers;
|
||||
|
||||
export const TierFilter = memo(() => {
|
||||
const by = TankSort.use((state) => state.by);
|
||||
const search = TankFilters.use((state) => state.search);
|
||||
const tiers = TankFilters.use((state) => state.tiers);
|
||||
|
||||
if (by !== null || search) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Flex justify="center">
|
||||
<Flex
|
||||
direction="row"
|
||||
overflow="hidden"
|
||||
style={{ borderRadius: "var(--radius-full)" }}
|
||||
>
|
||||
{TIERS.map((tier) => {
|
||||
const selected = tiers.includes(tier);
|
||||
|
||||
return (
|
||||
<IconButton
|
||||
key={tier}
|
||||
variant={selected ? "solid" : "soft"}
|
||||
radius="none"
|
||||
color={selected ? undefined : "gray"}
|
||||
highContrast
|
||||
onClick={() => {
|
||||
TankFilters.mutate((draft) => {
|
||||
if (tiers.includes(tier)) {
|
||||
draft.tiers = tiers.filter((t) => t !== tier);
|
||||
} else {
|
||||
draft.tiers = [...tiers, tier];
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Text size="2">{romanize(tier)}</Text>
|
||||
</IconButton>
|
||||
);
|
||||
})}
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
});
|
||||
@@ -48,6 +48,7 @@ export type TankSearchProps = MaybeSkeletonComponentProps & {
|
||||
onSelectAll?: (tanks: TankDefinition[]) => void;
|
||||
};
|
||||
|
||||
// TODO: across the project, remove "definitions"
|
||||
const [gameDefinitions, tankDefinitions, tankNames] = await Promise.all([
|
||||
api.game(),
|
||||
api.tanks(),
|
||||
@@ -55,6 +56,7 @@ const [gameDefinitions, tankDefinitions, tankNames] = await Promise.all([
|
||||
]);
|
||||
const tankDefinitionsArray = Object.values(tankDefinitions.tanks);
|
||||
|
||||
// TODO: add compact mode
|
||||
export const TankSearch = memo<TankSearchProps>(
|
||||
({ compact, onSelect, onSelectAll, skeleton }) => {
|
||||
const strings = useStrings();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
gap: var(--space-4);
|
||||
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
.bar {
|
||||
height: 100%;
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
gap: var(--space-4);
|
||||
align-items: center;
|
||||
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
min-width: 5rem;
|
||||
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
|
||||
@@ -255,7 +255,7 @@
|
||||
height: 65%;
|
||||
border-radius: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
&[data-shot="true"] {
|
||||
width: 70%;
|
||||
@@ -368,7 +368,7 @@
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: transparent;
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
&[data-shot="true"] {
|
||||
background: var(--white-a3);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
top: 50%;
|
||||
|
||||
user-select: none;
|
||||
transition: var(--duration-brief);
|
||||
transition-duration: var(--duration-brief);
|
||||
|
||||
/* slides off the right edge when the static armor view isn't active */
|
||||
transform: translate(calc(100% + var(--space-4)), -50%);
|
||||
|
||||
@@ -10,10 +10,7 @@ interface Props {
|
||||
|
||||
const { locale, tool } = Astro.props;
|
||||
const strings = await api.strings(locale);
|
||||
const toolStrings =
|
||||
strings.website.tools[
|
||||
(tool.strings ?? tool.id) as keyof typeof strings.website.tools
|
||||
];
|
||||
const toolStrings = strings.tools[tool.id as keyof typeof strings.tools];
|
||||
---
|
||||
|
||||
<AstroSeo
|
||||
|
||||
@@ -42,7 +42,6 @@ export const tools: Record<string, Tool> = {
|
||||
banner_background_position: "bottom",
|
||||
},
|
||||
mixer: {
|
||||
disabled: true,
|
||||
id: "mixer",
|
||||
banner_background_position: "bottom",
|
||||
},
|
||||
|
||||
@@ -57,6 +57,7 @@ const tool = tools.tanks;
|
||||
min-height: 100dvh;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
|
||||
background-color: var(--gray-1);
|
||||
color: var(--gray-12);
|
||||
@@ -65,21 +66,24 @@ const tool = tools.tanks;
|
||||
.main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 80rem) {
|
||||
flex-direction: column-reverse;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<NavbarDesktop {locale} {tool} />
|
||||
<NavbarMobile {locale} {tool} solid={solidNavbar} />
|
||||
|
||||
<body data-solid-navbar={solidNavbar}>
|
||||
<main class="main">
|
||||
<slot />
|
||||
</main>
|
||||
|
||||
<NavbarDesktop {locale} {tool} />
|
||||
<NavbarMobile {locale} {tool} solid={solidNavbar} />
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
.content {
|
||||
position: relative;
|
||||
height: 100dvh;
|
||||
background-color: black;
|
||||
|
||||
flex: 1;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
.wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.content {
|
||||
position: relative;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.scene {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.controls {
|
||||
position: absolute;
|
||||
bottom: var(--space-4);
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.modules {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
@@ -1,214 +1,33 @@
|
||||
import {
|
||||
alias,
|
||||
romanize,
|
||||
} from "@blitzkit/core";
|
||||
import { literals } from "@blitzkit/i18n";
|
||||
import {
|
||||
GunDefinition,
|
||||
TankDefinition,
|
||||
TurretDefinition,
|
||||
} from "@blitzkit/protos";
|
||||
import { CaretRightIcon, CaretUpIcon, UpdateIcon } from "@radix-ui/react-icons";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Dialog,
|
||||
Flex,
|
||||
IconButton,
|
||||
Popover,
|
||||
Skeleton,
|
||||
Text,
|
||||
type ButtonProps,
|
||||
} from "@radix-ui/themes";
|
||||
import { useRef, useState } from "react";
|
||||
import { api } from "../../../../api/dynamic";
|
||||
import { UpdateIcon } from "@radix-ui/react-icons";
|
||||
import { useRef } from "react";
|
||||
import { Button } from "../../../../components/Button";
|
||||
import { MixerModuleChooser } from "../../../../components/MixerModuleChooser";
|
||||
import { MixerModuleSeparator } from "../../../../components/MixerModuleSeparator";
|
||||
import { MixerScene } from "../../../../components/MixerScene";
|
||||
import { ModuleButton } from "../../../../components/ModuleButtons/ModuleButton";
|
||||
import { PageWrapper } from "../../../../components/PageWrapper";
|
||||
import { ScreenshotButton } from "../../../../components/ScreenshotButton";
|
||||
import { TankSearch } from "../../../../components/TankSearch";
|
||||
import { curateMixer } from "../../../../core/blitzkit/curateMixer";
|
||||
import {
|
||||
LocaleProvider,
|
||||
useLocale,
|
||||
type LocaleAcceptorProps,
|
||||
} from "../../../../hooks/useLocale";
|
||||
import { withErrorWrapper } from "../../../../hocs/withErrorWrapper";
|
||||
import { withLocale } from "../../../../hocs/withLocale";
|
||||
import { useStrings } from "../../../../hooks/useStrings";
|
||||
import { Mixer } from "../../../../stores/mixer";
|
||||
import { Tankopedia } from "../../../../stores/tankopedia";
|
||||
import type { MaybeSkeletonComponentProps } from "../../../../types/maybeSkeletonComponentProps";
|
||||
import styles from "./_index.module.css";
|
||||
|
||||
const modelDefinition = await api.models().then(({ models }) => models[1]);
|
||||
const tankDefinitions = await api.tanks();
|
||||
export const Page = withLocale(
|
||||
withErrorWrapper(({ skeleton }: MaybeSkeletonComponentProps) => {
|
||||
const initial = useRef(curateMixer());
|
||||
|
||||
export function Page({
|
||||
locale,
|
||||
skeleton,
|
||||
}: LocaleAcceptorProps & MaybeSkeletonComponentProps) {
|
||||
const initial = useRef(curateMixer());
|
||||
Mixer.useInitialization(initial.current);
|
||||
Tankopedia.useInitialization(initial.current.hull);
|
||||
|
||||
Mixer.useInitialization(initial.current);
|
||||
Tankopedia.useInitialization(modelDefinition);
|
||||
|
||||
return (
|
||||
<PageWrapper color="gray" p="0" maxWidth="unset">
|
||||
<LocaleProvider locale={locale}>
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
<Content skeleton={skeleton} />
|
||||
</LocaleProvider>
|
||||
</PageWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
type ModuleButtonProps = Omit<ButtonProps, "onSelect"> &
|
||||
MaybeSkeletonComponentProps & {
|
||||
tank: number;
|
||||
onSelect: (
|
||||
tank: TankDefinition,
|
||||
turret?: TurretDefinition,
|
||||
gun?: GunDefinition,
|
||||
) => void;
|
||||
turret?: number;
|
||||
gun?: number;
|
||||
};
|
||||
|
||||
function ModuleChooser({
|
||||
skeleton,
|
||||
tank,
|
||||
onSelect,
|
||||
turret,
|
||||
gun,
|
||||
...props
|
||||
}: ModuleButtonProps) {
|
||||
const { strings } = useLocale();
|
||||
const [open, setOpen] = useState(false);
|
||||
const tankDefinition = tankDefinitions.tanks[tank];
|
||||
const turretDefinition = tankDefinition.turrets.find((t) => t.id === turret);
|
||||
const gunDefinition = turretDefinition?.guns.find((g) => g.id === gun);
|
||||
const subSelector =
|
||||
turret !== undefined &&
|
||||
(tankDefinition.turrets.length > 1 ||
|
||||
(gun !== undefined && turretDefinition!.guns.length > 1));
|
||||
|
||||
return (
|
||||
<Flex>
|
||||
<Dialog.Root open={open} onOpenChange={setOpen}>
|
||||
<Dialog.Trigger>
|
||||
<Button
|
||||
variant="surface"
|
||||
size={{ initial: "2", xs: "3", md: "4" }}
|
||||
style={{
|
||||
overflow: "clip",
|
||||
borderTopRightRadius: subSelector ? 0 : undefined,
|
||||
borderBottomRightRadius: subSelector ? 0 : undefined,
|
||||
}}
|
||||
{...props}
|
||||
>
|
||||
{skeleton ? (
|
||||
<Skeleton width="4em" height="2em" />
|
||||
) : (
|
||||
<img
|
||||
style={{
|
||||
width: "4em",
|
||||
height: "4em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src={alias("api", `/tanks/${tank}/icons/big.webp`)}
|
||||
/>
|
||||
)}
|
||||
</Button>
|
||||
</Dialog.Trigger>
|
||||
|
||||
<Dialog.Content maxHeight={DIALOG_MAX_HEIGHT}>
|
||||
<Dialog.Title>
|
||||
{strings.website.common.tank_search.select_dialog_title}
|
||||
</Dialog.Title>
|
||||
|
||||
<TankSearch
|
||||
compact
|
||||
onSelect={(tank) => {
|
||||
onSelect?.(tank);
|
||||
setOpen(false);
|
||||
}}
|
||||
/>
|
||||
</Dialog.Content>
|
||||
</Dialog.Root>
|
||||
|
||||
{subSelector && (
|
||||
<Popover.Root>
|
||||
<Popover.Trigger>
|
||||
<IconButton
|
||||
variant="surface"
|
||||
size={{ initial: "2", xs: "3", md: "4" }}
|
||||
style={{
|
||||
overflow: "clip",
|
||||
borderTopLeftRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
marginLeft: -1,
|
||||
}}
|
||||
{...props}
|
||||
>
|
||||
<CaretUpIcon />
|
||||
</IconButton>
|
||||
</Popover.Trigger>
|
||||
|
||||
<Popover.Content>
|
||||
<Flex direction="column" gap="2">
|
||||
{tankDefinition.turrets.length > 1 && (
|
||||
<Flex gap="2">
|
||||
{tankDefinition.turrets.map((turret) => (
|
||||
<ModuleButton
|
||||
variant={
|
||||
turret.id === turretDefinition?.id ? "solid" : undefined
|
||||
}
|
||||
key={turret.id}
|
||||
module="turret"
|
||||
discriminator={romanize(turret.tier)}
|
||||
onClick={() => {
|
||||
onSelect?.(tankDefinition, turret);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</Flex>
|
||||
)}
|
||||
|
||||
{turretDefinition && turretDefinition.guns.length > 1 && (
|
||||
<Flex gap="2">
|
||||
{turretDefinition.guns.map((gun) => (
|
||||
<ModuleButton
|
||||
variant={
|
||||
gun.id === gunDefinition?.id ? "solid" : undefined
|
||||
}
|
||||
key={gun.id}
|
||||
module="gun"
|
||||
discriminator={romanize(gun.tier)}
|
||||
secondaryDiscriminator={
|
||||
<Text style={{ fontSize: "0.75em" }}>
|
||||
{literals(strings.common.units.mm, {
|
||||
value: gun.shells[0].caliber.toFixed(0),
|
||||
})}
|
||||
</Text>
|
||||
}
|
||||
onClick={() => {
|
||||
onSelect?.(tankDefinition, turretDefinition, gun);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</Flex>
|
||||
)}
|
||||
</Flex>
|
||||
</Popover.Content>
|
||||
</Popover.Root>
|
||||
)}
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
function ModuleSeparator() {
|
||||
return (
|
||||
<Text size={{ initial: "3", xs: "5" }} color="gray" trim="end">
|
||||
<CaretRightIcon width="1em" height="1em" />
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
function Content({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
const hullTankId = Mixer.use((state) => state.hull);
|
||||
@@ -218,34 +37,25 @@ function Content({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
const gunTurretId = Mixer.use((state) => state.gun.turret.id);
|
||||
const gunGunId = Mixer.use((state) => state.gun.gun.id);
|
||||
const canvas = useRef<HTMLCanvasElement>(null!);
|
||||
const { strings } = useLocale();
|
||||
const strings = useStrings();
|
||||
|
||||
return (
|
||||
<Box flexGrow="1" position="relative">
|
||||
<Box position="absolute" width="100%" height="100%" top="0" left="0">
|
||||
<div className={styles.content}>
|
||||
<div className={styles.scene}>
|
||||
{!skeleton && <MixerScene ref={canvas} />}
|
||||
</Box>
|
||||
</div>
|
||||
|
||||
<Flex
|
||||
align="center"
|
||||
direction="column"
|
||||
position="absolute"
|
||||
bottom="4"
|
||||
left="50%"
|
||||
style={{ transform: "translateX(-50%)" }}
|
||||
gap="4"
|
||||
>
|
||||
<Flex gap="2">
|
||||
<div className={styles.controls}>
|
||||
<div className={styles.row}>
|
||||
<ScreenshotButton
|
||||
name={hullTankId.slug}
|
||||
canvas={canvas}
|
||||
highContrast
|
||||
variant="surface"
|
||||
>
|
||||
{strings.website.tools.mixer.screenshot}
|
||||
{strings.mixer.screenshot}
|
||||
</ScreenshotButton>
|
||||
|
||||
<Button
|
||||
highContrast
|
||||
variant="surface"
|
||||
onClick={() => {
|
||||
const mixed = curateMixer();
|
||||
@@ -256,12 +66,12 @@ function Content({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
}}
|
||||
>
|
||||
<UpdateIcon />
|
||||
{strings.website.tools.mixer.randomize}
|
||||
{strings.mixer.randomize}
|
||||
</Button>
|
||||
</Flex>
|
||||
</div>
|
||||
|
||||
<Flex gap={{ initial: "1", xs: "2" }} align="center">
|
||||
<ModuleChooser
|
||||
<div className={styles.modules}>
|
||||
<MixerModuleChooser
|
||||
skeleton={skeleton}
|
||||
tank={hullTankId.id}
|
||||
onSelect={(tank) => {
|
||||
@@ -270,8 +80,8 @@ function Content({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ModuleSeparator />
|
||||
<ModuleChooser
|
||||
<MixerModuleSeparator />
|
||||
<MixerModuleChooser
|
||||
skeleton={skeleton}
|
||||
tank={turretTankId}
|
||||
turret={turretTurretId}
|
||||
@@ -284,8 +94,8 @@ function Content({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ModuleSeparator />
|
||||
<ModuleChooser
|
||||
<MixerModuleSeparator />
|
||||
<MixerModuleChooser
|
||||
skeleton={skeleton}
|
||||
tank={gunTankId}
|
||||
turret={gunTurretId}
|
||||
@@ -303,8 +113,8 @@ function Content({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Box>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+1
-1
@@ -11,7 +11,7 @@ const { locale } = Astro.props;
|
||||
|
||||
<ToolOpenGraph {locale} tool={tools.mixer} />
|
||||
|
||||
<BaseLayout {locale} integrated>
|
||||
<BaseLayout accent="gray" {locale} solidNavbar>
|
||||
<Page {locale} client:only="react">
|
||||
<Page {locale} skeleton slot="fallback" />
|
||||
</Page>
|
||||
Reference in new issue
Block a user