Skip to content

Commit

Permalink
Make checkboxes and normal menu items toggle when left/right arrows a…
Browse files Browse the repository at this point in the history
…re pressed
  • Loading branch information
TomGrobbe committed Jul 9, 2019
1 parent fc5e10a commit 903cf87
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
20 changes: 20 additions & 0 deletions MenuAPI/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,16 @@ public void GoLeft()
DynamicListItemCurrentItemChanged(this, dynList, oldValue, newSelectedItem);
PlaySoundFrontend(-1, "NAV_LEFT_RIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET", false);
}
// If it's a checkbox, just trigger the box instead.
else if (item.Enabled && item is MenuCheckboxItem checkbox)
{
SelectItem(checkbox);
}
// If the item is enabled and it's not any of the above, just select it.
else if (item.Enabled)
{
SelectItem(item);
}
}
}

Expand Down Expand Up @@ -864,6 +874,16 @@ public void GoRight()
DynamicListItemCurrentItemChanged(this, dynList, oldValue, newSelectedItem);
PlaySoundFrontend(-1, "NAV_LEFT_RIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET", false);
}
// If it's a checkbox, just trigger the box instead.
else if (item.Enabled && item is MenuCheckboxItem checkbox)
{
SelectItem(checkbox);
}
// If the item is enabled and it's not any of the above, just select it.
else if (item.Enabled)
{
SelectItem(item);
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions MenuAPI/MenuController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ private async Task ProcessMainButtons()
if (currentMenu.Visible && AreMenuButtonsEnabled)
{
// Select / Enter
if (Game.IsDisabledControlJustReleased(0, Control.FrontendAccept) || Game.IsControlJustReleased(0, Control.FrontendAccept) || (Game.IsDisabledControlJustReleased(0, Control.VehicleMouseControlOverride) || Game.IsControlJustReleased(0, Control.VehicleMouseControlOverride)))
if (
Game.IsDisabledControlJustReleased(0, Control.FrontendAccept) ||
Game.IsControlJustReleased(0, Control.FrontendAccept) ||
Game.IsDisabledControlJustReleased(0, Control.VehicleMouseControlOverride) ||
Game.IsControlJustReleased(0, Control.VehicleMouseControlOverride)
)
{
if (currentMenu.Size > 0)
{
Expand Down Expand Up @@ -709,7 +714,7 @@ internal static async Task DrawInstructionalButtons()
EndScaleformMovieMethod();




for (int i = 0; i < menu.InstructionalButtons.Count; i++)
{
Expand Down

0 comments on commit 903cf87

Please sign in to comment.