public void ShowConsole() { _consoleEnabled = ConsoleAllocator.Alloc(); Colorful.Console.BackgroundColor = BackgroundColor; Colorful.Console.ForegroundColor = TextColor; Colorful.Console.Clear(); }
/* Default constructor */ /// <summary> /// Creates a new console instance, asynchronously initializing the console. /// </summary> /// <param name="enabled">True if console is enabled, else false.</param> /// <param name="logger">The logger associated with the console.</param> /// <param name="proxy">Proxy to the system console behind the scenes.</param> public Console(bool enabled, Logger logger, IConsoleProxy proxy) { IsEnabled = enabled; if (!IsEnabled) { return; } _consoleProxy = proxy; _logger = logger; _logger.WaitForConsoleInitFunc = WaitForConsoleInit; _logger.OnWriteLine += OnWriteLine; _logger.OnWrite += OnWrite; Task.Run(() => { var consoleAllocated = ConsoleAllocator.Alloc(); if (!consoleAllocated) { return; } _consoleCtrlDelegate = NotifyOnConsoleClose; Kernel32.SetConsoleCtrlHandler(_consoleCtrlDelegate, true); _consoleProxy.SetBackColor(_logger.BackgroundColor); _consoleProxy.SetForeColor(_logger.TextColor); _consoleProxy.Clear(); ReloadedBannerLogger.PrintBanner(proxy, logger); IsReady = true; FlushQueuedMessages(); }); }
public override void Initialize() { #if DEBUG InitLogging(); if (Globals.IsWindows()) { ConsoleAllocator.ShowConsoleWindow(); } #endif AvaloniaXamlLoader.Load(this); }
public static int Main(string[] args) { if (args.Length != 0) { ConsoleAllocator.ShowConsoleWindow(); } // run windowed App app = new App(); app.InitializeComponent(); app.Run(); return(0); }
public static void Initialize() { foreach (var arg in Environment.GetCommandLineArgs()) { if (arg == StartupArguments.DisableFancyColors) { ConsoleAllocator.FancyColorsEnabled = false; } if (arg == StartupArguments.AllocateConsole) { ConsoleAllocator.Redirect(); ConsoleEnabled = true; } } var version = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; EarlyLog.Info($"Centrifuge bootstrap for Reactor Mod Loader and API. Version {version}. Unity {ApplicationBridge.UnityVersion}"); if (ConsoleEnabled) { EarlyLog.Info($"Diagnostics mode enabled. Remove '{StartupArguments.AllocateConsole}' command line argument to disable."); } if (ApplicationBridge.GetRunningUnityGeneration() == UnityGeneration.Unity4OrOlder) { EarlyLog.Error("Centrifuge requires Unity 5 or newer. Terminating."); return; } EarlyLog.Info("Trying to find Centrifuge Reactor DLL..."); var reactorPath = GetCrossPlatformCompatibleReactorPath(); if (!File.Exists(reactorPath)) { EarlyLog.Error($"Centrifuge Reactor DLL could not be found at '{reactorPath}'. Mods will not be loaded."); return; } Type proxyType; try { EarlyLog.Info("Validating and loading Centrifuge Reactor DLL..."); Assembly.LoadFrom(reactorPath); EarlyLog.Info("Building manager proxy component for Unity Engine..."); proxyType = new ManagerProxyBuilder().WriteDynamicAssemblyAndLoadProxyType(); if (proxyType == null) { EarlyLog.Info("Failed."); return; } } catch (ReflectionTypeLoadException rtle) { EarlyLog.Exception(rtle); EarlyLog.Info(" --- LOADER EXCEPTIONS FOLLOW --- "); foreach (var lex in rtle.LoaderExceptions) { EarlyLog.Exception(lex); } return; } catch (Exception ex) { EarlyLog.Exception(ex); return; } try { EarlyLog.Info("Creating Reactor Manager GameObject..."); ReactorManagerObject = GameObjectBridge.CreateGameObject("com.github.ciastex/ReactorModLoaderProxy"); } catch (Exception e) { EarlyLog.Exception(e); return; } EarlyLog.Info("About to add component to Reactor Manager GameObject."); object proxyComponent; try { proxyComponent = GameObjectBridge.AttachComponentTo(ReactorManagerObject, proxyType); } catch (Exception e) { EarlyLog.Exception(e); return; } if (proxyComponent == null) { EarlyLog.Error("Manager proxy component has failed to attach when it wasn't really supposed to fail on Unity 5+."); EarlyLog.Info("Report this stuff to https://github.com/Ciastex/Centrifuge/issues."); EarlyLog.Info("Make sure to check for and - if existing - include your game's output_log.txt (and/or Player.log) in the report."); EarlyLog.Info("Definitely include this entire log as well."); EarlyLog.Info("Otherwise I'll be very angry and ask you for this stuff in a very rude manner."); if (Platform.IsUnix()) { EarlyLog.Info("Look in ~/.config/unity3d/<CompanyName>/<GameName>/ for any .log and/or .txt files."); } else { var path = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "\\AppData\\LocalLow"); EarlyLog.Info($"Look in {path}\\<CompanyName>\\<GameName> for any .log and/or .txt files."); } } EarlyLog.Info(" --- BOOTSTRAPPER FINISHED --- "); }