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,44 @@
|
||||
-- states/load_game.lua
|
||||
--
|
||||
-- Entries are save metadata. The screen draws three columns per row: character
|
||||
-- name, in-game elapsed time, and the real-world save timestamp. We speak all
|
||||
-- three, in that order -- the character name is what identifies a save, but the
|
||||
-- timestamps are how you tell two runs of the same character apart.
|
||||
|
||||
local capitalize = require("functions.capitalize")
|
||||
local turnsToTime = require("functions.turnsToTime")
|
||||
|
||||
return {
|
||||
probe = {
|
||||
fn = "keypressed",
|
||||
focus = "selectedOption",
|
||||
list = "metadataList",
|
||||
focusMayBeNil = true,
|
||||
},
|
||||
|
||||
render = function(entry, index, total)
|
||||
local parts = {}
|
||||
|
||||
parts[#parts + 1] = entry.characterName or "Unnamed"
|
||||
|
||||
if entry.turn then
|
||||
local ok, turnString = pcall(function()
|
||||
return capitalize(turnsToTime(entry.turn))
|
||||
end)
|
||||
if ok and turnString then
|
||||
parts[#parts + 1] = turnString
|
||||
end
|
||||
end
|
||||
|
||||
if entry.lastUpdatedTimestamp then
|
||||
local ok, dateString = pcall(os.date, "%X %x", entry.lastUpdatedTimestamp)
|
||||
if ok and dateString then
|
||||
parts[#parts + 1] = dateString
|
||||
end
|
||||
end
|
||||
|
||||
parts[#parts + 1] = index .. " of " .. total
|
||||
|
||||
return table.concat(parts, ", ")
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user