From ff35c7fbbced94a5fbeef0f3010f704361e5769b Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Mon, 31 Oct 2022 17:14:29 -0700 Subject: [PATCH] Add animations turn off Signed-off-by: James Ketrenos --- client/.env | 2 +- client/src/App.js | 25 +++++++++++++++++++++---- client/src/Board.js | 31 +++++++++++++++++-------------- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/client/.env b/client/.env index 550b42b..2b48535 100644 --- a/client/.env +++ b/client/.env @@ -1,3 +1,3 @@ PUBLIC_URL=/ketr.ketran -HOST=nuc.ketrenos.com +HOST=localhost DANGEROUSLY_DISABLE_HOST_CHECK='true' diff --git a/client/src/App.js b/client/src/App.js index 08aed7f..9c7c97d 100755 --- a/client/src/App.js +++ b/client/src/App.js @@ -28,7 +28,7 @@ import { Winner } from "./Winner.js"; import { HouseRules } from "./HouseRules.js"; import { Dice } from "./Dice.js"; import { assetsPath } from "./Common.js"; -import { Sheep } from "./Sheep.js"; +//import { Sheep } from "./Sheep.js"; import history from "./history.js"; import "./App.css"; @@ -84,6 +84,11 @@ const Table = () => { const [winnerDismissed, setWinnerDismissed] = useState(undefined); const [global, setGlobal] = useState({}); const [count, setCount] = useState(0); + const [audio, setAudio] = useState( + localStorage.getItem('audio') ? + localStorage.getItem('audio') : false); + const [animations, setAnimations] = useState( + localStorage.getItem('animations') || false); const [volume, setVolume] = useState( localStorage.getItem('volume') ? parseFloat(localStorage.getItem('volume')) : 0.5); @@ -421,7 +426,7 @@ const Table = () => { audioEffects.knights.hasPlayed = false; } } - }, [turn, color, volume]); + }, [state, turn, color, volume]); useEffect(() => { for (let key in audioEffects) { @@ -473,13 +478,19 @@ const Table = () => { - +
{ name !== "" && volume !== undefined && +
Audio effects
{ + const value = !audio; + localStorage.setItem('audio', value); + setAudio(value) + }}/>
Sound effects volume
{ @@ -488,7 +499,13 @@ const Table = () => { localStorage.setItem('volume', alpha); setVolume(alpha); }}/> -
} +
Animations
{ + const value = !animations; + localStorage.setItem('animations', value); + setAnimations(value) + }} /> + } { name !== "" && } { name !== "" && } diff --git a/client/src/Board.js b/client/src/Board.js index 8e72a00..5f2bb9e 100644 --- a/client/src/Board.js +++ b/client/src/Board.js @@ -34,7 +34,7 @@ const clearTooltip = () => { document.querySelector('.Board .Tooltip').style.display = 'none'; }; -const Board = () => { +const Board = ({ animations }) => { const { ws } = useContext(GlobalContext); const board = useRef(); const [transform, setTransform] = useState(1.); @@ -554,24 +554,27 @@ const Board = () => { if (tile.type === 'wheat') { div =
+ { animations &&
; - } else if (tile.type === 'sheep') { - div =
- }
; + } else if (tile.type === 'sheep') { + div =
+ { animations && + + }
; } else { @@ -696,7 +699,7 @@ const Board = () => { signature, generated, pips, pipOrder, borders, borderOrder, tiles, tileOrder, animationSeeds, - ws, state, rules + ws, state, rules, animations ]); /* Re-render turn info after every render */