new background image
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
std::array<SDL_FRect, 5> computeMenuButtonRects(const MenuLayoutParams& p) {
|
||||
std::array<SDL_FRect, MENU_BTN_COUNT> computeMenuButtonRects(const MenuLayoutParams& p) {
|
||||
const float LOGICAL_W = static_cast<float>(p.logicalW);
|
||||
const float LOGICAL_H = static_cast<float>(p.logicalH);
|
||||
float contentOffsetX = (p.winW - LOGICAL_W * p.logicalScale) * 0.5f / p.logicalScale;
|
||||
@ -13,7 +13,7 @@ std::array<SDL_FRect, 5> computeMenuButtonRects(const MenuLayoutParams& p) {
|
||||
|
||||
// Cockpit HUD layout (matches main_screen art):
|
||||
// - A big centered PLAY button
|
||||
// - A second row of 4 smaller buttons: LEVEL / OPTIONS / HELP / EXIT
|
||||
// - A second row of 5 smaller buttons: LEVEL / OPTIONS / HELP / ABOUT / EXIT
|
||||
const float marginX = std::max(24.0f, LOGICAL_W * 0.03f);
|
||||
const float marginBottom = std::max(26.0f, LOGICAL_H * 0.03f);
|
||||
const float availableW = std::max(120.0f, LOGICAL_W - marginX * 2.0f);
|
||||
@ -25,7 +25,8 @@ std::array<SDL_FRect, 5> computeMenuButtonRects(const MenuLayoutParams& p) {
|
||||
float smallSpacing = 28.0f;
|
||||
|
||||
// Scale down for narrow windows so nothing goes offscreen.
|
||||
float smallTotal = smallW * 4.0f + smallSpacing * 3.0f;
|
||||
const int smallCount = MENU_BTN_COUNT - 1;
|
||||
float smallTotal = smallW * static_cast<float>(smallCount) + smallSpacing * static_cast<float>(smallCount - 1);
|
||||
if (smallTotal > availableW) {
|
||||
float s = availableW / smallTotal;
|
||||
smallW *= s;
|
||||
@ -45,14 +46,14 @@ std::array<SDL_FRect, 5> computeMenuButtonRects(const MenuLayoutParams& p) {
|
||||
std::array<SDL_FRect, MENU_BTN_COUNT> rects{};
|
||||
rects[0] = SDL_FRect{ centerX - playW * 0.5f, playCY - playH * 0.5f, playW, playH };
|
||||
|
||||
float rowW = smallW * 4.0f + smallSpacing * 3.0f;
|
||||
float rowW = smallW * static_cast<float>(smallCount) + smallSpacing * static_cast<float>(smallCount - 1);
|
||||
float left = centerX - rowW * 0.5f;
|
||||
float minLeft = contentOffsetX + marginX;
|
||||
float maxRight = contentOffsetX + LOGICAL_W - marginX;
|
||||
if (left < minLeft) left = minLeft;
|
||||
if (left + rowW > maxRight) left = std::max(minLeft, maxRight - rowW);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int i = 0; i < smallCount; ++i) {
|
||||
float x = left + i * (smallW + smallSpacing);
|
||||
rects[i + 1] = SDL_FRect{ x, smallCY - smallH * 0.5f, smallW, smallH };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user