🚀 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";
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)}
/>
</>
);
};