🚀 add save menu

This commit is contained in:
Chase Manning 2023-09-15 16:23:16 +01:00
commit 8c39b5e541

View file

@ -10,11 +10,17 @@ import {
} from "../state/uiSlice"; } from "../state/uiSlice";
import useEvent from "../app/use-event"; import useEvent from "../app/use-event";
import emitter, { Event } from "../app/emitter"; import emitter, { Event } from "../app/emitter";
import { useState } from "react";
import ConfirmationMenu from "./ConfirmationMenu";
import { selectName } from "../state/gameSlice";
const StartMenu = () => { const StartMenu = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const show = useSelector(selectStartMenu); const show = useSelector(selectStartMenu);
const disabled = useSelector(selectStartMenuSubOpen); const disabled = useSelector(selectStartMenuSubOpen);
const name = useSelector(selectName);
const [saving, setSaving] = useState(false);
useEvent(Event.Start, () => { useEvent(Event.Start, () => {
dispatch(showStartMenu()); dispatch(showStartMenu());
@ -22,37 +28,46 @@ const StartMenu = () => {
}); });
return ( return (
<Menu <>
disabled={disabled} <Menu
show={show} disabled={disabled || saving}
close={() => dispatch(hideStartMenu())} show={show}
menuItems={[ close={() => dispatch(hideStartMenu())}
// { menuItems={[
// label: "Pokédex", // {
// action: () => console.log("TODO"), // label: "Pokédex",
// }, // action: () => console.log("TODO"),
// { // },
// label: "Pokémon", // {
// action: () => console.log("TODO"), // label: "Pokémon",
// }, // action: () => console.log("TODO"),
{ // },
label: "Item", {
action: () => dispatch(showItemsMenu()), label: "Item",
}, action: () => dispatch(showItemsMenu()),
{ },
label: "Player", {
action: () => dispatch(showPlayerMenu()), label: "Player",
}, action: () => dispatch(showPlayerMenu()),
// { },
// label: "Save", {
// action: () => console.log("TODO"), label: "Save",
// }, action: () => setSaving(true),
// { },
// label: "Option", // {
// action: () => console.log("TODO"), // 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)}
/>
</>
); );
}; };