feat(audio): add the Audio source dropdown to the welcome screen

The opening screen only had Volume + Video speed — no way to pick the sound mode
before launching. Add a welcome Audio dropdown (None/Soundtrack/Music) mirroring
the panel; applyWelcomeToPanel carries the choice into the session on launch, None
greys the welcome Volume, and ?audio= presets it on the welcome screen too. +4 e2e
(welcome-audio.spec.ts).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
BenStullsBets
2026-07-02 16:56:17 -07:00
parent 4f4f21a767
commit da3581afea
3 changed files with 62 additions and 0 deletions
+12
View File
@@ -1420,6 +1420,7 @@ function applyUrlAudioParams() {
const src = (p.get("audio") || "").toLowerCase();
if (src === "none" || src === "soundtrack" || src === "music") {
const el = $("audio-source"); if (el) el.value = src;
const w = $("welcome-audio-source"); if (w) w.value = src; // reflect on the opening screen too
}
const vol = p.get("vol");
if (vol !== null && vol !== "" && Number.isFinite(+vol)) {
@@ -1681,11 +1682,18 @@ function applyWelcomeToPanel() {
$("visual").checked = true; // the welcome screen assumes Video on (no toggle)
const wa = $("welcome-audio");
if (wa) { $("audio").value = wa.value; updateAudioLevelLabel(); }
const ws = $("welcome-audio-source"); // carry the chosen source into the panel dropdown
if (ws) { $("audio-source").value = ws.value; syncVolumeDisabled(); }
}
function updateWelcomeAudioLabel() {
const el = $("welcome-audio-val");
if (el) el.textContent = String(+($("welcome-audio") || {}).value || 0);
}
// Volume is meaningless on None — grey the welcome slider too, mirroring the panel.
function syncWelcomeVolumeDisabled() {
const src = $("welcome-audio-source"), slider = $("welcome-audio");
if (src && slider) slider.disabled = src.value === "none";
}
// Remove the welcome overlay (fade out) — the panel reveals via `body:has(#welcome)`.
function enterSimulation() {
@@ -1718,6 +1726,9 @@ function initWelcome() {
updateWelcomeAudioLabel();
const wa = $("welcome-audio");
if (wa) wa.addEventListener("input", updateWelcomeAudioLabel);
const ws = $("welcome-audio-source");
if (ws) ws.addEventListener("change", syncWelcomeVolumeDisabled);
syncWelcomeVolumeDisabled();
const launch = $("welcome-launch");
if (launch) launch.addEventListener("click", onLaunch);
}
@@ -1748,6 +1759,7 @@ async function main() {
$("audio-source").addEventListener("change", () => { syncVolumeDisabled(); applyAudio(); debounced(); });
applyUrlAudioParams(); // shareable ?audio=/?vol= deep-link presets
syncVolumeDisabled();
syncWelcomeVolumeDisabled(); // reflect a URL-set source on the welcome slider too
updateWelcomeAudioLabel();
// Video toggle (panel): the FIRST time video turns on without having entered via
// Launch, begin the experience too — couple audio in. (Normally Launch entered
+7
View File
@@ -26,6 +26,13 @@
list="play-speed-ticks" aria-describedby="welcome-play-speed-val" />
<span id="welcome-play-speed-val">1.00×</span>
</label>
<label class="audio-source"><span data-i18n="output.audio">Audio</span>
<select id="welcome-audio-source" aria-label="Audio source">
<option value="none" data-i18n="output.audio.none">None</option>
<option value="soundtrack" data-i18n="output.audio.soundtrack" selected>Soundtrack</option>
<option value="music" data-i18n="output.audio.music">Music</option>
</select>
</label>
<label class="audio-level"><span data-i18n="output.volume">Volume</span>
<input type="range" id="welcome-audio" min="0" max="10" value="2" step="1" />
<span id="welcome-audio-val">2</span>/10