Bottom menu reorganized

This commit is contained in:
2025-12-17 19:23:16 +01:00
parent a671825502
commit 122de2b36f
3 changed files with 83 additions and 85 deletions

View File

@ -147,44 +147,6 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
};
auto rects = ui::computeMenuButtonRects(params);
// Draw a compact translucent panel behind the button row for readability.
// Keep it tight so the main_screen art stays visible.
{
float left = rects[0].x;
float right = rects[0].x + rects[0].w;
float top = rects[0].y;
float bottom = rects[0].y + rects[0].h;
for (int i = 1; i < MENU_BTN_COUNT; ++i) {
left = std::min(left, rects[i].x);
right = std::max(right, rects[i].x + rects[i].w);
top = std::min(top, rects[i].y);
bottom = std::max(bottom, rects[i].y + rects[i].h);
}
const float padX = 16.0f;
const float padY = 12.0f;
SDL_FRect panel{ left - padX, top - padY, (right - left) + padX * 2.0f, (bottom - top) + padY * 2.0f };
SDL_BlendMode prevBlend = SDL_BLENDMODE_NONE;
SDL_GetRenderDrawBlendMode(renderer, &prevBlend);
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
// Soft shadow (dark, low alpha)
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 80);
SDL_FRect shadow{ panel.x + 3.0f, panel.y + 5.0f, panel.w, panel.h };
SDL_RenderFillRect(renderer, &shadow);
// Bright translucent fill (use existing cyan family used elsewhere in UI)
SDL_SetRenderDrawColor(renderer, 180, 235, 255, 46);
SDL_RenderFillRect(renderer, &panel);
// Border
SDL_SetRenderDrawColor(renderer, 120, 220, 255, 120);
SDL_RenderRect(renderer, &panel);
SDL_SetRenderDrawBlendMode(renderer, prevBlend);
}
// Compose same button definition used in render()
char levelBtnText[32];
int startLevel = ctx.startLevelSelection ? *ctx.startLevelSelection : 0;
@ -201,7 +163,8 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
std::array<SDL_Texture*,5> icons = { playIcon, levelIcon, optionsIcon, helpIcon, exitIcon };
// Draw all five buttons on top of the main_screen art (text/icon only).
// Draw PLAY as a real glowing button, and the four bottom items as HUD buttons.
for (int i = 0; i < 5; ++i) {
const SDL_FRect& r = rects[i];
float cxCenter = r.x + r.w * 0.5f;
@ -212,15 +175,38 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
const bool isHovered = (ctx.hoveredButton && *ctx.hoveredButton == i);
const bool isSelected = (selectedButton == i);
// Apply group alpha and transient flash to button colors
double aMul = std::clamp(buttonGroupAlpha + buttonFlash * buttonFlashAmount, 0.0, 1.0);
SDL_Color bgCol = buttons[i].bg;
SDL_Color bdCol = buttons[i].border;
bgCol.a = static_cast<Uint8>(std::round(aMul * static_cast<double>(bgCol.a)));
bdCol.a = static_cast<Uint8>(std::round(aMul * static_cast<double>(bdCol.a)));
UIRenderer::drawButton(renderer, ctx.pixelFont, cxCenter, cyCenter, btnW, btnH,
buttons[i].label, isHovered, isSelected,
bgCol, bdCol, true, icons[i]);
if (i == 0) {
SDL_Color bgCol{ 18, 22, 28, static_cast<Uint8>(std::round(180.0 * aMul)) };
SDL_Color bdCol{ 255, 200, 70, static_cast<Uint8>(std::round(220.0 * aMul)) };
UIRenderer::drawButton(renderer, ctx.pixelFont, cxCenter, cyCenter, btnW, btnH,
buttons[i].label, isHovered, isSelected,
bgCol, bdCol, false, nullptr);
} else {
SDL_Color bgCol{ 20, 30, 42, static_cast<Uint8>(std::round(160.0 * aMul)) };
SDL_Color bdCol{ 120, 220, 255, static_cast<Uint8>(std::round(200.0 * aMul)) };
UIRenderer::drawButton(renderer, ctx.pixelFont, cxCenter, cyCenter, btnW, btnH,
buttons[i].label, isHovered, isSelected,
bgCol, bdCol, true, nullptr);
}
}
// Draw small '+' separators between the bottom HUD buttons (matches the reference vibe).
{
SDL_BlendMode prevBlend = SDL_BLENDMODE_NONE;
SDL_GetRenderDrawBlendMode(renderer, &prevBlend);
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(renderer, 120, 220, 255, 180);
float y = rects[1].y + rects[1].h * 0.5f;
for (int i = 1; i < 4; ++i) {
float x = (rects[i].x + rects[i].w + rects[i + 1].x) * 0.5f;
SDL_RenderLine(renderer, x - 4.0f, y, x + 4.0f, y);
SDL_RenderLine(renderer, x, y - 4.0f, x, y + 4.0f);
}
SDL_SetRenderDrawBlendMode(renderer, prevBlend);
}
}