|
|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
// MenuState.cpp
|
|
|
|
|
#include "MenuState.h"
|
|
|
|
|
#include "../Scores.h"
|
|
|
|
|
#include "../Font.h"
|
|
|
|
|
#include "persistence/Scores.h"
|
|
|
|
|
#include "graphics/Font.h"
|
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
@ -11,25 +11,11 @@
|
|
|
|
|
static constexpr int LOGICAL_W = 1200;
|
|
|
|
|
static constexpr int LOGICAL_H = 1000;
|
|
|
|
|
|
|
|
|
|
extern bool showLevelPopup; // from main
|
|
|
|
|
extern bool showSettingsPopup; // from main
|
|
|
|
|
extern bool musicEnabled; // from main
|
|
|
|
|
extern int hoveredButton; // from main
|
|
|
|
|
// Call wrappers defined in main.cpp
|
|
|
|
|
extern void menu_drawFireworks(SDL_Renderer* renderer);
|
|
|
|
|
extern void menu_updateFireworks(double frameMs);
|
|
|
|
|
extern double menu_getLogoAnimCounter();
|
|
|
|
|
extern int menu_getHoveredButton();
|
|
|
|
|
extern void menu_drawEnhancedButton(SDL_Renderer* renderer, FontAtlas& font, float cx, float cy, float w, float h,
|
|
|
|
|
const std::string& label, bool isHovered, bool isSelected);
|
|
|
|
|
|
|
|
|
|
// Menu button wrapper implemented in main.cpp
|
|
|
|
|
extern void menu_drawMenuButton(SDL_Renderer* renderer, FontAtlas& font, float cx, float cy, float w, float h,
|
|
|
|
|
const std::string& label, SDL_Color bgColor, SDL_Color borderColor);
|
|
|
|
|
|
|
|
|
|
// wrappers for popups (defined in main.cpp)
|
|
|
|
|
extern void menu_drawLevelSelectionPopup(SDL_Renderer* renderer, FontAtlas& font, SDL_Texture* bgTex, int selectedLevel);
|
|
|
|
|
extern void menu_drawSettingsPopup(SDL_Renderer* renderer, FontAtlas& font, bool musicEnabled);
|
|
|
|
|
// Shared flags and resources are provided via StateContext `ctx`.
|
|
|
|
|
// Removed fragile extern declarations and use `ctx.showLevelPopup`, `ctx.showSettingsPopup`,
|
|
|
|
|
// `ctx.musicEnabled` and `ctx.hoveredButton` instead to avoid globals.
|
|
|
|
|
// Menu helper wrappers are declared in a shared header implemented in main.cpp
|
|
|
|
|
#include "../audio/MenuWrappers.h"
|
|
|
|
|
|
|
|
|
|
MenuState::MenuState(StateContext& ctx) : State(ctx) {}
|
|
|
|
|
|
|
|
|
|
@ -79,7 +65,7 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fireworks (draw above high scores / near buttons)
|
|
|
|
|
menu_drawFireworks(renderer);
|
|
|
|
|
menu_drawFireworks(renderer, ctx.blocksTex);
|
|
|
|
|
|
|
|
|
|
// Score list and top players with a sine-wave vertical animation (use pixelFont for retro look)
|
|
|
|
|
float topPlayersY = LOGICAL_H * 0.30f + contentOffsetY; // more top padding
|
|
|
|
|
|