WP-131: The ImGui debug panel (Gen 1)
Status: ✅ Done (2026-11-30). Fork PR barefootbetters/scummvm#57 merged on 2026-11-30 (merge commit a890f32625); Jeff ran the panel and accepted it on 2026-11-30. Decisions D1–D3 approved by Jeff, 2026-11-30.
Phase: 5 (tooling for the rooms-played packets).
Depends on: WP-130 ✅ (the operations the
panel calls, and the hit overlay).
Companion EC: none (inline checklist under Exit criteria).
Pre-flight: pre-flight-WP-131-2026-11-30. Required: the packet modifies engines/terraglyph/** and the build’s configuration.
Targets generation(s): Gen 1, both titles. Desktop (SDL) builds only.
Estimated effort: a day.
Goal
A panel beside the game that shows its state and changes it through WP-130’s operations. It does for TerraGlyph what Tweakpane does for Legendary Arena and Herbs vs. Ailments, with the library ScummVM already uses for this: Dear ImGui.
Background
ImGui in ScummVM
ScummVM vendors Dear ImGui (backends/imgui/) as the optional imgui
component (USE_IMGUI, “Dear ImGui based debugger” in configure). In the
fork, director, qdengine, scumm, twp, ultima8 and others use it
for their debuggers. Director and qdengine share one pattern:
- the engine passes
init,renderandcleanupcallbacks with_system->setImGuiCallbacks(); - the panel shows only while the
imguidebug channel is on (debugChannelSet(-1, kDebugImGui)). The run loop checks the channel and sets or clears therendercallback, so the panel costs nothing while it’s off; - the channel is turned on with
--debugflags=imgui, or from the console withdebugflag_enable imgui.
An ImGui debugger is an accepted shape upstream, so this packet doesn’t add to WP-082’s risk if it follows that pattern.
Why it’s off in our build
configure enables ImGui only with FreeType and an SDL backend. The fork’s
build (./configure --disable-all-engines --enable-engine=terraglyph,
2026-11-27) has #undef USE_FREETYPE2 in config.h, because the UCRT64
toolchain has no FreeType: C:\msys64\ucrt64\lib has SDL2 and no
libfreetype. Installing mingw-w64-ucrt-x86_64-freetype and re-running
configure should report ImGui... yes.
The Android backend isn’t an SDL backend, so configure turns ImGui off
there (“no (backend unsupported)”). The TV build is unchanged.
Scope
In scope
- The build. FreeType in the UCRT64 toolchain, the fork reconfigured,
USE_IMGUIdefined. The pre-flight records the configure line and itsImGuiresult. If the TerraGlyph release build (Make-Release.ps1) picks up ImGui too, that’s expected: the panel stays behind the debug channel. - The gate. A new debug channel,
kDebugImGui(“imgui”, “Show the ImGui debug panel”), and the Director and qdengine callback pattern inTerraglyphEngine::run(). Every ImGui file and call is inside#ifdef USE_IMGUI, andmodule.mkadds the panel’s files only underifdef USE_IMGUI. - The panel,
debug_panel.cpp/.h. Each window reads the engine’s state each frame and writes only through WP-130’s operations.- Room: the current room, its class,
StartRoom, and a filterable list ofROOM_names. Picking one callsgotoRoom(). - Game values: the
[Game]section as a table.Yes/Novalues are checkboxes, numbers are input fields, and the rest are text. An edit callssetGameValue(). A row adds a new key. - Clues:
CluesFound0-4andClueOwners0-4, the villain (Whodunit), and a button per suspect that callsgiveClue(). - Inventory: the toolbar’s slots and the cursor. Add from a filterable list of inventory objects, remove per slot.
- Hits: the overlay’s toggle (
setHitOverlay()), and the sprite under the mouse: index, kind, object, label, destination, rollover and hit type. - Sound and movies: the clip list with play and stop, and the movie
ids. These call the same code as
sound_play,sound_stopandmovie. - Profile:
getProfileText(), read-only, with a copy button. A copied profile pasted into a.savis a base for a live run’s script.
- Room: the current room, its class,
- Self-test: none new. The panel has no logic of its own beyond calling WP-130’s operations, which WP-130’s check covers. The exit criteria check the build and the panel live.
Out of scope
- New operations. If a window needs a write that WP-130 doesn’t have, it goes into WP-130’s operations first, with its check.
- Pause and single-tick stepping. It’s useful for animation work, but the run loop’s tick and the music timing need their own look first. That’s a separate packet if wanted.
- Live tuning values (
ghost_chanceis read once at start, inTerraglyphEngine::run()). Making it live is an engine change for a later packet. - The Hotspot Magnet’s targets, after WP-107.
- The TV build.
Decisions for Jeff
Jeff, 2026-11-30: “Yes, approve all”. Every recommendation below is the decision.
| # | Question | Options | Recommendation (approved) |
|---|---|---|---|
| D1 | The gate | (a) the imgui debug channel, as Director and qdengine do; (b) a config key; (c) a build flag of our own |
(a). It matches upstream, it’s off unless asked for, and it can be turned on from the console in a running game. |
| D2 | FreeType in the toolchain | (a) install it and build with ImGui by default; (b) a second build directory with ImGui | (a). One build. With the channel off, the panel costs only the #ifdef‘d code size. |
| D3 | Which windows come first | the seven above, in that order; or a subset | All seven. Each is a thin view over a getter and an operation. Room, Game values and Hits carry most of the value. If the day runs out, ship those three and note the rest. |
Execution
- Pre-flight: install FreeType, reconfigure, and record
ImGui... yes. Confirm the panel draws over the engine’s 640×480 RGB565 mode through the SDL backend (the OpenGL or SDL-renderer pathconfigurepicked). Note whetherMake-Release.ps1’s build now definesUSE_IMGUI. - Add
kDebugImGui, the callbacks inrun()and an empty window. Build, run with--debugflags=imgui, and see it. - Add the windows, each over WP-130’s operations.
- Run the self-test with the channel off: it matches the WP-130 run.
- Live: with the channel on, from a new game, pick a Phantom room, set a
[Game]flag, give a clue and an item, turn hits on, and take a screenshot. - Fork PR against
scooby-engine, using the style checker. Staged by name.
Exit criteria
- Build.
configurereportsImGui... yes. The engine builds with no new warnings, with and without--disable-imgui. - Off by default. Without the
imguichannel, no panel shows, therendercallback is unset, and the self-test matches the WP-130 run but for the random keys. - One path. The panel’s code has no direct
setGame*,giveClue,InventoryorshowRoomcall. Every write goes throughdebug_tools.cpp, and each logs itsDebug:line. - Live. With
--debugflags=imgui: a room picked from the list is entered with its opening; a flag set in the table reads back ingame KEYin the console; a clue given shows in the Clues window and in the clue book; the overlay toggles. A screenshot shows the panel beside the game. Met on Jeff’s run and acceptance (see Result): his screenshot shows the panel beside the game with the overlay on; the flag and clue clicks aren’t in it, and the run kept no log. - Process. The fork PR against
scooby-engineis open.
Result
Evidence labels: log (a self-test’s or a run’s debug log), live (session) (a scripted run this session drove and read), live (Jeff) (Jeff’s own run and his screenshot).
- The change (source). On
wp-131-imgui-debug-panel(1abb8d4231), fork PR barefootbetters/scummvm#57:configure.enginenames theimguicomponent;module.mkbuildsdebug_panel.ounderUSE_IMGUI;debug_panel.{h,cpp}: the seven windows, the View menu and the callbacks;debug_tools.cpp:runDebugCommand(), the one dispatcher for the script’s debug verbs and the panel’s queue, which also plays sounds and movies (sound,sound_stop,movie), andrunDebugRequests(), which the loop calls before each tick;terraglyph.cpp: the callbacks inrun(), set and cleared with the channel as Director and qdengine do; the script driver on the dispatcher;terraglyph.h,clues.cpp: the getters the windows read (getSuspects(),getInventoryObjectNames(),getStartRoom(),hasRoomClass()).
Two parts of the plan changed:
- The channel is ScummVM’s common
kDebugImGui, not a new one. - The panel doesn’t call the operations: it queues commands, because its
callback runs inside
updateScreen().
- Build (log).
ImGui... yes(SDL renderer 2) with FreeType, andImGui... no,USE_IMGUIundefined, with--disable-imgui. Neither build has warnings; the style checker finds nothing in the source. - A crash, found and fixed. The first run with
--debugflags=imguicrashed at the title screen. gdb put it ingetGameValues():INIFile::getKeys("Game")reads through a missing section, and before a game starts there’s no[Game]. That bug came in with WP-130, whose consolegamecommand would crash the same way at the title; WP-130’s runs never listed the values before setting one. Fixed in this PR. - Self-test (log). With the channel off, on the final build, the check lines match the WP-130 run except for the per-run random picks and the overlay’s time (56 ms against 35). Same 18 warnings.
- The script on the dispatcher (live (session)). WP-130’s live script
on this build:
- the same
Debug:lines: room, two[Game]values, the ruby, Ewan’s clue, hits on and off, the ruby taken; - the same four refusals;
- the same five screenshots.
- the same
- The panel running (log). After the fix, a run with
--debugflags=imgui,script,inputstayed up for five minutes in the town, its script’sDebug:lines logged, until it was stopped. The render callback runs every frame with the channel on: the crash was inside it. - The clicks (live (Jeff)). ImGui reads SDL’s events, not the
engine’s, so
test_scriptcan’t click the panel, and desktop control of the game window was declined. Jeff ran the build himself on 2026-11-30 and accepted it (“Looks good”). His screenshot shows:- the View menu above the game, with the Room and Hits windows open beside it;
- the room changed from the script’s Town to
ROOM_P05_Gardeners_House, the Room window reading it and listing the rooms under its filter; - the hit overlay on, tinted by kind: the exit green, the requires-gated curtain magenta, the drawers yellow, the gang orange, the toolbar’s van blue, the layers untinted;
- the Hits window reading the sprite under the mouse (
Sprite 1: layer, hit type 1).
The run kept no log, so a flag set in the table and a clue given from its button rest on Jeff’s acceptance, not on a
Debug:line.
Deliverables
- Toolchain:
mingw-w64-ucrt-x86_64-freetype2.15.0 in UCRT64; the configure line is in the pre-flight. - Fork:
wp-131-imgui-debug-panel, PR barefootbetters/scummvm#57 (1abb8d4231), merged asa890f32625. Staged by name:configure.engine,module.mk,debug_panel.{h,cpp},debug_tools.cpp,clues.cpp,terraglyph.{h,cpp}. - Docs: this packet, its pre-flight and the index row.
- Local only: the logs, the gdb backtrace and the screenshots, Jeff’s among them.