Extract an abstract EntityList base for the HUD lists (#146) #148

Merged
liamjd merged 1 commit from 146-entity-list-base into main 2026-10-10 15:31:56 +01:00
Owner

Closes #146

What changed

  • ui/lists/entity_list.gd: new @abstract class_name EntityList. It holds expand/collapse, add/remove, interaction-mode handling and selection sync. _cards is keyed by Entity, and _cards.has(new) replaces the is Pawn / is Building checks.
  • ui/lists/entity_list.tscn: the only definition of the list layout, with neutral unique names (%ListContainer). Its root has no script.
  • PawnList / BuildingList: only CARD_SCENE, _connect_entity_signals() and _make_card() remain. Both scenes are inherited from entity_list.tscn and keep their original uids, so game.tscn is untouched.
  • common/game.gd: removed the pawns_list.pawns / building_list.buildings wiring. The lists never read these references.

Behaviour changes (bug fixes)

  • Clicking a card emitted selection_changed twice: once from the GameState.selected setter and again by hand. It now fires once.
  • A card added outside NONE mode (e.g. a building placed in PLACE) started enabled. It now starts disabled.
  • Adding an entity while a list is collapsed now leaves it collapsed. The add still snaps rather than animating, so the startup spawn burst doesn't keep restarting the tween.
  • The arrow started as ^ while expanded. It now starts as v.
  • The two scenes' header layouts differed slightly. Both now use the building list's vertically centred version.

Verification

  • test/unit/test_entity_list.gd: 12 tests, each run against both lists. Full GUT suite: 895 passed, 1 pending (the existing #85 placeholder).
  • Headed check with tools/screenshot_entity_lists.gd on the real game scene: lists render, clicking a card selects the pawn, the header collapses the list, and cards are disabled in PLACE mode.

Not done / caveats

  • Disabled cards are not visibly dimmed. The same is true on main; this is deferred until art and theming.
  • --headless --editor --quit prints Invalid access to property or key 'building_placed' on ... GameState. This also happens on main, so this PR did not cause it.
  • Building rows were only checked by the tests; the headed run starts with no buildings.

🤖 Generated with Claude Code

Closes #146 ## What changed - **`ui/lists/entity_list.gd`**: new `@abstract class_name EntityList`. It holds expand/collapse, add/remove, interaction-mode handling and selection sync. `_cards` is keyed by `Entity`, and `_cards.has(new)` replaces the `is Pawn` / `is Building` checks. - **`ui/lists/entity_list.tscn`**: the only definition of the list layout, with neutral unique names (`%ListContainer`). Its root has no script. - **`PawnList` / `BuildingList`**: only `CARD_SCENE`, `_connect_entity_signals()` and `_make_card()` remain. Both scenes are inherited from `entity_list.tscn` and keep their original uids, so `game.tscn` is untouched. - **`common/game.gd`**: removed the `pawns_list.pawns` / `building_list.buildings` wiring. The lists never read these references. ## Behaviour changes (bug fixes) - Clicking a card emitted `selection_changed` twice: once from the `GameState.selected` setter and again by hand. It now fires once. - A card added outside NONE mode (e.g. a building placed in PLACE) started enabled. It now starts disabled. - Adding an entity while a list is collapsed now leaves it collapsed. The add still snaps rather than animating, so the startup spawn burst doesn't keep restarting the tween. - The arrow started as `^` while expanded. It now starts as `v`. - The two scenes' header layouts differed slightly. Both now use the building list's vertically centred version. ## Verification - `test/unit/test_entity_list.gd`: 12 tests, each run against both lists. Full GUT suite: 895 passed, 1 pending (the existing #85 placeholder). - Headed check with `tools/screenshot_entity_lists.gd` on the real game scene: lists render, clicking a card selects the pawn, the header collapses the list, and cards are disabled in PLACE mode. ## Not done / caveats - Disabled cards are not visibly dimmed. The same is true on `main`; this is deferred until art and theming. - `--headless --editor --quit` prints `Invalid access to property or key 'building_placed' on ... GameState`. This also happens on `main`, so this PR did not cause it. - Building rows were only checked by the tests; the headed run starts with no buildings. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PawnList and BuildingList were near-copies. The shared behaviour - expand/
collapse, add/remove, interaction-mode handling and selection sync - moves
into an @abstract EntityList, keyed by entity rather than id. The subclasses
keep only CARD_SCENE, _connect_entity_signals() and _make_card().

The layout moves to entity_list.tscn, whose root carries no script; both list
scenes inherit it and keep their uids, so game.tscn is untouched.

Small fixes picked up on the way:
- clicking a card no longer emits selection_changed twice (the setter
  already emits it)
- a card added outside NONE mode starts disabled
- adding an entity while collapsed leaves the list collapsed
- the arrow starts as "v", matching the expanded state
- the unused pawns/buildings refs and their wiring in game.gd are gone

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
liamjd merged commit 004c7c6827 into main 2026-10-10 15:31:56 +01:00
liamjd deleted branch 146-entity-list-base 2026-10-10 15:32:00 +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!148
No description provided.