fixed main menu background
This commit is contained in:
@ -50,7 +50,10 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
|
||||
float btnW = 200.0f;
|
||||
float btnH = 70.0f;
|
||||
float btnX = LOGICAL_W * 0.5f + contentOffsetX;
|
||||
float btnY = LOGICAL_H * 0.865f + contentOffsetY;
|
||||
// move buttons a bit lower for better visibility
|
||||
// small global vertical offset for the whole menu (tweak to move UI down)
|
||||
float menuYOffset = LOGICAL_H * 0.03f;
|
||||
float btnY = LOGICAL_H * 0.865f + contentOffsetY + (LOGICAL_H * 0.02f) + menuYOffset;
|
||||
|
||||
// Compose same button definition used in render()
|
||||
char levelBtnText[32];
|
||||
@ -69,6 +72,35 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
|
||||
|
||||
float spacing = isSmall ? btnW * 1.2f : btnW * 1.15f;
|
||||
|
||||
// Draw semi-transparent background panel behind the full button group (draw first so text sits on top)
|
||||
{
|
||||
float groupCenterX = btnX;
|
||||
float halfSpan = 1.5f * spacing; // covers from leftmost to rightmost button centers
|
||||
float panelLeft = groupCenterX - halfSpan - btnW * 0.5f - 14.0f;
|
||||
float panelRight = groupCenterX + halfSpan + btnW * 0.5f + 14.0f;
|
||||
float panelTop = btnY - btnH * 0.5f - 12.0f;
|
||||
float panelH = btnH + 24.0f;
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
// Brighter, less-opaque background to increase contrast
|
||||
SDL_SetRenderDrawColor(renderer, 28, 36, 46, 180);
|
||||
// Fill full-width background so edges are covered in fullscreen
|
||||
float viewportLogicalW = (float)logicalVP.w / logicalScale;
|
||||
float fullLeft = 0.0f;
|
||||
float fullW = viewportLogicalW;
|
||||
SDL_FRect fullPanel{ fullLeft, panelTop, fullW, panelH };
|
||||
SDL_RenderFillRect(renderer, &fullPanel);
|
||||
// Also draw the central strip to keep visual center emphasis
|
||||
SDL_FRect panelRect{ panelLeft, panelTop, panelRight - panelLeft, panelH };
|
||||
SDL_RenderFillRect(renderer, &panelRect);
|
||||
// brighter full-width border
|
||||
SDL_SetRenderDrawColor(renderer, 120, 140, 160, 200);
|
||||
// Expand border to cover full window width (use actual viewport)
|
||||
float fullLeftTop = 0.0f;
|
||||
float fullWTop = viewportLogicalW;
|
||||
SDL_FRect borderFull{ fullLeftTop, panelTop, fullWTop, panelH };
|
||||
SDL_RenderRect(renderer, &borderFull);
|
||||
}
|
||||
|
||||
// Draw all four buttons on top
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
float cxCenter = 0.0f;
|
||||
@ -94,7 +126,10 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
|
||||
UIRenderer::drawButton(renderer, ctx.pixelFont, cxCenter, cyCenter, btnW, btnH,
|
||||
buttons[i].label, false, selectedButton == i,
|
||||
bgCol, bdCol, true, icons[i]);
|
||||
// no per-button neon outline here; draw group background below instead
|
||||
}
|
||||
|
||||
// (panel for the top-button draw path is drawn before the buttons so text is on top)
|
||||
}
|
||||
|
||||
void MenuState::onExit() {
|
||||
@ -565,7 +600,8 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
|
||||
// Draw a larger centered logo above the highscores area, then a small "TOP PLAYER" label
|
||||
// Move logo a bit lower for better spacing
|
||||
float topPlayersY = LOGICAL_H * 0.20f + contentOffsetY - panelDelta;
|
||||
float menuYOffset = LOGICAL_H * 0.03f; // same offset used for buttons
|
||||
float topPlayersY = LOGICAL_H * 0.20f + contentOffsetY - panelDelta + menuYOffset;
|
||||
float scoresStartY = topPlayersY;
|
||||
if (useFont) {
|
||||
// Preferred logo texture (full) if present, otherwise the small logo
|
||||
@ -591,7 +627,7 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
int tW = 0, tH = 0;
|
||||
useFont->measure(smallTitle, titleScale, tW, tH);
|
||||
float titleX = (LOGICAL_W - (float)tW) * 0.5f + contentOffsetX;
|
||||
useFont->draw(renderer, titleX, scoresStartY, smallTitle, titleScale, SDL_Color{200,220,230,200});
|
||||
useFont->draw(renderer, titleX, scoresStartY, smallTitle, titleScale, SDL_Color{200,220,230,255});
|
||||
scoresStartY += (float)tH + 12.0f;
|
||||
}
|
||||
static const std::vector<ScoreEntry> EMPTY_SCORES;
|
||||
@ -710,8 +746,8 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
float btnW = 200.0f; // Fixed width to match background buttons
|
||||
float btnH = 70.0f; // Fixed height to match background buttons
|
||||
float btnX = LOGICAL_W * 0.5f + contentOffsetX;
|
||||
// Adjust vertical position to align with background buttons
|
||||
float btnY = LOGICAL_H * 0.865f + contentOffsetY;
|
||||
// Adjust vertical position to align with background buttons; move slightly down
|
||||
float btnY = LOGICAL_H * 0.865f + contentOffsetY + (LOGICAL_H * 0.02f) + menuYOffset;
|
||||
|
||||
if (ctx.pixelFont) {
|
||||
{
|
||||
@ -747,6 +783,34 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
|
||||
// Draw each button individually so each can have its own coordinates
|
||||
if (drawMainButtonNormally) {
|
||||
// Draw semi-transparent background panel behind the full button group
|
||||
{
|
||||
float groupCenterX = btnX;
|
||||
float halfSpan = 1.5f * spacing;
|
||||
float panelLeft = groupCenterX - halfSpan - btnW * 0.5f - 14.0f;
|
||||
float panelRight = groupCenterX + halfSpan + btnW * 0.5f + 14.0f;
|
||||
float panelTop = btnY - btnH * 0.5f - 12.0f;
|
||||
float panelH = btnH + 24.0f;
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
// Brighter, less-opaque background to increase contrast (match top path)
|
||||
SDL_SetRenderDrawColor(renderer, 28, 36, 46, 180);
|
||||
// Fill full-width background so edges are covered in fullscreen
|
||||
float viewportLogicalW = (float)logicalVP.w / logicalScale;
|
||||
float fullLeft = 0.0f;
|
||||
float fullW = viewportLogicalW;
|
||||
SDL_FRect fullPanel{ fullLeft, panelTop, fullW, panelH };
|
||||
SDL_RenderFillRect(renderer, &fullPanel);
|
||||
// Also draw the central strip to keep visual center emphasis
|
||||
SDL_FRect panelRect{ panelLeft, panelTop, panelRight - panelLeft, panelH };
|
||||
SDL_RenderFillRect(renderer, &panelRect);
|
||||
// subtle border across full logical width
|
||||
SDL_SetRenderDrawColor(renderer, 120, 140, 160, 200);
|
||||
// Expand border to cover full window width (use actual viewport)
|
||||
float fullLeftNormal = 0.0f;
|
||||
float fullWNormal = viewportLogicalW;
|
||||
SDL_FRect borderFull{ fullLeftNormal, panelTop, fullWNormal, panelH };
|
||||
SDL_RenderRect(renderer, &borderFull);
|
||||
}
|
||||
// Button 0 - PLAY
|
||||
{
|
||||
const int i = 0;
|
||||
@ -762,6 +826,7 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
UIRenderer::drawButton(renderer, ctx.pixelFont, cxCenter, cyCenter, btnW, btnH,
|
||||
buttons[i].label, false, selectedButton == i,
|
||||
buttons[i].bg, buttons[i].border, true, icons[i]);
|
||||
// no per-button neon outline; group background handles emphasis
|
||||
}
|
||||
|
||||
// Button 1 - LEVEL
|
||||
@ -829,7 +894,7 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
float panelY = panelBaseY + (1.0f - easedE) * slideAmount;
|
||||
|
||||
FontAtlas* titleFont = ctx.pixelFont ? ctx.pixelFont : ctx.font;
|
||||
if (titleFont) titleFont->draw(renderer, panelBaseX + 12.0f, panelY + 6.0f, "EXIT GAME?", 1.6f, SDL_Color{255,200,80,220});
|
||||
if (titleFont) titleFont->draw(renderer, panelBaseX + 12.0f, panelY + 6.0f, "EXIT GAME?", 1.6f, SDL_Color{255,200,80,255});
|
||||
|
||||
SDL_FRect area{ panelBaseX + 12.0f, panelY + 56.0f, panelW - 24.0f, panelH - 120.0f };
|
||||
// Sample long message (scrollable)
|
||||
@ -845,9 +910,9 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
FontAtlas* f = ctx.font ? ctx.font : ctx.pixelFont;
|
||||
float y = area.y - (float)exitScroll;
|
||||
const float lineSpacing = 34.0f; // increased spacing for readability
|
||||
if (f) {
|
||||
if (f) {
|
||||
for (size_t i = 0; i < lines.size(); ++i) {
|
||||
f->draw(renderer, area.x + 6.0f, y + i * lineSpacing, lines[i], 1.0f, SDL_Color{200,220,240,220});
|
||||
f->draw(renderer, area.x + 6.0f, y + i * lineSpacing, lines[i], 1.0f, SDL_Color{200,220,240,255});
|
||||
}
|
||||
}
|
||||
|
||||
@ -893,7 +958,7 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
FontAtlas* retroFont = ctx.font ? ctx.font : ctx.pixelFont;
|
||||
|
||||
if (retroFont) {
|
||||
retroFont->draw(renderer, panelBaseX + 12.0f, panelY + 6.0f, "OPTIONS", 1.8f, SDL_Color{120, 220, 255, 220});
|
||||
retroFont->draw(renderer, panelBaseX + 12.0f, panelY + 6.0f, "OPTIONS", 1.8f, SDL_Color{120, 220, 255, 255});
|
||||
}
|
||||
|
||||
SDL_FRect area{panelBaseX, panelY + 48.0f, panelW, panelH - 64.0f};
|
||||
@ -915,9 +980,9 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
SDL_RenderRect(renderer, &row);
|
||||
}
|
||||
|
||||
if (retroFont) {
|
||||
SDL_Color labelColor = SDL_Color{170, 210, 220, 220};
|
||||
SDL_Color valueColor = SDL_Color{160, 240, 255, 240};
|
||||
if (retroFont) {
|
||||
SDL_Color labelColor = SDL_Color{170, 210, 220, 255};
|
||||
SDL_Color valueColor = SDL_Color{160, 240, 255, 255};
|
||||
if (!label.empty()) {
|
||||
float labelScale = 1.0f;
|
||||
int labelW = 0, labelH = 0;
|
||||
@ -968,7 +1033,7 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
||||
|
||||
// Header
|
||||
FontAtlas* titleFont = ctx.pixelFont ? ctx.pixelFont : ctx.font;
|
||||
if (titleFont) titleFont->draw(renderer, panelBaseX + PW * 0.5f - 140.0f, panelY + 6.0f, "SELECT STARTING LEVEL", 1.1f, SDL_Color{160,220,255,220});
|
||||
if (titleFont) titleFont->draw(renderer, panelBaseX + PW * 0.5f - 140.0f, panelY + 6.0f, "SELECT STARTING LEVEL", 1.1f, SDL_Color{160,220,255,255});
|
||||
|
||||
// Grid area
|
||||
float marginX = 34.0f, marginY = 56.0f;
|
||||
|
||||
Reference in New Issue
Block a user