Skip to content

Commit

Permalink
Ability to change postfix (_u / _r) in project window. (#16)
Browse files Browse the repository at this point in the history
* Ability to change postfix (_u / _r) in project window.

It needs further testing.

The only components that SHOULD have _r is lowr, feet and head. (Only if .ydd model contains skin, otherwise it should be _u)
Rest should have _u

* it was only needed in testing :P

* readme update
  • Loading branch information
grzybeek authored Jan 29, 2022
1 parent 68c132e commit 3f87ca3
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 63 deletions.
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@ If you are in search for an easy way to browse all GTA V clothes data, try **Ple
[![Pleb Masters Forge Logo](https://i.imgur.com/hotlSPf.png)](https://forge.plebmasters.de)

# Additional notes
## from `Divined#2725`
## from `grzybeek#9100`
```
feet ydd needs to be imported with _r
lowr ydd needs to be imported with _r
teef ydd needs to be imported with _u
everything else imported with _u for .ydd
lowr ytd needs to be imported with _whi
feet ytd needs to be imported with _uni
```
## from `Nicoo#3630`
```
berd ydd needs to be imported with _r
berd ytd needs to be imported with _whi
The only components that SHOULD have _r is lowr, feet and head. (Only if .ydd model contains skin, otherwise it should be _u)
Rest should have _u
.ydd model ends with _u = .ytd texture needs to have _uni
.ydd model ends with _r = .ytd texture needs to have _whi
```
## from `DurtyFree#3216`
#### peds .ymt postfixes for models & textures
Expand Down
76 changes: 30 additions & 46 deletions altClothTool.App/Builders/Base/ResourceBuilderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private List<MUnk_254518642> GetTexDataForCloth(ClothData clothData)
List<MUnk_254518642> items = new List<MUnk_254518642>();
for (int i = 0; i < clothData.Textures.Count; i++)
{
byte texId = GetTexIdByDrawableType(clothData, i);
byte texId = clothData.IsPostfix_U() ? (byte) 0 : (byte) 1;
MUnk_254518642 texture = new MUnk_254518642
{
TexId = texId
Expand All @@ -63,25 +63,6 @@ private List<MUnk_254518642> GetTexDataForCloth(ClothData clothData)
return items;
}

// TODO DURTY: verify if its really based on index? Shouldnt be like this actually, because its connected to skin tone or something
private byte GetTexIdByDrawableType(ClothData clothData, int index = 0)
{
byte texId = (byte) index;
switch (clothData.DrawableType)
{
case ClothNameResolver.DrawableTypes.Legs:
texId = 1;
break;
case ClothNameResolver.DrawableTypes.Shoes:
texId = 0;
break;
case ClothNameResolver.DrawableTypes.Mask:
texId = 1;
break;
}
return texId;
}

protected MUnk_94549140 GenerateYmtPedPropItem(YmtPedDefinitionFile ymt, Unk_2834549053 anchor, ClothData clothData)
{
var item = new MUnk_94549140(ymt.Unk_376833625.PropInfo)
Expand Down Expand Up @@ -112,24 +93,8 @@ protected MUnk_94549140 GenerateYmtPedPropItem(YmtPedDefinitionFile ymt, Unk_283

protected void GetClothPostfixes(ClothData clothData, out string ytdPostfix, out string yddPostfix)
{
yddPostfix = clothData.MainPath.EndsWith("_u.ydd") ? "u" : "r";
ytdPostfix = clothData.MainPath.EndsWith("_u.ydd") ? "uni" : "whi";

switch (clothData.DrawableType)
{
case ClothNameResolver.DrawableTypes.Legs:
yddPostfix = "r";
ytdPostfix = "whi";
break;
case ClothNameResolver.DrawableTypes.Mask:
yddPostfix = "r";
ytdPostfix = "whi";
break;
case ClothNameResolver.DrawableTypes.Shoes:
yddPostfix = "r";
ytdPostfix = "uni";
break;
}
yddPostfix = clothData.IsPostfix_U() ? "u" : "r";
ytdPostfix = clothData.IsPostfix_U() ? "uni" : "whi";
}

protected MCComponentInfo GenerateYmtPedComponentItem(ClothData clothData, ref MUnk_3538495220[] componentTextureBindings)
Expand All @@ -138,25 +103,44 @@ protected MCComponentInfo GenerateYmtPedComponentItem(ClothData clothData, ref M
if (componentTextureBindings[componentTypeId] == null)
componentTextureBindings[componentTypeId] = new MUnk_3538495220();

byte nextPropMask = 17;
byte nextPropMask = 1;
switch (componentTypeId)
{
case 0:
nextPropMask = clothData.IsPostfix_U() ? (byte) 1 : (byte) 17;
break;
case 1:
nextPropMask = clothData.IsPostfix_U() ? (byte) 1 : (byte) 17;
break;
case 2:
case 7:
nextPropMask = 11;
nextPropMask = clothData.IsPostfix_U() ? (byte) 1 : (byte) 17;
break;
case 3:
nextPropMask = clothData.IsPostfix_U() ? (byte) 1 : (byte) 17;
break;
case 4:
nextPropMask = clothData.IsPostfix_U() ? (byte) 1 : (byte) 17;
break;
case 5:
nextPropMask = clothData.IsPostfix_U() ? (byte) 1 : (byte) 17;
break;
case 6:
nextPropMask = clothData.IsPostfix_U() ? (byte) 1 : (byte) 17;
break;
case 7:
nextPropMask = clothData.IsPostfix_U() ? (byte) 11 : (byte) 17;
break;
case 8:
nextPropMask = 65;
nextPropMask = clothData.IsPostfix_U() ? (byte) 65: (byte) 17;
break;
case 9:
nextPropMask = 1;
nextPropMask = clothData.IsPostfix_U() ? (byte) 1 : (byte) 17;
break;
case 10:
nextPropMask = 5;
nextPropMask = clothData.IsPostfix_U() ? (byte) 5 : (byte) 17;
break;
case 11:
nextPropMask = 1;
nextPropMask = clothData.IsPostfix_U() ? (byte) 1 : (byte) 17;
break;
default:
break;
Expand All @@ -172,7 +156,7 @@ protected MCComponentInfo GenerateYmtPedComponentItem(ClothData clothData, ref M
}
};

byte texId = GetTexIdByDrawableType(clothData);
byte texId = clothData.IsPostfix_U() ? (byte)0 : (byte)1;
foreach (string texPath in clothData.Textures)
{
MUnk_1036962405 texInfo = new MUnk_1036962405
Expand Down
10 changes: 10 additions & 0 deletions altClothTool.App/ClothData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,15 @@ public void SetComponentNumerics(string componentNumerics, int currentComponentI
ComponentNumerics = componentNumerics;
CurrentComponentIndex = currentComponentIndex;
}

public bool IsPostfix_U()
{
return _postfix == "u" ? true : false;
}

public void SetCustomPostfix(string newPostfix)
{
_postfix = newPostfix;
}
}
}
20 changes: 15 additions & 5 deletions altClothTool.App/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,24 @@
</StackPanel>
</GroupBox>
</Grid>
<GroupBox Header="Name" HorizontalAlignment="Left" Height="40" Margin="0,0,0,0" VerticalAlignment="Top" Width="200">
<GroupBox Header="Name" HorizontalAlignment="Left" Height="40" Margin="0,0,0,0" VerticalAlignment="Top" Width="145">
<TextBox x:Name="drawableName" TextWrapping="Wrap" VerticalAlignment="Top" Margin="0" TextChanged="DrawableName_TextChanged" BorderBrush="{x:Null}"/>
</GroupBox>
<GroupBox Header="First person model" HorizontalAlignment="Right" Height="40" Margin="0,0,0,0" VerticalAlignment="Top" Width="360">
<GroupBox Header="First person model" HorizontalAlignment="Right" Height="40" Margin="0,0,0,0" VerticalAlignment="Top" Width="324">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="23*"/>
<ColumnDefinition Width="151*"/>
</Grid.ColumnDefinitions>
<TextBox x:Name="firstPersonModelPath" VerticalAlignment="Stretch" Margin="0, 0, 100, 0" Text="Not selected..." FontSize="12" Background="Transparent" BorderBrush="{x:Null}" IsEnabled="False" IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" Grid.ColumnSpan="2"/>
<Button x:Name="selectFirstPersonModel" HorizontalAlignment="Right" Width="40" Margin="0,0,50,0" Content="Select" BorderBrush="{x:Null}" BorderThickness="0" Click="SelectFirstPersonModel_Click" Grid.Column="1"/>
<Button x:Name="clearFirstPersonModel" VerticalAlignment="Stretch" HorizontalAlignment="Right" Width="40" Content="Clear" BorderThickness="0" Click="ClearFirstPersonModel_Click" Grid.Column="1"/>
</Grid>
</GroupBox>
<GroupBox Header="Postfix" HorizontalAlignment="Left" Height="40" Margin="150,0,0,0" VerticalAlignment="Top" Width="89">
<Grid>
<TextBox x:Name="firstPersonModelPath" VerticalAlignment="Stretch" Margin="0, 0, 100, 0" Text="Not selected..." FontSize="12" Background="Transparent" BorderBrush="{x:Null}" IsEnabled="False" IsReadOnly="True" IsUndoEnabled="False" MaxLines="1"/>
<Button x:Name="selectFirstPersonModel" HorizontalAlignment="Right" Width="40" Margin="0,0,50,-0.333" Content="Select" BorderBrush="{x:Null}" BorderThickness="0" Click="SelectFirstPersonModel_Click"/>
<Button x:Name="clearFirstPersonModel" VerticalAlignment="Stretch" HorizontalAlignment="Right" Width="40" Content="Clear" BorderThickness="0" Click="ClearFirstPersonModel_Click"/>
<RadioButton x:Name="PostfixUCheck" GroupName="postfix" Content="__u" Checked="PostfixUCheck_Checked" Margin="0,0,40,0"/>
<RadioButton x:Name="PostfixRCheck" GroupName="postfix" Content="__r" Checked="PostfixRCheck_Checked" Margin="42,0,0,0"/>
</Grid>
</GroupBox>
</Grid>
Expand Down
20 changes: 20 additions & 0 deletions altClothTool.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ private void ClothesListBox_SelectionChanged(object sender, SelectionChangedEven
unkFlag3Check.IsChecked = _selectedCloth.PedComponentFlags.unkFlag3;
unkFlag4Check.IsChecked = _selectedCloth.PedComponentFlags.unkFlag4;
isHighHeelsCheck.IsChecked = _selectedCloth.PedComponentFlags.isHighHeels;

PostfixUCheck.IsChecked = _selectedCloth.IsPostfix_U();
PostfixRCheck.IsChecked = !_selectedCloth.IsPostfix_U();

}
else
{
Expand Down Expand Up @@ -266,5 +270,21 @@ private void PedPropFlag5_Checked(object sender, RoutedEventArgs e)
if (_selectedCloth != null)
_selectedCloth.PedPropFlags.unkFlag5 = unkFlag1Check.IsChecked.GetValueOrDefault(false);
}

private void PostfixUCheck_Checked(object sender, RoutedEventArgs e)
{
if (_selectedCloth != null)
{
_selectedCloth.SetCustomPostfix("u");
}
}

private void PostfixRCheck_Checked(object sender, RoutedEventArgs e)
{
if (_selectedCloth != null)
{
_selectedCloth.SetCustomPostfix("r");
}
}
}
}

0 comments on commit 3f87ca3

Please sign in to comment.