loot overlay: speak the contents of visible containers

The tutorial teaches "press s to see the contents of containers", and it was
silent. For a sighted player s sets levelWindow.itemsHighlightEnabled, which
draws the top item's icon on every loot-bearing tile in FoV.

We watch that flag rather than binding s ourselves -- it is game-claimed, and
keybindings.getCommand() ignores modifiers -- and speak on its rising edge, so
the player's own binding, hold vs toggle mode and the toolbar icon all work.
The flag is checked both at end of frame and inside the keypressed wrapper,
because in hold mode a quick tap goes up and down within one frame.

Reads the whole tile.loot list, not just the icon's top entry, nearest first,
with each container pushed to the console history for [ ] review.

71 testbed checks, 0 failures.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Accessibility Mod
2026-08-03 01:45:18 +02:00
co-authored by Claude Opus 5
parent dddd8ed9de
commit 93ef26349a
5 changed files with 529 additions and 3 deletions
+10
View File
@@ -99,6 +99,9 @@ function accessibility.selfTest()
end
end
local lootOk, lootStatus = pcall(require("accessibility.lootoverlay").probeStatus)
print("[accessibility] loot overlay: " .. (lootOk and tostring(lootStatus) or ("FAILED: " .. tostring(lootStatus))))
print("[accessibility] --- end self test ---")
end
@@ -165,6 +168,7 @@ local function hookStates()
pcall(require("accessibility.viewwatch").update, dt)
pcall(require("accessibility.status").update)
pcall(require("accessibility.details").update, dt)
pcall(require("accessibility.lootoverlay").update)
pcall(speech.flush)
if testbedActive then
pcall(testbed.update, dt)
@@ -190,6 +194,12 @@ local function hookStates()
local keyResult = realKeypressed(key, scancode)
-- The loot overlay is edge-triggered off a flag the game sets, and in
-- hold-to-highlight mode a quick tap can set it and clear it again inside
-- one frame -- the end-of-frame poll would then never see it up. Checking
-- here, between the game's keypressed and its keyreleased, catches the tap.
pcall(require("accessibility.lootoverlay").update)
-- After the game handler, so we read the focus it just moved to.
pcall(function()
menus.announceFocusIfChanged(states.getCurrent())