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,18 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "BehaviorKind.h"
|
||||
#include "ShipLayout.h"
|
||||
#include "ShipStatsCalculator.h"
|
||||
|
||||
struct GameConfig;
|
||||
class QLabel;
|
||||
#include "BehaviorKind.h"
|
||||
|
||||
struct GameConfig;
|
||||
class BarRow;
|
||||
class SectionBox;
|
||||
class StatRow;
|
||||
|
||||
// The hull stats and capability module summaries of one ship, as a bar for HP and a
|
||||
// label/value row for everything else. Shared by the live selection card
|
||||
// (REQ-UI-SHIP-STATS-PANEL), the layout configuration dialog's design preview
|
||||
// (REQ-MOD-UI-STATS-PANEL) and the balancing tool, so all three read alike.
|
||||
//
|
||||
// The behavior row is for consumers with no header to put it in. The selection card
|
||||
// shows the behavior in its header instead (REQ-UI-SHIP-BEHAVIOR) and leaves the row
|
||||
// unset; the design preview has no live ship to have a behavior at all.
|
||||
class ShipStatsPanel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -20,44 +30,47 @@ class ShipStatsPanel : public QWidget
|
||||
public:
|
||||
explicit ShipStatsPanel(const GameConfig* config, QWidget* parent = nullptr);
|
||||
|
||||
// Stats of a design rather than of a live ship: the HP bar reads full, because the
|
||||
// number shown is the maximum the design would have.
|
||||
void refresh(const std::string& shipId,
|
||||
const std::vector<PlacedModule>& modules);
|
||||
|
||||
void refreshFromLive(const ShipStats& stats, float currentHp);
|
||||
|
||||
// Displays the ship's current top-priority behavior (REQ-UI-SHIP-BEHAVIOR).
|
||||
// Shows the ship's top-priority behavior as a row of its own. Never called by the
|
||||
// selection card, which has a header slot for it.
|
||||
void setBehavior(BehaviorKind kind);
|
||||
|
||||
void setThreatCost(double cost);
|
||||
void setDebugDrawEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
void applyStats(const ShipStats& stats, const QString& hpText);
|
||||
void applyStats(const ShipStats& stats, double hpFraction, const QString& hpText);
|
||||
|
||||
const GameConfig* m_config;
|
||||
bool m_debugDraw = false;
|
||||
|
||||
QLabel* m_behaviorLabel;
|
||||
QLabel* m_hpLabel;
|
||||
QLabel* m_speedLabel;
|
||||
QLabel* m_sensorRangeLabel;
|
||||
QLabel* m_mainAccelLabel;
|
||||
QLabel* m_maneuveringAccelLabel;
|
||||
QLabel* m_angularAccelLabel;
|
||||
QLabel* m_maxRotSpeedLabel;
|
||||
QLabel* m_cargoCapacityLabel;
|
||||
BarRow* m_hpBar;
|
||||
StatRow* m_speedRow;
|
||||
StatRow* m_sensorRangeRow;
|
||||
StatRow* m_mainAccelRow;
|
||||
StatRow* m_maneuveringAccelRow;
|
||||
StatRow* m_angularAccelRow;
|
||||
StatRow* m_maxRotSpeedRow;
|
||||
StatRow* m_cargoCapacityRow;
|
||||
|
||||
QWidget* m_weaponSection;
|
||||
QLabel* m_weaponDpsLabel;
|
||||
QLabel* m_weaponRangeLabel;
|
||||
SectionBox* m_weaponSection;
|
||||
StatRow* m_weaponDpsRow;
|
||||
StatRow* m_weaponRangeRow;
|
||||
|
||||
QWidget* m_salvageSection;
|
||||
QLabel* m_salvageRateLabel;
|
||||
QLabel* m_salvageRangeLabel;
|
||||
SectionBox* m_salvageSection;
|
||||
StatRow* m_salvageRateRow;
|
||||
StatRow* m_salvageRangeRow;
|
||||
|
||||
QWidget* m_repairSection;
|
||||
QLabel* m_repairRateLabel;
|
||||
QLabel* m_repairRangeLabel;
|
||||
SectionBox* m_repairSection;
|
||||
StatRow* m_repairRateRow;
|
||||
StatRow* m_repairRangeRow;
|
||||
|
||||
QLabel* m_threatCostLabel;
|
||||
StatRow* m_behaviorRow;
|
||||
StatRow* m_threatCostRow;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user