The panel is sized to its card, so anything that changes the card's width drags the panel with it. The status caption changes as a building works -- "producing" is shorter than "missing input", which is shorter than "output full" -- and the panel twitched every time it did. On a Smelter it also changed height, because a narrower card wraps its item chips differently. The pill now reserves room for the widest caption it can ever show, so the header keeps one width whatever the state is. The captions were spelled out in the switch that chose them, which left no way to ask for the set; they come from one function now, and the set is what the reservation is built from. Ship cards do the same with the behaviour names (REQ-UI-SHIP-BEHAVIOR), which change just as often while a ship fights. Miner card, sampled every tick for 900 ticks across two different-length captions: one distinct width, one distinct height. The reservation is what does it -- the same run without it sits at 138px, with it at 155px, the width of the longest caption. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcReq7hVk4KUPhTDKWAG7K
49 lines
1.7 KiB
C++
49 lines
1.7 KiB
C++
#include "SelectionNames.h"
|
|
|
|
#include <QObject>
|
|
|
|
#include "DisplayName.h"
|
|
|
|
QString getBuildingTypeName(BuildingType type)
|
|
{
|
|
// "Hq" would read as a word rather than an acronym through the generic conversion,
|
|
// and the player's own base deserves naming as such.
|
|
if (type == BuildingType::Hq)
|
|
{
|
|
return QObject::tr("Player HQ");
|
|
}
|
|
return QString::fromStdString(toDisplayName(buildingTypeId(type)));
|
|
}
|
|
|
|
QString getBehaviorLabel(BehaviorKind kind)
|
|
{
|
|
// Only the winning behavior is named; the salvage and repair cycles that run
|
|
// regardless of it are not behaviors here (REQ-UI-SHIP-BEHAVIOR).
|
|
switch (kind)
|
|
{
|
|
case BehaviorKind::Retreat: return QObject::tr("Retreating");
|
|
case BehaviorKind::Attack: return QObject::tr("Engaging");
|
|
case BehaviorKind::SalvageScrap:
|
|
case BehaviorKind::DeliverScrap: return QObject::tr("Salvaging");
|
|
case BehaviorKind::Repair: return QObject::tr("Repairing");
|
|
case BehaviorKind::Rally: return QObject::tr("Rallying");
|
|
case BehaviorKind::Standby: return QObject::tr("Standby");
|
|
case BehaviorKind::Advance: return QObject::tr("Advancing");
|
|
case BehaviorKind::None: break;
|
|
}
|
|
return QString();
|
|
}
|
|
|
|
QStringList getAllBehaviorLabels()
|
|
{
|
|
QStringList labels;
|
|
for (BehaviorKind kind : { BehaviorKind::Retreat, BehaviorKind::Attack,
|
|
BehaviorKind::SalvageScrap, BehaviorKind::Repair,
|
|
BehaviorKind::Rally, BehaviorKind::Standby,
|
|
BehaviorKind::Advance })
|
|
{
|
|
labels << getBehaviorLabel(kind);
|
|
}
|
|
return labels;
|
|
}
|