mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-04 00:10:38 +01:00
Feature: Switch all shells in Compare
This commit is contained in:
1 parent
7234c39ad8
commit
d93b202ee8
4 files changed
+53
-5
No files matched your search
@@ -742,7 +742,8 @@
|
|||||||
"none": "No deltas",
|
"none": "No deltas",
|
||||||
"percentage": "Percentage",
|
"percentage": "Percentage",
|
||||||
"absolute": "Absolute"
|
"absolute": "Absolute"
|
||||||
}
|
},
|
||||||
|
"sync_shells": "Sync shells"
|
||||||
},
|
},
|
||||||
|
|
||||||
"no_tanks": {
|
"no_tanks": {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { alias } from "@blitzkit/core";
|
|||||||
import { Flex, Heading, IconButton, Table } from "@radix-ui/themes";
|
import { Flex, Heading, IconButton, Table } from "@radix-ui/themes";
|
||||||
import type { TankCharacteristics } from "../../core/blitzkit/tankCharacteristics";
|
import type { TankCharacteristics } from "../../core/blitzkit/tankCharacteristics";
|
||||||
import { useLocale } from "../../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { CompareEphemeral } from "../../stores/compareEphemeral";
|
import { CompareEphemeral, syncShellSlot } from "../../stores/compareEphemeral";
|
||||||
import { CompareCellDirection } from "../CompareCell";
|
import { CompareCellDirection } from "../CompareCell";
|
||||||
import { StickyColumnHeaderCell } from "../StickyColumnHeaderCell";
|
import { StickyColumnHeaderCell } from "../StickyColumnHeaderCell";
|
||||||
import { CompareRow } from "./CompareRow";
|
import { CompareRow } from "./CompareRow";
|
||||||
@@ -50,7 +50,11 @@ export function Body({ stats }: BodyProps) {
|
|||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
CompareEphemeral.mutate((draft) => {
|
CompareEphemeral.mutate((draft) => {
|
||||||
draft.members[index].shell = thisShell;
|
if (draft.syncShells) {
|
||||||
|
syncShellSlot(draft.members, shellIndex);
|
||||||
|
} else {
|
||||||
|
draft.members[index].shell = thisShell;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
import { PlusIcon, TrashIcon } from "@radix-ui/react-icons";
|
import { PlusIcon, TrashIcon } from "@radix-ui/react-icons";
|
||||||
import { Button, Dialog, Flex, SegmentedControl } from "@radix-ui/themes";
|
import {
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
Dialog,
|
||||||
|
Flex,
|
||||||
|
SegmentedControl,
|
||||||
|
Text,
|
||||||
|
} from "@radix-ui/themes";
|
||||||
import { api } from "../../core/blitzkit/api";
|
import { api } from "../../core/blitzkit/api";
|
||||||
import { tankToCompareMember } from "../../core/blitzkit/tankToCompareMember";
|
import { tankToCompareMember } from "../../core/blitzkit/tankToCompareMember";
|
||||||
import { useLocale } from "../../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { CompareEphemeral } from "../../stores/compareEphemeral";
|
import { CompareEphemeral, syncShellSlot } from "../../stores/compareEphemeral";
|
||||||
import {
|
import {
|
||||||
ComparePersistent,
|
ComparePersistent,
|
||||||
type DeltaMode,
|
type DeltaMode,
|
||||||
@@ -22,6 +29,7 @@ export function Controls({
|
|||||||
onAddTankDialogOpenChange,
|
onAddTankDialogOpenChange,
|
||||||
}: ControlsProps) {
|
}: ControlsProps) {
|
||||||
const deltaMode = ComparePersistent.use((state) => state.deltaMode);
|
const deltaMode = ComparePersistent.use((state) => state.deltaMode);
|
||||||
|
const syncShells = CompareEphemeral.use((state) => state.syncShells);
|
||||||
const { strings } = useLocale();
|
const { strings } = useLocale();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -111,6 +119,31 @@ export function Controls({
|
|||||||
{strings.website.tools.compare.actions.deltas.absolute}
|
{strings.website.tools.compare.actions.deltas.absolute}
|
||||||
</SegmentedControl.Item>
|
</SegmentedControl.Item>
|
||||||
</SegmentedControl.Root>
|
</SegmentedControl.Root>
|
||||||
|
|
||||||
|
<Flex
|
||||||
|
align="center"
|
||||||
|
gap="2"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => {
|
||||||
|
CompareEphemeral.mutate((draft) => {
|
||||||
|
draft.syncShells = !draft.syncShells;
|
||||||
|
|
||||||
|
if (!draft.syncShells || draft.members.length === 0) return;
|
||||||
|
|
||||||
|
const [first] = draft.members;
|
||||||
|
|
||||||
|
syncShellSlot(
|
||||||
|
draft.members,
|
||||||
|
first.gun.shells.findIndex(({ id }) => id === first.shell.id),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Checkbox variant="classic" checked={syncShells} />
|
||||||
|
<Text size="2">
|
||||||
|
{strings.website.tools.compare.actions.sync_shells}
|
||||||
|
</Text>
|
||||||
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ export interface CompareMember extends DuelMember {
|
|||||||
export interface CompareEphemeral {
|
export interface CompareEphemeral {
|
||||||
crewSkills: Record<string, number>;
|
crewSkills: Record<string, number>;
|
||||||
equalize: boolean;
|
equalize: boolean;
|
||||||
|
syncShells: boolean;
|
||||||
members: CompareMember[];
|
members: CompareMember[];
|
||||||
sorting?: {
|
sorting?: {
|
||||||
direction: "ascending" | "descending";
|
direction: "ascending" | "descending";
|
||||||
@@ -21,5 +22,14 @@ export const CompareEphemeral = new Varuna<
|
|||||||
>((crewSkills) => ({
|
>((crewSkills) => ({
|
||||||
crewSkills,
|
crewSkills,
|
||||||
equalize: false,
|
equalize: false,
|
||||||
|
syncShells: false,
|
||||||
members: [],
|
members: [],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
export function syncShellSlot(members: CompareMember[], slot: number) {
|
||||||
|
for (const member of members) {
|
||||||
|
const shell = member.gun.shells[slot];
|
||||||
|
|
||||||
|
if (shell) member.shell = shell;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user