fixed menu

This commit is contained in:
2025-12-17 18:55:55 +01:00
parent cecf5cf68e
commit a671825502
5 changed files with 124 additions and 88 deletions

View File

@ -39,6 +39,30 @@ void UIRenderer::drawButton(SDL_Renderer* renderer, FontAtlas* font, float cx, f
float x = cx - w * 0.5f;
float y = cy - h * 0.5f;
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
// In "textOnly" mode we don't draw a full button body (the art may be in the background image),
// but we still add a subtle highlight so hover/selection feels intentional.
if (textOnly && (isHovered || isSelected)) {
Uint8 outlineA = isSelected ? 170 : 110;
Uint8 fillA = isSelected ? 60 : 32;
SDL_Color hl = borderColor;
hl.a = outlineA;
SDL_SetRenderDrawColor(renderer, hl.r, hl.g, hl.b, hl.a);
SDL_FRect o1{x - 3.0f, y - 3.0f, w + 6.0f, h + 6.0f};
SDL_RenderRect(renderer, &o1);
SDL_FRect o2{x - 6.0f, y - 6.0f, w + 12.0f, h + 12.0f};
SDL_SetRenderDrawColor(renderer, hl.r, hl.g, hl.b, static_cast<Uint8>(std::max(0, (int)hl.a - 60)));
SDL_RenderRect(renderer, &o2);
SDL_Color fill = bgColor;
fill.a = fillA;
SDL_SetRenderDrawColor(renderer, fill.r, fill.g, fill.b, fill.a);
SDL_FRect f{x, y, w, h};
SDL_RenderFillRect(renderer, &f);
}
if (!textOnly) {
// Adjust colors based on state
if (isSelected) {
@ -54,7 +78,6 @@ void UIRenderer::drawButton(SDL_Renderer* renderer, FontAtlas* font, float cx, f
}
// Neon glow aura around the button to increase visibility (subtle)
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
for (int gi = 0; gi < 3; ++gi) {
float grow = 6.0f + gi * 3.0f;
Uint8 glowA = static_cast<Uint8>(std::max(0, (int)borderColor.a / (3 - gi)));
@ -89,18 +112,27 @@ void UIRenderer::drawButton(SDL_Renderer* renderer, FontAtlas* font, float cx, f
float iconX = cx - scaledW * 0.5f;
float iconY = cy - scaledH * 0.5f;
// Apply yellow tint when selected
SDL_FRect iconRect{iconX, iconY, scaledW, scaledH};
// Soft icon shadow for readability over busy backgrounds
SDL_SetTextureBlendMode(icon, SDL_BLENDMODE_BLEND);
SDL_SetTextureColorMod(icon, 0, 0, 0);
SDL_SetTextureAlphaMod(icon, 150);
SDL_FRect shadowRect{iconX + 2.0f, iconY + 2.0f, scaledW, scaledH};
SDL_RenderTexture(renderer, icon, nullptr, &shadowRect);
// Main icon (yellow tint when selected)
if (isSelected) {
SDL_SetTextureColorMod(icon, 255, 220, 0);
} else {
SDL_SetTextureColorMod(icon, 255, 255, 255);
}
SDL_FRect iconRect{iconX, iconY, scaledW, scaledH};
SDL_SetTextureAlphaMod(icon, 255);
SDL_RenderTexture(renderer, icon, nullptr, &iconRect);
// Reset color mod
// Reset
SDL_SetTextureColorMod(icon, 255, 255, 255);
SDL_SetTextureAlphaMod(icon, 255);
} else if (font) {
// Draw text (smaller scale for tighter buttons)
float textScale = 1.2f;