Opening the journal and selecting an entry announced its title and stopped,
which is an index into content the player could never reach. Page flipping was
silent too.
The screen is three widgets at once: the tab row (q/e), the list of entry
titles down the left (up/down), and the page on the right holding the actual
text (left/right). The descriptor read only the first two.
It now reads options[selectedOption].pages[selectedPageId] and speaks its text
blocks. A page is bounded by what fits on screen, so it is safe as a single
utterance. Layout newlines are flattened first -- splitTextByPages joins the
game's own wrapped lines with \n, so left in they make the reader pause
mid-sentence at every wrap point. Page position is announced only when there is
more than one page, and the blocks are pushed into the console history so [ and
] walk back through a long lore entry after the utterance has gone by.
The tab leads only when the tab changed and the title only when the entry
changed, so flipping pages does not bury the new page under a repeated heading.
That suppression made read() stateful, which is a trap: it is called for the
same focus from four places -- the per-frame poll, the post-keypress announce,
repeatFocus, and the testbed's before/after probes -- so a poll would consume
the "changed" flag and the real announcement would come out headless. The
descriptor now caches its last (key, text) and replays it whenever the key is
unchanged, making read() idempotent; the suppression state advances exactly
once per genuine focus change.
Adds a generic descriptor.reset hook, called from menus.announceScreen. The
memory lives in file-locals that outlive the screen, so without it reopening
the journal on the entry you left it on would read the page with no title.
Testbed asserts the spoken text contains the page body rather than merely being
non-nil. 29 checks, 0 failures.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Game-file footprint unchanged: still one line in main.lua.
Adds descriptors for actions_menu, worldmap, alchemy_table, journal, character,
inventory, and a shared one for the full-screen prose states (menu_text,
ingame_message, menu_message). The prose states also push their text into the
console history, so the existing review keys walk the manual paragraph by
paragraph rather than delivering it as one unusable utterance.
Two driver improvements, both prompted by real failures the self-test caught:
- menus.getAnyUpvalue finds a file-local across all of a state's functions and
one level into inner closures. Safe because a Lua file-local is a single
shared upvalue. Needed because actions_menu and worldmap build their lists in
open() and never reference them in keypressed, so the named probe function
found nothing. The generic probe path now falls back to this.
- menus.hasUpvalue checks that a local exists rather than that it holds a value.
getUpvalue cannot distinguish 'no such local' from 'declared but currently
nil', which made the self-test report PROBE BROKEN for worldmap, whose
'local options' is nil until the screen is first opened.
patches/popups.lua now stands down for any state that has a descriptor.
inventoryCursorPopup.set only fires when an item is under the cursor, so empty
slots and empty tabs were silent and you could not tell the cursor had moved.
The inventory descriptor reports item-or-empty plus slot and tab instead.
21/21 testbed checks, history unit tests passing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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>