-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to custom settings file/serialization.
The built-in .NET settings system works fine for regular builds, but keeps changing the directory path used for published builds even if the assembly info hasn't changed. Updates the Settings system to use a JSON file in the app directory, same as where autosaves, logs, etc. go. Updates the minor version number, as recent updates have made significant changes and can no longer be considered a hotfix.
- Loading branch information
1 parent
14bd801
commit 5e17bdb
Showing
11 changed files
with
94 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 0 additions & 75 deletions
75
Focus.Apps.EasyNpc/Configuration/BundlerSettings.Designer.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using Focus.Apps.EasyNpc.Build; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Newtonsoft.Json.Serialization; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.IO; | ||
|
||
namespace Focus.Apps.EasyNpc.Configuration | ||
{ | ||
public class Settings | ||
{ | ||
// This needs to be first (contrary to default sorting rules) so that it can be used in the Default | ||
// construction. | ||
private static readonly JsonSerializer Serializer = new() | ||
{ | ||
ContractResolver = new DefaultContractResolver | ||
{ | ||
NamingStrategy = new CamelCaseNamingStrategy(), | ||
}, | ||
Formatting = Formatting.Indented, | ||
}; | ||
|
||
public static Settings Default = new(ProgramData.SettingsPath); | ||
|
||
public List<BuildWarningSuppression> BuildWarningWhitelist { get; set; } = new(); | ||
public string ModRootDirectory { get; set; } | ||
public string MugshotsDirectory { get; set; } | ||
|
||
private readonly string path; | ||
|
||
public Settings(string path) | ||
{ | ||
this.path = path; | ||
Load(); | ||
} | ||
|
||
public void Save() | ||
{ | ||
using var fs = File.Create(path); | ||
using var streamWriter = new StreamWriter(fs); | ||
using var jsonWriter = new JsonTextWriter(streamWriter); | ||
Serializer.Serialize(jsonWriter, this); | ||
} | ||
|
||
private void Load() | ||
{ | ||
if (!File.Exists(path)) | ||
return; | ||
using var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); | ||
using var streamReader = new StreamReader(fs); | ||
using var jsonReader = new JsonTextReader(streamReader); | ||
Serializer.Populate(jsonReader, this); | ||
} | ||
} | ||
|
||
public class BuildWarningSuppression | ||
{ | ||
public string PluginName { get; set; } | ||
[JsonProperty(ItemConverterType = typeof(StringEnumConverter))] | ||
public List<BuildWarningId> IgnoredWarnings { get; set; } = new(); | ||
|
||
public BuildWarningSuppression() | ||
{ | ||
} | ||
|
||
public BuildWarningSuppression(string pluginName, IEnumerable<BuildWarningId> ignoredWarnings) | ||
{ | ||
PluginName = pluginName; | ||
IgnoredWarnings = ignoredWarnings.ToList(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters