diff --git a/Umbra.Game/src/Player/Gearset/GearsetRepository.cs b/Umbra.Game/src/Player/Gearset/GearsetRepository.cs index 305dd776..49ac3b0b 100644 --- a/Umbra.Game/src/Player/Gearset/GearsetRepository.cs +++ b/Umbra.Game/src/Player/Gearset/GearsetRepository.cs @@ -16,13 +16,12 @@ using Dalamud.Hooking; using Dalamud.Plugin.Services; -using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.UI.Agent; +using FFXIVClientStructs.FFXIV.Client.UI.Misc; +using FFXIVClientStructs.FFXIV.Component.GUI; using System; using System.Collections.Generic; using System.Linq; -using FFXIVClientStructs.FFXIV.Client.UI.Misc; -using FFXIVClientStructs.FFXIV.Component.GUI; using Umbra.Common; namespace Umbra.Game; @@ -42,12 +41,16 @@ internal sealed class GearsetRepository : IGearsetRepository, IDisposable private readonly Hook _linkGlamourPlateHook; + private readonly IPlayer _player; + public unsafe GearsetRepository( IGameInteropProvider interopProvider, IGearsetCategoryRepository categoryRepository, IPlayer player ) { + _player = player; + _linkGlamourPlateHook = interopProvider.HookFromAddress( RaptureGearsetModule.MemberFunctionPointers.LinkGlamourPlate, OnLinkGlamourPlateToGearset @@ -97,7 +100,7 @@ public unsafe void OpenPortraitEditorForGearset(Gearset gs) private unsafe void OnLinkGlamourPlateToGearset(RaptureGearsetModule* gsm, int gearsetId, byte glamourPlateId) { - _linkGlamourPlateHook!.Original(gsm, gearsetId, glamourPlateId); + _linkGlamourPlateHook.Original(gsm, gearsetId, glamourPlateId); if (CurrentGearset?.Id == gearsetId) { // The game does not apply the linked glamour plates until the gearset itself is reequipped. @@ -152,9 +155,10 @@ public unsafe void EquipGearset(ushort id) public unsafe void OpenGlamourSetLinkWindow(Gearset gearset) { AgentMiragePrismMiragePlate* amp = AgentMiragePrismMiragePlate.Instance(); + if (amp == null) return; - if (!GameMain.IsInSanctuary()) + if (!_player.IsInSanctuary) { Framework.Service().ShowError(I18N.Translate("UnableToApplyGlamourPlatesHere")); return; diff --git a/Umbra/src/Toolbar/Widgets/Library/GearsetSwitcher/GearsetSwitcherPopup.Data.cs b/Umbra/src/Toolbar/Widgets/Library/GearsetSwitcher/GearsetSwitcherPopup.Data.cs index efd469d4..1453121c 100644 --- a/Umbra/src/Toolbar/Widgets/Library/GearsetSwitcher/GearsetSwitcherPopup.Data.cs +++ b/Umbra/src/Toolbar/Widgets/Library/GearsetSwitcher/GearsetSwitcherPopup.Data.cs @@ -14,7 +14,6 @@ * GNU Affero General Public License for more details. */ -using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Client.UI.Agent; using System.Collections.Generic; @@ -87,7 +86,7 @@ private unsafe void OnGearsetRightClick(Node node) _ctxSelectedGearset = gsNode.Gearset; ContextMenu!.SetEntryLabel("UnlinkGlam", I18N.Translate("Widget.GearsetSwitcher.ContextMenu.UnlinkGlamourPlate", _ctxSelectedGearset.GlamourSetLink == 0 ? "" : _ctxSelectedGearset.GlamourSetLink.ToString())); - ContextMenu!.SetEntryDisabled("LinkGlam", !UIState.Instance()->IsUnlockLinkUnlocked(15) || !GameMain.IsInSanctuary()); + ContextMenu!.SetEntryDisabled("LinkGlam", !UIState.Instance()->IsUnlockLinkUnlocked(15) || !_player.IsInSanctuary); ContextMenu!.SetEntryDisabled("UnlinkGlam", _ctxSelectedGearset.GlamourSetLink == 0); ContextMenu!.SetEntryDisabled("EditBanner", !AgentBannerEditor.Instance()->IsActivatable()); ContextMenu!.SetEntryDisabled("MoveUp", _gearsetRepository.FindPrevIdInCategory(_ctxSelectedGearset) == null); diff --git a/Umbra/src/Toolbar/Widgets/Library/GearsetSwitcher/GearsetSwitcherPopup.cs b/Umbra/src/Toolbar/Widgets/Library/GearsetSwitcher/GearsetSwitcherPopup.cs index 5925e0ca..315f43f5 100644 --- a/Umbra/src/Toolbar/Widgets/Library/GearsetSwitcher/GearsetSwitcherPopup.cs +++ b/Umbra/src/Toolbar/Widgets/Library/GearsetSwitcher/GearsetSwitcherPopup.cs @@ -235,7 +235,7 @@ protected override void OnUpdate() _player.GetJobInfo(_currentGearset.JobId).GetIcon(HeaderIconType); Node.QuerySelector("#HeaderIcon")!.Style.ImageOffset = new(0, HeaderIconYOffset); - Node.QuerySelector("#OpenGlam")!.IsDisabled = !GameMain.IsInSanctuary(); + Node.QuerySelector("#OpenGlam")!.IsDisabled = !_player.IsInSanctuary; // Assign role containers to the configured columns. foreach ((GearsetCategory category, Node node) in RoleContainers) {