Skip to content

WebGL: bring back sounds #3991

Open
VariableVince wants to merge 5 commits into
mainfrom
sound-effects-back
Open

WebGL: bring back sounds #3991
VariableVince wants to merge 5 commits into
mainfrom
sound-effects-back

Conversation

@VariableVince
Copy link
Copy Markdown
Contributor

@VariableVince VariableVince commented May 23, 2026

Description:

Play sound effects again after move to WebGL for which FxLayer.ts was removed. Now all is done from SoundController, triggered from ClientGameRunner.

Also:

  • Did NOT make SoundController handle other sounds from Radial Menu (since "click" is better just emitted directly on.. click) nor EventsDisplay or ActionableEvents (for seperation of concerns and too much complexity needed in SoundController compared to emitting them where all context is available).
  • Made sound effect names usage more type-safe.
  • Added the missing Silo built sound. Which was officially waiting for approval but i'm thinking it was probably overlooked (Implement FX sound effects #3394).

We still need to get a decision on adding the other 4 sounds though, for a later PR possibly. Warship shot, Warship lost, SAM shoot, SAM hit. The sound files are present but PR3394 showed status Waiting for approval:

image

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

tryout33

…d. Now all is done from ClientGameRunner.

Added the missing Silo built sound. Which was officially waiting for approval but i'm thinking it was probably overlooked (#3394).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a typed SoundEffect enum and URL registry, emits SoundUpdateEvent from ClientGameRunner, adds SoundController to translate game updates into PlaySoundEffectEvent emissions, wires the controller into the renderer, and updates HUD layers and tests to use the enum identifiers.

Changes

Game Sound Effects

Layer / File(s) Summary
Sound effect type registry
src/client/sound/Sounds.ts
Converted sound identifiers to an exported SoundEffect enum, added SoundEffect.SiloBuilt, and updated soundEffectUrls and PlaySoundEffectEvent typing.
ClientGameRunner emits SoundUpdateEvent
src/client/ClientGameRunner.ts
Import SoundUpdateEvent and emit new SoundUpdateEvent(gu) in the worker update callback after hash events and before applying the game view update.
SoundController: update handling & sound logic
src/client/controllers/SoundController.ts
New controller subscribes to SoundUpdateEvent, gates by pending turns/ticks, and maps conquest and unit updates to PlaySoundEffectEvent(SoundEffect.*) for ka-ching, launch/build, and impact sounds.
Renderer and HUD integration
src/client/hud/GameRenderer.ts, src/client/hud/layers/*, src/client/hud/layers/RadialMenu.ts
Instantiate SoundController in renderer layers and update HUD layers (ActionableEvents, EventsDisplay, RadialMenu) to emit PlaySoundEffectEvent using SoundEffect enum values instead of raw strings.
Tests: migrate to enum identifiers
tests/client/sound/SoundManager.test.ts
Update tests to import SoundEffect and use enum values (Click, AtomHit, etc.) in place of string IDs across lazy-load, volume, dispose, error, and channel-cap tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • evanpelle

Poem

🎵 When updates flash and units take flight,
A tiny ka-ching greets conquest's bright.
Enums click tidy at each event,
Builds and impacts sound their intent.
Game and HUD hum in sync tonight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'WebGL: bring back sounds' directly and clearly summarizes the main change - restoring sound effects after the WebGL migration when FxLayer.ts was removed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly explains the changes: restoring sound effects after WebGL migration, making sound effect names type-safe, and adding the missing Silo built sound.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 23, 2026
Comment thread src/client/ClientGameRunner.ts Outdated
this.eventBus.emit(new SendHashEvent(hu.tick, hu.hash));
});

// Sound FX
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should create a controller for this? Like SoundController in the controller/ directory

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, done and also made it a bit more type-safe (hence the other files that emit PlaySoundEffectEvent that were also changed)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/client/ClientGameRunner.ts`:
- Around line 522-524: ClientGameRunner currently defines SoundUpdateEvent which
creates a circular import between ClientGameRunner, GameRenderer, and
SoundController; to fix this, extract the SoundUpdateEvent type (the
class/interface/union used to signal sound updates) into a tiny shared module
named e.g. SoundEvents and update imports so ClientGameRunner, GameRenderer, and
SoundController all import SoundUpdateEvent from that new module instead of from
ClientGameRunner; ensure you remove the original SoundUpdateEvent export from
ClientGameRunner and update any import sites to reference the new module so the
three-way init-order cycle is broken.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b333d2e9-0af2-4f4b-9c62-2550ac70c74c

📥 Commits

Reviewing files that changed from the base of the PR and between fb05e1f and 5210a51.

📒 Files selected for processing (8)
  • src/client/ClientGameRunner.ts
  • src/client/controllers/SoundController.ts
  • src/client/hud/GameRenderer.ts
  • src/client/hud/layers/ActionableEvents.ts
  • src/client/hud/layers/EventsDisplay.ts
  • src/client/hud/layers/RadialMenu.ts
  • src/client/sound/Sounds.ts
  • tests/client/sound/SoundManager.test.ts

Comment thread src/client/ClientGameRunner.ts Outdated
@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management May 23, 2026
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 23, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 23, 2026
@VariableVince VariableVince requested a review from evanpelle May 23, 2026 20:35
…n a replay (and possibly others in the future that are not local-player bound)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

2 participants