Skip to content

Commit

Permalink
fix objdata directories not saving
Browse files Browse the repository at this point in the history
  • Loading branch information
LeftofZen committed Feb 9, 2024
1 parent 4611e32 commit 8cd9bb0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
19 changes: 11 additions & 8 deletions Gui/GuiSettings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace OpenLoco.ObjectEditor.Gui
{
public class GuiSettings
Expand All @@ -8,32 +11,32 @@ public string ObjDataDirectory
set
{
objectDirectory = value;
_ = ObjDataDirectories.Add(objectDirectory);
ObjDataDirectories ??= [];
ObjDataDirectories.Add(objectDirectory);
}
}
string objectDirectory = string.Empty;
string objectDirectory;

public HashSet<string> ObjDataDirectories { get; } = [];
public HashSet<string> ObjDataDirectories { get; set; }

public string DataDirectory
{
get => dataDirectory;
set
{
dataDirectory = value;
_ = DataDirectories.Add(dataDirectory);
DataDirectories ??= [];
DataDirectories.Add(dataDirectory);
}
}
string dataDirectory = string.Empty;
string dataDirectory;

public HashSet<string> DataDirectories { get; } = [];
public HashSet<string> 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);
}
Expand Down
10 changes: 7 additions & 3 deletions Gui/MainFormModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8cd9bb0

Please sign in to comment.