mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: selector
This commit is contained in:
1 parent
581d889e9b
commit
2aba4da1af
1 file changed
+33
-11
@@ -1,4 +1,10 @@
|
|||||||
import { asset, TIER_ROMAN_NUMERALS } from "@blitzkit/core";
|
import {
|
||||||
|
asset,
|
||||||
|
GunDefinition,
|
||||||
|
TankDefinition,
|
||||||
|
TIER_ROMAN_NUMERALS,
|
||||||
|
TurretDefinition,
|
||||||
|
} from "@blitzkit/core";
|
||||||
import { literals } from "@blitzkit/i18n";
|
import { literals } from "@blitzkit/i18n";
|
||||||
import { CaretRightIcon, CaretUpIcon, UpdateIcon } from "@radix-ui/react-icons";
|
import { CaretRightIcon, CaretUpIcon, UpdateIcon } from "@radix-ui/react-icons";
|
||||||
import {
|
import {
|
||||||
@@ -17,10 +23,7 @@ import { MixerScene } from "../../../components/MixerScene";
|
|||||||
import { ModuleButton } from "../../../components/ModuleButtons/ModuleButton";
|
import { ModuleButton } from "../../../components/ModuleButtons/ModuleButton";
|
||||||
import { PageWrapper } from "../../../components/PageWrapper";
|
import { PageWrapper } from "../../../components/PageWrapper";
|
||||||
import { ScreenshotButton } from "../../../components/ScreenshotButton";
|
import { ScreenshotButton } from "../../../components/ScreenshotButton";
|
||||||
import {
|
import { TankSearch } from "../../../components/TankSearch";
|
||||||
TankSearch,
|
|
||||||
type TankSearchProps,
|
|
||||||
} from "../../../components/TankSearch";
|
|
||||||
import { awaitableModelDefinitions } from "../../../core/awaitables/modelDefinitions";
|
import { awaitableModelDefinitions } from "../../../core/awaitables/modelDefinitions";
|
||||||
import { awaitableTankDefinitions } from "../../../core/awaitables/tankDefinitions";
|
import { awaitableTankDefinitions } from "../../../core/awaitables/tankDefinitions";
|
||||||
import { curateMixer } from "../../../core/blitzkit/curateMixer";
|
import { curateMixer } from "../../../core/blitzkit/curateMixer";
|
||||||
@@ -59,7 +62,11 @@ export function Page({
|
|||||||
type ModuleButtonProps = Omit<ButtonProps, "onSelect"> &
|
type ModuleButtonProps = Omit<ButtonProps, "onSelect"> &
|
||||||
MaybeSkeletonComponentProps & {
|
MaybeSkeletonComponentProps & {
|
||||||
tank: number;
|
tank: number;
|
||||||
onSelect: TankSearchProps["onSelect"];
|
onSelect: (
|
||||||
|
tank: TankDefinition,
|
||||||
|
turret?: TurretDefinition,
|
||||||
|
gun?: GunDefinition
|
||||||
|
) => void;
|
||||||
turret?: number;
|
turret?: number;
|
||||||
gun?: number;
|
gun?: number;
|
||||||
};
|
};
|
||||||
@@ -150,9 +157,15 @@ function ModuleChooser({
|
|||||||
<Flex gap="2">
|
<Flex gap="2">
|
||||||
{tankDefinition.turrets.map((turret) => (
|
{tankDefinition.turrets.map((turret) => (
|
||||||
<ModuleButton
|
<ModuleButton
|
||||||
|
variant={
|
||||||
|
turret.id === turretDefinition?.id ? "solid" : undefined
|
||||||
|
}
|
||||||
key={turret.id}
|
key={turret.id}
|
||||||
module="turret"
|
module="turret"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[turret.tier]}
|
discriminator={TIER_ROMAN_NUMERALS[turret.tier]}
|
||||||
|
onClick={() => {
|
||||||
|
onSelect?.(tankDefinition, turret);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -162,6 +175,9 @@ function ModuleChooser({
|
|||||||
<Flex gap="2">
|
<Flex gap="2">
|
||||||
{turretDefinition.guns.map((gun) => (
|
{turretDefinition.guns.map((gun) => (
|
||||||
<ModuleButton
|
<ModuleButton
|
||||||
|
variant={
|
||||||
|
gun.id === gunDefinition?.id ? "solid" : undefined
|
||||||
|
}
|
||||||
key={gun.id}
|
key={gun.id}
|
||||||
module="gun"
|
module="gun"
|
||||||
discriminator={TIER_ROMAN_NUMERALS[gun.tier]}
|
discriminator={TIER_ROMAN_NUMERALS[gun.tier]}
|
||||||
@@ -172,6 +188,9 @@ function ModuleChooser({
|
|||||||
})}
|
})}
|
||||||
</Text>
|
</Text>
|
||||||
}
|
}
|
||||||
|
onClick={() => {
|
||||||
|
onSelect?.(tankDefinition, turretDefinition, gun);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -257,11 +276,11 @@ function Content({ skeleton }: MaybeSkeletonComponentProps) {
|
|||||||
skeleton={skeleton}
|
skeleton={skeleton}
|
||||||
tank={turretTankId}
|
tank={turretTankId}
|
||||||
turret={turretTurretId}
|
turret={turretTurretId}
|
||||||
onSelect={(tank) => {
|
onSelect={(tank, turret) => {
|
||||||
Mixer.mutate((draft) => {
|
Mixer.mutate((draft) => {
|
||||||
draft.turret = {
|
draft.turret = {
|
||||||
tank,
|
tank,
|
||||||
turret: tank.turrets.at(-1)!,
|
turret: turret ?? tank.turrets.at(-1)!,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -272,12 +291,15 @@ function Content({ skeleton }: MaybeSkeletonComponentProps) {
|
|||||||
tank={gunTankId}
|
tank={gunTankId}
|
||||||
turret={gunTurretId}
|
turret={gunTurretId}
|
||||||
gun={gunGunId}
|
gun={gunGunId}
|
||||||
onSelect={(tank) => {
|
onSelect={(tank, turret, gun) => {
|
||||||
Mixer.mutate((draft) => {
|
Mixer.mutate((draft) => {
|
||||||
draft.gun = {
|
draft.gun = {
|
||||||
tank,
|
tank,
|
||||||
turret: tank.turrets.at(-1)!,
|
turret: turret ?? tank.turrets.at(-1)!,
|
||||||
gun: tank.turrets.at(-1)!.guns.at(-1)!,
|
gun:
|
||||||
|
gun ??
|
||||||
|
turret?.guns.at(-1) ??
|
||||||
|
tank.turrets.at(-1)!.guns.at(-1)!,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in new issue
Block a user