fixed statistics panel

This commit is contained in:
2025-12-07 18:25:13 +01:00
parent 12bc4870b1
commit e27d1b60b1
2 changed files with 53 additions and 36 deletions

View File

@ -348,14 +348,20 @@ void GameRenderer::renderPlayingState(
snprintf(countStr, sizeof(countStr), "%d", count);
int countW = 0, countH = 0;
pixelFont->measure(countStr, 1.0f, countW, countH);
float countX = previewX + rowWidth - static_cast<float>(countW);
// Horizontal shift to push the counts/percent a bit more to the right
const float statsNumbersShift = 20.0f;
// Small left shift for progress bar so the track aligns better with the design
const float statsBarShift = -10.0f;
float countX = previewX + rowWidth - static_cast<float>(countW) + statsNumbersShift;
float countY = previewY + 9.0f;
int perc = (totalBlocks > 0) ? int(std::round(100.0 * double(count) / double(totalBlocks))) : 0;
char percStr[16];
snprintf(percStr, sizeof(percStr), "%d%%", perc);
int percW = 0, percH = 0;
pixelFont->measure(percStr, 0.8f, percW, percH);
float barX = previewX;
float barX = previewX + statsBarShift;
float barY = previewY + pieceHeight + 12.0f;
float barH = 6.0f;
float barW = rowWidth;
@ -378,7 +384,9 @@ void GameRenderer::renderPlayingState(
drawSmallPiece(renderer, blocksTex, static_cast<PieceType>(i), previewX, previewY, previewSize);
pixelFont->draw(renderer, countX, countY, countStr, 1.0f, {245, 245, 255, 255});
pixelFont->draw(renderer, previewX, percY, percStr, 0.8f, {215, 225, 240, 255});
// Draw percent right-aligned near the same right edge as the count
float percX = previewX + rowWidth - static_cast<float>(percW) + statsNumbersShift;
pixelFont->draw(renderer, percX, percY, percStr, 0.8f, {215, 225, 240, 255});
SDL_SetRenderDrawColor(renderer, 110, 120, 140, 200);
SDL_FRect track{barX, barY, barW, barH};