From 9a02ba298724c68766b4a3fae4afeb00d8a072cd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 31 Aug 2024 20:51:38 +0200 Subject: [PATCH] Add support for previewing non-existing items from Penumbra. --- Glamourer/Gui/PenumbraChangedItemTooltip.cs | 28 +++++++++++++++++-- Glamourer/Interop/Penumbra/PenumbraService.cs | 2 +- Penumbra.Api | 2 +- Penumbra.GameData | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Glamourer/Gui/PenumbraChangedItemTooltip.cs b/Glamourer/Gui/PenumbraChangedItemTooltip.cs index c74d6a3..c6f2fc4 100644 --- a/Glamourer/Gui/PenumbraChangedItemTooltip.cs +++ b/Glamourer/Gui/PenumbraChangedItemTooltip.cs @@ -1,4 +1,4 @@ -using Glamourer.Designs; +using Glamourer.Designs; using Glamourer.Events; using Glamourer.Interop; using Glamourer.Interop.Penumbra; @@ -168,12 +168,23 @@ public sealed class PenumbraChangedItemTooltip : IDisposable { case ChangedItemType.ItemOffhand: case ChangedItemType.Item: + { if (!_items.ItemData.TryGetValue(id, type is ChangedItemType.Item ? EquipSlot.MainHand : EquipSlot.OffHand, out var item)) return; CreateTooltip(item, "[Glamourer] ", false); return; + } + case ChangedItemType.CustomArmor: + { + var (model, variant, slot) = IdentifiedItem.Split(id); + var item = _items.Identify(slot.ToSlot(), model, variant); + if (item.Valid) + CreateTooltip(item, "[Glamourer] ", false); + return; + } case ChangedItemType.Customization: + { var (race, gender, index, value) = IdentifiedCustomization.Split(id); if (!_objects.Player.Model.IsHuman) return; @@ -183,6 +194,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable ImGui.TextUnformatted("[Glamourer] Right-Click to apply to current actor."); return; + } } } @@ -212,17 +224,29 @@ public sealed class PenumbraChangedItemTooltip : IDisposable { case ChangedItemType.Item: case ChangedItemType.ItemOffhand: + { if (!_items.ItemData.TryGetValue(id, type is ChangedItemType.Item ? EquipSlot.MainHand : EquipSlot.OffHand, out var item)) return; ApplyItem(state, item); return; + } + case ChangedItemType.CustomArmor: + { + var (model, variant, slot) = IdentifiedItem.Split(id); + var item = _items.Identify(slot.ToSlot(), model, variant); + if (item.Valid) + ApplyItem(state, item); + return; + } case ChangedItemType.Customization: + { var (race, gender, index, value) = IdentifiedCustomization.Split(id); var customize = state.ModelData.Customize; if (CheckGenderRace(customize, race, gender) && VerifyValue(customize, index, value)) _stateManager.ChangeCustomize(state, index, value, ApplySettings.Manual); return; + } } } @@ -236,7 +260,7 @@ public sealed class PenumbraChangedItemTooltip : IDisposable else { var oldItem = state.ModelData.Item(slot); - if (oldItem.ItemId != item.ItemId) + if (oldItem.Id != item.Id) _lastItems[slot.ToIndex()] = oldItem; } } diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 85235e7..4f6c44a 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -31,7 +31,7 @@ public readonly record struct ModSettings(Dictionary> Setti => new(); } -public unsafe class PenumbraService : IDisposable +public class PenumbraService : IDisposable { public const int RequiredPenumbraBreakingVersion = 5; public const int RequiredPenumbraFeatureVersion = 0; diff --git a/Penumbra.Api b/Penumbra.Api index 552246e..97e9f42 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 552246e595ffab2aaba2c75f578d564f8938fc9a +Subproject commit 97e9f427406f82a59ddef764b44ecea654a51623 diff --git a/Penumbra.GameData b/Penumbra.GameData index d9d4b28..66bc00d 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit d9d4b286d54ad4027a1e8a2bbf900ee79aefaa93 +Subproject commit 66bc00dc8517204e58c6515af5aec0ba6d196716