mirror of
https://github.com/chase-manning/pokemon-js.git
synced 2025-08-01 16:49:12 +00:00
🚀 add save menu
This commit is contained in:
parent
327521d513
commit
8c39b5e541
1 changed files with 46 additions and 31 deletions
|
@ -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)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue