Skip to content

Commit

Permalink
Select next active option if previous one no longer is
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Dec 29, 2023
1 parent dc4a493 commit d304603
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Quake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3382,7 +3382,11 @@ static int M_Options_GetSelected (void)

static qboolean M_Options_IsEnabled (int index)
{
if ((unsigned int) index >= (unsigned int)optionsmenu.list.numitems)
return false;
index += optionsmenu.first_item;
if ((unsigned int) index >= countof (options_names))
return false;
if (index > GPAD_OPTIONS_FIRST && index < GPAD_OPTIONS_FIRST + GPAD_OPTIONS_ITEMS && !joy_enable.value)
return false;
if (M_Options_IsGyroId (index) && !IN_HasGyro ())
Expand All @@ -3395,10 +3399,7 @@ static qboolean M_Options_IsSelectable (int index)
if (!M_Options_IsEnabled (index))
return false;
index += optionsmenu.first_item;
return
(unsigned int) index < countof (options_names) &&
options_names[index][0] != '\0'
;
return options_names[index][0] != '\0';
}

static qboolean M_Options_Match (int index)
Expand Down Expand Up @@ -3461,6 +3462,10 @@ void M_Options_Init (enum m_state_e state)

M_List_ClearSearch (&optionsmenu.list);

// If the cursor is on an inactive item, move it to the next active one
if (!M_Options_IsSelectable (optionsmenu.list.cursor))
M_List_SelectNextActive (&optionsmenu.list, optionsmenu.list.cursor, 1, true);

M_Options_UpdateLayout ();
}

Expand Down

0 comments on commit d304603

Please sign in to comment.