mirror of
https://github.com/Vikeo/LifeTrinket.git
synced 2025-11-18 16:58:01 +00:00
move initialGameSettings to global settings
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { InitialSettings } from '../Data/getInitialPlayers';
|
||||
import Play from './Views/Play';
|
||||
import StartMenu from './Views/StartMenu/StartMenu';
|
||||
import { useGlobalSettings } from '../Hooks/useGlobalSettings';
|
||||
@@ -31,21 +29,7 @@ const EmergencyResetButton = styled.button`
|
||||
`;
|
||||
|
||||
export const LifeTrinket = () => {
|
||||
const savedGameSettings = localStorage.getItem('initialGameSettings');
|
||||
|
||||
const { showPlay, goToStart } = useGlobalSettings();
|
||||
|
||||
const [initialGameSettings, setInitialGameSettings] =
|
||||
useState<InitialSettings | null>(
|
||||
savedGameSettings ? JSON.parse(savedGameSettings) : null
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem(
|
||||
'initialGameSettings',
|
||||
JSON.stringify(initialGameSettings)
|
||||
);
|
||||
}, [initialGameSettings]);
|
||||
const { showPlay, goToStart, initialGameSettings } = useGlobalSettings();
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -61,10 +45,7 @@ export const LifeTrinket = () => {
|
||||
</PlayWrapper>
|
||||
) : (
|
||||
<StartWrapper>
|
||||
<StartMenu
|
||||
initialGameSettings={initialGameSettings}
|
||||
setInitialGameSettings={setInitialGameSettings}
|
||||
/>
|
||||
<StartMenu />
|
||||
</StartWrapper>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -97,15 +97,16 @@ const healthMarks = [
|
||||
},
|
||||
];
|
||||
|
||||
type StartProps = {
|
||||
setInitialGameSettings: (options: InitialSettings) => void;
|
||||
initialGameSettings: InitialSettings | null;
|
||||
};
|
||||
|
||||
const Start = ({ initialGameSettings, setInitialGameSettings }: StartProps) => {
|
||||
const Start = () => {
|
||||
const { setPlayers } = usePlayers();
|
||||
const analytics = useAnalytics();
|
||||
const { fullscreen, wakeLock, setShowPlay } = useGlobalSettings();
|
||||
const {
|
||||
fullscreen,
|
||||
wakeLock,
|
||||
setShowPlay,
|
||||
initialGameSettings,
|
||||
setInitialGameSettings,
|
||||
} = useGlobalSettings();
|
||||
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
const [keepAwake, setKeepAwake] = useState(true);
|
||||
@@ -132,8 +133,6 @@ const Start = ({ initialGameSettings, setInitialGameSettings }: StartProps) => {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
console.log('go to start', wakeLock.active);
|
||||
|
||||
if (keepAwake) {
|
||||
wakeLock.request();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user