visual makeover of backgrounds for each level
This commit is contained in:
@ -120,7 +120,7 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
|
||||
const float LOGICAL_W = 1200.f;
|
||||
const float LOGICAL_H = 1000.f;
|
||||
float contentOffsetX = 0.0f;
|
||||
float contentOffsetY = 20.0f;
|
||||
float contentOffsetY = 0.0f;
|
||||
UIRenderer::computeContentOffsets((float)logicalVP.w, (float)logicalVP.h, LOGICAL_W, LOGICAL_H, logicalScale, contentOffsetX, contentOffsetY);
|
||||
|
||||
float contentW = LOGICAL_W * logicalScale;
|
||||
@ -131,7 +131,7 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
|
||||
// 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 + 45.0f;
|
||||
float btnY = LOGICAL_H * 0.865f + contentOffsetY + (LOGICAL_H * 0.02f) + menuYOffset + 4.5f;
|
||||
|
||||
// Compose same button definition used in render()
|
||||
char levelBtnText[32];
|
||||
@ -153,6 +153,8 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
|
||||
|
||||
|
||||
// Draw semi-transparent background panel behind the full button group (draw first so text sits on top)
|
||||
// `groupCenterY` is declared here so it can be used when drawing the buttons below.
|
||||
float groupCenterY = 0.0f;
|
||||
{
|
||||
float groupCenterX = btnX;
|
||||
float halfSpan = 1.5f * spacing; // covers from leftmost to rightmost button centers
|
||||
@ -179,12 +181,15 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
|
||||
// Expand border to cover full window width (use actual viewport)
|
||||
SDL_FRect borderFull{ 0.0f, panelTop, viewportLogicalW, panelH };
|
||||
SDL_RenderRect(renderer, &borderFull);
|
||||
// Compute a vertical center for the group so labels/icons can be centered
|
||||
groupCenterY = panelTop + panelH * 0.5f;
|
||||
}
|
||||
|
||||
// Draw all four buttons on top
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
float cxCenter = 0.0f;
|
||||
float cyCenter = btnY;
|
||||
// Use the group's center Y so text/icons sit visually centered in the panel
|
||||
float cyCenter = groupCenterY;
|
||||
if (ctx.menuButtonsExplicit) {
|
||||
cxCenter = ctx.menuButtonCX[i] + contentOffsetX;
|
||||
cyCenter = ctx.menuButtonCY[i] + contentOffsetY;
|
||||
@ -302,8 +307,8 @@ void MenuState::handleEvent(const SDL_Event& e) {
|
||||
|
||||
// If the inline options HUD is visible and not animating, capture navigation
|
||||
if (optionsVisible && !optionsAnimating) {
|
||||
// Options now has more rows; use OPTIONS_ROW_COUNT
|
||||
constexpr int OPTIONS_ROW_COUNT = 8;
|
||||
// Options rows drawn here are 5 (Fullscreen, Music, Sound FX, Smooth Scroll, Return)
|
||||
constexpr int OPTIONS_ROW_COUNT = 5;
|
||||
switch (e.key.scancode) {
|
||||
case SDL_SCANCODE_UP:
|
||||
{
|
||||
@ -356,25 +361,6 @@ void MenuState::handleEvent(const SDL_Event& e) {
|
||||
return;
|
||||
}
|
||||
case 4: {
|
||||
// PULSE ENABLE
|
||||
buttonPulseEnabled = !buttonPulseEnabled;
|
||||
return;
|
||||
}
|
||||
case 5: {
|
||||
// PULSE SPEED (Enter toggles to default)
|
||||
if (e.key.scancode == SDL_SCANCODE_RETURN || e.key.scancode == SDL_SCANCODE_KP_ENTER || e.key.scancode == SDL_SCANCODE_SPACE) {
|
||||
buttonPulseSpeed = 1.0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 6: {
|
||||
// PULSE MIN ALPHA (Enter resets)
|
||||
if (e.key.scancode == SDL_SCANCODE_RETURN || e.key.scancode == SDL_SCANCODE_KP_ENTER || e.key.scancode == SDL_SCANCODE_SPACE) {
|
||||
buttonPulseMinAlpha = 0.6;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 7: {
|
||||
// RETURN TO MENU -> hide panel
|
||||
optionsAnimating = true;
|
||||
optionsDirection = -1;
|
||||
|
||||
Reference in New Issue
Block a user