Skip to content

Commit

Permalink
Replaced deprecated GameMain.IsInSanctuary call
Browse files Browse the repository at this point in the history
  • Loading branch information
haroldiedema committed Oct 5, 2024
1 parent c98cccb commit 88a6145
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
14 changes: 9 additions & 5 deletions Umbra.Game/src/Player/Gearset/GearsetRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,12 +41,16 @@ internal sealed class GearsetRepository : IGearsetRepository, IDisposable

private readonly Hook<RaptureGearsetModule.Delegates.LinkGlamourPlate> _linkGlamourPlateHook;

private readonly IPlayer _player;

public unsafe GearsetRepository(
IGameInteropProvider interopProvider,
IGearsetCategoryRepository categoryRepository,
IPlayer player
)
{
_player = player;

_linkGlamourPlateHook = interopProvider.HookFromAddress<RaptureGearsetModule.Delegates.LinkGlamourPlate>(
RaptureGearsetModule.MemberFunctionPointers.LinkGlamourPlate,
OnLinkGlamourPlateToGearset
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<IToastGui>().ShowError(I18N.Translate("UnableToApplyGlamourPlatesHere"));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 88a6145

Please sign in to comment.