mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Fix try-on interaction with Penumbra for facewear.
This commit is contained in:
parent
434a5a809e
commit
76b214c643
2 changed files with 64 additions and 6 deletions
|
|
@ -22,11 +22,12 @@ public sealed class PenumbraChangedItemTooltip : IDisposable
|
|||
private readonly CustomizeService _customize;
|
||||
private readonly GPoseService _gpose;
|
||||
|
||||
private readonly EquipItem[] _lastItems = new EquipItem[EquipFlagExtensions.NumEquipFlags / 2];
|
||||
private readonly EquipItem[] _lastItems = new EquipItem[EquipFlagExtensions.NumEquipFlags / 2 + BonusExtensions.AllFlags.Count];
|
||||
|
||||
public IEnumerable<KeyValuePair<EquipSlot, EquipItem>> LastItems
|
||||
=> EquipSlotExtensions.EqdpSlots.Append(EquipSlot.MainHand).Append(EquipSlot.OffHand).Zip(_lastItems)
|
||||
.Select(p => new KeyValuePair<EquipSlot, EquipItem>(p.First, p.Second));
|
||||
public IEnumerable<KeyValuePair<object, EquipItem>> LastItems
|
||||
=> EquipSlotExtensions.EqdpSlots.Cast<object>().Append(EquipSlot.MainHand).Append(EquipSlot.OffHand)
|
||||
.Concat(BonusExtensions.AllFlags.Cast<object>()).Zip(_lastItems)
|
||||
.Select(p => new KeyValuePair<object, EquipItem>(p.First, p.Second));
|
||||
|
||||
public ChangedItemType LastType { get; private set; } = ChangedItemType.None;
|
||||
public uint LastId { get; private set; }
|
||||
|
|
@ -72,6 +73,21 @@ public sealed class PenumbraChangedItemTooltip : IDisposable
|
|||
if (!Player())
|
||||
return;
|
||||
|
||||
var bonusSlot = item.Type.ToBonus();
|
||||
if (bonusSlot is not BonusItemFlag.Unknown)
|
||||
{
|
||||
// + 2 due to weapons.
|
||||
var glasses = _lastItems[bonusSlot.ToSlot() + 2];
|
||||
using (_ = !openTooltip ? null : ImRaii.Tooltip())
|
||||
{
|
||||
ImGui.TextUnformatted($"{prefix}Right-Click to apply to current actor.");
|
||||
if (glasses.Valid)
|
||||
ImGui.TextUnformatted($"{prefix}Control + Right-Click to re-apply {glasses.Name} to current actor.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var slot = item.Type.ToSlot();
|
||||
var last = _lastItems[slot.ToIndex()];
|
||||
switch (slot)
|
||||
|
|
@ -109,6 +125,27 @@ public sealed class PenumbraChangedItemTooltip : IDisposable
|
|||
|
||||
public void ApplyItem(ActorState state, EquipItem item)
|
||||
{
|
||||
var bonusSlot = item.Type.ToBonus();
|
||||
if (bonusSlot is not BonusItemFlag.Unknown)
|
||||
{
|
||||
// + 2 due to weapons.
|
||||
var glasses = _lastItems[bonusSlot.ToSlot() + 2];
|
||||
if (ImGui.GetIO().KeyCtrl && glasses.Valid)
|
||||
{
|
||||
Glamourer.Log.Debug($"Re-Applying {glasses.Name} to {bonusSlot.ToName()}.");
|
||||
SetLastItem(bonusSlot, default, state);
|
||||
_stateManager.ChangeBonusItem(state, bonusSlot, glasses, ApplySettings.Manual);
|
||||
}
|
||||
else
|
||||
{
|
||||
Glamourer.Log.Debug($"Applying {item.Name} to {bonusSlot.ToName()}.");
|
||||
SetLastItem(bonusSlot, item, state);
|
||||
_stateManager.ChangeBonusItem(state, bonusSlot, item, ApplySettings.Manual);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var slot = item.Type.ToSlot();
|
||||
var last = _lastItems[slot.ToIndex()];
|
||||
switch (slot)
|
||||
|
|
@ -265,7 +302,22 @@ public sealed class PenumbraChangedItemTooltip : IDisposable
|
|||
{
|
||||
var oldItem = state.ModelData.Item(slot);
|
||||
if (oldItem.Id != item.Id)
|
||||
_lastItems[slot.ToIndex()] = oldItem;
|
||||
last = oldItem;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetLastItem(BonusItemFlag slot, EquipItem item, ActorState state)
|
||||
{
|
||||
ref var last = ref _lastItems[slot.ToSlot() + 2];
|
||||
if (!item.Valid)
|
||||
{
|
||||
last = default;
|
||||
}
|
||||
else
|
||||
{
|
||||
var oldItem = state.ModelData.BonusItem(slot);
|
||||
if (oldItem.Id != item.Id)
|
||||
last = oldItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,13 @@ public unsafe class PenumbraPanel(PenumbraService _penumbra, PenumbraChangedItem
|
|||
ImGui.Separator();
|
||||
foreach (var (slot, item) in _penumbraTooltip.LastItems)
|
||||
{
|
||||
ImGuiUtil.DrawTableColumn($"{slot.ToName()} Revert-Item");
|
||||
switch (slot)
|
||||
{
|
||||
case EquipSlot e: ImGuiUtil.DrawTableColumn($"{e.ToName()} Revert-Item"); break;
|
||||
case BonusItemFlag f: ImGuiUtil.DrawTableColumn($"{f.ToName()} Revert-Item"); break;
|
||||
default: ImGuiUtil.DrawTableColumn("Unk Revert-Item"); break;
|
||||
}
|
||||
|
||||
ImGuiUtil.DrawTableColumn(item.Valid ? item.Name : "None");
|
||||
ImGui.TableNextColumn();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue