77 lines
2.2 KiB
C++
77 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <QWidget>
|
|
|
|
#include "ShipLayout.h"
|
|
#include "ShipStatsCalculator.h"
|
|
|
|
#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
|
|
|
|
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);
|
|
|
|
// 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, double hpFraction, const QString& hpText);
|
|
|
|
const GameConfig* m_config;
|
|
bool m_debugDraw = false;
|
|
|
|
BarRow* m_hpBar;
|
|
StatRow* m_speedRow;
|
|
StatRow* m_sensorRangeRow;
|
|
StatRow* m_mainAccelRow;
|
|
StatRow* m_maneuveringAccelRow;
|
|
StatRow* m_angularAccelRow;
|
|
StatRow* m_maxRotSpeedRow;
|
|
StatRow* m_cargoCapacityRow;
|
|
|
|
SectionBox* m_weaponSection;
|
|
StatRow* m_weaponDpsRow;
|
|
StatRow* m_weaponRangeRow;
|
|
|
|
SectionBox* m_salvageSection;
|
|
StatRow* m_salvageRateRow;
|
|
StatRow* m_salvageRangeRow;
|
|
|
|
SectionBox* m_repairSection;
|
|
StatRow* m_repairRateRow;
|
|
StatRow* m_repairRangeRow;
|
|
|
|
StatRow* m_behaviorRow;
|
|
StatRow* m_threatCostRow;
|
|
};
|