fixed menu
This commit is contained in:
@ -16,6 +16,30 @@ std::array<SDL_FRect, 5> computeMenuButtonRects(const MenuLayoutParams& p) {
|
||||
float btnCX = LOGICAL_W * 0.5f + contentOffsetX;
|
||||
float btnCY = LOGICAL_H * 0.86f + contentOffsetY + MENU_BTN_Y_OFFSET;
|
||||
float spacing = isSmall ? btnW * MENU_BTN_SPACING_FACTOR_SMALL : btnW * MENU_BTN_SPACING_FACTOR_LARGE;
|
||||
|
||||
// Guarantee the full 5-button group fits within the logical width so no options
|
||||
// disappear in windowed mode. We shrink width + spacing proportionally when needed.
|
||||
const float margin = std::max(18.0f, LOGICAL_W * 0.02f);
|
||||
const float availableW = std::max(100.0f, LOGICAL_W - margin * 2.0f);
|
||||
float totalW = btnW + (MENU_BTN_COUNT - 1) * spacing;
|
||||
if (totalW > availableW) {
|
||||
float scale = availableW / totalW;
|
||||
btnW *= scale;
|
||||
btnH *= scale;
|
||||
spacing *= scale;
|
||||
totalW = btnW + (MENU_BTN_COUNT - 1) * spacing;
|
||||
}
|
||||
|
||||
// Keep the group centered but ensure left/right edges respect margins.
|
||||
float groupLeft = btnCX - totalW * 0.5f;
|
||||
float minLeft = contentOffsetX + margin;
|
||||
float maxRight = contentOffsetX + LOGICAL_W - margin;
|
||||
float groupRight = groupLeft + totalW;
|
||||
if (groupLeft < minLeft) {
|
||||
btnCX += (minLeft - groupLeft);
|
||||
} else if (groupRight > maxRight) {
|
||||
btnCX -= (groupRight - maxRight);
|
||||
}
|
||||
std::array<SDL_FRect, MENU_BTN_COUNT> rects{};
|
||||
for (int i = 0; i < MENU_BTN_COUNT; ++i) {
|
||||
float center = btnCX + (static_cast<float>(i) - MENU_BTN_CENTER) * spacing;
|
||||
|
||||
Reference in New Issue
Block a user