Skip to content

Commit

Permalink
Autoconfirming portrait update after gear upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
erdelf committed Dec 4, 2024
1 parent 1943a53 commit f89b27f
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions AutoDuty/Helpers/PortraitHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace AutoDuty.Helpers
{
using Dalamud.Plugin.Services;
using ECommons;
using ECommons.DalamudServices;
using ECommons.Throttlers;
using FFXIVClientStructs.FFXIV.Component.GUI;

internal static class PortraitHelper
{
internal static ActionState State = ActionState.None;

internal static void Invoke()
{
if (State != ActionState.Running && Svc.ClientState.TerritoryType != 0)
{
Svc.Log.Info("Portrait Started");
State = ActionState.Running;
Plugin.States |= PluginState.Other;

SchedulerHelper.ScheduleAction("PortraitTimeOut", Stop, 10000);
Plugin.Action = "Updating Portrait";
Svc.Framework.Update += PortraitUpdate;
}
}

internal static void Stop()
{
Plugin.Action = "";
SchedulerHelper.DescheduleAction("PortraitTimeOut");
Svc.Framework.Update -= PortraitUpdate;
}


internal static unsafe void PortraitUpdate(IFramework framework)
{
if (!EzThrottler.Throttle("PortraitUpdate", 500))
return;
if (!GenericHelpers.TryGetAddonByName("BannerPreview", out AtkUnitBase* addonBanner) || !GenericHelpers.IsAddonReady(addonBanner))
return;
AddonHelper.FireCallBack(addonBanner, true, 0);

Svc.Framework.Update -= PortraitUpdate;
}

}
}

0 comments on commit f89b27f

Please sign in to comment.