From d22ff8fad8d00acb1b1e106053cda1e4fad52a17 Mon Sep 17 00:00:00 2001 From: goat Date: Thu, 2 Jan 2025 17:21:57 +0100 Subject: [PATCH] don't save windows that haven't changed --- .../Interface/Windowing/Persistence/PresetModel.cs | 8 ++++++++ .../Windowing/Persistence/WindowSystemPersistence.cs | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/Windowing/Persistence/PresetModel.cs b/Dalamud/Interface/Windowing/Persistence/PresetModel.cs index db91bad8a..f7910e0b2 100644 --- a/Dalamud/Interface/Windowing/Persistence/PresetModel.cs +++ b/Dalamud/Interface/Windowing/Persistence/PresetModel.cs @@ -49,5 +49,13 @@ internal class PresetModel /// [JsonProperty("a")] public float? Alpha { get; set; } + + /// + /// Gets a value indicating whether this preset is in the default state. + /// + public bool IsDefault => + !this.IsPinned && + !this.IsClickThrough && + !this.Alpha.HasValue; } } diff --git a/Dalamud/Interface/Windowing/Persistence/WindowSystemPersistence.cs b/Dalamud/Interface/Windowing/Persistence/WindowSystemPersistence.cs index 8b884b0e5..a64928003 100644 --- a/Dalamud/Interface/Windowing/Persistence/WindowSystemPersistence.cs +++ b/Dalamud/Interface/Windowing/Persistence/WindowSystemPersistence.cs @@ -41,7 +41,17 @@ internal class WindowSystemPersistence : IServiceType /// The preset window instance. public void SaveWindow(uint id, PresetModel.PresetWindow window) { - this.ActivePreset.Windows[id] = window; + // If the window is in the default state, don't save it to avoid saving every possible window + // if the user has not customized anything. + if (window.IsDefault) + { + this.ActivePreset.Windows.Remove(id); + } + else + { + this.ActivePreset.Windows[id] = window; + } + this.config.QueueSave(); } }