From 4215e0ad447cd425d6f9f4b27fe0d46db0cfd6ef Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 27 Nov 2024 23:44:30 +0100 Subject: [PATCH] Add default settings for design configuration. --- Glamourer/Configuration.cs | 9 +++++ Glamourer/Designs/Design.cs | 12 ++++--- Glamourer/Designs/DesignManager.cs | 36 +++++++++++-------- Glamourer/Designs/Links/LinkContainer.cs | 16 +++++++-- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 15 ++++++++ 5 files changed, 67 insertions(+), 21 deletions(-) diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index 165e20d7..77fc84f3 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -25,6 +25,13 @@ public enum HeightDisplayType OlympicPool, } +public class DefaultDesignSettings +{ + public bool AlwaysForceRedrawing = false; + public bool ResetAdvancedDyes = false; + public bool ShowQuickDesignBar = true; +} + public class Configuration : IPluginConfiguration, ISavable { [JsonIgnore] @@ -59,6 +66,8 @@ public class Configuration : IPluginConfiguration, ISavable public bool AllowDoubleClickToApply { get; set; } = false; public bool RespectManualOnAutomationUpdate { get; set; } = false; + public DefaultDesignSettings DefaultDesignSettings { get; set; } = new(); + public HeightDisplayType HeightDisplayType { get; set; } = HeightDisplayType.Centimetre; public RenameField ShowRename { get; set; } = RenameField.BothDataPrio; public ModifiableHotkey ToggleQuickDesignBar { get; set; } = new(VirtualKey.NO_KEY); diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index c58d74fd..6cc9eef6 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -28,10 +28,14 @@ internal Design(DesignBase other) internal Design(Design other) : base(other) { - Tags = [.. other.Tags]; - Description = other.Description; - QuickDesign = other.QuickDesign; - AssociatedMods = new SortedList(other.AssociatedMods); + Tags = [.. other.Tags]; + Description = other.Description; + QuickDesign = other.QuickDesign; + ForcedRedraw = other.ForcedRedraw; + ResetAdvancedDyes = other.ResetAdvancedDyes; + Color = other.Color; + AssociatedMods = new SortedList(other.AssociatedMods); + Links = Links.Clone(); } // Metadata diff --git a/Glamourer/Designs/DesignManager.cs b/Glamourer/Designs/DesignManager.cs index 15e38ee9..b889649e 100644 --- a/Glamourer/Designs/DesignManager.cs +++ b/Glamourer/Designs/DesignManager.cs @@ -99,11 +99,14 @@ public Design CreateEmpty(string name, bool handlePath) var (actualName, path) = ParseName(name, handlePath); var design = new Design(Customizations, Items) { - CreationDate = DateTimeOffset.UtcNow, - LastEdit = DateTimeOffset.UtcNow, - Identifier = CreateNewGuid(), - Name = actualName, - Index = Designs.Count, + CreationDate = DateTimeOffset.UtcNow, + LastEdit = DateTimeOffset.UtcNow, + Identifier = CreateNewGuid(), + Name = actualName, + Index = Designs.Count, + ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing, + ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes, + QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar, }; Designs.Add(design); Glamourer.Log.Debug($"Added new design {design.Identifier}."); @@ -118,11 +121,14 @@ public Design CreateClone(DesignBase clone, string name, bool handlePath) var (actualName, path) = ParseName(name, handlePath); var design = new Design(clone) { - CreationDate = DateTimeOffset.UtcNow, - LastEdit = DateTimeOffset.UtcNow, - Identifier = CreateNewGuid(), - Name = actualName, - Index = Designs.Count, + CreationDate = DateTimeOffset.UtcNow, + LastEdit = DateTimeOffset.UtcNow, + Identifier = CreateNewGuid(), + Name = actualName, + Index = Designs.Count, + ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing, + ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes, + QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar, }; Designs.Add(design); @@ -138,11 +144,11 @@ public Design CreateClone(Design clone, string name, bool handlePath) var (actualName, path) = ParseName(name, handlePath); var design = new Design(clone) { - CreationDate = DateTimeOffset.UtcNow, - LastEdit = DateTimeOffset.UtcNow, - Identifier = CreateNewGuid(), - Name = actualName, - Index = Designs.Count, + CreationDate = DateTimeOffset.UtcNow, + LastEdit = DateTimeOffset.UtcNow, + Identifier = CreateNewGuid(), + Name = actualName, + Index = Designs.Count, }; Designs.Add(design); Glamourer.Log.Debug( diff --git a/Glamourer/Designs/Links/LinkContainer.cs b/Glamourer/Designs/Links/LinkContainer.cs index ef67688e..6cfc1213 100644 --- a/Glamourer/Designs/Links/LinkContainer.cs +++ b/Glamourer/Designs/Links/LinkContainer.cs @@ -14,6 +14,16 @@ public List Before public new int Count => base.Count + After.Count; + public LinkContainer Clone() + { + var ret = new LinkContainer(); + ret.EnsureCapacity(base.Count); + ret.After.EnsureCapacity(After.Count); + ret.AddRange(this); + ret.After.AddRange(After); + return ret; + } + public bool Reorder(int fromIndex, LinkOrder fromOrder, int toIndex, LinkOrder toOrder) { var fromList = fromOrder switch @@ -89,13 +99,15 @@ public static bool CanAddLink(Design parent, Design child, LinkOrder order, out if (GetAllLinks(parent).Any(l => l.Link.Link == child && l.Order != order)) { - error = $"Adding {child.Incognito} to {parent.Incognito}s links would create a circle, the parent already links to the child in the opposite direction."; + error = + $"Adding {child.Incognito} to {parent.Incognito}s links would create a circle, the parent already links to the child in the opposite direction."; return false; } if (GetAllLinks(child).Any(l => l.Link.Link == parent && l.Order == order)) { - error = $"Adding {child.Incognito} to {parent.Incognito}s links would create a circle, the child already links to the parent in the opposite direction."; + error = + $"Adding {child.Incognito} to {parent.Incognito}s links would create a circle, the child already links to the parent in the opposite direction."; return false; } diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 15406962..052c0b85 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -10,6 +10,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; +using OtterGui.Text; using OtterGui.Widgets; namespace Glamourer.Gui.Tabs.SettingsTab; @@ -51,6 +52,7 @@ public void DrawContent() using (ImRaii.Child("SettingsChild")) { DrawBehaviorSettings(); + DrawDesignDefaultSettings(); DrawInterfaceSettings(); DrawColorSettings(); overrides.Draw(); @@ -101,6 +103,19 @@ private void DrawBehaviorSettings() ImGui.NewLine(); } + private void DrawDesignDefaultSettings() + { + if (!ImUtf8.CollapsingHeader("Design Defaults")) + return; + + Checkbox("Show in Quick Design Bar", "Newly created designs will be shown in the quick design bar by default.", + config.DefaultDesignSettings.ShowQuickDesignBar, v => config.DefaultDesignSettings.ShowQuickDesignBar = v); + Checkbox("Reset Advanced Dyes", "Newly created designs will be configured to reset advanced dyes on application by default.", + config.DefaultDesignSettings.ResetAdvancedDyes, v => config.DefaultDesignSettings.ResetAdvancedDyes = v); + Checkbox("Always Force Redraw", "Newly created designs will be configured to force character redraws on application by default.", + config.DefaultDesignSettings.AlwaysForceRedrawing, v => config.DefaultDesignSettings.AlwaysForceRedrawing = v); + } + private void DrawInterfaceSettings() { if (!ImGui.CollapsingHeader("Interface"))