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
71 lines
2.3 KiB
C++
71 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include "entt/entity/entity.hpp"
|
|
|
|
#include "BuildingId.h"
|
|
#include "SelectionContext.h"
|
|
|
|
class QWidget;
|
|
class SelectionContent;
|
|
class Simulation;
|
|
|
|
// What is currently selected, in the selection panel's terms. The two categories are
|
|
// mutually exclusive (REQ-UI-SELECTION-CATEGORIES): either buildings is non-empty, or
|
|
// actors and/or debris are, never both.
|
|
struct SelectionRequest
|
|
{
|
|
std::vector<BuildingId> buildings;
|
|
std::vector<entt::entity> actors;
|
|
std::vector<entt::entity> debris;
|
|
|
|
bool isEmpty() const
|
|
{
|
|
return buildings.empty() && actors.empty() && debris.empty();
|
|
}
|
|
};
|
|
|
|
// One entry of the content catalog (REQ-UI-SELECTION-CONTENT). Selections that share an
|
|
// entry get the same content and differ only in the name and symbol in the header.
|
|
enum class SelectionContentKind
|
|
{
|
|
None, // nothing selected: the panel hides itself entirely
|
|
RecipeProduction, // Miner, Assembler
|
|
AutoProduction, // Smelter, Reprocessing Plant
|
|
Shipyard,
|
|
Storage, // Salvage Bay
|
|
Hq,
|
|
Belt, // Belt, Tunnel Entry, Tunnel Exit
|
|
Splitter,
|
|
MultiBuilding,
|
|
Ship,
|
|
Station,
|
|
Debris,
|
|
FieldMulti,
|
|
};
|
|
|
|
// Identifies the card on screen. The panel rebuilds when this changes and only refreshes
|
|
// otherwise, so a construction site finishing swaps the card while a progress counter
|
|
// running does not.
|
|
struct ContentKey
|
|
{
|
|
SelectionContentKind kind = SelectionContentKind::None;
|
|
bool isSite = false;
|
|
|
|
bool operator==(const ContentKey& other) const
|
|
{
|
|
return kind == other.kind && isSite == other.isSite;
|
|
}
|
|
bool operator!=(const ContentKey& other) const { return !(*this == other); }
|
|
};
|
|
|
|
// The card this selection calls for. This is where REQ-UI-SELECTION-AGGREGATE is
|
|
// decided: a multi-selection that aggregates resolves to the single-object kind, and
|
|
// everything else to one of the two count summaries.
|
|
ContentKey chooseContent(const SelectionRequest& request, Simulation& sim);
|
|
|
|
// Builds the card. Returns nullptr for SelectionContentKind::None.
|
|
SelectionContent* createContent(const ContentKey& key, const SelectionRequest& request,
|
|
const SelectionContext& context, QWidget* parent);
|