diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-01 18:16:09 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-01 18:16:09 -0400 |
commit | c8ad50dad1d706a1901798f9396f6becfea36c0e (patch) | |
tree | 28bd818a5db39ec5ece1bd141a28de955950463b /src/SMAPI.Internal/ConsoleWriting/ColorfulConsoleWriter.cs | |
parent | 451b70953ff4c0b1b27ae0de203ad99379b45b2a (diff) | |
parent | f78093bdb58d477b400cde3f19b70ffd6ddf833d (diff) | |
download | SMAPI-c8ad50dad1d706a1901798f9396f6becfea36c0e.tar.gz SMAPI-c8ad50dad1d706a1901798f9396f6becfea36c0e.tar.bz2 SMAPI-c8ad50dad1d706a1901798f9396f6becfea36c0e.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Internal/ConsoleWriting/ColorfulConsoleWriter.cs')
-rw-r--r-- | src/SMAPI.Internal/ConsoleWriting/ColorfulConsoleWriter.cs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/SMAPI.Internal/ConsoleWriting/ColorfulConsoleWriter.cs b/src/SMAPI.Internal/ConsoleWriting/ColorfulConsoleWriter.cs index bfe155e0..78db0d65 100644 --- a/src/SMAPI.Internal/ConsoleWriting/ColorfulConsoleWriter.cs +++ b/src/SMAPI.Internal/ConsoleWriting/ColorfulConsoleWriter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using StardewModdingAPI.Toolkit.Utilities; namespace StardewModdingAPI.Internal.ConsoleWriting @@ -11,10 +12,11 @@ namespace StardewModdingAPI.Internal.ConsoleWriting ** Fields *********/ /// <summary>The console text color for each log level.</summary> - private readonly IDictionary<ConsoleLogLevel, ConsoleColor> Colors; + private readonly IDictionary<ConsoleLogLevel, ConsoleColor>? Colors; /// <summary>Whether the current console supports color formatting.</summary> - private readonly bool SupportsColor; + [MemberNotNullWhen(true, nameof(ColorfulConsoleWriter.Colors))] + private bool SupportsColor { get; } /********* @@ -72,10 +74,9 @@ namespace StardewModdingAPI.Internal.ConsoleWriting /// <remarks>The colors here should be kept in sync with the SMAPI config file.</remarks> public static ColorSchemeConfig GetDefaultColorSchemeConfig(MonitorColorScheme useScheme) { - return new ColorSchemeConfig - { - UseScheme = useScheme, - Schemes = new Dictionary<MonitorColorScheme, IDictionary<ConsoleLogLevel, ConsoleColor>> + return new ColorSchemeConfig( + useScheme: useScheme, + schemes: new Dictionary<MonitorColorScheme, IDictionary<ConsoleLogLevel, ConsoleColor>> { [MonitorColorScheme.DarkBackground] = new Dictionary<ConsoleLogLevel, ConsoleColor> { @@ -98,7 +99,7 @@ namespace StardewModdingAPI.Internal.ConsoleWriting [ConsoleLogLevel.Success] = ConsoleColor.DarkGreen } } - }; + ); } @@ -134,7 +135,7 @@ namespace StardewModdingAPI.Internal.ConsoleWriting } // get colors for scheme - return colorConfig.Schemes.TryGetValue(schemeID, out IDictionary<ConsoleLogLevel, ConsoleColor> scheme) + return colorConfig.Schemes.TryGetValue(schemeID, out IDictionary<ConsoleLogLevel, ConsoleColor>? scheme) ? scheme : throw new NotSupportedException($"Unknown color scheme '{schemeID}'."); } |