Add demolish-mode vignette border (REQ-UI-DEMOLISH-BORDER)
Extract the mitred picture-frame vignette from drawPauseBorder into a shared drawVignetteBorder(edgeColor) helper, and draw a second vignette while demolish mode is active, tinted with visuals.toml [overlays].demolish_tint (including its configured alpha) instead of black. Both vignettes compose when the game is paused and in demolish mode at once. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y7N59FsLA5e2kuVdqe4Uhc
This commit is contained in:
@@ -433,6 +433,7 @@ void GameWorldView::paintGL()
|
|||||||
drawOverlays(painter);
|
drawOverlays(painter);
|
||||||
drawScreenSpace(painter);
|
drawScreenSpace(painter);
|
||||||
drawPauseBorder(painter);
|
drawPauseBorder(painter);
|
||||||
|
drawDemolishBorder(painter);
|
||||||
drawReplayOverlay(painter);
|
drawReplayOverlay(painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1700,15 +1701,27 @@ void GameWorldView::drawScreenSpace(QPainter& /*painter*/)
|
|||||||
void GameWorldView::drawPauseBorder(QPainter& painter)
|
void GameWorldView::drawPauseBorder(QPainter& painter)
|
||||||
{
|
{
|
||||||
if (m_gameSpeedMultiplier > 0.0) { return; }
|
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
|
// 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>(
|
const qreal borderPx = std::min<qreal>(
|
||||||
100.0, std::min(width(), height()) / 2.0);
|
100.0, std::min(width(), height()) / 2.0);
|
||||||
if (borderPx <= 0.0) { return; }
|
if (borderPx <= 0.0) { return; }
|
||||||
|
|
||||||
const QColor edge(0, 0, 0, 128); // 50% black at the viewport edge
|
const QColor& edge = edgeColor; // full color (and alpha) at the viewport edge
|
||||||
const QColor inner(0, 0, 0, 0); // fully transparent toward the center
|
QColor inner = edgeColor;
|
||||||
|
inner.setAlpha(0); // same color, fully transparent toward the center
|
||||||
|
|
||||||
const qreal w = width();
|
const qreal w = width();
|
||||||
const qreal h = height();
|
const qreal h = height();
|
||||||
|
|||||||
@@ -131,10 +131,18 @@ private:
|
|||||||
void drawBeams(QPainter& painter);
|
void drawBeams(QPainter& painter);
|
||||||
void drawOverlays(QPainter& painter);
|
void drawOverlays(QPainter& painter);
|
||||||
void drawScreenSpace(QPainter& painter);
|
void drawScreenSpace(QPainter& painter);
|
||||||
// Vignette-style border shown while the game is paused (speed 0x) to make the
|
// Vignette-style border shown while the game is paused (speed 0x, REQ-UI-PAUSE-BORDER)
|
||||||
// paused state hard to miss: a black frame whose alpha fades from 50% at the
|
// to make the paused state hard to miss: a black frame whose alpha fades from 50% at
|
||||||
// viewport edges to 0% toward the center.
|
// the viewport edges to 0% toward the center.
|
||||||
void drawPauseBorder(QPainter& painter);
|
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);
|
void drawReplayOverlay(QPainter& painter);
|
||||||
|
|
||||||
float getTilePx() const;
|
float getTilePx() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user