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
54 lines
2.5 KiB
C++
54 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include <map>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "Building.h"
|
|
#include "GameConfig.h"
|
|
#include "RecipesConfig.h"
|
|
|
|
// Production state of a building for the UI status light (REQ-UI-STATUS-LIGHT).
|
|
// The simulation owns the classification so it stays in sync with the
|
|
// production-cycle predicates (REQ-MAT-CYCLE); the UI maps each value to a fill
|
|
// color.
|
|
enum class ProductionStatus
|
|
{
|
|
Unconfigured, // no recipe/schematic selected (grey)
|
|
Producing, // a production cycle is active (green)
|
|
Starved, // idle: a required input is missing / Salvage Bay empty (red)
|
|
Blocked, // idle: output buffer full, inputs otherwise present (yellow)
|
|
};
|
|
|
|
// The rules deciding what a building can produce and whether it can start.
|
|
// Pure functions of the config and the building itself — they read no factory
|
|
// state, so they are free functions rather than BuildingSystem members.
|
|
|
|
// Recipes this building could run: every recipe of its type for an auto-recipe
|
|
// building (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING), otherwise just its selected one.
|
|
std::vector<const RecipeDef*> gatherCandidateRecipes(const GameConfig& config,
|
|
const Building& b);
|
|
|
|
// True when the building's input buffer holds every ingredient the recipe needs.
|
|
bool recipeInputsAvailable(const Building& b, const RecipeDef& recipe);
|
|
|
|
// Total materials a shipyard needs for its schematic plus its placed modules
|
|
// (REQ-BLD-SHIPYARD), keyed by item id.
|
|
std::map<std::string, int> computeShipyardRequiredMaterials(const GameConfig& config,
|
|
const Building& b);
|
|
|
|
// The same sum over a stored configuration rather than an operational building, so a
|
|
// construction site's schematic can be costed before it is built (REQ-BLD-SITE-CONFIG).
|
|
std::map<std::string, int> computeShipyardRequiredMaterials(
|
|
const GameConfig& config, const std::string& recipeId,
|
|
const std::optional<ShipLayoutConfig>& shipLayout);
|
|
|
|
// True when a production cycle could start right now, ignoring output-buffer space.
|
|
bool hasInputsToStart(const GameConfig& config, const Building& b);
|
|
|
|
// Status light for a building, or nullopt for types that show none — belts,
|
|
// splitters, tunnels, HQ and defence stations (REQ-UI-STATUS-LIGHT).
|
|
std::optional<ProductionStatus> getProductionStatus(const GameConfig& config,
|
|
const Building& building);
|