From ec83af170a9fd70a82c3f514a844ff98a59ffc57 Mon Sep 17 00:00:00 2001 From: Michael S Date: Tue, 16 Jan 2024 07:05:42 +0200 Subject: [PATCH] Preform code cleanup --- vMenu/MainMenu.cs | 26 +++++++++++++------------- vMenu/Noclip.cs | 2 +- vMenu/menus/MpPedCustomization.cs | 8 ++++---- vMenu/menus/SavedVehicles.cs | 6 +++--- vMenu/menus/VoiceChat.cs | 10 ++++------ 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/vMenu/MainMenu.cs b/vMenu/MainMenu.cs index d0f65957..69ce86ec 100644 --- a/vMenu/MainMenu.cs +++ b/vMenu/MainMenu.cs @@ -120,10 +120,10 @@ public MainMenu() } #endregion #region keymapping - string KeyMappingID = String.IsNullOrWhiteSpace(GetSettingsString(Setting.vmenu_keymapping_id)) ? "Default" : GetSettingsString(Setting.vmenu_keymapping_id); + string KeyMappingID = String.IsNullOrWhiteSpace(GetSettingsString(Setting.vmenu_keymapping_id)) ? "Default" : GetSettingsString(Setting.vmenu_keymapping_id); RegisterCommand($"vMenu:{KeyMappingID}:NoClip", new Action, string>((dynamic source, List args, string rawCommand) => { - if ( IsAllowed(Permission.NoClip) ) + if (IsAllowed(Permission.NoClip)) { if (Game.PlayerPed.IsInVehicle()) { @@ -146,17 +146,17 @@ public MainMenu() }), false); RegisterCommand($"vMenu:{KeyMappingID}:MenuToggle", new Action, string>((dynamic source, List args, string rawCommand) => { - if (MenuEnabled) - { - if (!MenuController.IsAnyMenuOpen()) - { - Menu.OpenMenu(); - } - else - { - MenuController.CloseAllMenus(); - } - } + if (MenuEnabled) + { + if (!MenuController.IsAnyMenuOpen()) + { + Menu.OpenMenu(); + } + else + { + MenuController.CloseAllMenus(); + } + } }), false); if (!(GetSettingsString(Setting.vmenu_noclip_toggle_key) == null)) diff --git a/vMenu/Noclip.cs b/vMenu/Noclip.cs index e919188b..559af08b 100644 --- a/vMenu/Noclip.cs +++ b/vMenu/Noclip.cs @@ -137,7 +137,7 @@ private async Task NoClipHandler() BeginScaleformMovieMethod(Scale, "SET_DATA_SLOT"); ScaleformMovieMethodAddParamInt(6); - string KeyMappingID = String.IsNullOrWhiteSpace(GetSettingsString(Setting.vmenu_keymapping_id)) ? "Default" : GetSettingsString(Setting.vmenu_keymapping_id); + string KeyMappingID = String.IsNullOrWhiteSpace(GetSettingsString(Setting.vmenu_keymapping_id)) ? "Default" : GetSettingsString(Setting.vmenu_keymapping_id); PushScaleformMovieMethodParameterString($"~INPUT_{JOAAT($"vMenu:{KeyMappingID}:NoClip")}~"); PushScaleformMovieMethodParameterString($"Toggle NoClip"); EndScaleformMovieMethod(); diff --git a/vMenu/menus/MpPedCustomization.cs b/vMenu/menus/MpPedCustomization.cs index 77ff2925..03469e87 100644 --- a/vMenu/menus/MpPedCustomization.cs +++ b/vMenu/menus/MpPedCustomization.cs @@ -38,8 +38,8 @@ public class MpPedCustomization internal MenuItem editPedBtn = new("Edit Saved Character", "This allows you to edit everything about your saved character. The changes will be saved to this character's save file entry once you hit the save button."); // Need to be editable from other functions - private readonly MenuListItem setCategoryBtn = new("Set Character Category", new List {}, 0, "Sets this character's category. Select to save."); - private readonly MenuListItem categoryBtn = new("Character Category", new List {}, 0, "Sets this character's category."); + private readonly MenuListItem setCategoryBtn = new("Set Character Category", new List { }, 0, "Sets this character's category. Select to save."); + private readonly MenuListItem categoryBtn = new("Character Category", new List { }, 0, "Sets this character's category."); public static bool DontCloseMenus { get { return MenuController.PreventExitingMenu; } set { MenuController.PreventExitingMenu = value; } } public static bool DisableBackButton { get { return MenuController.DisableBackButton; } set { MenuController.DisableBackButton = value; } } @@ -2605,7 +2605,7 @@ string ChangeCallback(MenuDynamicListItem item, bool left) } } } - } + } Notify.Success($"Your saved category has been deleted. {updatedCount}/{totalCount} characters {(deletePeds ? "deleted" : "updated")}."); MenuController.CloseAllMenus(); @@ -2737,7 +2737,7 @@ private List GetAllCategoryNames() private List GetCategoryIcons(List categoryNames) { - List icons = new List {}; + List icons = new List { }; foreach (var name in categoryNames) { diff --git a/vMenu/menus/SavedVehicles.cs b/vMenu/menus/SavedVehicles.cs index e58f7ab5..955d1b9e 100644 --- a/vMenu/menus/SavedVehicles.cs +++ b/vMenu/menus/SavedVehicles.cs @@ -31,7 +31,7 @@ public class SavedVehicles private SavedVehicleCategory currentCategory; // Need to be editable from other functions - private readonly MenuListItem setCategoryBtn = new("Set Vehicle Category", new List {}, 0, "Sets this Vehicle's category. Select to save."); + private readonly MenuListItem setCategoryBtn = new("Set Vehicle Category", new List { }, 0, "Sets this Vehicle's category. Select to save."); /// /// Creates the menu. @@ -185,7 +185,7 @@ string ChangeCallback(MenuDynamicListItem item, bool left) var spacer = GetSpacerMenuItem("↓ Vehicles ↓"); savedVehiclesCategoryMenu.AddMenuItem(spacer); - + if (savedVehicles.Count > 0) { foreach (var kvp in savedVehicles) @@ -901,7 +901,7 @@ private List GetAllCategoryNames() private List GetCategoryIcons(List categoryNames) { - List icons = new List {}; + List icons = new List { }; foreach (var name in categoryNames) { diff --git a/vMenu/menus/VoiceChat.cs b/vMenu/menus/VoiceChat.cs index dcf4e0eb..67ec5278 100644 --- a/vMenu/menus/VoiceChat.cs +++ b/vMenu/menus/VoiceChat.cs @@ -5,10 +5,8 @@ using MenuAPI; using static vMenuClient.CommonFunctions; - -using static vMenuShared.PermissionsManager; - using static vMenuShared.ConfigManager; +using static vMenuShared.PermissionsManager; namespace vMenuClient.menus { @@ -69,7 +67,7 @@ private void CreateMenu() "2 km", "Global", }; - var voiceChatProximity = new MenuItem("Voice Chat Proximity (" + ConvertToMetric(currentProximity) + ")" , "Set the voice chat receiving proximity in meters. Set to 0 for global."); + var voiceChatProximity = new MenuItem("Voice Chat Proximity (" + ConvertToMetric(currentProximity) + ")", "Set the voice chat receiving proximity in meters. Set to 0 for global."); var voiceChatChannel = new MenuListItem("Voice Chat Channel", channels, channels.IndexOf(currentChannel), "Set the voice chat channel."); if (IsAllowed(Permission.VCEnable)) @@ -121,7 +119,7 @@ private void CreateMenu() { currentProximity = resultfloat; Subtitle.Custom($"New voice chat proximity set to: ~b~{ConvertToMetric(currentProximity)}~s~."); - voiceChatProximity.Text = ("Voice Chat Proximity (" + ConvertToMetric(currentProximity) + ")" ); + voiceChatProximity.Text = ("Voice Chat Proximity (" + ConvertToMetric(currentProximity) + ")"); } } }; @@ -145,7 +143,7 @@ static string ConvertToMetric(float input) val = (input / 1000) + "km"; } } - if (input==0) + if (input == 0) { val = "global"; }