From a1162439007212d7bf3cbb198ae7f6ad69215d1c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 16 Dec 2024 14:29:32 +0100 Subject: [PATCH] Maybe fix disabling auto designs. --- Glamourer/Automation/AutoDesignApplier.cs | 21 +++++++++++++++---- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 10 +++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Glamourer/Automation/AutoDesignApplier.cs b/Glamourer/Automation/AutoDesignApplier.cs index 8e0b75c..e506d9f 100644 --- a/Glamourer/Automation/AutoDesignApplier.cs +++ b/Glamourer/Automation/AutoDesignApplier.cs @@ -55,6 +55,15 @@ public sealed class AutoDesignApplier : IDisposable _equippedGearset.Subscribe(OnEquippedGearset, EquippedGearset.Priority.AutoDesignApplier); } + public void OnEnableAutoDesignsChanged(bool value) + { + if (value) + return; + + foreach (var state in _state.Values) + state.Sources.RemoveFixedDesignSources(); + } + public void Dispose() { _weapons.Unsubscribe(OnWeaponLoading); @@ -234,9 +243,6 @@ public sealed class AutoDesignApplier : IDisposable AutoDesignSet set; if (!_state.TryGetValue(identifier, out state)) { - if (!_config.EnableAutoDesigns) - return false; - if (!GetPlayerSet(identifier, out set!)) return false; @@ -257,7 +263,8 @@ public sealed class AutoDesignApplier : IDisposable return true; } - private unsafe void Reduce(Actor actor, ActorState state, AutoDesignSet set, bool respectManual, bool fromJobChange, bool newApplication, out bool forcedRedraw) + private unsafe void Reduce(Actor actor, ActorState state, AutoDesignSet set, bool respectManual, bool fromJobChange, bool newApplication, + out bool forcedRedraw) { if (set.BaseState is AutoDesignSet.Base.Game) { @@ -294,6 +301,12 @@ public sealed class AutoDesignApplier : IDisposable /// Get world-specific first and all-world afterward. private bool GetPlayerSet(ActorIdentifier identifier, [NotNullWhen(true)] out AutoDesignSet? set) { + if (!_config.EnableAutoDesigns) + { + set = null; + return false; + } + switch (identifier.Type) { case IdentifierType.Player: diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 052c0b8..c6d69fd 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -3,6 +3,7 @@ using Dalamud.Interface; using Dalamud.Interface.Components; using Dalamud.Interface.Utility; using Dalamud.Plugin.Services; +using Glamourer.Automation; using Glamourer.Designs; using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Interop; @@ -27,7 +28,8 @@ public class SettingsTab( PalettePlusChecker paletteChecker, CollectionOverrideDrawer overrides, CodeDrawer codeDrawer, - Glamourer glamourer) + Glamourer glamourer, + AutoDesignApplier autoDesignApplier) : ITab { private readonly VirtualKey[] _validKeys = keys.GetValidVirtualKeys().Prepend(VirtualKey.NO_KEY).ToArray(); @@ -43,7 +45,11 @@ public class SettingsTab( Checkbox("Enable Auto Designs", "Enable the application of designs associated to characters in the Automation tab to be applied automatically.", - config.EnableAutoDesigns, v => config.EnableAutoDesigns = v); + config.EnableAutoDesigns, v => + { + config.EnableAutoDesigns = v; + autoDesignApplier.OnEnableAutoDesignsChanged(v); + }); ImGui.NewLine(); ImGui.NewLine(); ImGui.NewLine();