Repository navigation
Block step 1 Continue without a valid MIDI device - #12
Conversation
setupStep1NextButton was wired through the generic menuButtonTargets map exactly like every other nav button, advancing unconditionally. isValidMidiInput() already existed and was used correctly in startGame() (step 3) -- so a player could click through all 3 steps with no keyboard connected and only find out several steps removed from where they'd actually go plug one in. Pulls setupStep1NextButton out of the generic map into its own handler that checks isValidMidiInput() first. On failure it shows an inline message via a new showStep1Error()/#setupStep1Error pair (same pattern as showSetupError/#setupError, which lives inside #setupStep3Screen's DOM and isn't present on step 1). The message text is now a shared NO_MIDI_SELECTED_MESSAGE constant so step 1's gate and startGame()'s own check can't drift apart. startGame()'s check is untouched -- this is a second, earlier gate, not a replacement. Closes Men-in-Black-5/ideas#163
|
reviewer: approved. Confirmed |
Closes Men-in-Black-5/ideas#163.
Bug
setupStep1NextButtonwas wired through the genericmenuButtonTargetsmap exactly like every other nav button — it calledshowScreen('setupStep2Screen')unconditionally.isValidMidiInput(midi?.options)already existed and was used correctly, but only insidestartGame()(step 3) — so a player could click through all 3 steps with no keyboard connected and only find out on the final Start Game button, several steps removed from where they'd actually go plug something in.Fix
setupStep1NextButtonout of the genericmenuButtonTargetsloop into its own click handler that checksisValidMidiInput(midi?.options)before callingshowScreen('setupStep2Screen').showStep1Error()/#setupStep1Errorpair — same pattern asshowSetupError/#setupError, added because#setupErrorlives inside#setupStep3Screen's DOM and isn't present (or visible) on step 1.NO_MIDI_SELECTED_MESSAGEconstant, used by both step 1's new gate andstartGame()'s existing check, so the two can't drift apart.startGame()'s own check is untouched — this is a second, earlier gate, not a replacement.Testing
npx tsc --noEmit— clean.npx vitest run— 172 passed (15 files), including a newshowStep1Errortest mirroring the existingshowSetupErrorone.npm run build— clean,dist/app.jsincluded.chromium+ puppeteer-core) against a local static server:<option>and selected it, clicked Continue again: advanced to step 2 normally, and the step 1 error was cleared.