Inspector panel for the selected pawn or building (#142) #151

Merged
liamjd merged 1 commit from 142-inspector-panel into main 2026-10-10 18:02:04 +01:00
Owner

Closes #142

Adds the inspector panel: details of whatever GameState.selected holds, on the left edge of the HUD. The decisions are in #142's body, and the spec is in its comments (the outline, plus the 2026-10-10 amendment, which stops the tests from fixing wording and row order).

What changed

  • ui/inspector/inspector_panel.gd / .tscn: InspectorPanel. Three pure static builders (title_for, pawn_rows, building_rows) produce the rows, and refresh() renders them for the current selection.
    • Pawn: state, cell, and task (its label, or "idle").
    • Building: status. While PLANNED or UNDER_CONSTRUCTION it also shows progress, and a Blocked row when blocked. It shows Marked for demolition only when marked, and the workers when there is a task ("none" when nobody holds it).
  • Refresh: on GameState.selection_changed and GameClock.tick, with no _process. The panel is hidden whenever nothing is selected, so a mode change or removing the selected entity hides it through #78's clearing.
  • entities/buildings/buildings.gd: _task_for() is now public as task_for(). No behaviour change.
  • common/game.gd / game.tscn: the panel is instanced under UIHUDLayer, and game.gd injects TaskManager and Buildings inside the editor guard. The panel copes with either being missing.
  • tools/screenshot_inspector.gd: the headed check.

Verification

  • test/unit/test_inspector_panel.gd, 34 tests:

    • Builders: what each builder shows, and that the flag rows appear only when set.
    • Panel: shown, hidden and replacing its rows as the selection changes; redrawn on a tick but not on frames alone; catches the mouse.
    • Registries: the injected registries, including only the TaskManager being set.
    • Buildings.task_for.
  • Full GUT suite: 929 passed, 1 pending (the existing #85 placeholder). Editor scan: no script errors.

  • Headed, with tools/screenshot_inspector.gd on the real game scene:

    • an idle pawn;
    • an ore mine under construction with Pawn 1 on it;
    • the same pawn WORKING, showing the construction task.

    All three were checked by eye.

Caveats

  • Flag rows have an empty value, so the second column is blank. This is left for the styling pass.
  • The panel's width follows its content: about 240 px for a pawn, up to about 380 px for a long task label. It is anchored left, so it grows rightwards. Also left for styling.
  • No role row: pawns have no role until #74, which now carries that criterion.
  • The panel's position (left edge) may swap with the lists later (decision 7).

🤖 Generated with Claude Code

Closes #142 Adds the inspector panel: details of whatever `GameState.selected` holds, on the left edge of the HUD. The decisions are in #142's body, and the spec is in its comments (the outline, plus the 2026-10-10 amendment, which stops the tests from fixing wording and row order). ## What changed - **`ui/inspector/inspector_panel.gd` / `.tscn`**: `InspectorPanel`. Three pure static builders (`title_for`, `pawn_rows`, `building_rows`) produce the rows, and `refresh()` renders them for the current selection. - **Pawn:** state, cell, and task (its label, or "idle"). - **Building:** status. While PLANNED or UNDER_CONSTRUCTION it also shows progress, and a Blocked row when blocked. It shows Marked for demolition only when marked, and the workers when there is a task ("none" when nobody holds it). - **Refresh:** on `GameState.selection_changed` and `GameClock.tick`, with no `_process`. The panel is hidden whenever nothing is selected, so a mode change or removing the selected entity hides it through #78's clearing. - **`entities/buildings/buildings.gd`**: `_task_for()` is now public as `task_for()`. No behaviour change. - **`common/game.gd` / `game.tscn`**: the panel is instanced under `UIHUDLayer`, and `game.gd` injects `TaskManager` and `Buildings` inside the editor guard. The panel copes with either being missing. - **`tools/screenshot_inspector.gd`**: the headed check. ## Verification - `test/unit/test_inspector_panel.gd`, 34 tests: - **Builders:** what each builder shows, and that the flag rows appear only when set. - **Panel:** shown, hidden and replacing its rows as the selection changes; redrawn on a tick but not on frames alone; catches the mouse. - **Registries:** the injected registries, including only the `TaskManager` being set. - **`Buildings.task_for`.** - Full GUT suite: 929 passed, 1 pending (the existing #85 placeholder). Editor scan: no script errors. - Headed, with `tools/screenshot_inspector.gd` on the real game scene: - an idle pawn; - an ore mine under construction with Pawn 1 on it; - the same pawn WORKING, showing the construction task. All three were checked by eye. ## Caveats - Flag rows have an empty value, so the second column is blank. This is left for the styling pass. - The panel's width follows its content: about 240 px for a pawn, up to about 380 px for a long task label. It is anchored left, so it grows rightwards. Also left for styling. - No role row: pawns have no role until #74, which now carries that criterion. - The panel's position (left edge) may swap with the lists later (decision 7). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
InspectorPanel shows whatever GameState.selected holds: a pawn's state, cell
and task, or a building's status, construction progress, flags and workers.
Hidden when nothing is selected, so a mode change or removing the selection
hides it through #78's clearing.

- Rows come from pure static builders (title_for, pawn_rows, building_rows),
  so the tests need no scene.
- Refreshes on selection_changed and GameClock.tick rather than _process;
  only building_status_changed exists as a state signal.
- Building flags get a row only when set - "blocked: no" is noise.
- Buildings._task_for() is now public task_for(), which the panel uses to
  find a building's workers.
- TaskManager and Buildings are injected by game.gd; either may be null.

The spec tests pin what the panel shows, not its wording or row order, as
the panel is expected to change a lot. tools/screenshot_inspector.gd is the
headed check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
liamjd merged commit 74d8bd1c0a into main 2026-10-10 18:02:04 +01:00
liamjd deleted branch 142-inspector-panel 2026-10-10 18:02:04 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder!151
No description provided.