diff --git a/MenuAPI/MenuController.cs b/MenuAPI/MenuController.cs index 39bb6e6..1a28846 100644 --- a/MenuAPI/MenuController.cs +++ b/MenuAPI/MenuController.cs @@ -239,7 +239,7 @@ public static Menu GetCurrentMenu() /// Returns true if any menu is currently open. /// /// - public static bool IsAnyMenuOpen() => VisibleMenus.Any(); + public static bool IsAnyMenuOpen() => VisibleMenus.Count > 0; #region Process Menu Buttons @@ -446,12 +446,15 @@ private async Task ProcessToggleMenuButton() #endif #if REDM ProcessToggleMenuButtonRedM(); - await Task.FromResult(0); #endif } #if REDM private void ProcessToggleMenuButtonRedM() { + if (MenuToggleKey == 0) + { + return; + } DisableControlAction(0, (uint)MenuToggleKey, true); if ( !IsPauseMenuActive() && diff --git a/MenuAPI/items/MenuItem.cs b/MenuAPI/items/MenuItem.cs index a4ff375..c459436 100644 --- a/MenuAPI/items/MenuItem.cs +++ b/MenuAPI/items/MenuItem.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using CitizenFX.Core; +using System.Text.RegularExpressions; using static CitizenFX.Core.Native.API; using static CitizenFX.Core.Native.Function; using static CitizenFX.Core.Native.Hash; @@ -226,23 +227,9 @@ public string Description { string text = value; int maxLength = 50; - List lines = new List(); - while (text.Length > maxLength) + if (text.Length > maxLength) { - var substr = text.Substring(0, Math.Min(text.Length - 1, maxLength)); - var lastIndex = substr.LastIndexOf(" "); - if (lastIndex == -1) - { - lastIndex = Math.Min(text.Length - 1, maxLength); - } - lines.Add(text.Substring(0, lastIndex)); - text = text.Substring(lastIndex); - } - lines.Add(text); - text = ""; - foreach (var str in lines) - { - text += str + "\n"; + text = Regex.Replace(text, @"(.{1," + maxLength + @"})(?:\s|$)", "$1\n"); } _description = text; }