Exemple #1
0
 /// <summary>Construct an instance.</summary>
 /// <param name="platform">The target platform.</param>
 /// <param name="colorConfig">The colors to use for text written to the SMAPI console.</param>
 public ColorfulConsoleWriter(Platform platform, ColorSchemeConfig colorConfig)
 {
     if (colorConfig.UseScheme == MonitorColorScheme.None)
     {
         this.SupportsColor = false;
         this.Colors        = null;
     }
     else
     {
         this.SupportsColor = this.TestColorSupport();
         this.Colors        = this.GetConsoleColorScheme(platform, colorConfig);
     }
 }
Exemple #2
0
        /// <summary>Get the color scheme to use for the current console.</summary>
        /// <param name="platform">The target platform.</param>
        /// <param name="colorConfig">The colors to use for text written to the SMAPI console.</param>
        private IDictionary <ConsoleLogLevel, ConsoleColor> GetConsoleColorScheme(Platform platform, ColorSchemeConfig colorConfig)
        {
            // get color scheme ID
            MonitorColorScheme schemeID = colorConfig.UseScheme;

            if (schemeID == MonitorColorScheme.AutoDetect)
            {
                schemeID = platform == Platform.Mac
                    ? MonitorColorScheme.LightBackground // MacOS doesn't provide console background color info, but it's usually white.
                    : ColorfulConsoleWriter.IsDark(Console.BackgroundColor) ? MonitorColorScheme.DarkBackground : MonitorColorScheme.LightBackground;
            }

            // get colors for scheme
            return(colorConfig.Schemes.TryGetValue(schemeID, out IDictionary <ConsoleLogLevel, ConsoleColor> scheme)
                ? scheme
                : throw new NotSupportedException($"Unknown color scheme '{schemeID}'."));
        }
Exemple #3
0
 /// <summary>Construct an instance.</summary>
 /// <param name="platform">The target platform.</param>
 /// <param name="colorConfig">The colors to use for text written to the SMAPI console.</param>
 public ColorfulConsoleWriter(Platform platform, ColorSchemeConfig colorConfig)
 {
     this.SupportsColor = this.TestColorSupport();
     this.Colors        = this.GetConsoleColorScheme(platform, colorConfig);
 }