diff --git a/src/balancing/InspectWindow.cpp b/src/balancing/InspectWindow.cpp index b21397a..17706d2 100644 --- a/src/balancing/InspectWindow.cpp +++ b/src/balancing/InspectWindow.cpp @@ -14,6 +14,7 @@ #include "HealthComponent.h" #include "InspectWindowClosedEvent.h" #include "ModuleOwnerComponent.h" +#include "SelectedBehaviorComponent.h" #include "ShipIdentityComponent.h" #include "ShipStatsCalculator.h" #include "ShipStatsPanel.h" @@ -278,6 +279,8 @@ void InspectWindow::handleEvent(std::shared_ptr event const ShipStats stats = buildShipStatsFromEntity(admin, entity); m_entityStatsPanel->refreshFromLive(stats, health.hp); + m_entityStatsPanel->setBehavior( + admin.get(entity).winner); m_entityStatsPanel->show(); m_stationStatsLabel->hide(); } @@ -355,6 +358,8 @@ void InspectWindow::refreshEntityStats() { const ShipStats stats = buildShipStatsFromEntity(admin, entity); m_entityStatsPanel->refreshFromLive(stats, health.hp); + m_entityStatsPanel->setBehavior( + admin.get(entity).winner); } else if (admin.hasAll(entity)) { diff --git a/src/ui/SelectedBuildingPanel.cpp b/src/ui/SelectedBuildingPanel.cpp index 1e3ee73..42bd910 100644 --- a/src/ui/SelectedBuildingPanel.cpp +++ b/src/ui/SelectedBuildingPanel.cpp @@ -21,6 +21,7 @@ #include "FactionComponent.h" #include "HealthComponent.h" #include "ModuleOwnerComponent.h" +#include "SelectedBehaviorComponent.h" #include "ShipIdentityComponent.h" #include "ShipStatsCalculator.h" #include "ShipStatsPanel.h" @@ -948,6 +949,8 @@ void SelectedBuildingPanel::buildEntityShip(entt::entity entity) const ShipStats stats = buildShipStatsFromEntity(admin, entity); m_entityStatsPanel->refreshFromLive(stats, health.hp); + m_entityStatsPanel->setBehavior( + admin.get(entity).winner); m_entityStatsPanel->setDebugDrawEnabled(m_debugDraw); for (const ShipDef& def : m_config->ships.ships) @@ -1027,6 +1030,8 @@ void SelectedBuildingPanel::refreshEntityStats() { const ShipStats stats = buildShipStatsFromEntity(admin, entity); m_entityStatsPanel->refreshFromLive(stats, health.hp); + m_entityStatsPanel->setBehavior( + admin.get(entity).winner); } else if (admin.hasAll(entity)) { diff --git a/src/ui/ShipStatsPanel.cpp b/src/ui/ShipStatsPanel.cpp index 30dfac3..babbcfb 100644 --- a/src/ui/ShipStatsPanel.cpp +++ b/src/ui/ShipStatsPanel.cpp @@ -42,6 +42,12 @@ ShipStatsPanel::ShipStatsPanel(const GameConfig* config, QWidget* parent) layout->setSpacing(2); layout->setAlignment(Qt::AlignTop); + // Current behavior — live entities only; hidden in the static design + // preview (REQ-UI-SHIP-BEHAVIOR). + m_behaviorLabel = makeSectionHeader(QString(), this); + m_behaviorLabel->setVisible(false); + layout->addWidget(m_behaviorLabel); + // Hull stats — always visible. m_hpLabel = makeStatLabel(this); m_speedLabel = makeStatLabel(this); @@ -125,6 +131,9 @@ void ShipStatsPanel::refresh(const std::string& shipId, const double threat = calculateShipThreatCost(m_config->threatCosts, *m_config, shipId, modules); setThreatCost(threat); + + // The static design preview has no live behavior to show. + m_behaviorLabel->setVisible(false); } void ShipStatsPanel::refreshFromLive(const ShipStats& stats, float currentHp) @@ -204,6 +213,32 @@ void ShipStatsPanel::applyStats(const ShipStats& stats, const QString& hpText) } } +void ShipStatsPanel::setBehavior(BehaviorKind kind) +{ + QString label; + switch (kind) + { + case BehaviorKind::Retreat: label = tr("Retreating"); break; + case BehaviorKind::Attack: label = tr("Engaging"); break; + case BehaviorKind::SalvageScrap: + case BehaviorKind::DeliverScrap: label = tr("Salvaging"); break; + case BehaviorKind::Repair: label = tr("Repairing"); break; + case BehaviorKind::Rally: label = tr("Rallying"); break; + case BehaviorKind::Standby: label = tr("Standby"); break; + case BehaviorKind::Advance: label = tr("Advancing"); break; + case BehaviorKind::None: break; + } + + if (label.isEmpty()) + { + m_behaviorLabel->setVisible(false); + return; + } + + m_behaviorLabel->setText(tr("Behavior: %1").arg(label)); + m_behaviorLabel->setVisible(true); +} + void ShipStatsPanel::setThreatCost(double cost) { m_threatCostLabel->setText(tr("Threat Cost: %1").arg(cost, 0, 'f', 1)); diff --git a/src/ui/ShipStatsPanel.h b/src/ui/ShipStatsPanel.h index f44d282..d7745bb 100644 --- a/src/ui/ShipStatsPanel.h +++ b/src/ui/ShipStatsPanel.h @@ -6,6 +6,7 @@ #include +#include "BehaviorKind.h" #include "ShipLayout.h" #include "ShipStatsCalculator.h" @@ -24,6 +25,9 @@ public: void refreshFromLive(const ShipStats& stats, float currentHp); + // Displays the ship's current top-priority behavior (REQ-UI-SHIP-BEHAVIOR). + void setBehavior(BehaviorKind kind); + void setThreatCost(double cost); void setDebugDrawEnabled(bool enabled); @@ -33,6 +37,7 @@ private: const GameConfig* m_config; bool m_debugDraw = false; + QLabel* m_behaviorLabel; QLabel* m_hpLabel; QLabel* m_speedLabel; QLabel* m_sensorRangeLabel;