split the selection panel into one card per kind of selection

The panel rendered every selection out of a single pool of member widgets,
hidden and shown per branch, so each build path had to remember to hide the
other branches' widgets. That coupling produced the two defects fixed in
668ce0f, and the per-type detail the requirements now ask for would only add
more of it.

The pool is gone. SelectionPanel keeps the category arbitration, the float and
the hide-when-empty behaviour, and hosts exactly one SelectionContent at a
time; SelectionContentFactory picks which one from the selection alone. Each
card is one row of the catalog in REQ-UI-SELECTION-CONTENT and owns only its
own widgets.

The card structure (REQ-UI-SELECTION-CARD) lives in the base class: a header
with an identity symbol, a name and one right slot, then a configuration group
and a runtime group. A construction site keeps its configuration and has its
whole runtime group replaced by the construction progress, decided once there
rather than in every card (REQ-BLD-SITE-CONFIG).

Also implemented here:
- REQ-UI-SELECTION-STATUS: the header status dot, taken from the simulation's
  own getProductionStatus() so the panel and the world's status light cannot
  disagree.
- REQ-UI-SELECTION-AGGREGATE: belt-subsystem tiles and debris-only selections
  collapse into one card with a count instead of a count summary.
- REQ-UI-HQ-PANEL: the HQ shows the global block stock and its HP, neither of
  which is a buffer.
- BuildingIconCache, extracted from BuildButtonBar's file-local chip loading so
  the card headers and the build buttons rasterize the same SVGs once.

FieldSelectionPanel is deleted: ships, stations, debris and the field count
summary are four more cards in the same factory, so the two-panel arbitration
collapses into one decision.

The card parts are still today's labels and buttons; the item chips, bars,
recipe summary and stat rows follow.

Build clean, 541 tests pass, app runs with no Qt warnings. Visual check
pending.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcReq7hVk4KUPhTDKWAG7K
This commit is contained in:
2026-08-07 12:18:33 +02:00
parent 90e40dddbc
commit 89e984ec76
59 changed files with 2966 additions and 1549 deletions

View File

@@ -20,6 +20,7 @@
class QPushButton;
class Simulation;
class BuildingIconCache;
class ItemIconCache;
// The build menu: one horizontal row of build buttons floating over the game world
@@ -36,13 +37,11 @@ class BuildButtonBar : public QWidget,
Q_OBJECT
public:
// iconDir is the directory holding the per-building "<id>.svg" chip icons
// (REQ-UI-BUILD-ICON), read from disk at runtime like the config files.
// itemIcons is the window-wide per-item icon cache and supplies the
// building_block icon shown in each button's cost (REQ-UI-BUILD-COST). Not
// owned; must outlive this widget.
// buildingIcons supplies each button's chip icon (REQ-UI-BUILD-ICON) and itemIcons
// the building_block icon shown in each button's cost (REQ-UI-BUILD-COST). Both are
// window-wide caches; neither is owned, and both must outlive this widget.
BuildButtonBar(Simulation* sim, const GameConfig* config,
const std::string& iconDir, ItemIconCache* itemIcons,
BuildingIconCache* buildingIcons, ItemIconCache* itemIcons,
QWidget* parent = nullptr);
~BuildButtonBar() override;
@@ -85,8 +84,8 @@ private slots:
private:
Simulation* m_sim;
const GameConfig* m_config;
std::string m_iconDir;
ItemIconCache* m_itemIcons; // Not owned; lives in MainWindow.
BuildingIconCache* m_buildingIcons; // Not owned; lives in MainWindow.
ItemIconCache* m_itemIcons; // Not owned; lives in MainWindow.
std::vector<BuildingType> m_types;
std::vector<QPushButton*> m_buttons;
std::map<BuildingType, int> m_costs;