mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 04:34:19 +01:00
Add handling for left and right ring.
This commit is contained in:
parent
ea2a411a2e
commit
40b7266c22
3 changed files with 91 additions and 59 deletions
|
|
@ -17,8 +17,24 @@ namespace Penumbra.Mods.ItemSwap;
|
||||||
|
|
||||||
public static class EquipmentSwap
|
public static class EquipmentSwap
|
||||||
{
|
{
|
||||||
|
private static EquipSlot[] ConvertSlots( EquipSlot slot, bool rFinger, bool lFinger )
|
||||||
|
{
|
||||||
|
if( slot != EquipSlot.RFinger )
|
||||||
|
{
|
||||||
|
return new[] { slot };
|
||||||
|
}
|
||||||
|
|
||||||
|
return rFinger
|
||||||
|
? lFinger
|
||||||
|
? new[] { EquipSlot.RFinger, EquipSlot.LFinger }
|
||||||
|
: new[] { EquipSlot.RFinger }
|
||||||
|
: lFinger
|
||||||
|
? new[] { EquipSlot.LFinger }
|
||||||
|
: Array.Empty< EquipSlot >();
|
||||||
|
}
|
||||||
|
|
||||||
public static Item[] CreateItemSwap( List< Swap > swaps, Func< Utf8GamePath, FullPath > redirections, Func< MetaManipulation, MetaManipulation > manips, Item itemFrom,
|
public static Item[] CreateItemSwap( List< Swap > swaps, Func< Utf8GamePath, FullPath > redirections, Func< MetaManipulation, MetaManipulation > manips, Item itemFrom,
|
||||||
Item itemTo )
|
Item itemTo, bool rFinger = true, bool lFinger = true )
|
||||||
{
|
{
|
||||||
// Check actual ids, variants and slots. We only support using the same slot.
|
// Check actual ids, variants and slots. We only support using the same slot.
|
||||||
LookupItem( itemFrom, out var slotFrom, out var idFrom, out var variantFrom );
|
LookupItem( itemFrom, out var slotFrom, out var idFrom, out var variantFrom );
|
||||||
|
|
@ -40,12 +56,14 @@ public static class EquipmentSwap
|
||||||
swaps.Add( gmp );
|
swaps.Add( gmp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var affectedItems = Array.Empty< Item >();
|
||||||
|
foreach( var slot in ConvertSlots( slotFrom, rFinger, lFinger ) )
|
||||||
|
{
|
||||||
|
(var imcFileFrom, var variants, affectedItems) = GetVariants( slot, idFrom, idTo, variantFrom );
|
||||||
|
var imcFileTo = new ImcFile( new ImcManipulation( slot, variantTo, idTo.Value, default ) );
|
||||||
|
|
||||||
var (imcFileFrom, variants, affectedItems) = GetVariants( slotFrom, idFrom, idTo, variantFrom );
|
var isAccessory = slot.IsAccessory();
|
||||||
var imcFileTo = new ImcFile( new ImcManipulation( slotFrom, variantTo, idTo.Value, default ) );
|
var estType = slot switch
|
||||||
|
|
||||||
var isAccessory = slotFrom.IsAccessory();
|
|
||||||
var estType = slotFrom switch
|
|
||||||
{
|
{
|
||||||
EquipSlot.Head => EstManipulation.EstType.Head,
|
EquipSlot.Head => EstManipulation.EstType.Head,
|
||||||
EquipSlot.Body => EstManipulation.EstType.Body,
|
EquipSlot.Body => EstManipulation.EstType.Body,
|
||||||
|
|
@ -54,7 +72,7 @@ public static class EquipmentSwap
|
||||||
|
|
||||||
var skipFemale = false;
|
var skipFemale = false;
|
||||||
var skipMale = false;
|
var skipMale = false;
|
||||||
var mtrlVariantTo = imcFileTo.GetEntry( ImcFile.PartIndex( slotFrom ), variantTo ).MaterialId;
|
var mtrlVariantTo = imcFileTo.GetEntry( ImcFile.PartIndex( slot ), variantTo ).MaterialId;
|
||||||
foreach( var gr in Enum.GetValues< GenderRace >() )
|
foreach( var gr in Enum.GetValues< GenderRace >() )
|
||||||
{
|
{
|
||||||
switch( gr.Split().Item1 )
|
switch( gr.Split().Item1 )
|
||||||
|
|
@ -78,7 +96,7 @@ public static class EquipmentSwap
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var eqdp = CreateEqdp( redirections, manips, slotFrom, gr, idFrom, idTo, mtrlVariantTo );
|
var eqdp = CreateEqdp( redirections, manips, slot, gr, idFrom, idTo, mtrlVariantTo );
|
||||||
if( eqdp != null )
|
if( eqdp != null )
|
||||||
{
|
{
|
||||||
swaps.Add( eqdp );
|
swaps.Add( eqdp );
|
||||||
|
|
@ -101,9 +119,10 @@ public static class EquipmentSwap
|
||||||
|
|
||||||
foreach( var variant in variants )
|
foreach( var variant in variants )
|
||||||
{
|
{
|
||||||
var imc = CreateImc( redirections, manips, slotFrom, idFrom, idTo, variant, variantTo, imcFileFrom, imcFileTo );
|
var imc = CreateImc( redirections, manips, slot, idFrom, idTo, variant, variantTo, imcFileFrom, imcFileTo );
|
||||||
swaps.Add( imc );
|
swaps.Add( imc );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return affectedItems;
|
return affectedItems;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,11 +124,11 @@ public class ItemSwapContainer
|
||||||
return m => set.TryGetValue( m, out var a ) ? a : m;
|
return m => set.TryGetValue( m, out var a ) ? a : m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item[] LoadEquipment( Item from, Item to, ModCollection? collection = null )
|
public Item[] LoadEquipment( Item from, Item to, ModCollection? collection = null, bool useRightRing = true, bool useLeftRing = true )
|
||||||
{
|
{
|
||||||
Swaps.Clear();
|
Swaps.Clear();
|
||||||
Loaded = false;
|
Loaded = false;
|
||||||
var ret = EquipmentSwap.CreateItemSwap( Swaps, PathResolver( collection ), MetaResolver( collection ), from, to );
|
var ret = EquipmentSwap.CreateItemSwap( Swaps, PathResolver( collection ), MetaResolver( collection ), from, to, useRightRing, useLeftRing );
|
||||||
Loaded = true;
|
Loaded = true;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,8 @@ public class ItemSwapWindow : IDisposable
|
||||||
private bool _subModValid = false;
|
private bool _subModValid = false;
|
||||||
private bool _useFileSwaps = true;
|
private bool _useFileSwaps = true;
|
||||||
private bool _useCurrentCollection = false;
|
private bool _useCurrentCollection = false;
|
||||||
|
private bool _useLeftRing = true;
|
||||||
|
private bool _useRightRing = true;
|
||||||
|
|
||||||
private Item[]? _affectedItems;
|
private Item[]? _affectedItems;
|
||||||
|
|
||||||
|
|
@ -159,7 +161,7 @@ public class ItemSwapWindow : IDisposable
|
||||||
if( values.Source.CurrentSelection.Item2 != null && values.Target.CurrentSelection.Item2 != null )
|
if( values.Source.CurrentSelection.Item2 != null && values.Target.CurrentSelection.Item2 != null )
|
||||||
{
|
{
|
||||||
_affectedItems = _swapData.LoadEquipment( values.Target.CurrentSelection.Item2, values.Source.CurrentSelection.Item2,
|
_affectedItems = _swapData.LoadEquipment( values.Target.CurrentSelection.Item2, values.Source.CurrentSelection.Item2,
|
||||||
_useCurrentCollection ? Penumbra.CollectionManager.Current : null );
|
_useCurrentCollection ? Penumbra.CollectionManager.Current : null, _useRightRing, _useLeftRing );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -399,11 +401,22 @@ public class ItemSwapWindow : IDisposable
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
_dirty |= sourceSelector.Draw( "##itemSource", sourceSelector.CurrentSelection.Item1 ?? string.Empty, InputWidth * 2, ImGui.GetTextLineHeightWithSpacing() );
|
_dirty |= sourceSelector.Draw( "##itemSource", sourceSelector.CurrentSelection.Item1 ?? string.Empty, InputWidth * 2, ImGui.GetTextLineHeightWithSpacing() );
|
||||||
|
|
||||||
|
if( type == SwapType.Ring )
|
||||||
|
{
|
||||||
|
ImGui.SameLine();
|
||||||
|
_dirty |= ImGui.Checkbox( "Swap Right Ring", ref _useRightRing );
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.AlignTextToFramePadding();
|
ImGui.AlignTextToFramePadding();
|
||||||
ImGui.TextUnformatted( text2 );
|
ImGui.TextUnformatted( text2 );
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
_dirty |= targetSelector.Draw( "##itemTarget", targetSelector.CurrentSelection.Item1 ?? string.Empty, InputWidth * 2, ImGui.GetTextLineHeightWithSpacing() );
|
_dirty |= targetSelector.Draw( "##itemTarget", targetSelector.CurrentSelection.Item1 ?? string.Empty, InputWidth * 2, ImGui.GetTextLineHeightWithSpacing() );
|
||||||
|
if( type == SwapType.Ring )
|
||||||
|
{
|
||||||
|
ImGui.SameLine();
|
||||||
|
_dirty |= ImGui.Checkbox( "Swap Left Ring", ref _useLeftRing );
|
||||||
|
}
|
||||||
|
|
||||||
if( _affectedItems is { Length: > 1 } )
|
if( _affectedItems is { Length: > 1 } )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue