Prechádzať zdrojové kódy

Fix console compatibility with unix platforms

Bepis 4 rokov pred
rodič
commit
dbea82eb2a

+ 6 - 12
BepInEx.Core/ConsoleManager.cs

@@ -71,37 +71,31 @@ namespace BepInEx
 
 		public static void SetConsoleTitle(string title)
 		{
-			if (!ConsoleActive)
-				throw new InvalidOperationException("Console is not currently active");
-
 			switch (Environment.OSVersion.Platform)
 			{
 				case PlatformID.Win32NT:
 				{
+					if (!ConsoleActive)
+						return;
+
 					ConsoleWindow.Title = title;
 					break;
 				}
-				default:
-					throw new PlatformNotSupportedException("Spawning a console is not currently supported on this platform");
 			}
 		}
 
 		public static void SetConsoleColor(ConsoleColor color)
 		{
-			if (!ConsoleActive)
-				throw new InvalidOperationException("Console is not currently active");
-
 			switch (Environment.OSVersion.Platform)
 			{
 				case PlatformID.Win32NT:
 				{
+					if (!ConsoleActive)
+						return;
+
 					Kon.ForegroundColor = color;
 					break;
 				}
-				default:
-				{
-					break;
-				}
 			}
 
 			Console.ForegroundColor = color;

+ 2 - 2
BepInEx.Preloader.Core/Logging/PreloaderLogWriter.cs

@@ -37,9 +37,9 @@ namespace BepInEx.Preloader.Core.Logging
 
 			LogBuilder.Append(log);
 
-			Kon.ForegroundColor = eventArgs.Level.GetConsoleColor();
+			ConsoleManager.SetConsoleColor(eventArgs.Level.GetConsoleColor());
 			ConsoleDirectWrite(log);
-			Kon.ForegroundColor = ConsoleColor.Gray;
+			ConsoleManager.SetConsoleColor(ConsoleColor.Gray);
 		}
 
 		public void ConsoleDirectWrite(string value)