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,30 @@
|
||||
-- states/new_game.lua
|
||||
--
|
||||
-- Not a list — a single text field for the character's name. So this uses a
|
||||
-- custom read() rather than the focus/list probe.
|
||||
--
|
||||
-- `inputText` is an upvalue of keypressed (which handles backspace and tab).
|
||||
-- Note the game only enables textinput here, so our hotkey layer stays out of
|
||||
-- this state (see hotkeys.lua textEntryStates) and typed brackets reach the game.
|
||||
|
||||
return {
|
||||
-- Spoken when the screen opens, since the on-screen hint window is the only
|
||||
-- thing explaining what to do.
|
||||
onOpen = 'Enter your character name. Tab suggests a name, Enter confirms.',
|
||||
|
||||
read = function(stateTable, menus)
|
||||
local inputText = menus.getUpvalue(stateTable.keypressed, "inputText")
|
||||
|
||||
if type(inputText) ~= "string" then
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
if inputText == "" then
|
||||
return "Name, blank", "blank"
|
||||
end
|
||||
|
||||
-- Key is the text itself, so the driver re-announces on every change
|
||||
-- (typing, backspace, tab-suggest) but not on keys that change nothing.
|
||||
return inputText, inputText
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user