mirror of
https://github.com/chase-manning/pokemon-js.git
synced 2025-08-26 03:07:14 +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";
|
} 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)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue