Skip to content

Commit

Permalink
Spectator no longer gets spammed with sound effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Papel committed Jan 7, 2025
1 parent aa98b92 commit b663dc9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion client/src/game/gameState.d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ export type PlayerClientType = {
}

type GameState = {
stateType: "game"
stateType: "game",
roomCode: number,
lobbyName: string,

initialized: boolean,

myId: number | null,

Expand Down
2 changes: 2 additions & 0 deletions client/src/game/gameState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export function createGameState(): GameState {
roomCode: 0,
lobbyName: "",

initialized: false,

myId: null,

chatMessages : [],
Expand Down
13 changes: 9 additions & 4 deletions client/src/game/messageListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ export default function messageListener(packet: ToClientPacket){
break;
case "gameInitializationComplete": {
const isSpectator = GAME_MANAGER.getMySpectator();
if(GAME_MANAGER.state.stateType === "game"){
GAME_MANAGER.state.initialized = true;
}
if(isSpectator){
ANCHOR_CONTROLLER?.setContent(<SpectatorGameScreen/>);
}else{
Expand Down Expand Up @@ -482,10 +485,12 @@ export default function messageListener(packet: ToClientPacket){
}
}

for(let chatMessage of packet.chatMessages){
let audioSrc = chatMessageToAudio(chatMessage);
if(audioSrc)
AudioController.queueFile(audioSrc);
if (GAME_MANAGER.state.stateType !== "game" || GAME_MANAGER.state.initialized === true) {
for(let chatMessage of packet.chatMessages){
let audioSrc = chatMessageToAudio(chatMessage);
if(audioSrc)
AudioController.queueFile(audioSrc);
}
}
}
break;
Expand Down
1 change: 0 additions & 1 deletion client/src/menu/game/gameScreenContent/ChatMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Icon from "../../../components/Icon";
import StyledText, { KeywordDataMap, PLAYER_KEYWORD_DATA, PLAYER_SENDER_KEYWORD_DATA } from "../../../components/StyledText";
import { useGameState, useLobbyOrGameState, usePlayerState } from "../../../components/useHooks";
import { Virtuoso } from 'react-virtuoso';
import Select from "../../../components/Select";


export default function ChatMenu(): ReactElement {
Expand Down

0 comments on commit b663dc9

Please sign in to comment.