Skip to content

Commit

Permalink
Fixed vehicle mods livery bug as mentioned in pull request #235
Browse files Browse the repository at this point in the history
Vehicle mods menu no longer relies on menu list index, but rather on ItemData passed directly to the menu item.
  • Loading branch information
TomGrobbe committed May 25, 2021
1 parent 6539320 commit 87396ca
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions vMenu/menus/VehicleOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,15 @@ public void UpdateMods(int selectedIndex = 0)

// Create the MenuListItem for this mod type.
var currIndex = GetVehicleMod(veh.Handle, (int)mod.ModType) + 1;
MenuListItem modTypeListItem = new MenuListItem(typeName, modlist, currIndex, $"Choose a ~y~{typeName}~s~ upgrade, it will be automatically applied to your vehicle.");
MenuListItem modTypeListItem = new MenuListItem(
typeName,
modlist,
currIndex,
$"Choose a ~y~{typeName}~s~ upgrade, it will be automatically applied to your vehicle."
)
{
ItemData = (int)mod.ModType
};

// Add the list item to the menu.
VehicleModMenu.AddMenuItem(modTypeListItem);
Expand Down Expand Up @@ -1960,21 +1968,8 @@ public void UpdateMods(int selectedIndex = 0)
#region handle the dynamic (vehicle-specific) mods
// If the affected list is actually a "dynamically" generated list, continue. If it was one of the manual options, go to else.
if (itemIndex < sender2.Size - 9)
if (item2.ItemData is int modType)
{
// Get all mods available on this vehicle.
mods = veh.Mods.GetAllMods();
var dict = new Dictionary<int, int>();
var x = 0;
foreach (var mod in mods)
{
dict.Add(x, (int)mod.ModType);
x++;
}
int modType = dict[itemIndex];
int selectedUpgrade = item2.ListIndex - 1;
bool customWheels = GetVehicleModVariation(veh.Handle, 23);
Expand Down

0 comments on commit 87396ca

Please sign in to comment.