Program.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. if (args.Length == 1)
  26. {
  27. mainWindow.LoadApplication(args[0]);
  28. }
  29. Application.Run();
  30. }
  31. private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
  32. {
  33. Logger.Shutdown();
  34. }
  35. private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  36. {
  37. var exception = e.ExceptionObject as Exception;
  38. Logger.PrintError(LogClass.Emulation, $"Unhandled exception caught: {exception}");
  39. if (e.IsTerminating)
  40. {
  41. Logger.Shutdown();
  42. }
  43. }
  44. }
  45. }