Program.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. GLib.ExceptionManager.UnhandledException += Glib_UnhandledException;
  19. Profile.Initialize();
  20. Application.Init();
  21. string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFs", "system", "prod.keys");
  22. string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys");
  23. if (!File.Exists(appDataPath) && !File.Exists(userProfilePath))
  24. {
  25. GtkDialog.CreateErrorDialog($"Key file was not found. Please refer to `KEYS.md` for more info");
  26. }
  27. MainWindow mainWindow = new MainWindow();
  28. mainWindow.Show();
  29. if (args.Length == 1)
  30. {
  31. mainWindow.LoadApplication(args[0]);
  32. }
  33. Application.Run();
  34. }
  35. private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
  36. {
  37. Logger.Shutdown();
  38. }
  39. private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  40. {
  41. Exception exception = e.ExceptionObject as Exception;
  42. Logger.PrintError(LogClass.Emulation, $"Unhandled exception caught: {exception}");
  43. if (e.IsTerminating)
  44. {
  45. Logger.Shutdown();
  46. }
  47. }
  48. private static void Glib_UnhandledException(GLib.UnhandledExceptionArgs e)
  49. {
  50. Exception exception = e.ExceptionObject as Exception;
  51. Logger.PrintError(LogClass.Application, $"Unhandled exception caught: {exception}");
  52. if (e.IsTerminating)
  53. {
  54. Logger.Shutdown();
  55. }
  56. }
  57. }
  58. }