Remove Enabled Config.

This commit is contained in:
Ottermandias 2023-11-10 18:21:26 +01:00
parent eb6e665147
commit a3583dd5f1
4 changed files with 7 additions and 35 deletions

View file

@ -19,7 +19,6 @@ namespace Glamourer;
public class Configuration : IPluginConfiguration, ISavable public class Configuration : IPluginConfiguration, ISavable
{ {
public bool Enabled { get; set; } = true;
public bool UseRestrictedGearProtection { get; set; } = false; public bool UseRestrictedGearProtection { get; set; } = false;
public bool OpenFoldersByDefault { get; set; } = false; public bool OpenFoldersByDefault { get; set; } = false;
public bool AutoRedrawEquipOnChanges { get; set; } = false; public bool AutoRedrawEquipOnChanges { get; set; } = false;

View file

@ -3,6 +3,7 @@ using Dalamud.Plugin;
using Glamourer.Gui; using Glamourer.Gui;
using Glamourer.Interop; using Glamourer.Interop;
using Glamourer.Services; using Glamourer.Services;
using Glamourer.State;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using OtterGui.Classes; using OtterGui.Classes;
using OtterGui.Log; using OtterGui.Log;
@ -31,6 +32,7 @@ public class Glamourer : IDalamudPlugin
{ {
_services = ServiceManager.CreateProvider(pluginInterface, Log); _services = ServiceManager.CreateProvider(pluginInterface, Log);
Messager = _services.GetRequiredService<MessageService>(); Messager = _services.GetRequiredService<MessageService>();
_services.GetRequiredService<StateListener>(); // Initialize State Listener.
_services.GetRequiredService<GlamourerWindowSystem>(); // initialize ui. _services.GetRequiredService<GlamourerWindowSystem>(); // initialize ui.
_services.GetRequiredService<CommandService>(); // initialize commands. _services.GetRequiredService<CommandService>(); // initialize commands.
_services.GetRequiredService<VisorService>(); _services.GetRequiredService<VisorService>();

View file

@ -24,7 +24,6 @@ public class SettingsTab : ITab
private readonly VirtualKey[] _validKeys; private readonly VirtualKey[] _validKeys;
private readonly Configuration _config; private readonly Configuration _config;
private readonly DesignFileSystemSelector _selector; private readonly DesignFileSystemSelector _selector;
private readonly StateListener _stateListener;
private readonly CodeService _codeService; private readonly CodeService _codeService;
private readonly PenumbraAutoRedraw _autoRedraw; private readonly PenumbraAutoRedraw _autoRedraw;
private readonly ContextMenuService _contextMenuService; private readonly ContextMenuService _contextMenuService;
@ -32,13 +31,11 @@ public class SettingsTab : ITab
private readonly GlamourerChangelog _changelog; private readonly GlamourerChangelog _changelog;
private readonly FunModule _funModule; private readonly FunModule _funModule;
public SettingsTab(Configuration config, DesignFileSystemSelector selector, StateListener stateListener, public SettingsTab(Configuration config, DesignFileSystemSelector selector, CodeService codeService, PenumbraAutoRedraw autoRedraw,
CodeService codeService, PenumbraAutoRedraw autoRedraw, ContextMenuService contextMenuService, UiBuilder uiBuilder, ContextMenuService contextMenuService, UiBuilder uiBuilder, GlamourerChangelog changelog, FunModule funModule, IKeyState keys)
GlamourerChangelog changelog, FunModule funModule, IKeyState keys)
{ {
_config = config; _config = config;
_selector = selector; _selector = selector;
_stateListener = stateListener;
_codeService = codeService; _codeService = codeService;
_autoRedraw = autoRedraw; _autoRedraw = autoRedraw;
_contextMenuService = contextMenuService; _contextMenuService = contextMenuService;
@ -59,11 +56,11 @@ public class SettingsTab : ITab
if (!child) if (!child)
return; return;
Checkbox("Enabled", "Enable main functionality of keeping and applying state.", _stateListener.Enabled, _stateListener.Enable);
Checkbox("Enable Auto Designs", "Enable the application of designs associated to characters to be applied automatically.", Checkbox("Enable Auto Designs", "Enable the application of designs associated to characters to be applied automatically.",
_config.EnableAutoDesigns, v => _config.EnableAutoDesigns = v); _config.EnableAutoDesigns, v => _config.EnableAutoDesigns = v);
ImGui.NewLine(); ImGui.NewLine();
ImGui.NewLine(); ImGui.NewLine();
ImGui.NewLine();
using (var child2 = ImRaii.Child("SettingsChild")) using (var child2 = ImRaii.Child("SettingsChild"))
{ {

View file

@ -13,7 +13,6 @@ using Penumbra.GameData.Structs;
using System; using System;
using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Conditions;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Glamourer.Structs;
namespace Glamourer.State; namespace Glamourer.State;
@ -49,12 +48,6 @@ public class StateListener : IDisposable
private ActorState? _creatingState; private ActorState? _creatingState;
private CharacterWeapon _lastFistOffhand = CharacterWeapon.Empty; private CharacterWeapon _lastFistOffhand = CharacterWeapon.Empty;
public bool Enabled
{
get => _config.Enabled;
set => Enable(value);
}
public StateListener(StateManager manager, ItemManager items, PenumbraService penumbra, ActorService actors, Configuration config, public StateListener(StateManager manager, ItemManager items, PenumbraService penumbra, ActorService actors, Configuration config,
SlotUpdating slotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, WeaponVisibilityChanged weaponVisibility, SlotUpdating slotUpdating, WeaponLoading weaponLoading, VisorStateChanged visorState, WeaponVisibilityChanged weaponVisibility,
HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, FunModule funModule, HumanModelList humans, HeadGearVisibilityChanged headGearVisibility, AutoDesignApplier autoDesignApplier, FunModule funModule, HumanModelList humans,
@ -81,30 +74,11 @@ public class StateListener : IDisposable
_changeCustomizeService = changeCustomizeService; _changeCustomizeService = changeCustomizeService;
_customizations = customizations; _customizations = customizations;
_condition = condition; _condition = condition;
Subscribe();
if (Enabled)
Subscribe();
}
public void Enable(bool value)
{
if (value == Enabled)
return;
_config.Enabled = value;
_config.Save();
if (value)
Subscribe();
else
Unsubscribe();
} }
void IDisposable.Dispose() void IDisposable.Dispose()
{ => Unsubscribe();
if (Enabled)
Unsubscribe();
}
/// <summary> The result of updating the base state of an ActorState. </summary> /// <summary> The result of updating the base state of an ActorState. </summary>
private enum UpdateState private enum UpdateState