From 70918e539379871eb256a21ebad833d13315031d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 24 Jan 2025 15:04:22 +0100 Subject: [PATCH] Add AutoDesignSet toggle for resetting settings. --- Glamourer/Automation/AutoDesignManager.cs | 16 +++++ Glamourer/Events/AutomationChanged.cs | 3 + Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs | 71 ++++++++++++-------- 3 files changed, 62 insertions(+), 28 deletions(-) diff --git a/Glamourer/Automation/AutoDesignManager.cs b/Glamourer/Automation/AutoDesignManager.cs index 5d30de0..6635a89 100644 --- a/Glamourer/Automation/AutoDesignManager.cs +++ b/Glamourer/Automation/AutoDesignManager.cs @@ -234,6 +234,22 @@ public class AutoDesignManager : ISavable, IReadOnlyList, IDispos _event.Invoke(AutomationChanged.Type.ChangedBase, set, (old, newBase)); } + public void ChangeResetSettings(int whichSet, bool newValue) + { + if (whichSet >= _data.Count || whichSet < 0) + return; + + var set = _data[whichSet]; + if (newValue == set.ResetTemporarySettings) + return; + + var old = set.ResetTemporarySettings; + set.ResetTemporarySettings = newValue; + Save(); + Glamourer.Log.Debug($"Changed resetting of temporary settings of set {whichSet + 1} from {old} to {newValue}."); + _event.Invoke(AutomationChanged.Type.ChangedTemporarySettingsReset, set, newValue); + } + public void AddDesign(AutoDesignSet set, IDesignStandIn design) { var newDesign = new AutoDesign() diff --git a/Glamourer/Events/AutomationChanged.cs b/Glamourer/Events/AutomationChanged.cs index 26f799a..c368899 100644 --- a/Glamourer/Events/AutomationChanged.cs +++ b/Glamourer/Events/AutomationChanged.cs @@ -37,6 +37,9 @@ public sealed class AutomationChanged() /// Change the used base state of a given set. Additional data is prior and new base. [(AutoDesignSet.Base, AutoDesignSet.Base)]. ChangedBase, + /// Change the resetting of temporary settings for a given set. Additional data is the new value. + ChangedTemporarySettingsReset, + /// Add a new associated design to a given set. Additional data is the index it got added at [int]. AddedDesign, diff --git a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs index 924f822..caa7d60 100644 --- a/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs +++ b/Glamourer/Gui/Tabs/AutomationTab/SetPanel.cs @@ -58,38 +58,53 @@ public class SetPanel( var spacing = ImGui.GetStyle().ItemInnerSpacing with { Y = ImGui.GetStyle().ItemSpacing.Y }; - using (_ = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) + using (ImUtf8.Group()) { - var enabled = Selection.Enabled; - if (ImGui.Checkbox("##Enabled", ref enabled)) - _manager.SetState(_selector.SelectionIndex, enabled); - ImGuiUtil.LabeledHelpMarker("Enabled", - "Whether the designs in this set should be applied at all. Only one set can be enabled for a character at the same time."); - } - - ImGui.SameLine(); - using (_ = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) - { - var useGame = _selector.Selection!.BaseState is AutoDesignSet.Base.Game; - if (ImGui.Checkbox("##gameState", ref useGame)) - _manager.ChangeBaseState(_selector.SelectionIndex, useGame ? AutoDesignSet.Base.Game : AutoDesignSet.Base.Current); - ImGuiUtil.LabeledHelpMarker("Use Game State as Base", - "When this is enabled, the designs matching conditions will be applied successively on top of what your character is supposed to look like for the game. " - + "Otherwise, they will be applied on top of the characters actual current look using Glamourer."); - } - - ImGui.SameLine(); - using (_ = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) - { - var editing = _config.ShowAutomationSetEditing; - if (ImGui.Checkbox("##Show Editing", ref editing)) + using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) { - _config.ShowAutomationSetEditing = editing; - _config.Save(); + var enabled = Selection.Enabled; + if (ImGui.Checkbox("##Enabled", ref enabled)) + _manager.SetState(_selector.SelectionIndex, enabled); + ImGuiUtil.LabeledHelpMarker("Enabled", + "Whether the designs in this set should be applied at all. Only one set can be enabled for a character at the same time."); } - ImGuiUtil.LabeledHelpMarker("Show Editing", - "Show options to change the name or the associated character or NPC of this design set."); + using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) + { + var useGame = _selector.Selection!.BaseState is AutoDesignSet.Base.Game; + if (ImGui.Checkbox("##gameState", ref useGame)) + _manager.ChangeBaseState(_selector.SelectionIndex, useGame ? AutoDesignSet.Base.Game : AutoDesignSet.Base.Current); + ImGuiUtil.LabeledHelpMarker("Use Game State as Base", + "When this is enabled, the designs matching conditions will be applied successively on top of what your character is supposed to look like for the game. " + + "Otherwise, they will be applied on top of the characters actual current look using Glamourer."); + } + } + + ImGui.SameLine(); + using (ImUtf8.Group()) + { + using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) + { + var editing = _config.ShowAutomationSetEditing; + if (ImGui.Checkbox("##Show Editing", ref editing)) + { + _config.ShowAutomationSetEditing = editing; + _config.Save(); + } + + ImGuiUtil.LabeledHelpMarker("Show Editing", + "Show options to change the name or the associated character or NPC of this design set."); + } + + using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, spacing)) + { + var resetSettings = _selector.Selection!.ResetTemporarySettings; + if (ImGui.Checkbox("##resetSettings", ref resetSettings)) + _manager.ChangeResetSettings(_selector.SelectionIndex, resetSettings); + + ImGuiUtil.LabeledHelpMarker("Reset Temporary Settings", + "Always reset all temporary settings applied by Glamourer when this automation set is applied, regardless of active designs."); + } } if (_config.ShowAutomationSetEditing)