popups: read the modal recipe, lore and map popups

Learning a recipe spoke the word "Popup" and then nothing.

There are two separate popup mechanisms and only one was covered.
patches/popupstack.lua wraps popupStack.add, but views/fadingPopup.lua
registers just four types -- journal, loot, bestiary and tutorial -- so
the recipe/lore/map keys in that patch could never fire. Those three are
modal instead: states/{ingame,inventory,research} build one from
modules/{recipe,lore,map}Popup.lua and switch to states/ingame_popup.

ingame_popup had a name in stateNames.lua and no descriptor, so
announceScreen said "Popup" and the focus poll had nothing to add.

The popup modules are factories exposing only draw(), so every string is
a closure local. The new descriptor takes popupObject off the state and
reads them as upvalues of popupObject.draw, detecting the type by which
locals exist since the object carries no type tag. Reading order follows
draw order, newlines are flattened (the lore footer is one sentence with
hard breaks in it), and the blocks go into the console history so [ and ]
walk a long fragment back; = re-reads it.

The prologue fires no popup, so the testbed raises them itself via
ingame.recipePopup and ingame.lorePopup -- both display-only, so nothing
is learned and the world is untouched. That check is this descriptor's
version-bump canary: the self-test can only report "custom read()" here,
because the probe is on the popup object rather than the state.

88 testbed checks, 0 failures.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Accessibility Mod
2026-08-03 02:29:01 +02:00
co-authored by Claude Opus 5
parent 55b19dd537
commit a1ad7f26c2
4 changed files with 298 additions and 5 deletions
+61 -5
View File
@@ -7,7 +7,7 @@ fixing what Talon hits. Remaining work is polish, mod settings and distribution.
**Game is playable start-to-finish by ear** from main menu through the intro
conversation into gameplay, plus journal, character, actions and inventory —
verified by the testbed, **78/78 checks**.
verified by the testbed, **88/88 checks**.
**Not set up yet, or unsure how the two trees relate?** →
[00-dev-setup.md](00-dev-setup.md).
@@ -790,6 +790,60 @@ pressing `1` twice, and putting the world back** (a lit torch would otherwise
change FoV for the viewwatch and loot checks that follow). Plus the header-table
canary and the `Wield`/`Unwield` flip.
### Done — modal popups: recipe / lore / map (bug fix, reported by Talon)
**Symptom:** learning a recipe (and similar) speaks the word **"Popup"** and then
nothing — the body text is never read.
**Cause.** There are **two entirely separate popup mechanisms**, and we had only
covered one.
- `patches/popupstack.lua` wraps `popupStack.add` — the *fading corner* popups.
But `views/fadingPopup.lua` registers only **four** types: `journal`, `loot`,
`bestiary`, `tutorial`. The `recipe` / `lore` / `map` keys in that patch's
`typeNames` table can never fire.
- Recipe, lore and map popups are **modal**. `states/{ingame,inventory,research}`
build one with `modules/{recipe,lore,map}Popup.lua` and then
`states.switch("ingame_popup", {popup = ...})`.
`ingame_popup` had a name in `stateNames.lua` ("Popup") and **no descriptor**, so
`announceScreen` said "Popup" and the poll had nothing to add. Exactly the
symptom.
**Fix** — `accessibility/states/ingame_popup.lua` (24th descriptor):
- `popupObject` comes off the state via `getAnyUpvalue`; the four popup modules
are factories exposing **only `draw`**, so every string is read as an upvalue
of `popupObject.draw`.
- **Type is detected by which locals exist**, since the popup object carries no
type tag: `itemsList`→loot, `items`→recipe, `title`+`subHeader`→lore,
`title`→map. An unrecognised popup falls back to reading the usual field names
rather than to silence.
- Reading order follows **draw order**, so speech matches the screen top to
bottom.
- Newlines are flattened (`lorePopup`'s footer is one sentence with hard breaks
in it) and blocks are pushed into the console history, so `[` / `]` / `\` walk
a long lore fragment back. `=` re-reads it via the `details` hook.
- `read()` is idempotent per the journal warning; the popup table's identity is
the focus key, and only the history push is guarded.
- Blocks are joined with a **space, not ". ", when the block already ends in
sentence punctuation** — otherwise NVDA gets "book.. This".
Live text:
`Popup. New recipe available! A bunch of ivy leaves. See the details in your
journal.`
**88 testbed checks, 0 failures** (was 78). The prologue fires no popup, so the
testbed raises them itself by calling `ingame.recipePopup` and `ingame.lorePopup`
— both display-only, so nothing is learned and the world is untouched. ⚠ The
dismiss key needs `wait(90)` first: `ingame_popup.keypressed` ignores input until
`fadeInAlpha >= 0.8`, over a 0.6 s fade. The self-test can only say
`custom read()` here (the probe is on the popup object, not the state), so **the
testbed check is this descriptor's version-bump canary**.
Still unexercised: the **map** popup (needs `worldmap.getLastAreaIcon`, i.e. a
discovered area) and the modal **loot** popup from `inventory.lootPopup`.
### Known gaps (next up)
- **Phase 5**: player status key (HP, statuses, current action), popup
announcements (`popupStack.add`), damage alerts
@@ -854,7 +908,7 @@ utterance — speech is verifiable from the log, not only by ear. `!` after
## HANDOFF — read this if you are resuming
### State of play
Phases 0–5 complete. **23 state descriptors, 7 patches, 78/78 testbed checks**,
Phases 0–5 complete. **24 state descriptors, 7 patches, 88/88 testbed checks**,
history unit tests passing, **one line changed in the game** (`main.lua`).
Everything in the original brief is implemented: console speech with
@@ -864,7 +918,7 @@ exploration, wall tones, and keyboard+speech access to every screen.
### First thing to do after any change
```
lua accessibility/tests/test_history.lua # pure Lua, instant
bash accessibility/tests/run-testbed.sh # ~4 min, 78 checks
bash accessibility/tests/run-testbed.sh # ~4 min, 88 checks
git diff --stat vanilla-0.4.2 -- . ':!accessibility' ':!.gitignore' ':!CLAUDE.md' # must stay: main.lua | 1 +
```
@@ -912,8 +966,10 @@ These are blocked on content the prologue does not contain, **not** known broken
- **The loot overlay (`s`) against real loot.** The prologue contains none, so
live it has only ever said `No loot in view`. The contents path is proven by
the testbed's planted-loot check, not by a real chest.
- **Popup announcements** (`patches/popupstack.lua`) — loot/quest/recipe popups
did not fire during the prologue run.
- **Corner popup announcements** (`patches/popupstack.lua`) — loot / quest /
bestiary / tutorial popups did not fire during the prologue run. (The *modal*
recipe / lore / map popups are a separate mechanism and are now covered by the
`ingame_popup` descriptor and the testbed.)
### Known-missing features (deliberate, not bugs)
- **No mod settings UI.** Verbosity (`describe.verbosity`), wall-tone config