give the selection cards their own parts instead of label blobs
The cards were assembled from plain labels carrying whole blocks of text. Replace those with the widget vocabulary the requirements describe, so a part means the same thing wherever it appears and a card is a list of parts rather than a string builder. The parts, all free of Simulation and GameConfig -- they take prepared values, and the contents work out what those are: - StatRow, BarRow, SectionBox: label/value line, captioned fill bar, captioned group. The bar is one part for three things: construction progress, production progress, and HP. - ItemChip / ItemChipRow: buffered items as icon, count and sub-line (REQ-UI-SINGLE-SELECTION). An input chip carries its per-cycle amount, an output chip its count against the buffer capacity. The chips are rebuilt only when the set of items changes, so a 30 Hz refresh moves numbers rather than widgets. - RecipeSummaryRow: inputs, arrow, outputs, cycle time (REQ-UI-RECIPE-SUMMARY), which is now the panel's only display of the cycle time. - CountRow, StatusPill, EmptyNote. Behaviour that changed with them: - The station card shows damage, range and fire rate as the requirement asks (REQ-UI-STATION-STATS-PANEL) rather than the combined DPS it showed before. - A ship's behaviour moves from a stats row into the card header (REQ-UI-SHIP-BEHAVIOR). ShipStatsPanel keeps setBehavior for the balancing tool's inspect window, which has no header to put it in. - A construction site's card shows a progress bar and the "no buffers until built" note (REQ-UI-SELECTION-CARD), and now also its recipe summary, since that is configuration and a site carries it (REQ-BLD-SITE-CONFIG). Costing a shipyard site's schematic needed computeShipyardRequiredMaterials to take a stored configuration as well as a live building -- one overload, so the module sum still exists once. ShipStatsPanel is rebuilt on StatRow, BarRow and SectionBox, so the selection card, the layout dialog's design preview and the balancing tool read alike. Those three parts are compiled into the balancing target, which does not link the ui library; keeping them sim-free is what makes that possible, and the build enforces it. Build clean, 541 tests pass, app and balancing tool both run 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:
@@ -1,5 +1,7 @@
|
||||
#include "BufferedBuildingContent.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Building.h"
|
||||
@@ -7,33 +9,76 @@
|
||||
#include "BuildingTarget.h"
|
||||
#include "FactoryQueries.h"
|
||||
#include "ProductionSection.h"
|
||||
#include "RecipeSummaryRow.h"
|
||||
#include "SelectionNames.h"
|
||||
#include "Simulation.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
std::vector<RecipeSummaryRow::Amount> toAmounts(const std::map<std::string, int>& map)
|
||||
{
|
||||
std::vector<RecipeSummaryRow::Amount> amounts;
|
||||
amounts.reserve(map.size());
|
||||
for (const std::pair<const std::string, int>& entry : map)
|
||||
{
|
||||
amounts.push_back(RecipeSummaryRow::Amount{ entry.first, entry.second });
|
||||
}
|
||||
return amounts;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
BufferedBuildingContent::BufferedBuildingContent(const SelectionContext& context,
|
||||
BuildingId id, QWidget* parent)
|
||||
: SelectionContent(context, asConstructionSite(context, id), parent)
|
||||
, m_id(id)
|
||||
{
|
||||
m_buffers = new BufferSection(this);
|
||||
// The summary is configuration -- what the building will do -- so it sits with the
|
||||
// selection control and is shown for a construction site too (REQ-UI-RECIPE-SUMMARY).
|
||||
m_recipeSummary = new RecipeSummaryRow(context.itemIcons, this);
|
||||
getConfigurationLayout()->addWidget(m_recipeSummary);
|
||||
|
||||
m_buffers = new BufferSection(context, this);
|
||||
m_production = new ProductionSection(this);
|
||||
getRuntimeLayout()->addWidget(m_buffers);
|
||||
getRuntimeLayout()->addWidget(m_production);
|
||||
}
|
||||
|
||||
void BufferedBuildingContent::refreshRuntime()
|
||||
void BufferedBuildingContent::refreshConfiguration()
|
||||
{
|
||||
const Building* building = findBuilding(getContext().sim->getFactoryState(), m_id);
|
||||
if (!building)
|
||||
const BuildingTarget target = resolveBuildingTarget(getContext(), m_id);
|
||||
if (!target.isValid())
|
||||
{
|
||||
// Gone under the card. SelectionPanel rebuilds on the same refresh; this only
|
||||
// has to avoid reading it.
|
||||
return;
|
||||
}
|
||||
|
||||
setProductionStatusSlot(*building);
|
||||
setBuildingIdentity(target.type, getBuildingTypeName(target.type));
|
||||
|
||||
const CycleInfo cycle = getCycleInfo(*building);
|
||||
m_buffers->setBuffers(*building, cycle.perCycleInputs, cycle.perCycleOutputs);
|
||||
m_production->setProduction(cycle.runsProduction, *building, cycle.durationSeconds,
|
||||
const CycleInfo cycle = getCycleInfo(target);
|
||||
m_recipeSummary->setSummary(toAmounts(cycle.perCycleInputs),
|
||||
toAmounts(cycle.perCycleOutputs),
|
||||
cycle.durationSeconds);
|
||||
|
||||
refreshControls(target);
|
||||
}
|
||||
|
||||
void BufferedBuildingContent::refreshRuntime()
|
||||
{
|
||||
const BuildingTarget target = resolveBuildingTarget(getContext(), m_id);
|
||||
if (!target.building)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setProductionStatusSlot(*target.building);
|
||||
|
||||
const CycleInfo cycle = getCycleInfo(target);
|
||||
m_buffers->setBuffers(*target.building, cycle.perCycleInputs, cycle.perCycleOutputs);
|
||||
m_production->setProduction(cycle.runsProduction, *target.building,
|
||||
cycle.durationSeconds,
|
||||
getContext().sim->getCurrentTick());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user