Program.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Gtk;
  2. using Ryujinx.Common.Logging;
  3. using Ryujinx.Profiler;
  4. using Ryujinx.UI;
  5. using System;
  6. using System.IO;
  7. namespace Ryujinx
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.Title = "Ryujinx Console";
  14. string systemPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
  15. Environment.SetEnvironmentVariable("Path", $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")};{systemPath}");
  16. AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
  17. AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
  18. Profile.Initialize();
  19. Application.Init();
  20. Application gtkApplication = new Application("Ryujinx.Ryujinx", GLib.ApplicationFlags.None);
  21. MainWindow mainWindow = new MainWindow(args, gtkApplication);
  22. gtkApplication.Register(GLib.Cancellable.Current);
  23. gtkApplication.AddWindow(mainWindow);
  24. mainWindow.Show();
  25. Application.Run();
  26. }
  27. private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
  28. {
  29. Logger.Shutdown();
  30. }
  31. private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  32. {
  33. var exception = e.ExceptionObject as Exception;
  34. Logger.PrintError(LogClass.Emulation, $"Unhandled exception caught: {exception}");
  35. if (e.IsTerminating)
  36. {
  37. Logger.Shutdown();
  38. }
  39. }
  40. }
  41. }