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();