2019-09-02 17:03:57 +01:00
|
|
|
using Gtk;
|
2018-10-17 14:15:50 -03:00
|
|
|
using Ryujinx.Common.Logging;
|
2019-04-26 05:53:10 +01:00
|
|
|
using Ryujinx.Profiler;
|
2019-11-29 04:32:51 +00:00
|
|
|
using Ryujinx.Ui;
|
2018-02-04 20:08:20 -03:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
namespace Ryujinx
|
|
|
|
{
|
|
|
|
class Program
|
|
|
|
{
|
|
|
|
static void Main(string[] args)
|
|
|
|
{
|
2018-02-09 01:43:22 +01:00
|
|
|
Console.Title = "Ryujinx Console";
|
|
|
|
|
2019-09-02 17:03:57 +01:00
|
|
|
string systemPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
|
|
|
|
Environment.SetEnvironmentVariable("Path", $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")};{systemPath}");
|
2019-04-26 05:53:10 +01:00
|
|
|
|
2019-01-31 04:49:15 +02:00
|
|
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
|
|
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
|
2019-11-29 04:32:51 +00:00
|
|
|
GLib.ExceptionManager.UnhandledException += Glib_UnhandledException;
|
2018-04-24 15:57:39 -03:00
|
|
|
|
2019-09-02 17:03:57 +01:00
|
|
|
Profile.Initialize();
|
2018-08-16 20:47:36 -03:00
|
|
|
|
2019-09-02 17:03:57 +01:00
|
|
|
Application.Init();
|
2019-04-26 05:53:10 +01:00
|
|
|
|
2019-11-29 04:32:51 +00:00
|
|
|
string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFs", "system", "prod.keys");
|
|
|
|
string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys");
|
|
|
|
if (!File.Exists(appDataPath) && !File.Exists(userProfilePath))
|
|
|
|
{
|
|
|
|
GtkDialog.CreateErrorDialog($"Key file was not found. Please refer to `KEYS.md` for more info");
|
|
|
|
}
|
2018-02-04 20:08:20 -03:00
|
|
|
|
2019-11-29 04:32:51 +00:00
|
|
|
MainWindow mainWindow = new MainWindow();
|
2019-09-02 17:03:57 +01:00
|
|
|
mainWindow.Show();
|
2019-05-30 21:27:43 +01:00
|
|
|
|
2019-09-08 03:59:41 +02:00
|
|
|
if (args.Length == 1)
|
|
|
|
{
|
|
|
|
mainWindow.LoadApplication(args[0]);
|
|
|
|
}
|
|
|
|
|
2019-09-02 17:03:57 +01:00
|
|
|
Application.Run();
|
2018-02-04 20:08:20 -03:00
|
|
|
}
|
2018-11-15 13:22:50 +11:00
|
|
|
|
2019-01-31 04:49:15 +02:00
|
|
|
private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
|
|
|
|
{
|
2019-02-11 23:00:32 +11:00
|
|
|
Logger.Shutdown();
|
2019-01-31 04:49:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
|
|
{
|
2019-11-29 04:32:51 +00:00
|
|
|
Exception exception = e.ExceptionObject as Exception;
|
2019-01-31 04:49:15 +02:00
|
|
|
|
|
|
|
Logger.PrintError(LogClass.Emulation, $"Unhandled exception caught: {exception}");
|
|
|
|
|
|
|
|
if (e.IsTerminating)
|
|
|
|
{
|
2019-02-11 23:00:32 +11:00
|
|
|
Logger.Shutdown();
|
2018-11-15 13:22:50 +11:00
|
|
|
}
|
|
|
|
}
|
2019-11-29 04:32:51 +00:00
|
|
|
|
|
|
|
private static void Glib_UnhandledException(GLib.UnhandledExceptionArgs e)
|
|
|
|
{
|
|
|
|
Exception exception = e.ExceptionObject as Exception;
|
|
|
|
|
|
|
|
Logger.PrintError(LogClass.Application, $"Unhandled exception caught: {exception}");
|
|
|
|
|
|
|
|
if (e.IsTerminating)
|
|
|
|
{
|
|
|
|
Logger.Shutdown();
|
|
|
|
}
|
|
|
|
}
|
2018-02-04 20:08:20 -03:00
|
|
|
}
|
2019-09-02 17:03:57 +01:00
|
|
|
}
|