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
46 lines
1.8 KiB
C++
46 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include <QPoint>
|
|
|
|
#include "BuildingId.h"
|
|
#include "BuildingType.h"
|
|
#include "ShipLayout.h"
|
|
|
|
struct Building;
|
|
struct ConstructionSite;
|
|
struct SelectionContext;
|
|
|
|
// One selected building id resolved to whichever of the two things it names: an
|
|
// operational building or a construction site still queued or under construction. A
|
|
// site carries the same configuration as the building it will become
|
|
// (REQ-BLD-SITE-CONFIG), so the fields both have are read out here once instead of in
|
|
// every content that shows a single building.
|
|
struct BuildingTarget
|
|
{
|
|
const Building* building = nullptr; // null while it is still a site
|
|
const ConstructionSite* site = nullptr; // null once it is built
|
|
|
|
BuildingType type = BuildingType::Miner;
|
|
std::string recipeId;
|
|
std::optional<ShipLayoutConfig> shipLayout;
|
|
QPoint anchor;
|
|
|
|
// False when the id names neither -- the object went away under the panel (it was
|
|
// deconstructed, or its site finished and its id was reused).
|
|
bool isValid() const { return building != nullptr || site != nullptr; }
|
|
};
|
|
|
|
// Resolves the id against the current factory state. The returned pointers are only
|
|
// valid until the simulation next mutates, so this is called per refresh rather than
|
|
// cached.
|
|
BuildingTarget resolveBuildingTarget(const SelectionContext& context, BuildingId id);
|
|
|
|
// The id wrapped as a construction site id when it names one, nullopt when it names an
|
|
// operational building. Every content showing a single building hands this to
|
|
// SelectionContent so the base can apply the site rule (REQ-UI-SELECTION-CARD).
|
|
std::optional<BuildingId> asConstructionSite(const SelectionContext& context,
|
|
BuildingId id);
|