show threat budget in debug text overlay

This commit is contained in:
2026-06-06 20:56:02 +02:00
parent 6b95619806
commit 8dad554800
7 changed files with 58 additions and 2 deletions

View File

@@ -326,6 +326,10 @@ The screen is divided into three vertical sections:
- REQ-UI-DEBUG-DRAW: A debug draw mode can be toggled on and off with the **M** key (REQ-UI-HOTKEYS). It is inactive by default. While active, the sensor range of every ship — both player and enemy — is drawn as a circle centered on the ship, using that ship schematic's outline color from `visuals.toml`.
- REQ-UI-DEBUG-OVERLAY: While debug draw mode is active (REQ-UI-DEBUG-DRAW), a text overlay is drawn in the upper left corner of the game world view. The overlay has a semi-transparent black background sized to fit its content. It displays the following lines of text:
- `Accumulated Threat Level: <level>` — where `<level>` is the current accumulated threat level (see REQ-WAV-THREAT-RATE).
- `Time until Wave: <time_s>` — where `<time_s>` is the remaining time in seconds on the normal-wave inter-wave gap timer (see REQ-WAV-GAP). During a quiet window the gap timer is frozen; the displayed value reflects that frozen state.
### Escape Menu
- REQ-UI-GAME-MENU: Pressing Escape at any time opens the escape menu as a modal dialog and pauses the simulation (sets speed to 0×). On close, the simulation speed is restored to what it was before the menu was opened — so if the game was already paused, it remains paused. The menu contains three buttons:

View File

@@ -555,6 +555,11 @@ Tick Simulation::bossCountdownTicks() const
return m_waveSystem->bossCountdownTicks();
}
Tick Simulation::normalGapRemainingTicks() const
{
return m_waveSystem->normalGapRemainingTicks();
}
int Simulation::schematicLevel(const std::string& shipId) const
{
const std::map<std::string, SchematicState>::const_iterator it =

View File

@@ -59,7 +59,8 @@ public:
bool isGameOver() const;
double threatLevel() const;
int bossWaveCounter() const;
Tick bossCountdownTicks() const;
Tick bossCountdownTicks() const;
Tick normalGapRemainingTicks() const;
// Schematic state queries.
int schematicLevel(const std::string& shipId) const;

View File

@@ -113,6 +113,11 @@ Tick WaveSystem::bossCountdownTicks() const
return m_bossCountdownTicks;
}
Tick WaveSystem::normalGapRemainingTicks() const
{
return m_normalGapRemainingTicks;
}
// ---------------------------------------------------------------------------
// Private helpers
// ---------------------------------------------------------------------------

View File

@@ -46,6 +46,10 @@ public:
// Ticks remaining until the next boss wave fires (REQ-WAV-BOSS-COUNTDOWN).
Tick bossCountdownTicks() const;
// Ticks remaining on the current normal-wave gap timer (REQ-WAV-GAP).
// Frozen during quiet windows.
Tick normalGapRemainingTicks() const;
private:
struct SpawnEntry
{

View File

@@ -292,7 +292,11 @@ void GameWorldView::paintGL()
drawStations(painter);
drawBeltItems(painter);
drawScrap(painter);
if (m_debugDraw) { drawDebugSensorRanges(painter); }
if (m_debugDraw)
{
drawDebugSensorRanges(painter);
drawDebugOverlay(painter);
}
drawShips(painter);
drawBeams(painter);
drawOverlays(painter);
@@ -937,6 +941,38 @@ void GameWorldView::drawDebugSensorRanges(QPainter& painter)
});
}
void GameWorldView::drawDebugOverlay(QPainter& painter)
{
painter.resetTransform();
const QString line1 = tr("Accumulated Threat Level: %1")
.arg(m_sim->threatLevel(), 0, 'f', 1);
const QString line2 = tr("Time until Wave: %1s")
.arg(ticksToSeconds(m_sim->normalGapRemainingTicks()), 0, 'f', 1);
QFont font = painter.font();
font.setPointSize(m_visuals->toast.fontSize);
painter.setFont(font);
const QFontMetrics fm = painter.fontMetrics();
const int lineH = fm.height();
const int padding = 8;
const int spacing = 4;
const int textW = std::max(fm.horizontalAdvance(line1),
fm.horizontalAdvance(line2));
const int bgW = textW + padding * 2;
const int bgH = lineH * 2 + spacing + padding * 2;
const QRect bgRect(padding, padding, bgW, bgH);
painter.fillRect(bgRect, QColor(0, 0, 0, 160));
painter.setPen(Qt::white);
const QRect textRect1(padding * 2, padding + padding, textW, lineH);
const QRect textRect2(padding * 2, textRect1.bottom() + spacing, textW, lineH);
painter.drawText(textRect1, Qt::AlignLeft | Qt::AlignVCenter, line1);
painter.drawText(textRect2, Qt::AlignLeft | Qt::AlignVCenter, line2);
}
void GameWorldView::drawBeams(QPainter& painter)
{
painter.setPen(QPen(m_visuals->beams.color, m_visuals->beams.widthPx));

View File

@@ -85,6 +85,7 @@ private:
void drawScrap(QPainter& painter);
void drawShips(QPainter& painter);
void drawDebugSensorRanges(QPainter& painter);
void drawDebugOverlay(QPainter& painter);
void drawBeams(QPainter& painter);
void drawOverlays(QPainter& painter);
void drawScreenSpace(QPainter& painter);