Step towards full multiplayer compatibility

This commit is contained in:
aronmal 2023-06-10 20:26:46 +02:00
parent 9895a286a3
commit 53a07b21b0
Signed by: aronmal
GPG key ID: 816B7707426FC612
16 changed files with 207 additions and 104 deletions

View file

@ -1,3 +1,4 @@
import { setGameSetting } from "@components/Gamefield/EventBar"
import {
faToggleLargeOff,
faToggleLargeOn,
@ -17,12 +18,12 @@ export type GameSettings = { [key in GameSettingKeys]?: boolean }
function Setting({
children,
props: { prop, gameSetting },
prop,
}: {
children: ReactNode
props: { prop: GameSettingKeys; gameSetting: (payload: GameSettings) => void }
prop: GameSettingKeys
}) {
const { payload } = useGameProps()
const { payload, setSetting, full } = useGameProps()
const state = useMemo(() => payload?.game?.[prop], [payload?.game, prop])
return (
@ -46,12 +47,15 @@ function Setting({
checked={state}
type="checkbox"
id={prop}
onChange={() => {
const payload = {
[prop]: !state,
}
gameSetting(payload)
}}
onChange={() =>
setGameSetting(
{
[prop]: !state,
},
setSetting,
full
)
}
hidden={true}
/>
</label>