menubehaviourflags_t: Add MBF_NOLOOPENTRIES

Abstracts one previously hardcoded exception to M_NextOpt/M_PrevOpt
This commit is contained in:
toaster 2023-06-07 11:51:15 +01:00
parent e162fffecf
commit c8f74aef2b
3 changed files with 12 additions and 9 deletions

View file

@ -131,8 +131,9 @@ void M_HandlePauseMenuGametype(INT32 choice);
typedef enum typedef enum
{ {
MBF_UD_LR_FLIPPED = 1, // flip up-down and left-right axes MBF_UD_LR_FLIPPED = 1, // flip up-down and left-right axes
MBF_SOUNDLESS = 2, // do not play base menu sounds MBF_SOUNDLESS = 1<<1, // do not play base menu sounds
MBF_NOLOOPENTRIES = 1<<2, // do not loop M_NextOpt/M_PrevOpt
} menubehaviourflags_t; } menubehaviourflags_t;
struct menuitem_t struct menuitem_t

View file

@ -159,10 +159,11 @@ boolean M_NextOpt(void)
if (itemOn + 1 > currentMenu->numitems - 1) if (itemOn + 1 > currentMenu->numitems - 1)
{ {
// Prevent looparound here // Prevent looparound here
// If you're going to add any extra exceptions, DON'T. if (currentMenu->behaviourflags & MBF_NOLOOPENTRIES)
// Add a "don't loop" flag to the menu_t struct instead. {
if (currentMenu == &MISC_AddonsDef) itemOn = oldItemOn;
return false; return false;
}
itemOn = 0; itemOn = 0;
} }
else else
@ -186,10 +187,11 @@ boolean M_PrevOpt(void)
if (!itemOn) if (!itemOn)
{ {
// Prevent looparound here // Prevent looparound here
// If you're going to add any extra exceptions, DON'T. if (currentMenu->behaviourflags & MBF_NOLOOPENTRIES)
// Add a "don't loop" flag to the menu_t struct instead. {
if (currentMenu == &MISC_AddonsDef) itemOn = oldItemOn;
return false; return false;
}
itemOn = currentMenu->numitems - 1; itemOn = currentMenu->numitems - 1;
} }
else else

View file

@ -23,7 +23,7 @@ menu_t MISC_AddonsDef = {
MISC_AddonsMenu, MISC_AddonsMenu,
50, 28, 50, 28,
0, 0, 0, 0,
0, MBF_NOLOOPENTRIES,
"EXTRAS", "EXTRAS",
0, 0, 0, 0,
M_DrawAddons, M_DrawAddons,