-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Sound & Effects Settings + Notifications #3951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ import { createCanvas } from "./Utils"; | |
| import { createRenderer, GameRenderer } from "./graphics/GameRenderer"; | ||
| import { GoToPlayerEvent } from "./graphics/TransformHandler"; | ||
| import { SoundManager } from "./sound/SoundManager"; | ||
| import { PlaySoundEffectEvent } from "./sound/Sounds"; | ||
|
|
||
| export interface LobbyConfig { | ||
| cosmetics: PlayerCosmeticRefs; | ||
|
|
@@ -99,6 +100,7 @@ export function joinLobby( | |
| startGame(lobbyConfig.gameID, lobbyConfig.gameStartInfo?.config ?? {}); | ||
|
|
||
| const transport = new Transport(lobbyConfig, eventBus); | ||
| const soundManager = new SoundManager(eventBus, userSettings); | ||
|
|
||
|
Comment on lines
+103
to
104
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dispose pre-start
Suggested fix return {
stop: (force: boolean = false) => {
if (!force && currentGameRunner?.shouldPreventWindowClose()) {
console.log("Player is active, prevent leaving game");
return false;
}
console.log("leaving game");
if (currentGameRunner) {
currentGameRunner.stop();
currentGameRunner = null;
} else {
+ soundManager.dispose();
transport.leaveGame();
}
return true;
},🤖 Prompt for AI Agents |
||
| let currentGameRunner: ClientGameRunner | null = null; | ||
|
|
||
|
|
@@ -130,6 +132,23 @@ export function joinLobby( | |
| if (message.type === "start") { | ||
| // Trigger prestart for singleplayer games | ||
| resolvePrestart(); | ||
|
|
||
| eventBus.emit(new PlaySoundEffectEvent("game-start")); | ||
|
|
||
| if ( | ||
| "Notification" in window && | ||
| Notification.permission === "granted" && | ||
| document.hidden && | ||
| userSettings.gameStartNotificationsEnabled() | ||
| ) { | ||
| try { | ||
| new Notification(translateText("game_start_notification.title"), { | ||
| body: translateText("game_start_notification.body"), | ||
| }); | ||
| } catch (err) { | ||
| console.warn("Failed to show game start notification:", err); | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| console.log( | ||
| `lobby: game started: ${JSON.stringify(message, replacer, 2)}`, | ||
| ); | ||
|
|
@@ -144,6 +163,7 @@ export function joinLobby( | |
| eventBus, | ||
| transport, | ||
| userSettings, | ||
| soundManager, | ||
| terrainLoad, | ||
| terrainMapFileLoader, | ||
| ) | ||
|
|
@@ -231,12 +251,14 @@ async function createClientGame( | |
| eventBus: EventBus, | ||
| transport: Transport, | ||
| userSettings: UserSettings, | ||
| soundManager: SoundManager, | ||
| terrainLoad: Promise<TerrainMapData> | null, | ||
| mapLoader: GameMapLoader, | ||
| ): Promise<ClientGameRunner> { | ||
| if (lobbyConfig.gameStartInfo === undefined) { | ||
| throw new Error("missing gameStartInfo"); | ||
| } | ||
|
|
||
| const config = new Config( | ||
| lobbyConfig.gameStartInfo.config, | ||
| userSettings, | ||
|
|
@@ -267,7 +289,6 @@ async function createClientGame( | |
| ); | ||
|
|
||
| const canvas = createCanvas(); | ||
| const soundManager = new SoundManager(eventBus, userSettings); | ||
| try { | ||
| const gameRenderer = createRenderer( | ||
| canvas, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move
game_start_notificationunderfullscreento match expected key path.This block is currently top-level, but the stack contract for this PR expects
fullscreen.game_start_notification.title/body. In the current shape, lookups on that path will fail.Proposed fix
"fullscreen": { - "enter": "Enter fullscreen", - "exit": "Exit fullscreen" - }, - "game_start_notification": { - "title": "The game is starting", - "body": "Choose your starting position" + "enter": "Enter fullscreen", + "exit": "Exit fullscreen", + "game_start_notification": { + "title": "The game is starting", + "body": "Choose your starting position" + } }📝 Committable suggestion
🤖 Prompt for AI Agents