Skip to content

Commit

Permalink
🆕 Option to mute sound
Browse files Browse the repository at this point in the history
Background
====

As an average player/debugger (and a fun of some live streamers),
I want to play/debug the game while watching a YouTube live etc.
Playing sound is a little annoying in such a usecase.

Suggestion
====

Add an option to mute the sound of the game.
  • Loading branch information
igrep committed Apr 13, 2024
1 parent 3f3521f commit 0aa6470
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/game/configuration/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const collisionPointOnBallClass = "bba-collision-point-on-ball"
export type StartOptions = {
withScoreboard: boolean
initialBallSpeed: "low" | "middle" | "high" | "superHigh"
sound: boolean
}

type BarSetting = {
Expand Down
2 changes: 1 addition & 1 deletion src/game/start/standby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function standby(
scoreboard: Scoreboard | null,
startOptions: StartOptions
) {
const ring = setSoundEffect()
const ring = startOptions.sound ? setSoundEffect() : () => {}

window.addEventListener("mousemove", moveBarAndBall)

Expand Down
22 changes: 21 additions & 1 deletion src/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function IndexPopup() {
) => {
setInitialBallSpeed(e.target.value as StartOptions["initialBallSpeed"])
}
const [sound, setSound] = useState(true)

const sendMessageToIsolatedWorldOnActiveTab = () => {
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
Expand All @@ -27,7 +28,7 @@ function IndexPopup() {
}
chrome.tabs.sendMessage<StartMessage>(
activeTab.id,
createStartMessage({ withScoreboard, initialBallSpeed })
createStartMessage({ withScoreboard, initialBallSpeed, sound })
)
})
}
Expand Down Expand Up @@ -117,6 +118,25 @@ function IndexPopup() {
Off
</label>
</div>
<div style={{ marginTop: "16px" }}>
Sound {sound ? "🔊" : "🔇"}<br />
<label>
<input
type="radio"
checked={sound}
onChange={(e) => setSound(e.target.checked)}
/>
On
</label>
<label>
<input
type="radio"
checked={!sound}
onChange={(e) => setSound(!e.target.checked)}
/>
Off
</label>
</div>
<br />
{process.env.NODE_ENV === "development" ? (
<button onClick={sendMessageToIsolatedWorldOnActiveTabForTest}>
Expand Down

0 comments on commit 0aa6470

Please sign in to comment.