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:
103
src/ui/selection/ShipyardContent.cpp
Normal file
103
src/ui/selection/ShipyardContent.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#include "ShipyardContent.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Building.h"
|
||||
#include "BuildingTarget.h"
|
||||
#include "EventManager.h"
|
||||
#include "GameConfig.h"
|
||||
#include "LayoutDialogRequestedEvent.h"
|
||||
#include "ProductionRules.h"
|
||||
#include "RecipeSelectionControl.h"
|
||||
#include "SelectionNames.h"
|
||||
#include "ShipLayoutPreview.h"
|
||||
|
||||
ShipyardContent::ShipyardContent(const SelectionContext& context,
|
||||
const SelectionRequest& request, QWidget* parent)
|
||||
: BufferedBuildingContent(context, request.buildings.front(), parent)
|
||||
{
|
||||
m_schematicControl = new RecipeSelectionControl(context, getBuildingId(),
|
||||
BuildingType::Shipyard, this);
|
||||
m_layoutPreview = new ShipLayoutPreview(this);
|
||||
m_configureButton = new QPushButton(tr("Configure Layout"), this);
|
||||
|
||||
getConfigurationLayout()->addWidget(m_schematicControl);
|
||||
getConfigurationLayout()->addWidget(m_layoutPreview);
|
||||
getConfigurationLayout()->addWidget(m_configureButton);
|
||||
|
||||
const BuildingId id = getBuildingId();
|
||||
connect(m_configureButton, &QPushButton::clicked, this, [id]() {
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<LayoutDialogRequestedEvent>(id));
|
||||
});
|
||||
}
|
||||
|
||||
void ShipyardContent::refreshConfiguration()
|
||||
{
|
||||
const BuildingTarget target = resolveBuildingTarget(getContext(), getBuildingId());
|
||||
if (!target.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setBuildingIdentity(target.type, getBuildingTypeName(target.type));
|
||||
m_schematicControl->setRecipeId(target.recipeId);
|
||||
|
||||
// The preview and Configure button are always shown for a shipyard and are only
|
||||
// enabled once a schematic is selected (REQ-MOD-UI-PREVIEW). The schematic arrives
|
||||
// by queued command, so this refresh is what picks it up rather than the click that
|
||||
// chose it.
|
||||
const ShipDef* shipDef = target.recipeId.empty()
|
||||
? nullptr
|
||||
: getContext().config->ships.findShipDef(target.recipeId);
|
||||
const bool hasSchematic = shipDef && !shipDef->layout.empty();
|
||||
if (hasSchematic)
|
||||
{
|
||||
m_layoutPreview->setShipAndLayout(
|
||||
shipDef->layout,
|
||||
target.shipLayout.has_value() ? *target.shipLayout : ShipLayoutConfig(),
|
||||
&getContext().config->modules);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_layoutPreview->showPlaceholder();
|
||||
}
|
||||
m_layoutPreview->setEnabled(hasSchematic);
|
||||
m_configureButton->setEnabled(hasSchematic);
|
||||
}
|
||||
|
||||
BufferedBuildingContent::CycleInfo ShipyardContent::getCycleInfo(
|
||||
const Building& building) const
|
||||
{
|
||||
CycleInfo info;
|
||||
const ShipDef* shipDef = building.recipeId.empty()
|
||||
? nullptr
|
||||
: getContext().config->ships.findShipDef(building.recipeId);
|
||||
if (!shipDef)
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
// The schematic's materials plus every placed module's, which is also what sized the
|
||||
// input buffers (REQ-BLD-SHIPYARD). The simulation owns that sum, so the panel asks
|
||||
// it rather than adding the modules up a second time.
|
||||
info.perCycleInputs =
|
||||
computeShipyardRequiredMaterials(*getContext().config, building);
|
||||
|
||||
info.durationSeconds = shipDef->schematic.productionTimeSeconds;
|
||||
if (building.shipLayout.has_value())
|
||||
{
|
||||
for (const PlacedModule& placed : building.shipLayout->placedModules)
|
||||
{
|
||||
const ModuleDef* moduleDef =
|
||||
getContext().config->modules.findModuleDef(placed.moduleId);
|
||||
if (moduleDef)
|
||||
{
|
||||
info.durationSeconds += moduleDef->productionTimeSeconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
info.runsProduction = true;
|
||||
return info;
|
||||
}
|
||||
Reference in New Issue
Block a user