From de834b39636aee2c622d2bf368647a5f222fb5f9 Mon Sep 17 00:00:00 2001 From: Jackson <9527380+Jaksuhn@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:57:57 +0100 Subject: [PATCH] add bannerpreview bother --- ECommons | 2 +- YesAlready/Configuration.cs | 1 + YesAlready/Features/BannerPreview.cs | 28 ++++++++++++++++++++++++++++ YesAlready/UI/Tabs/Bothers.cs | 8 ++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 YesAlready/Features/BannerPreview.cs diff --git a/ECommons b/ECommons index 89a1e91..86a2aab 160000 --- a/ECommons +++ b/ECommons @@ -1 +1 @@ -Subproject commit 89a1e9164cc41fe736a21ea21993060f20d6cae7 +Subproject commit 86a2aab40e79f6b3f33f69920f36afa9f4fc6ead diff --git a/YesAlready/Configuration.cs b/YesAlready/Configuration.cs index b8f593c..9b82461 100644 --- a/YesAlready/Configuration.cs +++ b/YesAlready/Configuration.cs @@ -67,6 +67,7 @@ public partial class Configuration() : IPluginConfiguration public bool AirShipExplorationResultRedeploy { get; set; } = false; public bool MiragePrismRemoveDispel { get; set; } = false; public bool MiragePrismExecuteCast { get; set; } = false; + public bool BannerPreviewUpdate { get; set; } = false; public List CustomCallbacks { get; set; } = []; diff --git a/YesAlready/Features/BannerPreview.cs b/YesAlready/Features/BannerPreview.cs new file mode 100644 index 0000000..11e0688 --- /dev/null +++ b/YesAlready/Features/BannerPreview.cs @@ -0,0 +1,28 @@ +using Dalamud.Game.Addon.Lifecycle; +using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; +using ECommons.Automation; +using YesAlready.BaseFeatures; + +namespace YesAlready.Features; +internal class BannerPreview : BaseFeature +{ + public override void Enable() + { + base.Enable(); + Svc.AddonLifecycle.RegisterListener(AddonEvent.PostSetup, "BannerPreview", AddonSetup); + } + + public override void Disable() + { + base.Disable(); + Svc.AddonLifecycle.UnregisterListener(AddonSetup); + } + + protected static unsafe void AddonSetup(AddonEvent eventType, AddonArgs addonInfo) + { + if (!P.Active || !P.Config.BannerPreviewUpdate) return; + Callback.Fire(addonInfo.Base(), true, 0); + // FIX: this causes a "Character not in frame error" when done PostSetup ... somehow + //new AddonMaster.BannerPreview(addonInfo.Base()).Update(); + } +} diff --git a/YesAlready/UI/Tabs/Bothers.cs b/YesAlready/UI/Tabs/Bothers.cs index 60a13eb..f19feeb 100644 --- a/YesAlready/UI/Tabs/Bothers.cs +++ b/YesAlready/UI/Tabs/Bothers.cs @@ -444,6 +444,14 @@ public static void Draw() P.Config.Save(); } ImGuiEx.IndentedTextColored("Automatically cast glamours when using Glamour Prisms."); + + var bpu = P.Config.BannerPreviewUpdate; + if (ImGui.Checkbox("BannerPreviewUpdate", ref bpu)) + { + P.Config.BannerPreviewUpdate = bpu; + P.Config.Save(); + } + ImGuiEx.IndentedTextColored("Automatically update portraits."); } #endregion