Updated bottom menu
This commit is contained in:
63
src/ui/BottomMenu.h
Normal file
63
src/ui/BottomMenu.h
Normal file
@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "ui/MenuLayout.h"
|
||||
#include "ui/UIConstants.h"
|
||||
|
||||
struct FontAtlas;
|
||||
|
||||
namespace ui {
|
||||
|
||||
enum class BottomMenuItem : int {
|
||||
Play = 0,
|
||||
Level = 1,
|
||||
Options = 2,
|
||||
Help = 3,
|
||||
Exit = 4,
|
||||
};
|
||||
|
||||
struct Button {
|
||||
BottomMenuItem item{};
|
||||
SDL_FRect rect{};
|
||||
std::string label;
|
||||
bool textOnly = true;
|
||||
};
|
||||
|
||||
struct BottomMenu {
|
||||
std::array<Button, MENU_BTN_COUNT> buttons{};
|
||||
};
|
||||
|
||||
BottomMenu buildBottomMenu(const MenuLayoutParams& params, int startLevel);
|
||||
|
||||
// Draws the cockpit HUD menu (PLAY + 4 bottom items) using existing UIRenderer primitives.
|
||||
// hoveredIndex: -1..4
|
||||
// selectedIndex: 0..4 (keyboard selection)
|
||||
// alphaMul: 0..1 (overall group alpha)
|
||||
void renderBottomMenu(SDL_Renderer* renderer,
|
||||
FontAtlas* font,
|
||||
const BottomMenu& menu,
|
||||
int hoveredIndex,
|
||||
int selectedIndex,
|
||||
double baseAlphaMul,
|
||||
double flashAddMul);
|
||||
|
||||
struct BottomMenuInputResult {
|
||||
int hoveredIndex = -1;
|
||||
std::optional<BottomMenuItem> activated;
|
||||
};
|
||||
|
||||
// Interprets mouse motion/button input for the bottom menu.
|
||||
// Expects x/y in the same logical coordinate space used by MenuLayout (the current main loop already provides this).
|
||||
BottomMenuInputResult handleBottomMenuInput(const MenuLayoutParams& params,
|
||||
const SDL_Event& e,
|
||||
float x,
|
||||
float y,
|
||||
int prevHoveredIndex,
|
||||
bool inputEnabled);
|
||||
|
||||
} // namespace ui
|
||||
Reference in New Issue
Block a user