Fix classic options menu not using proper layout

This commit is contained in:
UnknownShadow200 2025-06-01 10:52:01 +10:00
parent 0b40c37ccd
commit cecb4bc1b5

View File

@ -237,10 +237,13 @@ static int MenuOptionsScreen_AddButton(struct MenuOptionsScreen* s, const char*
return i; return i;
} }
static void MenuOptionsScreen_EndButtons(struct MenuOptionsScreen* s, Widget_LeftClick backClick) { static void MenuOptionsScreen_EndButtons(struct MenuOptionsScreen* s, int half, Widget_LeftClick backClick) {
struct ButtonWidget* btn; struct ButtonWidget* btn;
int i, col, row, half = (s->numButtons + 1) / 2; int i, col, row, begRow;
int begRow = 2 - half; /* Auto calculate half/dividing count */
if (half < 0) half = (s->numButtons + 1) / 2;
begRow = 2 - half;
if (s->numButtons & 1) begRow--; if (s->numButtons & 1) begRow--;
begRow = max(-3, begRow); begRow = max(-3, begRow);
@ -622,18 +625,16 @@ static void ClassicOptionsScreen_InitWidgets(struct MenuOptionsScreen* s) {
ClO_GetViewBob, ClO_SetViewBob, NULL); ClO_GetViewBob, ClO_SetViewBob, NULL);
MenuOptionsScreen_AddBool(s, "Limit framerate", MenuOptionsScreen_AddBool(s, "Limit framerate",
ClO_GetFPS, ClO_SetFPS, NULL); ClO_GetFPS, ClO_SetFPS, NULL);
MenuOptionsScreen_AddBool(s, "Hacks enabled", if (Game_ClassicHacks) {
ClO_GetHacks, ClO_SetHacks, NULL); MenuOptionsScreen_AddBool(s, "Hacks enabled",
ClO_GetHacks,ClO_SetHacks, NULL);
}
} }
MenuOptionsScreen_EndButtons(s, Menu_SwitchPause); MenuOptionsScreen_EndButtons(s, 4, Menu_SwitchPause);
s->DoRecreateExtra = ClassicOptionsScreen_RecreateExtra; s->DoRecreateExtra = ClassicOptionsScreen_RecreateExtra;
ButtonWidget_Add(s, &s->buttons[9], 400, Menu_SwitchBindsClassic); ButtonWidget_Add(s, &s->buttons[9], 400, Menu_SwitchBindsClassic);
Widget_SetLocation(&s->buttons[9], ANCHOR_CENTRE, ANCHOR_MAX, 0, 95); Widget_SetLocation(&s->buttons[9], ANCHOR_CENTRE, ANCHOR_MAX, 0, 95);
/* Disable certain options */
if (!Server.IsSinglePlayer) Menu_Remove(s, 3);
if (!Game_ClassicHacks) Menu_Remove(s, 8);
} }
void ClassicOptionsScreen_Show(void) { void ClassicOptionsScreen_Show(void) {
@ -703,7 +704,7 @@ static void EnvSettingsScreen_InitWidgets(struct MenuOptionsScreen* s) {
-2048, 2048, World.Height / 2, -2048, 2048, World.Height / 2,
ES_GetEdgeHeight, ES_SetEdgeHeight, NULL); ES_GetEdgeHeight, ES_SetEdgeHeight, NULL);
} }
MenuOptionsScreen_EndButtons(s, Menu_SwitchOptions); MenuOptionsScreen_EndButtons(s, -1, Menu_SwitchOptions);
} }
void EnvSettingsScreen_Show(void) { void EnvSettingsScreen_Show(void) {
@ -812,7 +813,7 @@ static void GraphicsOptionsScreen_InitWidgets(struct MenuOptionsScreen* s) {
MenuOptionsScreen_AddBool(s, "3D anaglyph", MenuOptionsScreen_AddBool(s, "3D anaglyph",
ClO_GetAnaglyph, ClO_SetAnaglyph, NULL); ClO_GetAnaglyph, ClO_SetAnaglyph, NULL);
}; };
MenuOptionsScreen_EndButtons(s, Menu_SwitchOptions); MenuOptionsScreen_EndButtons(s, -1, Menu_SwitchOptions);
s->OnLightingModeServerChanged = GrO_CheckLightingModeAllowed; s->OnLightingModeServerChanged = GrO_CheckLightingModeAllowed;
GrO_CheckLightingModeAllowed(s); GrO_CheckLightingModeAllowed(s);
} }
@ -880,7 +881,7 @@ static void ChatOptionsScreen_InitWidgets(struct MenuOptionsScreen* s) {
MenuOptionsScreen_AddBool(s, "Clickable chat", MenuOptionsScreen_AddBool(s, "Clickable chat",
ChO_GetClickable, ChO_SetClickable, NULL); ChO_GetClickable, ChO_SetClickable, NULL);
} }
MenuOptionsScreen_EndButtons(s, Menu_SwitchOptions); MenuOptionsScreen_EndButtons(s, -1, Menu_SwitchOptions);
} }
void ChatOptionsScreen_Show(void) { void ChatOptionsScreen_Show(void) {
@ -956,7 +957,7 @@ static void GuiOptionsScreen_InitWidgets(struct MenuOptionsScreen* s) {
MenuOptionsScreen_AddButton(s, "Select system font", Menu_SwitchFont, MenuOptionsScreen_AddButton(s, "Select system font", Menu_SwitchFont,
NULL, NULL, NULL); NULL, NULL, NULL);
} }
MenuOptionsScreen_EndButtons(s, Menu_SwitchOptions); MenuOptionsScreen_EndButtons(s, -1, Menu_SwitchOptions);
} }
void GuiOptionsScreen_Show(void) { void GuiOptionsScreen_Show(void) {
@ -1094,7 +1095,7 @@ static void HacksSettingsScreen_InitWidgets(struct MenuOptionsScreen* s) {
1, 179, 70, 1, 179, 70,
HS_GetFOV, HS_SetFOV, NULL); HS_GetFOV, HS_SetFOV, NULL);
} }
MenuOptionsScreen_EndButtons(s, Menu_SwitchOptions); MenuOptionsScreen_EndButtons(s, -1, Menu_SwitchOptions);
s->OnHacksChanged = HacksSettingsScreen_CheckHacksAllowed; s->OnHacksChanged = HacksSettingsScreen_CheckHacksAllowed;
HacksSettingsScreen_CheckHacksAllowed(s); HacksSettingsScreen_CheckHacksAllowed(s);
@ -1192,7 +1193,7 @@ static void MiscSettingsScreen_InitWidgets(struct MenuOptionsScreen* s) {
#endif #endif
MiO_GetSensitivity, MiO_SetSensitivity, NULL); MiO_GetSensitivity, MiO_SetSensitivity, NULL);
} }
MenuOptionsScreen_EndButtons(s, Menu_SwitchOptions); MenuOptionsScreen_EndButtons(s, -1, Menu_SwitchOptions);
/* Disable certain options */ /* Disable certain options */
if (!Server.IsSinglePlayer) Menu_Remove(s, 0); if (!Server.IsSinglePlayer) Menu_Remove(s, 0);
@ -1268,7 +1269,7 @@ static void NostalgiaAppearanceScreen_InitWidgets(struct MenuOptionsScreen* s) {
MenuOptionsScreen_AddBool(s, "Classic options", MenuOptionsScreen_AddBool(s, "Classic options",
NA_GetOpts, NA_SetOpts, NULL); NA_GetOpts, NA_SetOpts, NULL);
} }
MenuOptionsScreen_EndButtons(s, Menu_SwitchNostalgia); MenuOptionsScreen_EndButtons(s, -1, Menu_SwitchNostalgia);
} }
void NostalgiaAppearanceScreen_Show(void) { void NostalgiaAppearanceScreen_Show(void) {
@ -1341,7 +1342,7 @@ static void NostalgiaFunctionalityScreen_InitWidgets(struct MenuOptionsScreen* s
"\n" \ "\n" \
"&cNote that some servers only support 0.30 game version"); "&cNote that some servers only support 0.30 game version");
} }
MenuOptionsScreen_EndButtons(s, Menu_SwitchNostalgia); MenuOptionsScreen_EndButtons(s, -1, Menu_SwitchNostalgia);
s->DoRecreateExtra = NostalgiaScreen_RecreateExtra; s->DoRecreateExtra = NostalgiaScreen_RecreateExtra;
TextWidget_Add(s, &nostalgia_desc); TextWidget_Add(s, &nostalgia_desc);