Add default settings for design configuration.

This commit is contained in:
Ottermandias 2024-11-27 23:44:30 +01:00
parent 533c53fd8d
commit 4215e0ad44
5 changed files with 67 additions and 21 deletions

View file

@ -25,6 +25,13 @@ public enum HeightDisplayType
OlympicPool, OlympicPool,
} }
public class DefaultDesignSettings
{
public bool AlwaysForceRedrawing = false;
public bool ResetAdvancedDyes = false;
public bool ShowQuickDesignBar = true;
}
public class Configuration : IPluginConfiguration, ISavable public class Configuration : IPluginConfiguration, ISavable
{ {
[JsonIgnore] [JsonIgnore]
@ -59,6 +66,8 @@ public class Configuration : IPluginConfiguration, ISavable
public bool AllowDoubleClickToApply { get; set; } = false; public bool AllowDoubleClickToApply { get; set; } = false;
public bool RespectManualOnAutomationUpdate { get; set; } = false; public bool RespectManualOnAutomationUpdate { get; set; } = false;
public DefaultDesignSettings DefaultDesignSettings { get; set; } = new();
public HeightDisplayType HeightDisplayType { get; set; } = HeightDisplayType.Centimetre; public HeightDisplayType HeightDisplayType { get; set; } = HeightDisplayType.Centimetre;
public RenameField ShowRename { get; set; } = RenameField.BothDataPrio; public RenameField ShowRename { get; set; } = RenameField.BothDataPrio;
public ModifiableHotkey ToggleQuickDesignBar { get; set; } = new(VirtualKey.NO_KEY); public ModifiableHotkey ToggleQuickDesignBar { get; set; } = new(VirtualKey.NO_KEY);

View file

@ -28,10 +28,14 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
internal Design(Design other) internal Design(Design other)
: base(other) : base(other)
{ {
Tags = [.. other.Tags]; Tags = [.. other.Tags];
Description = other.Description; Description = other.Description;
QuickDesign = other.QuickDesign; QuickDesign = other.QuickDesign;
AssociatedMods = new SortedList<Mod, ModSettings>(other.AssociatedMods); ForcedRedraw = other.ForcedRedraw;
ResetAdvancedDyes = other.ResetAdvancedDyes;
Color = other.Color;
AssociatedMods = new SortedList<Mod, ModSettings>(other.AssociatedMods);
Links = Links.Clone();
} }
// Metadata // Metadata

View file

@ -99,11 +99,14 @@ public sealed class DesignManager : DesignEditor
var (actualName, path) = ParseName(name, handlePath); var (actualName, path) = ParseName(name, handlePath);
var design = new Design(Customizations, Items) var design = new Design(Customizations, Items)
{ {
CreationDate = DateTimeOffset.UtcNow, CreationDate = DateTimeOffset.UtcNow,
LastEdit = DateTimeOffset.UtcNow, LastEdit = DateTimeOffset.UtcNow,
Identifier = CreateNewGuid(), Identifier = CreateNewGuid(),
Name = actualName, Name = actualName,
Index = Designs.Count, Index = Designs.Count,
ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing,
ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes,
QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar,
}; };
Designs.Add(design); Designs.Add(design);
Glamourer.Log.Debug($"Added new design {design.Identifier}."); Glamourer.Log.Debug($"Added new design {design.Identifier}.");
@ -118,11 +121,14 @@ public sealed class DesignManager : DesignEditor
var (actualName, path) = ParseName(name, handlePath); var (actualName, path) = ParseName(name, handlePath);
var design = new Design(clone) var design = new Design(clone)
{ {
CreationDate = DateTimeOffset.UtcNow, CreationDate = DateTimeOffset.UtcNow,
LastEdit = DateTimeOffset.UtcNow, LastEdit = DateTimeOffset.UtcNow,
Identifier = CreateNewGuid(), Identifier = CreateNewGuid(),
Name = actualName, Name = actualName,
Index = Designs.Count, Index = Designs.Count,
ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing,
ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes,
QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar,
}; };
Designs.Add(design); Designs.Add(design);
@ -138,11 +144,11 @@ public sealed class DesignManager : DesignEditor
var (actualName, path) = ParseName(name, handlePath); var (actualName, path) = ParseName(name, handlePath);
var design = new Design(clone) var design = new Design(clone)
{ {
CreationDate = DateTimeOffset.UtcNow, CreationDate = DateTimeOffset.UtcNow,
LastEdit = DateTimeOffset.UtcNow, LastEdit = DateTimeOffset.UtcNow,
Identifier = CreateNewGuid(), Identifier = CreateNewGuid(),
Name = actualName, Name = actualName,
Index = Designs.Count, Index = Designs.Count,
}; };
Designs.Add(design); Designs.Add(design);
Glamourer.Log.Debug( Glamourer.Log.Debug(

View file

@ -14,6 +14,16 @@ public sealed class LinkContainer : List<DesignLink>
public new int Count public new int Count
=> base.Count + After.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) public bool Reorder(int fromIndex, LinkOrder fromOrder, int toIndex, LinkOrder toOrder)
{ {
var fromList = fromOrder switch var fromList = fromOrder switch
@ -89,13 +99,15 @@ public sealed class LinkContainer : List<DesignLink>
if (GetAllLinks(parent).Any(l => l.Link.Link == child && l.Order != order)) 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; return false;
} }
if (GetAllLinks(child).Any(l => l.Link.Link == parent && l.Order == order)) 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; return false;
} }

View file

@ -10,6 +10,7 @@ using Glamourer.Interop.PalettePlus;
using ImGuiNET; using ImGuiNET;
using OtterGui; using OtterGui;
using OtterGui.Raii; using OtterGui.Raii;
using OtterGui.Text;
using OtterGui.Widgets; using OtterGui.Widgets;
namespace Glamourer.Gui.Tabs.SettingsTab; namespace Glamourer.Gui.Tabs.SettingsTab;
@ -51,6 +52,7 @@ public class SettingsTab(
using (ImRaii.Child("SettingsChild")) using (ImRaii.Child("SettingsChild"))
{ {
DrawBehaviorSettings(); DrawBehaviorSettings();
DrawDesignDefaultSettings();
DrawInterfaceSettings(); DrawInterfaceSettings();
DrawColorSettings(); DrawColorSettings();
overrides.Draw(); overrides.Draw();
@ -101,6 +103,19 @@ public class SettingsTab(
ImGui.NewLine(); 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() private void DrawInterfaceSettings()
{ {
if (!ImGui.CollapsingHeader("Interface")) if (!ImGui.CollapsingHeader("Interface"))