summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Models/SConfig.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-24 13:49:30 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-24 13:49:30 -0500
commita3f21685049cabf2d824c8060dc0b1de47e9449e (patch)
treead9add30e9da2a50e0ea0245f1546b7378f0d282 /src/SMAPI/Framework/Models/SConfig.cs
parent6521df7b131924835eb797251c1e956fae0d6e13 (diff)
parent277bf082675b98b95bf6184fe3c7a45b969c7ac2 (diff)
downloadSMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.tar.gz
SMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.tar.bz2
SMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/Models/SConfig.cs')
-rw-r--r--src/SMAPI/Framework/Models/SConfig.cs71
1 files changed, 62 insertions, 9 deletions
diff --git a/src/SMAPI/Framework/Models/SConfig.cs b/src/SMAPI/Framework/Models/SConfig.cs
index e2b33160..b778af5d 100644
--- a/src/SMAPI/Framework/Models/SConfig.cs
+++ b/src/SMAPI/Framework/Models/SConfig.cs
@@ -1,3 +1,6 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
using StardewModdingAPI.Internal.ConsoleWriting;
namespace StardewModdingAPI.Framework.Models
@@ -6,6 +9,35 @@ namespace StardewModdingAPI.Framework.Models
internal class SConfig
{
/********
+ ** Fields
+ ********/
+ /// <summary>The default config values, for fields that should be logged if different.</summary>
+ private static readonly IDictionary<string, object> DefaultValues = new Dictionary<string, object>
+ {
+ [nameof(CheckForUpdates)] = true,
+ [nameof(ParanoidWarnings)] =
+#if DEBUG
+ true,
+#else
+ false,
+#endif
+ [nameof(UseBetaChannel)] = Constants.ApiVersion.IsPrerelease(),
+ [nameof(GitHubProjectName)] = "Pathoschild/SMAPI",
+ [nameof(WebApiBaseUrl)] = "https://api.smapi.io",
+ [nameof(VerboseLogging)] = false,
+ [nameof(LogNetworkTraffic)] = false,
+ [nameof(DumpMetadata)] = false
+ };
+
+ /// <summary>The default values for <see cref="SuppressUpdateChecks"/>, to log changes if different.</summary>
+ private static readonly HashSet<string> DefaultSuppressUpdateChecks = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase)
+ {
+ "SMAPI.ConsoleCommands",
+ "SMAPI.SaveBackup"
+ };
+
+
+ /********
** Accessors
********/
/// <summary>Whether to enable development features.</summary>
@@ -15,15 +47,10 @@ namespace StardewModdingAPI.Framework.Models
public bool CheckForUpdates { get; set; }
/// <summary>Whether to add a section to the 'mod issues' list for mods which which directly use potentially sensitive .NET APIs like file or shell access.</summary>
- public bool ParanoidWarnings { get; set; } =
-#if DEBUG
- true;
-#else
- false;
-#endif
+ public bool ParanoidWarnings { get; set; } = (bool)SConfig.DefaultValues[nameof(SConfig.ParanoidWarnings)];
/// <summary>Whether to show beta versions as valid updates.</summary>
- public bool UseBetaChannel { get; set; } = Constants.ApiVersion.IsPrerelease();
+ public bool UseBetaChannel { get; set; } = (bool)SConfig.DefaultValues[nameof(SConfig.UseBetaChannel)];
/// <summary>SMAPI's GitHub project name, used to perform update checks.</summary>
public string GitHubProjectName { get; set; }
@@ -34,13 +61,39 @@ namespace StardewModdingAPI.Framework.Models
/// <summary>Whether SMAPI should log more information about the game context.</summary>
public bool VerboseLogging { get; set; }
+ /// <summary>Whether SMAPI should log network traffic. Best combined with <see cref="VerboseLogging"/>, which includes network metadata.</summary>
+ public bool LogNetworkTraffic { get; set; }
+
/// <summary>Whether to generate a file in the mods folder with detailed metadata about the detected mods.</summary>
public bool DumpMetadata { get; set; }
- /// <summary>The console color scheme to use.</summary>
- public MonitorColorScheme ColorScheme { get; set; }
+ /// <summary>The colors to use for text written to the SMAPI console.</summary>
+ public ColorSchemeConfig ConsoleColors { get; set; }
/// <summary>The mod IDs SMAPI should ignore when performing update checks or validating update keys.</summary>
public string[] SuppressUpdateChecks { get; set; }
+
+
+ /********
+ ** Public methods
+ ********/
+ /// <summary>Get the settings which have been customised by the player.</summary>
+ public IDictionary<string, object> GetCustomSettings()
+ {
+ IDictionary<string, object> custom = new Dictionary<string, object>();
+
+ foreach (var pair in SConfig.DefaultValues)
+ {
+ object value = typeof(SConfig).GetProperty(pair.Key)?.GetValue(this);
+ if (!pair.Value.Equals(value))
+ custom[pair.Key] = value;
+ }
+
+ HashSet<string> curSuppressUpdateChecks = new HashSet<string>(this.SuppressUpdateChecks ?? new string[0], StringComparer.InvariantCultureIgnoreCase);
+ if (SConfig.DefaultSuppressUpdateChecks.Count != curSuppressUpdateChecks.Count || SConfig.DefaultSuppressUpdateChecks.Any(p => !curSuppressUpdateChecks.Contains(p)))
+ custom[nameof(this.SuppressUpdateChecks)] = "[" + string.Join(", ", this.SuppressUpdateChecks ?? new string[0]) + "]";
+
+ return custom;
+ }
}
}