Skip to content

Commit

Permalink
Add default settings for design configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Nov 27, 2024
1 parent 533c53f commit 4215e0a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 21 deletions.
9 changes: 9 additions & 0 deletions Glamourer/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions Glamourer/Designs/Design.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mod, ModSettings>(other.AssociatedMods);
Tags = [.. other.Tags];
Description = other.Description;
QuickDesign = other.QuickDesign;
ForcedRedraw = other.ForcedRedraw;
ResetAdvancedDyes = other.ResetAdvancedDyes;
Color = other.Color;
AssociatedMods = new SortedList<Mod, ModSettings>(other.AssociatedMods);
Links = Links.Clone();
}

// Metadata
Expand Down
36 changes: 21 additions & 15 deletions Glamourer/Designs/DesignManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}.");
Expand All @@ -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);
Expand All @@ -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(
Expand Down
16 changes: 14 additions & 2 deletions Glamourer/Designs/Links/LinkContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ public List<DesignLink> 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
Expand Down Expand Up @@ -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;
}

Expand Down
15 changes: 15 additions & 0 deletions Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using OtterGui.Text;
using OtterGui.Widgets;

namespace Glamourer.Gui.Tabs.SettingsTab;
Expand Down Expand Up @@ -51,6 +52,7 @@ public void DrawContent()
using (ImRaii.Child("SettingsChild"))
{
DrawBehaviorSettings();
DrawDesignDefaultSettings();
DrawInterfaceSettings();
DrawColorSettings();
overrides.Draw();
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit 4215e0a

Please sign in to comment.