mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: combine controls
This commit is contained in:
1 parent
1d955078ef
commit
551e562109
2 files changed
+76
-76
No files matched your search
@@ -1,18 +1,14 @@
|
|||||||
import { Flex, Heading, Switch, Text } from '@radix-ui/themes';
|
import { Flex, Heading, Text } from '@radix-ui/themes';
|
||||||
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
||||||
import { useWideFormat } from '../../../../../../hooks/useWideFormat';
|
import { useWideFormat } from '../../../../../../hooks/useWideFormat';
|
||||||
import strings from '../../../../../../lang/en-US.json';
|
import strings from '../../../../../../lang/en-US.json';
|
||||||
import { theme } from '../../../../../../stitches.config';
|
import { theme } from '../../../../../../stitches.config';
|
||||||
import { useDuel } from '../../../../../../stores/duel';
|
import { useDuel } from '../../../../../../stores/duel';
|
||||||
import mutateTankopediaPersistent, {
|
|
||||||
useTankopediaPersistent,
|
|
||||||
} from '../../../../../../stores/tankopedia';
|
|
||||||
import { TankSandbox } from './TankSandbox';
|
import { TankSandbox } from './TankSandbox';
|
||||||
import { Options } from './components/Options';
|
import { Options } from './components/Options';
|
||||||
|
|
||||||
export function HeroSection() {
|
export function HeroSection() {
|
||||||
const tank = useDuel((state) => state.protagonist!.tank);
|
const tank = useDuel((state) => state.protagonist!.tank);
|
||||||
const mode = useTankopediaPersistent((state) => state.mode);
|
|
||||||
const wideFormat = useWideFormat(880);
|
const wideFormat = useWideFormat(880);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -77,31 +73,10 @@ export function HeroSection() {
|
|||||||
<TankSandbox />
|
<TankSandbox />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Flex
|
<Options />
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
bottom: 16,
|
|
||||||
left: '50%',
|
|
||||||
transform: 'translateX(-50%)',
|
|
||||||
cursor: 'default',
|
|
||||||
userSelect: 'none',
|
|
||||||
}}
|
|
||||||
align="center"
|
|
||||||
gap="2"
|
|
||||||
onClick={() => {
|
|
||||||
mutateTankopediaPersistent((draft) => {
|
|
||||||
draft.mode = draft.mode === 'armor' ? 'model' : 'armor';
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Switch checked={mode === 'armor'} />
|
|
||||||
Armor
|
|
||||||
</Flex>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Options />
|
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
EyeOpenIcon,
|
EyeOpenIcon,
|
||||||
GearIcon,
|
GearIcon,
|
||||||
} from '@radix-ui/react-icons';
|
} from '@radix-ui/react-icons';
|
||||||
import { DropdownMenu, Flex, IconButton } from '@radix-ui/themes';
|
import { DropdownMenu, Flex, IconButton, Switch } from '@radix-ui/themes';
|
||||||
import { Pose, poseEvent } from '../../../../../../../core/blitzkit/pose';
|
import { Pose, poseEvent } from '../../../../../../../core/blitzkit/pose';
|
||||||
import { useFullScreen } from '../../../../../../../hooks/useFullScreen';
|
import { useFullScreen } from '../../../../../../../hooks/useFullScreen';
|
||||||
import { useApp } from '../../../../../../../stores/app';
|
import { useApp } from '../../../../../../../stores/app';
|
||||||
@@ -15,6 +15,7 @@ import mutateTankopediaPersistent, {
|
|||||||
import { ENVIRONMENTS } from '../../Lighting';
|
import { ENVIRONMENTS } from '../../Lighting';
|
||||||
|
|
||||||
export function Options() {
|
export function Options() {
|
||||||
|
const mode = useTankopediaPersistent((state) => state.mode);
|
||||||
const isFullScreen = useFullScreen();
|
const isFullScreen = useFullScreen();
|
||||||
const showGrid = useTankopediaPersistent(
|
const showGrid = useTankopediaPersistent(
|
||||||
(state) => state.model.visual.showGrid,
|
(state) => state.model.visual.showGrid,
|
||||||
@@ -42,12 +43,32 @@ export function Options() {
|
|||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
gap="4"
|
gap="4"
|
||||||
|
align="center"
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: 18,
|
bottom: 16,
|
||||||
right: 18,
|
left: '50%',
|
||||||
|
transform: 'translateX(-50%)',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Flex
|
||||||
|
style={{
|
||||||
|
cursor: 'default',
|
||||||
|
userSelect: 'none',
|
||||||
|
}}
|
||||||
|
align="center"
|
||||||
|
gap="2"
|
||||||
|
onClick={() => {
|
||||||
|
mutateTankopediaPersistent((draft) => {
|
||||||
|
draft.mode = draft.mode === 'armor' ? 'model' : 'armor';
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
mr="2"
|
||||||
|
>
|
||||||
|
<Switch size="1" checked={mode === 'armor'} />
|
||||||
|
Armor
|
||||||
|
</Flex>
|
||||||
|
|
||||||
<DropdownMenu.Root>
|
<DropdownMenu.Root>
|
||||||
<DropdownMenu.Trigger>
|
<DropdownMenu.Trigger>
|
||||||
<IconButton variant="ghost" color="gray">
|
<IconButton variant="ghost" color="gray">
|
||||||
@@ -78,57 +99,61 @@ export function Options() {
|
|||||||
</DropdownMenu.Trigger>
|
</DropdownMenu.Trigger>
|
||||||
|
|
||||||
<DropdownMenu.Content>
|
<DropdownMenu.Content>
|
||||||
<DropdownMenu.Label>Armor</DropdownMenu.Label>
|
{mode === 'armor' && (
|
||||||
|
<>
|
||||||
|
<DropdownMenu.Label>Armor</DropdownMenu.Label>
|
||||||
|
|
||||||
<DropdownMenu.CheckboxItem
|
<DropdownMenu.CheckboxItem
|
||||||
checked={showSpacedArmor}
|
checked={showSpacedArmor}
|
||||||
onCheckedChange={(checked) => {
|
onCheckedChange={(checked) => {
|
||||||
mutateTankopediaPersistent((draft) => {
|
mutateTankopediaPersistent((draft) => {
|
||||||
draft.model.visual.showSpacedArmor = checked;
|
draft.model.visual.showSpacedArmor = checked;
|
||||||
});
|
});
|
||||||
mutateTankopediaTemporary((draft) => {
|
mutateTankopediaTemporary((draft) => {
|
||||||
draft.shot = undefined;
|
draft.shot = undefined;
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Spaced armor
|
Spaced armor
|
||||||
</DropdownMenu.CheckboxItem>
|
</DropdownMenu.CheckboxItem>
|
||||||
|
|
||||||
<DropdownMenu.CheckboxItem
|
<DropdownMenu.CheckboxItem
|
||||||
checked={greenPenetration}
|
checked={greenPenetration}
|
||||||
onCheckedChange={(checked) => {
|
onCheckedChange={(checked) => {
|
||||||
mutateTankopediaPersistent((draft) => {
|
mutateTankopediaPersistent((draft) => {
|
||||||
draft.model.visual.greenPenetration = checked;
|
draft.model.visual.greenPenetration = checked;
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Green penetration
|
Green penetration
|
||||||
</DropdownMenu.CheckboxItem>
|
</DropdownMenu.CheckboxItem>
|
||||||
|
|
||||||
{developerMode && (
|
{developerMode && (
|
||||||
<DropdownMenu.CheckboxItem
|
<DropdownMenu.CheckboxItem
|
||||||
checked={wireframe}
|
checked={wireframe}
|
||||||
onCheckedChange={(checked) => {
|
onCheckedChange={(checked) => {
|
||||||
mutateTankopediaPersistent((draft) => {
|
mutateTankopediaPersistent((draft) => {
|
||||||
draft.model.visual.wireframe = checked;
|
draft.model.visual.wireframe = checked;
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Wireframe
|
Wireframe
|
||||||
</DropdownMenu.CheckboxItem>
|
</DropdownMenu.CheckboxItem>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<DropdownMenu.CheckboxItem
|
||||||
|
checked={opaque}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
mutateTankopediaPersistent((draft) => {
|
||||||
|
draft.model.visual.opaque = checked;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Opaque
|
||||||
|
</DropdownMenu.CheckboxItem>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DropdownMenu.CheckboxItem
|
|
||||||
checked={opaque}
|
|
||||||
onCheckedChange={(checked) => {
|
|
||||||
mutateTankopediaPersistent((draft) => {
|
|
||||||
draft.model.visual.opaque = checked;
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Opaque
|
|
||||||
</DropdownMenu.CheckboxItem>
|
|
||||||
|
|
||||||
<DropdownMenu.Label>Environment</DropdownMenu.Label>
|
<DropdownMenu.Label>Environment</DropdownMenu.Label>
|
||||||
|
|
||||||
<DropdownMenu.CheckboxItem
|
<DropdownMenu.CheckboxItem
|
||||||
|
|||||||
Reference in new issue
Block a user