Skip to content

Commit a1caedf

Browse files
authored
Merge pull request #50 from cm8263/feature/disableMenuToggleButton
Validates MenuToggleKey (0-402)
2 parents 9a7195a + 733a227 commit a1caedf

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

MenuAPI/MenuController.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ public class MenuController : BaseScript
6767
public static bool PreventExitingMenu { get; set; } = false;
6868
public static bool DisableBackButton { get; set; } = false;
6969
public static bool SetDrawOrder { get; set; } = true;
70+
public static bool MenuToggleKeyIsValid
71+
{
72+
get
73+
{
74+
int keyInt = (int)MenuToggleKey;
75+
return keyInt >= 0 && keyInt <= 402; // 402 is max control value allowed after TU3788
76+
}
77+
}
7078
public static Control MenuToggleKey { get; set; }
7179
#if FIVEM
7280
= Control.InteractionMenu;
@@ -441,6 +449,12 @@ private bool IsDownPressed()
441449
/// <returns></returns>
442450
private async Task ProcessToggleMenuButton()
443451
{
452+
if (!MenuToggleKeyIsValid)
453+
{
454+
await Delay(1_500);
455+
return;
456+
}
457+
444458
#if FIVEM
445459
await ProcessToggleMenuButtonFiveM();
446460
#endif
@@ -754,6 +768,11 @@ private async Task HandleMenuToggleKeyForController()
754768

755769
private void DisableMenuKeyThisFrame()
756770
{
771+
if (!MenuToggleKeyIsValid)
772+
{
773+
return;
774+
}
775+
757776
Game.DisableControlThisFrame(0, MenuToggleKey);
758777
if (Game.CurrentInputMode == InputMode.MouseAndKeyboard)
759778
{

0 commit comments

Comments
 (0)