diff --git a/Gui/GuiSettings.cs b/Gui/GuiSettings.cs index e7f1cf2c..3c8257b1 100644 --- a/Gui/GuiSettings.cs +++ b/Gui/GuiSettings.cs @@ -1,3 +1,6 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; + namespace OpenLoco.ObjectEditor.Gui { public class GuiSettings @@ -8,12 +11,13 @@ public string ObjDataDirectory set { objectDirectory = value; - _ = ObjDataDirectories.Add(objectDirectory); + ObjDataDirectories ??= []; + ObjDataDirectories.Add(objectDirectory); } } - string objectDirectory = string.Empty; + string objectDirectory; - public HashSet ObjDataDirectories { get; } = []; + public HashSet ObjDataDirectories { get; set; } public string DataDirectory { @@ -21,19 +25,18 @@ public string DataDirectory set { dataDirectory = value; - _ = DataDirectories.Add(dataDirectory); + DataDirectories ??= []; + DataDirectories.Add(dataDirectory); } } - string dataDirectory = string.Empty; + string dataDirectory; - public HashSet DataDirectories { get; } = []; + public HashSet DataDirectories { get; set; } public string PaletteFile { get; set; } = "palette.png"; public string IndexFileName { get; set; } = "objectIndex.json"; - public string G1DatFileName { get; set; } = "g1.DAT"; - public string GetObjDataFullPath(string fileName) => Path.Combine(ObjDataDirectory, fileName); public string GetDataFullPath(string fileName) => Path.Combine(DataDirectory, fileName); } diff --git a/Gui/MainFormModel.cs b/Gui/MainFormModel.cs index 293c7ad3..5dc76a56 100644 --- a/Gui/MainFormModel.cs +++ b/Gui/MainFormModel.cs @@ -166,9 +166,13 @@ static bool ValidateSettings(GuiSettings settings, ILogger logger) public void SaveSettings() { - var options = GetOptions(); - var text = JsonSerializer.Serialize(Settings, options); - File.WriteAllText(SettingsFile, text); + //if (Settings.HasChanges) + { + var options = GetOptions(); + var text = JsonSerializer.Serialize(Settings, options); + File.WriteAllText(SettingsFile, text); + //Settings.HasChanges = false; + } } // this method loads every single object entirely. it takes a long time to run