From 1ac788b0a270153a79c02b64520f37473ab9dc37 Mon Sep 17 00:00:00 2001 From: Gregor Klevze Date: Sun, 23 Nov 2025 10:10:07 +0100 Subject: [PATCH] fixed level selector menu --- src/states/LevelSelectorState.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/states/LevelSelectorState.cpp b/src/states/LevelSelectorState.cpp index 7c5e918..b293204 100644 --- a/src/states/LevelSelectorState.cpp +++ b/src/states/LevelSelectorState.cpp @@ -96,7 +96,7 @@ static void Vignette(SDL_Renderer* r, int w, int h) { static SDL_FRect DrawPanel(SDL_Renderer* r, float w, float h, bool draw = true, float offX = 0.f, float offY = 0.f) { float PW = std::min(520.f, w * 0.65f); float PH = std::min(360.f, h * 0.7f); - SDL_FRect p{ (w - PW) / 2.f + offX, (h - PH) / 2.f + 10.f + offY, PW, PH }; + SDL_FRect p{ (w - PW) / 2.f + offX, (h - PH) / 2.f - 40.f + offY, PW, PH }; // Moved up by 50px if (!draw) return p; // geometry only @@ -247,6 +247,22 @@ void LevelSelectorState::drawLevelSelectionPopup(SDL_Renderer* renderer, float l float contentOffsetX = (winW - contentW) * 0.5f / logicalScale; float contentOffsetY = (winH - contentH) * 0.5f / logicalScale; + // Draw the logo at the top (same as MenuState) + SDL_Texture* logoToUse = ctx.logoSmallTex ? ctx.logoSmallTex : ctx.logoTex; + if (logoToUse) { + // Use dimensions provided by the shared context when available + int texW = (logoToUse == ctx.logoSmallTex && ctx.logoSmallW > 0) ? ctx.logoSmallW : 872; + int texH = (logoToUse == ctx.logoSmallTex && ctx.logoSmallH > 0) ? ctx.logoSmallH : 273; + float maxW = LOGICAL_W * 0.6f; // Match MenuState and OptionsState + float scale = std::min(1.0f, maxW / float(texW)); + float dw = texW * scale; + float dh = texH * scale; + float logoX = (LOGICAL_W - dw) / 2.f + contentOffsetX; + float logoY = LOGICAL_H * 0.05f + contentOffsetY; // Match MenuState and OptionsState + SDL_FRect dst{logoX, logoY, dw, dh}; + SDL_RenderTexture(renderer, logoToUse, nullptr, &dst); + } + // Panel and title strip (in logical space) - centered properly with offsets SDL_FRect panel = DrawPanel(renderer, LOGICAL_W, LOGICAL_H, /*draw=*/true, contentOffsetX, contentOffsetY); @@ -262,10 +278,10 @@ void LevelSelectorState::drawLevelSelectionPopup(SDL_Renderer* renderer, float l DrawCell(renderer, rc, i, hoveredLevel == i, selectedLevel == i); } - // Footer/instructions - use regular TTF font for readability, centered and higher + // Footer/instructions - use regular TTF font for readability, centered and lower FontAtlas* footerFont = ctx.pixelFont ? ctx.pixelFont : ctx.font; DrawText(renderer, footerFont, "CLICK A LEVEL TO SELECT • ESC = CANCEL", - LOGICAL_W / 2.f + contentOffsetX, panel.y + panel.h + 30.f, 1.0f, COL_FOOTER, true, true); + LOGICAL_W / 2.f + contentOffsetX, panel.y + panel.h + 60.f, 1.0f, COL_FOOTER, true, true); } bool LevelSelectorState::isMouseInPopup(float mouseX, float mouseY, float& popupX, float& popupY, float& popupW, float& popupH) {