Add demolish-mode vignette

This commit is contained in:
2026-07-19 21:51:12 +02:00
parent c76ba07bc7
commit b708e1b29d
3 changed files with 28 additions and 6 deletions

View File

@@ -433,6 +433,7 @@ void GameWorldView::paintGL()
drawOverlays(painter);
drawScreenSpace(painter);
drawPauseBorder(painter);
drawDemolishBorder(painter);
drawReplayOverlay(painter);
}
@@ -1700,15 +1701,27 @@ void GameWorldView::drawScreenSpace(QPainter& /*painter*/)
void GameWorldView::drawPauseBorder(QPainter& painter)
{
if (m_gameSpeedMultiplier > 0.0) { return; }
drawVignetteBorder(painter, QColor(0, 0, 0, 128)); // 50% black at the edge
}
void GameWorldView::drawDemolishBorder(QPainter& painter)
{
if (!m_demolishMode) { return; }
// Reuse the demolish overlay color (with its configured alpha) as the edge color.
drawVignetteBorder(painter, m_visuals->overlays.demolishTint);
}
void GameWorldView::drawVignetteBorder(QPainter& painter, const QColor& edgeColor)
{
// Border thickness in pixels, capped so it never exceeds half the viewport on
// very small windows (which would leave no un-darkened center).
// very small windows (which would leave no un-tinted center).
const qreal borderPx = std::min<qreal>(
100.0, std::min(width(), height()) / 2.0);
if (borderPx <= 0.0) { return; }
const QColor edge(0, 0, 0, 128); // 50% black at the viewport edge
const QColor inner(0, 0, 0, 0); // fully transparent toward the center
const QColor& edge = edgeColor; // full color (and alpha) at the viewport edge
QColor inner = edgeColor;
inner.setAlpha(0); // same color, fully transparent toward the center
const qreal w = width();
const qreal h = height();

View File

@@ -131,10 +131,18 @@ private:
void drawBeams(QPainter& painter);
void drawOverlays(QPainter& painter);
void drawScreenSpace(QPainter& painter);
// Vignette-style border shown while the game is paused (speed 0x) to make the
// paused state hard to miss: a black frame whose alpha fades from 50% at the
// viewport edges to 0% toward the center.
// Vignette-style border shown while the game is paused (speed 0x, REQ-UI-PAUSE-BORDER)
// to make the paused state hard to miss: a black frame whose alpha fades from 50% at
// the viewport edges to 0% toward the center.
void drawPauseBorder(QPainter& painter);
// Vignette-style border shown while demolish mode is active (REQ-UI-DEMOLISH-BORDER),
// tinted with the demolish overlay color (including its configured alpha) from
// visuals.toml instead of black.
void drawDemolishBorder(QPainter& painter);
// Shared drawing for the pause/demolish vignettes: a mitred picture-frame border
// whose alpha fades from `edgeColor` (with its own alpha) at the viewport edge to
// fully transparent toward the center.
void drawVignetteBorder(QPainter& painter, const QColor& edgeColor);
void drawReplayOverlay(QPainter& painter);
float getTilePx() const;