-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description: This PR introduces the global setup for the game music and sound effects ## Changes - Implemented a Sound Provider to control sound states - Volume control for Master Audio, Music and UI Sound Effects - Menu Dialog UI to manipulate Audio
- Loading branch information
1 parent
1318a77
commit 3d9a8aa
Showing
71 changed files
with
495 additions
and
61 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+58.6 KB
public/music/Voice Over/Player Loses/Loss_IKnewWeCoulntTrustThatOne.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import BotBustersTheme from "./botbusters-theme-song.mp3"; | ||
|
||
export { BotBustersTheme }; |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const audio = { | ||
master: "Master Audio", | ||
music: "Music", | ||
sfx: "Sound Effects", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { type FC, useState } from "react"; | ||
import { Button, Menu, Stack, Typography } from "@mui/material"; | ||
import { SoundOffIcon, SoundOnIcon } from "~/assets/icons/index.js"; | ||
import { VolumeSlider } from "~/components/audio-settings/volume-slider.jsx"; | ||
import { | ||
useChangeMasterVolume, | ||
useChangeMusicVolume, | ||
useChangeSFXVolume, | ||
} from "~/hooks/volume.js"; | ||
import { | ||
AUDIO_OFF, | ||
DEFAULT_MASTER_VOLUME, | ||
DEFAULT_MUSIC_VOLUME, | ||
DEFAULT_SFX_VOLUME, | ||
} from "~/constants/main.js"; | ||
import { styles } from "./styles.js"; | ||
import { text } from "~/assets/text/index.js"; | ||
|
||
export const AudioSettings: FC = () => { | ||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); | ||
const open = Boolean(anchorEl); | ||
|
||
const handleOpen = (event: React.MouseEvent<HTMLElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
const { changeMasterVolume, masterVolume } = useChangeMasterVolume(); | ||
const { changeSFXVolume, sfxVolume } = useChangeSFXVolume(); | ||
const { changeMusicVolume, musicVolume } = useChangeMusicVolume(); | ||
|
||
const handleReset = () => { | ||
changeMasterVolume(DEFAULT_MASTER_VOLUME); | ||
changeSFXVolume(DEFAULT_SFX_VOLUME); | ||
changeMusicVolume(DEFAULT_MUSIC_VOLUME); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Button variant="text" onClick={handleOpen}> | ||
{masterVolume === AUDIO_OFF ? <SoundOffIcon /> : <SoundOnIcon />} | ||
</Button> | ||
<Menu | ||
open={open} | ||
anchorEl={anchorEl} | ||
onClose={() => handleClose()} | ||
transformOrigin={{ horizontal: "right", vertical: "top" }} | ||
anchorOrigin={{ horizontal: "right", vertical: "bottom" }} | ||
MenuListProps={{ | ||
sx: styles.menu, | ||
}} | ||
> | ||
<Stack sx={styles.menuItem}> | ||
<Typography variant="caption" sx={styles.text}> | ||
{text.audio.master} | ||
</Typography> | ||
<VolumeSlider | ||
volume={masterVolume} | ||
changeVolume={changeMasterVolume} | ||
/> | ||
</Stack> | ||
<Stack sx={styles.menuItem}> | ||
<Typography variant="caption" sx={styles.text}> | ||
{text.audio.music} | ||
</Typography> | ||
<VolumeSlider volume={musicVolume} changeVolume={changeMusicVolume} /> | ||
</Stack> | ||
<Stack sx={styles.menuItem}> | ||
<Typography variant="caption" sx={styles.text}> | ||
{text.audio.sfx} | ||
</Typography> | ||
<VolumeSlider volume={sfxVolume} changeVolume={changeSFXVolume} /> | ||
</Stack> | ||
<Stack sx={styles.resetButton}> | ||
<Button variant="text" sx={styles.button} onClick={handleReset}> | ||
Reset to Default | ||
</Button> | ||
</Stack> | ||
</Menu> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./audio-settings.jsx"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { theme } from "~/styles/index.js"; | ||
|
||
export const styles = { | ||
container: { | ||
flexDirection: "column", | ||
}, | ||
menu: { | ||
borderRadius: 0, | ||
border: `4px solid ${theme.palette.customGrey.main}`, | ||
}, | ||
resetButton: { | ||
flexDirection: "row", | ||
width: "100%", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
p: 2, | ||
}, | ||
button: { | ||
fontSize: 16, | ||
lineHeight: "normal", | ||
"&:hover": { | ||
cursor: "pointer", | ||
textDecoration: "underline", | ||
}, | ||
}, | ||
menuItem: { | ||
flexDirection: "row", | ||
width: "100%", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
p: 2, | ||
}, | ||
text: { | ||
fontSize: 16, | ||
lineHeight: "normal", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { FC } from "react"; | ||
import { Box, Button, Slider, Stack } from "@mui/material"; | ||
import { VolumeDown, VolumeUp } from "@mui/icons-material"; | ||
import { AUDIO_OFF, AUDIO_ON } from "~/constants/index.js"; | ||
|
||
interface Props { | ||
volume: number; | ||
changeVolume: (volume: number) => void; | ||
} | ||
export const VolumeSlider: FC<Props> = ({ volume, changeVolume }) => { | ||
const handleChange = (event: Event, newValue: number | number[]) => { | ||
if (typeof newValue === "number") { | ||
changeVolume(newValue); | ||
} else { | ||
return; // will never be an array | ||
} | ||
}; | ||
|
||
return ( | ||
<Box sx={{ width: 400 }}> | ||
<Stack spacing={2} direction="row" sx={{ mb: 1 }} alignItems="center"> | ||
<Button variant="text" onClick={() => changeVolume(AUDIO_OFF)}> | ||
<VolumeDown /> | ||
</Button> | ||
<Slider | ||
aria-label="Volume" | ||
value={volume} | ||
onChange={handleChange} | ||
min={AUDIO_OFF} | ||
max={AUDIO_ON} | ||
step={0.1} | ||
/> | ||
<Button variant="text" onClick={() => changeVolume(AUDIO_ON)}> | ||
<VolumeUp /> | ||
</Button> | ||
</Stack> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./sound-provider.jsx"; |
Oops, something went wrong.