Maybe fix disabling auto designs.

This commit is contained in:
Ottermandias 2024-12-16 14:29:32 +01:00
parent 33bf5c5392
commit a116243900
2 changed files with 25 additions and 6 deletions

View file

@ -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
/// <summary> Get world-specific first and all-world afterward. </summary>
private bool GetPlayerSet(ActorIdentifier identifier, [NotNullWhen(true)] out AutoDesignSet? set)
{
if (!_config.EnableAutoDesigns)
{
set = null;
return false;
}
switch (identifier.Type)
{
case IdentifierType.Player:

View file

@ -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();