feat: settings basework

This commit is contained in:
TrèsAbhi committed 2024-01-06 17:59:31 -06:00
1 parent 6753a72d97
commit 857cba902a
2 files changed
+34 -15

No files matched your search

+32 -15
View File
@@ -5,6 +5,7 @@ import {
CaretRightIcon, CaretRightIcon,
EnterFullScreenIcon, EnterFullScreenIcon,
ExitFullScreenIcon, ExitFullScreenIcon,
GearIcon,
MagnifyingGlassIcon, MagnifyingGlassIcon,
} from '@radix-ui/react-icons'; } from '@radix-ui/react-icons';
import { import {
@@ -38,6 +39,7 @@ import {
tankNamesDiacritics, tankNamesDiacritics,
} from '../../../../core/blitzkrieg/tankDefinitions'; } from '../../../../core/blitzkrieg/tankDefinitions';
import { theme } from '../../../../stitches.config'; import { theme } from '../../../../stitches.config';
import mutateTankopedia from '../../../../stores/tankopedia';
import { Loader } from '../../components/Loader'; import { Loader } from '../../components/Loader';
import { Controls } from './components/Control'; import { Controls } from './components/Control';
import { RotationInputs } from './components/RotationInputs'; import { RotationInputs } from './components/RotationInputs';
@@ -169,27 +171,42 @@ export default function Page({ params }: { params: { id: string } }) {
</Canvas> </Canvas>
</div> </div>
<Button <Flex
variant="ghost" gap="4"
style={{ style={{
position: 'absolute', position: 'absolute',
top: 18, top: 18,
right: 18, right: 18,
}} }}
onClick={() => {
if (isFullScreen) {
document.exitFullscreen();
} else {
canvasWrapper.current?.requestFullscreen();
}
}}
> >
{isFullScreen ? ( <Button
<ExitFullScreenIcon /> variant="ghost"
) : ( onClick={() => {
<EnterFullScreenIcon /> mutateTankopedia((draft) => {
)} draft.showSettings = true;
</Button> });
}}
>
<GearIcon />
</Button>
<Button
variant="ghost"
onClick={() => {
if (isFullScreen) {
document.exitFullscreen();
} else {
canvasWrapper.current?.requestFullscreen();
}
}}
>
{isFullScreen ? (
<ExitFullScreenIcon />
) : (
<EnterFullScreenIcon />
)}
</Button>
</Flex>
<RotationInputs <RotationInputs
gunId={gun.id} gunId={gun.id}
+2
View File
@@ -25,6 +25,7 @@ type Tankopedia = {
gunPitch: number; gunPitch: number;
controlsEnabled: boolean; controlsEnabled: boolean;
}; };
showSettings: boolean;
}; };
export const useTankopedia = create<Tankopedia>()(() => ({ export const useTankopedia = create<Tankopedia>()(() => ({
@@ -45,6 +46,7 @@ export const useTankopedia = create<Tankopedia>()(() => ({
turretYaw: 0, turretYaw: 0,
controlsEnabled: true, controlsEnabled: true,
}, },
showSettings: false,
})); }));
export default function mutateTankopedia(recipe: (draft: Tankopedia) => void) { export default function mutateTankopedia(recipe: (draft: Tankopedia) => void) {