Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions vMenu/menus/PlayerAppearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,25 +606,31 @@ async void SpawnPed(Menu m, MenuItem item, int index)
if (drawablesMenuListItems.ContainsKey(item))
{
int currentDrawableID = drawablesMenuListItems[item];
bool isValid = IsPedCollectionComponentVariationValid(pedHandle, currentDrawableID, collectionName, newListIndex, 0) && !IsPedCollectionComponentVariationGen9Exclusive(pedHandle, currentDrawableID, collectionName, newListIndex);

if (newListIndex == 0)
{
SetPedComponentVariation(pedHandle, currentDrawableID, 0, 0, 0);
item.Description = $"← & → to select, ~r~enter~s~ to cycle textures. None selected.";
return;
}

int actualDrawableIndex = newListIndex - 1;

bool isValid = IsPedCollectionComponentVariationValid(pedHandle, currentDrawableID, collectionName, actualDrawableIndex, 0)
&& !IsPedCollectionComponentVariationGen9Exclusive(pedHandle, currentDrawableID, collectionName, actualDrawableIndex);

if (isValid)
{
int maxDrawableTextures = GetNumberOfPedCollectionTextureVariations(pedHandle, currentDrawableID, collectionName, newListIndex);
int maxDrawableTextures = GetNumberOfPedCollectionTextureVariations(pedHandle, currentDrawableID, collectionName, actualDrawableIndex);

SetPedCollectionComponentVariation(pedHandle, currentDrawableID, collectionName, newListIndex, 0, 0);
SetPedCollectionComponentVariation(pedHandle, currentDrawableID, collectionName, actualDrawableIndex, 0, 0);

item.Description = $"← & → to select, ~r~enter~s~ to cycle textures. Selected texture: #{GetPedTextureVariation(pedHandle, currentDrawableID) + 1} (of {maxDrawableTextures}).";
}
else
{
item.Description = $"← & → to select, ~r~enter~s~ to cycle textures. Selection is invalid (broken, Gen9, etc.)";
}

if (item.ListItems[oldListIndex].StartsWith("None"))
{
item.ListItems.RemoveAt(oldListIndex);
}
}
else if (propsMenuListItems.ContainsKey(item))
{
Expand Down Expand Up @@ -659,17 +665,26 @@ async void SpawnPed(Menu m, MenuItem item, int index)
string collectionName = item.ItemData;

if (drawablesMenuListItems.ContainsKey(item))
{
{
int currentDrawableID = drawablesMenuListItems[item];
bool isValid = IsPedCollectionComponentVariationValid(pedHandle, currentDrawableID, collectionName, listIndex, 0) && !IsPedCollectionComponentVariationGen9Exclusive(pedHandle, currentDrawableID, collectionName, listIndex);

if (listIndex == 0)
{
return;
}

int actualDrawableIndex = listIndex - 1;

bool isValid = IsPedCollectionComponentVariationValid(pedHandle, currentDrawableID, collectionName, actualDrawableIndex, 0)
&& !IsPedCollectionComponentVariationGen9Exclusive(pedHandle, currentDrawableID, collectionName, actualDrawableIndex);

if (!isValid)
{
return;
}

int currentTextureIndex = GetPedTextureVariation(pedHandle, currentDrawableID);
int maxDrawableTextures = GetNumberOfPedCollectionTextureVariations(pedHandle, currentDrawableID, collectionName, listIndex) - 1;
int maxDrawableTextures = GetNumberOfPedCollectionTextureVariations(pedHandle, currentDrawableID, collectionName, actualDrawableIndex) - 1;

if (currentTextureIndex == -1)
{
Expand All @@ -678,7 +693,7 @@ async void SpawnPed(Menu m, MenuItem item, int index)

int newTexture = currentTextureIndex < maxDrawableTextures ? currentTextureIndex + 1 : 0;

SetPedCollectionComponentVariation(pedHandle, currentDrawableID, collectionName, listIndex, newTexture, 0);
SetPedCollectionComponentVariation(pedHandle, currentDrawableID, collectionName, actualDrawableIndex, newTexture, 0);

item.Description = $"← & → to select, ~r~enter~s~ to cycle textures. Selected texture: #{newTexture + 1} (of {maxDrawableTextures + 1}).";
}
Expand Down Expand Up @@ -835,27 +850,27 @@ private void RefreshCollectionsDrawables(string collectionName)

string suffixText;
int currentLocalIndex;
List<string> drawableTexturesList = [];
List<string> drawableTexturesList = new() { $"None Selected (of {totalVariations})" };
int currentDrawableGlobalId = GetPedDrawableVariation(pedHandle, drawable);
string currentCollection = GetPedCollectionNameFromDrawable(pedHandle, drawable, currentDrawableGlobalId);

for (int i = 0; i < totalVariations; i++)
{
bool isValid = IsPedCollectionComponentVariationValid(pedHandle, drawable, collectionName, i, 0) && !IsPedCollectionComponentVariationGen9Exclusive(pedHandle, drawable, collectionName, i);
bool isValid = IsPedCollectionComponentVariationValid(pedHandle, drawable, collectionName, i, 0)
&& !IsPedCollectionComponentVariationGen9Exclusive(pedHandle, drawable, collectionName, i);

drawableTexturesList.Add($"Drawable #{i + 1}{(!isValid ? " (Invalid)" : "")} (of {totalVariations})");
}

if (currentCollection == collectionName)
{
currentLocalIndex = GetPedCollectionLocalIndexFromDrawable(pedHandle, drawable, currentDrawableGlobalId);
suffixText = $"Selected texture: #{GetPedTextureVariation(pedHandle, drawable) + 1} (of {GetNumberOfPedCollectionTextureVariations(pedHandle, drawable, collectionName, currentLocalIndex)}).";
currentLocalIndex = GetPedCollectionLocalIndexFromDrawable(pedHandle, drawable, currentDrawableGlobalId) + 1;
suffixText = $"Selected texture: #{GetPedTextureVariation(pedHandle, drawable) + 1} (of {GetNumberOfPedCollectionTextureVariations(pedHandle, drawable, collectionName, currentLocalIndex - 1)}).";
}
else
{
drawableTexturesList.Add($"None Selected (of {totalVariations})");
currentLocalIndex = drawableTexturesList.Count - 1;
suffixText = "Current selection not part collection.";
currentLocalIndex = 0;
suffixText = $"None selected (of {totalVariations}).";
}

MenuListItem item = new MenuListItem($"{textureNames[drawable]}", drawableTexturesList, currentLocalIndex, $"← & → to select, ~r~enter~s~ to cycle textures. {suffixText}")
Expand Down