diff --git a/src/components/StartMenu.tsx b/src/components/StartMenu.tsx index 1fe2615..94060c0 100644 --- a/src/components/StartMenu.tsx +++ b/src/components/StartMenu.tsx @@ -10,11 +10,17 @@ import { } from "../state/uiSlice"; import useEvent from "../app/use-event"; import emitter, { Event } from "../app/emitter"; +import { useState } from "react"; +import ConfirmationMenu from "./ConfirmationMenu"; +import { selectName } from "../state/gameSlice"; const StartMenu = () => { const dispatch = useDispatch(); const show = useSelector(selectStartMenu); const disabled = useSelector(selectStartMenuSubOpen); + const name = useSelector(selectName); + + const [saving, setSaving] = useState(false); useEvent(Event.Start, () => { dispatch(showStartMenu()); @@ -22,37 +28,46 @@ const StartMenu = () => { }); return ( - <Menu - disabled={disabled} - show={show} - close={() => dispatch(hideStartMenu())} - menuItems={[ - // { - // label: "Pokédex", - // action: () => console.log("TODO"), - // }, - // { - // label: "Pokémon", - // action: () => console.log("TODO"), - // }, - { - label: "Item", - action: () => dispatch(showItemsMenu()), - }, - { - label: "Player", - action: () => dispatch(showPlayerMenu()), - }, - // { - // label: "Save", - // action: () => console.log("TODO"), - // }, - // { - // label: "Option", - // action: () => console.log("TODO"), - // }, - ]} - /> + <> + <Menu + disabled={disabled || saving} + show={show} + close={() => dispatch(hideStartMenu())} + menuItems={[ + // { + // label: "Pokédex", + // action: () => console.log("TODO"), + // }, + // { + // label: "Pokémon", + // action: () => console.log("TODO"), + // }, + { + label: "Item", + action: () => dispatch(showItemsMenu()), + }, + { + label: "Player", + action: () => dispatch(showPlayerMenu()), + }, + { + label: "Save", + action: () => setSaving(true), + }, + // { + // label: "Option", + // action: () => console.log("TODO"), + // }, + ]} + /> + <ConfirmationMenu + show={saving} + preMessage="Would you like to SAVE the game?" + postMessage={`${name} saved the game!`} + confirm={() => console.log("TODO")} + cancel={() => setSaving(false)} + /> + </> ); };