Fixed menu
This commit is contained in:
@ -30,6 +30,10 @@
|
||||
// This avoids renderer readback / surface APIs which aren't portable across SDL3 builds.
|
||||
static void renderBackdropBlur(SDL_Renderer* renderer, const SDL_Rect& logicalVP, float logicalScale, float panelTop, float panelH, SDL_Texture* sceneTex, int sceneW, int sceneH) {
|
||||
if (!renderer) return;
|
||||
// Preserve previous draw blend mode so callers don't get surprised when
|
||||
// the helper early-returns or changes blend state.
|
||||
SDL_BlendMode prevBlendMode = SDL_BLENDMODE_NONE;
|
||||
SDL_GetRenderDrawBlendMode(renderer, &prevBlendMode);
|
||||
// If we don't have a captured scene texture, fall back to the frosted tint.
|
||||
if (!sceneTex || sceneW <= 0 || sceneH <= 0) {
|
||||
float viewportLogicalW = (float)logicalVP.w / logicalScale;
|
||||
@ -43,7 +47,8 @@ static void renderBackdropBlur(SDL_Renderer* renderer, const SDL_Rect& logicalVP
|
||||
SDL_SetRenderDrawColor(renderer, 16, 24, 32, 12);
|
||||
SDL_FRect shadow{ 0.0f, panelTop + panelH - std::max(2.0f, panelH * 0.06f), viewportLogicalW, std::max(2.0f, panelH * 0.06f) };
|
||||
SDL_RenderFillRect(renderer, &shadow);
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
|
||||
// Restore previous blend mode
|
||||
SDL_SetRenderDrawBlendMode(renderer, prevBlendMode);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -67,7 +72,7 @@ static void renderBackdropBlur(SDL_Renderer* renderer, const SDL_Rect& logicalVP
|
||||
SDL_SetRenderDrawColor(renderer, 200, 210, 220, 48);
|
||||
SDL_FRect base{ 0.0f, panelTop, viewportLogicalW, panelH };
|
||||
SDL_RenderFillRect(renderer, &base);
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
|
||||
SDL_SetRenderDrawBlendMode(renderer, prevBlendMode);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -95,6 +100,8 @@ static void renderBackdropBlur(SDL_Renderer* renderer, const SDL_Rect& logicalVP
|
||||
|
||||
// Cleanup
|
||||
SDL_DestroyTexture(small);
|
||||
// Restore previous blend mode so caller drawing is unaffected
|
||||
SDL_SetRenderDrawBlendMode(renderer, prevBlendMode);
|
||||
}
|
||||
|
||||
MenuState::MenuState(StateContext& ctx) : State(ctx) {}
|
||||
@ -113,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 = 0.0f;
|
||||
float contentOffsetY = 20.0f;
|
||||
UIRenderer::computeContentOffsets((float)logicalVP.w, (float)logicalVP.h, LOGICAL_W, LOGICAL_H, logicalScale, contentOffsetX, contentOffsetY);
|
||||
|
||||
float contentW = LOGICAL_W * logicalScale;
|
||||
@ -124,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;
|
||||
float btnY = LOGICAL_H * 0.865f + contentOffsetY + (LOGICAL_H * 0.02f) + menuYOffset + 45.0f;
|
||||
|
||||
// Compose same button definition used in render()
|
||||
char levelBtnText[32];
|
||||
@ -151,13 +158,15 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
|
||||
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;
|
||||
// Nudge the panel slightly lower for better visual spacing
|
||||
float panelTop = btnY - btnH * 0.5f - 12.0f + 18.0f;
|
||||
float panelH = btnH + 24.0f;
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
// Backdrop blur pass before tint (use captured scene texture if available)
|
||||
renderBackdropBlur(renderer, logicalVP, logicalScale, panelTop, panelH, ctx.sceneTex, ctx.sceneW, ctx.sceneH);
|
||||
// Brighter, less-opaque background to increase contrast
|
||||
SDL_SetRenderDrawColor(renderer, 28, 36, 46, 180);
|
||||
// Brighter, more transparent background to increase contrast but keep scene visible
|
||||
// More transparent background so underlying scene shows through
|
||||
SDL_SetRenderDrawColor(renderer, 28, 36, 46, 110);
|
||||
// Fill full-width background so edges are covered in fullscreen
|
||||
float viewportLogicalW = (float)logicalVP.w / logicalScale;
|
||||
SDL_FRect fullPanel{ 0.0f, panelTop, viewportLogicalW, panelH };
|
||||
@ -165,8 +174,8 @@ void MenuState::renderMainButtonTop(SDL_Renderer* renderer, float logicalScale,
|
||||
// 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);
|
||||
// brighter full-width border (slightly more transparent)
|
||||
SDL_SetRenderDrawColor(renderer, 120, 140, 160, 120);
|
||||
// Expand border to cover full window width (use actual viewport)
|
||||
SDL_FRect borderFull{ 0.0f, panelTop, viewportLogicalW, panelH };
|
||||
SDL_RenderRect(renderer, &borderFull);
|
||||
|
||||
Reference in New Issue
Block a user