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,
}
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);

View file

@ -31,7 +31,11 @@ public sealed class Design : DesignBase, ISavable, IDesignStandIn
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

View file

@ -104,6 +104,9 @@ public sealed class DesignManager : DesignEditor
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}.");
@ -123,6 +126,9 @@ public sealed class DesignManager : DesignEditor
Identifier = CreateNewGuid(),
Name = actualName,
Index = Designs.Count,
ForcedRedraw = Config.DefaultDesignSettings.AlwaysForceRedrawing,
ResetAdvancedDyes = Config.DefaultDesignSettings.ResetAdvancedDyes,
QuickDesign = Config.DefaultDesignSettings.ShowQuickDesignBar,
};
Designs.Add(design);

View file

@ -14,6 +14,16 @@ public sealed class LinkContainer : List<DesignLink>
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 sealed class LinkContainer : List<DesignLink>
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;
}

View file

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