Fade from main menu to gameplay

This commit is contained in:
2025-11-22 20:18:00 +01:00
parent c0bee9296a
commit 3c3a85d6d4
7 changed files with 167 additions and 17 deletions

View File

@ -123,8 +123,11 @@ void GameRenderer::renderPlayingState(
float logicalScale,
float winW,
float winH,
bool showExitConfirmPopup
bool showExitConfirmPopup,
int exitPopupSelectedButton,
bool suppressPauseVisuals
) {
(void)exitPopupSelectedButton;
if (!game || !pixelFont) return;
// Calculate actual content area (centered within the window)
@ -236,8 +239,10 @@ void GameRenderer::renderPlayingState(
}
}
bool allowActivePieceRender = !game->isPaused() || suppressPauseVisuals;
// Draw ghost piece (where current piece will land)
if (!game->isPaused()) {
if (allowActivePieceRender) {
Game::Piece ghostPiece = game->current();
// Find landing position
while (true) {
@ -270,7 +275,7 @@ void GameRenderer::renderPlayingState(
}
// Draw the falling piece
if (!game->isPaused()) {
if (allowActivePieceRender) {
drawPiece(renderer, blocksTex, game->current(), gridX, gridY, finalBlockSize, false);
}
@ -412,8 +417,8 @@ void GameRenderer::renderPlayingState(
drawSmallPiece(renderer, blocksTex, static_cast<PieceType>(game->held().type), statsX + 60, statsY + statsH - 80, finalBlockSize * 0.6f);
}
// Pause overlay
if (game->isPaused() && !showExitConfirmPopup) {
// Pause overlay (suppressed when requested, e.g., countdown)
if (!suppressPauseVisuals && game->isPaused() && !showExitConfirmPopup) {
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 180);
SDL_FRect pauseOverlay{0, 0, logicalW, logicalH};
SDL_RenderFillRect(renderer, &pauseOverlay);

View File

@ -26,7 +26,9 @@ public:
float logicalScale,
float winW,
float winH,
bool showExitConfirmPopup
bool showExitConfirmPopup,
int exitPopupSelectedButton = 1,
bool suppressPauseVisuals = false
);
private:

View File

@ -124,7 +124,8 @@ void GameRenderer::renderPlayingState(
float winW,
float winH,
bool showExitConfirmPopup,
int exitPopupSelectedButton
int exitPopupSelectedButton,
bool suppressPauseVisuals
) {
if (!game || !pixelFont) return;
@ -237,8 +238,10 @@ void GameRenderer::renderPlayingState(
}
}
bool allowActivePieceRender = !game->isPaused() || suppressPauseVisuals;
// Draw ghost piece (where current piece will land)
if (!game->isPaused()) {
if (allowActivePieceRender) {
Game::Piece ghostPiece = game->current();
// Find landing position
while (true) {
@ -271,7 +274,7 @@ void GameRenderer::renderPlayingState(
}
// Draw the falling piece
if (!game->isPaused()) {
if (allowActivePieceRender) {
drawPiece(renderer, blocksTex, game->current(), gridX, gridY, finalBlockSize, false);
}
@ -413,8 +416,8 @@ void GameRenderer::renderPlayingState(
drawSmallPiece(renderer, blocksTex, static_cast<PieceType>(game->held().type), statsX + 60, statsY + statsH - 80, finalBlockSize * 0.6f);
}
// Pause overlay
if (game->isPaused() && !showExitConfirmPopup) {
// Pause overlay (skip when visuals are suppressed, e.g., countdown)
if (!suppressPauseVisuals && game->isPaused() && !showExitConfirmPopup) {
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 180);
SDL_FRect pauseOverlay{0, 0, logicalW, logicalH};
SDL_RenderFillRect(renderer, &pauseOverlay);

View File

@ -27,7 +27,8 @@ public:
float winW,
float winH,
bool showExitConfirmPopup,
int exitPopupSelectedButton = 1 // 0=YES, 1=NO
int exitPopupSelectedButton = 1, // 0=YES, 1=NO
bool suppressPauseVisuals = false
);
private: