diff --git a/vMenu/CommonFunctions.cs b/vMenu/CommonFunctions.cs index 0b81b130..2ac32424 100644 --- a/vMenu/CommonFunctions.cs +++ b/vMenu/CommonFunctions.cs @@ -1414,7 +1414,26 @@ private static async void ApplyVehicleModsDelayed(Vehicle vehicle, VehicleInfo v ToggleVehicleMod(vehicle.Handle, 22, vehicleInfo.xenonHeadlights); SetVehicleLivery(vehicle.Handle, vehicleInfo.livery); - SetVehicleColours(vehicle.Handle, vehicleInfo.colors["primary"], vehicleInfo.colors["secondary"]); + bool useCustomRgbPrimary = vehicleInfo.colors.ContainsKey("customPrimaryR") && vehicleInfo.colors.ContainsKey("customPrimaryG") && vehicleInfo.colors.ContainsKey("customPrimaryB"); + if (useCustomRgbPrimary && vehicleInfo.colors["customPrimaryR"] > 0 && vehicleInfo.colors["customPrimaryG"] > 0 && vehicleInfo.colors["customPrimaryB"] > 0) + { + vehicle.Mods.CustomPrimaryColor = System.Drawing.Color.FromArgb(255, vehicleInfo.colors["customPrimaryR"], vehicleInfo.colors["customPrimaryG"], vehicleInfo.colors["customPrimaryB"]); + } + else + { + vehicle.Mods.PrimaryColor = (VehicleColor)vehicleInfo.colors["primary"]; + } + + bool useCustomRgbSecondary = vehicleInfo.colors.ContainsKey("customSecondaryR") && vehicleInfo.colors.ContainsKey("customSecondaryG") && vehicleInfo.colors.ContainsKey("customSecondaryB"); + if (useCustomRgbSecondary && vehicleInfo.colors["customSecondaryR"] > 0 && vehicleInfo.colors["customSecondaryG"] > 0 && vehicleInfo.colors["customSecondaryB"] > 0) + { + vehicle.Mods.CustomSecondaryColor = System.Drawing.Color.FromArgb(255, vehicleInfo.colors["customSecondaryR"], vehicleInfo.colors["customSecondaryR"], vehicleInfo.colors["customSecondaryB"]); + } + else + { + vehicle.Mods.SecondaryColor = (VehicleColor)vehicleInfo.colors["secondary"]; + } + SetVehicleInteriorColour(vehicle.Handle, vehicleInfo.colors["trim"]); SetVehicleDashboardColour(vehicle.Handle, vehicleInfo.colors["dash"]); @@ -1549,6 +1568,20 @@ public static async void SaveVehicle(string updateExistingSavedVehicleName = nul colors.Add("tyresmokeR", tyresmokeR); colors.Add("tyresmokeG", tyresmokeG); colors.Add("tyresmokeB", tyresmokeB); + int customPrimaryR = -1; + int customPrimaryG = -1; + int customPrimaryB = -1; + GetVehicleCustomPrimaryColour(veh.Handle, ref customPrimaryR, ref customPrimaryG, ref customPrimaryB); + colors.Add("customPrimaryR", customPrimaryR); + colors.Add("customPrimaryG", customPrimaryG); + colors.Add("customPrimaryB", customPrimaryB); + int customSecondaryR = -1; + int customSecondaryG = -1; + int customSecondaryB = -1; + GetVehicleCustomSecondaryColour(veh.Handle, ref customSecondaryR, ref customSecondaryG, ref customSecondaryB); + colors.Add("customSecondaryR", customSecondaryR); + colors.Add("customSecondaryG", customSecondaryG); + colors.Add("customSecondaryB", customSecondaryB); #endregion var extras = new Dictionary(); diff --git a/vMenu/menus/VehicleOptions.cs b/vMenu/menus/VehicleOptions.cs index f453ea67..0343e15b 100644 --- a/vMenu/menus/VehicleOptions.cs +++ b/vMenu/menus/VehicleOptions.cs @@ -1132,7 +1132,7 @@ void HandleListIndexChanges(Menu sender, MenuListItem listItem, int oldIndex, in if (sender == primaryColorsMenu) { - if (itemIndex == 1) + if (itemIndex == 2) { pearlColor = VehicleData.ClassicColors[newIndex].id; } @@ -1144,26 +1144,27 @@ void HandleListIndexChanges(Menu sender, MenuListItem listItem, int oldIndex, in switch (itemIndex) { case 0: - case 1: + case 1: + case 2: primaryColor = VehicleData.ClassicColors[newIndex].id; break; - case 2: + case 3: primaryColor = VehicleData.MatteColors[newIndex].id; break; - case 3: + case 4: primaryColor = VehicleData.MetalColors[newIndex].id; break; - case 4: + case 5: primaryColor = VehicleData.UtilColors[newIndex].id; break; - case 5: + case 6: primaryColor = VehicleData.WornColors[newIndex].id; break; } if (GetSettingsBool(Setting.vmenu_using_chameleon_colours)) { - if (itemIndex == 6) + if (itemIndex == 7) { primaryColor = VehicleData.ChameleonColors[newIndex].id; secondaryColor = VehicleData.ChameleonColors[newIndex].id; @@ -1172,6 +1173,7 @@ void HandleListIndexChanges(Menu sender, MenuListItem listItem, int oldIndex, in } } + ClearVehicleCustomPrimaryColour(veh.Handle); SetVehicleColours(veh.Handle, primaryColor, secondaryColor); } else if (sender == secondaryColorsMenu) @@ -1179,25 +1181,28 @@ void HandleListIndexChanges(Menu sender, MenuListItem listItem, int oldIndex, in switch (itemIndex) { case 0: + case 1: pearlColor = VehicleData.ClassicColors[newIndex].id; break; - case 1: case 2: + case 3: secondaryColor = VehicleData.ClassicColors[newIndex].id; break; - case 3: + case 4: secondaryColor = VehicleData.MatteColors[newIndex].id; break; - case 4: + case 5: secondaryColor = VehicleData.MetalColors[newIndex].id; break; - case 5: + case 6: secondaryColor = VehicleData.UtilColors[newIndex].id; break; - case 6: + case 7: secondaryColor = VehicleData.WornColors[newIndex].id; break; } + + ClearVehicleCustomSecondaryColour(veh.Handle); SetVehicleColours(veh.Handle, primaryColor, secondaryColor); } else if (sender == VehicleColorsMenu) @@ -1237,8 +1242,38 @@ void HandleListIndexChanges(Menu sender, MenuListItem listItem, int oldIndex, in } } + async void HandleItemSelect(Menu menu, MenuItem menuItem, int itemIndex) + { + Vehicle veh = GetVehicle(); + if (veh != null && veh.Exists() && !veh.IsDead && veh.Driver == Game.PlayerPed) + { + string rawRValue = await GetUserInput("Custom RGB - R Value (number from 0-255)", "0", 3); + string rawGValue = await GetUserInput("Custom RGB - G Value (number from 0-255)", "0", 3); + string rawBValue = await GetUserInput("Custom RGB - B Value (number from 0-255)", "0", 3); + int rValue; + int gValue; + int bValue; + + if (!int.TryParse(rawRValue, out rValue) || !int.TryParse(rawGValue, out gValue) || !int.TryParse(rawBValue, out bValue)) + { + Notify.Error("An invalid RGB value was entered, ensure you enter numbers between 0 and 255"); + return; + } + + if (menu == primaryColorsMenu) + { + SetVehicleCustomPrimaryColour(veh.Handle, rValue, gValue, bValue); + } + else if (menu == secondaryColorsMenu) + { + SetVehicleCustomSecondaryColour(veh.Handle, rValue, gValue, bValue); + } + } + } + for (var i = 0; i < 2; i++) { + var customColour = new MenuItem("Custom RGB") { Label = ">>>" }; var pearlescentList = new MenuListItem("Pearlescent", classic, 0); var classicList = new MenuListItem("Classic", classic, 0); var metallicList = new MenuListItem("Metallic", classic, 0); @@ -1249,6 +1284,7 @@ void HandleListIndexChanges(Menu sender, MenuListItem listItem, int oldIndex, in if (i == 0) { + primaryColorsMenu.AddMenuItem(customColour); primaryColorsMenu.AddMenuItem(classicList); primaryColorsMenu.AddMenuItem(metallicList); primaryColorsMenu.AddMenuItem(matteList); @@ -1264,9 +1300,11 @@ void HandleListIndexChanges(Menu sender, MenuListItem listItem, int oldIndex, in } primaryColorsMenu.OnListIndexChange += HandleListIndexChanges; + primaryColorsMenu.OnItemSelect += HandleItemSelect; } else { + secondaryColorsMenu.AddMenuItem(customColour); secondaryColorsMenu.AddMenuItem(pearlescentList); secondaryColorsMenu.AddMenuItem(classicList); secondaryColorsMenu.AddMenuItem(metallicList); @@ -1276,6 +1314,7 @@ void HandleListIndexChanges(Menu sender, MenuListItem listItem, int oldIndex, in secondaryColorsMenu.AddMenuItem(wornList); secondaryColorsMenu.OnListIndexChange += HandleListIndexChanges; + secondaryColorsMenu.OnItemSelect += HandleItemSelect; } } #endregion