Skip to content

Commit

Permalink
Also disable custom button handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
TomGrobbe committed Mar 9, 2019
1 parent f9208b5 commit cf693bc
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions MenuAPI/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -857,33 +857,36 @@ internal async void Draw()
#region Listen for custom key presses.
if (ButtonPressHandlers.Count > 0)
{
foreach (ButtonPressHandler handler in ButtonPressHandlers)
if (!MenuController.DisableMenuButtons)
{
if (handler.disableControl)
foreach (ButtonPressHandler handler in ButtonPressHandlers)
{
Game.DisableControlThisFrame(0, handler.control);
}
if (handler.disableControl)
{
Game.DisableControlThisFrame(0, handler.control);
}

switch (handler.pressType)
{
case ControlPressCheckType.JUST_PRESSED:
if (Game.IsControlJustPressed(0, handler.control) || Game.IsDisabledControlJustPressed(0, handler.control))
handler.function.Invoke(this, handler.control);
break;
case ControlPressCheckType.JUST_RELEASED:
if (Game.IsControlJustReleased(0, handler.control) || Game.IsDisabledControlJustReleased(0, handler.control))
handler.function.Invoke(this, handler.control);
break;
case ControlPressCheckType.PRESSED:
if (Game.IsControlPressed(0, handler.control) || Game.IsDisabledControlPressed(0, handler.control))
handler.function.Invoke(this, handler.control);
break;
case ControlPressCheckType.RELEASED:
if (!Game.IsControlPressed(0, handler.control) && !Game.IsDisabledControlPressed(0, handler.control))
handler.function.Invoke(this, handler.control);
break;
default:
break;
switch (handler.pressType)
{
case ControlPressCheckType.JUST_PRESSED:
if (Game.IsControlJustPressed(0, handler.control) || Game.IsDisabledControlJustPressed(0, handler.control))
handler.function.Invoke(this, handler.control);
break;
case ControlPressCheckType.JUST_RELEASED:
if (Game.IsControlJustReleased(0, handler.control) || Game.IsDisabledControlJustReleased(0, handler.control))
handler.function.Invoke(this, handler.control);
break;
case ControlPressCheckType.PRESSED:
if (Game.IsControlPressed(0, handler.control) || Game.IsDisabledControlPressed(0, handler.control))
handler.function.Invoke(this, handler.control);
break;
case ControlPressCheckType.RELEASED:
if (!Game.IsControlPressed(0, handler.control) && !Game.IsDisabledControlPressed(0, handler.control))
handler.function.Invoke(this, handler.control);
break;
default:
break;
}
}
}
}
Expand Down

0 comments on commit cf693bc

Please sign in to comment.