Menu narration + code-driven testbed
Pulls menu focus narration forward from Phase 4: it was a blocker, since the screen name was spoken but not the selected option, so the game could not be started at all. Game-file footprint unchanged: still one line in main.lua. - menus.lua: descriptor driver supporting both D3 backends (upvalue probe and patched-announce), sharing one render per screen. Probe self-test included. - Descriptors for main_menu, settings_menu, load_game, new_game, narration. - testbed.lua: drives the game by code via love.event.push, so input takes the same path as a human keypress. Coroutine-based, and navigates by READING focus rather than counting keypresses, which drifts when options are disabled. Three bugs found by the testbed and fixed: 1. love.keypressed was still bound to the pre-wrapper states.keypressed. states.setup() captures love[callback] by value and runs before us, and main.lua does not define love.keypressed itself, so wrapping the states table field alone had no effect. Now reassigns love.keypressed/textinput. 2. Focus can move with no keypress: main_menu.mousemoved assigns selectedOption from cursor position, silently overriding selection including at startup. Focus is now polled in the update hook instead of announced only on keypress. 3. Probes sometimes need chaining. narration.keypressed only calls continueNarration(), so the text locals are upvalues of that inner function. Verified: main menu -> new game -> name entry -> intro narration -> gameplay, 8/8 checks passing, including console.print capture and its (x2) fold. Known gap: ingame_dialogue announces 'Game' and reads no dialogue text. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
fe872be683
commit
9945703fb7
@@ -0,0 +1,25 @@
|
||||
-- states/main_menu.lua
|
||||
--
|
||||
-- Options are static (Continue / New game / Load game / Options / Manual /
|
||||
-- Credits / Exit game); `isEnabled` is recomputed in open(), so "Continue" and
|
||||
-- "Load game" are unavailable on a fresh install. Announcing that matters --
|
||||
-- otherwise pressing enter appears to do nothing.
|
||||
|
||||
return {
|
||||
probe = {
|
||||
fn = "keypressed",
|
||||
focus = "selectedOption",
|
||||
list = "optionsList",
|
||||
focusMayBeNil = true, -- nil until open() picks the first enabled option
|
||||
},
|
||||
|
||||
render = function(entry, index, total)
|
||||
local text = entry.title or "?"
|
||||
|
||||
if entry.isEnabled == false then
|
||||
text = text .. ", unavailable"
|
||||
end
|
||||
|
||||
return text .. ", " .. index .. " of " .. total
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user