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:

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

  1. The build. FreeType in the UCRT64 toolchain, the fork reconfigured, USE_IMGUI defined. The pre-flight records the configure line and its ImGui result. If the TerraGlyph release build (Make-Release.ps1) picks up ImGui too, that’s expected: the panel stays behind the debug channel.
  2. The gate. A new debug channel, kDebugImGui (“imgui”, “Show the ImGui debug panel”), and the Director and qdengine callback pattern in TerraglyphEngine::run(). Every ImGui file and call is inside #ifdef USE_IMGUI, and module.mk adds the panel’s files only under ifdef USE_IMGUI.
  3. 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 of ROOM_ names. Picking one calls gotoRoom().
    • Game values: the [Game] section as a table. Yes / No values are checkboxes, numbers are input fields, and the rest are text. An edit calls setGameValue(). A row adds a new key.
    • Clues: CluesFound0-4 and ClueOwners0-4, the villain (Whodunit), and a button per suspect that calls giveClue().
    • 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_stop and movie.
    • Profile: getProfileText(), read-only, with a copy button. A copied profile pasted into a .sav is a base for a live run’s script.
  4. 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

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

  1. 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 path configure picked). Note whether Make-Release.ps1’s build now defines USE_IMGUI.
  2. Add kDebugImGui, the callbacks in run() and an empty window. Build, run with --debugflags=imgui, and see it.
  3. Add the windows, each over WP-130’s operations.
  4. Run the self-test with the channel off: it matches the WP-130 run.
  5. 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.
  6. Fork PR against scooby-engine, using the style checker. Staged by name.

Exit criteria

  1. Build. configure reports ImGui... yes. The engine builds with no new warnings, with and without --disable-imgui.
  2. Off by default. Without the imgui channel, no panel shows, the render callback is unset, and the self-test matches the WP-130 run but for the random keys.
  3. One path. The panel’s code has no direct setGame*, giveClue, Inventory or showRoom call. Every write goes through debug_tools.cpp, and each logs its Debug: line.
  4. Live. With --debugflags=imgui: a room picked from the list is entered with its opening; a flag set in the table reads back in game KEY in 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.
  5. Process. The fork PR against scooby-engine is 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).

Deliverables