2019-09-02 16:03:57 +00:00
|
|
|
using Gtk;
|
2018-10-17 17:15:50 +00:00
|
|
|
using Ryujinx.Common.Logging;
|
2019-12-21 19:52:31 +00:00
|
|
|
using Ryujinx.Configuration;
|
2020-02-06 11:25:47 +00:00
|
|
|
using Ryujinx.Debugger.Profiler;
|
2019-11-29 04:32:51 +00:00
|
|
|
using Ryujinx.Ui;
|
2018-02-04 23:08:20 +00:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
namespace Ryujinx
|
|
|
|
{
|
|
|
|
class Program
|
|
|
|
{
|
|
|
|
static void Main(string[] args)
|
|
|
|
{
|
2018-02-09 00:43:22 +00:00
|
|
|
Console.Title = "Ryujinx Console";
|
|
|
|
|
2019-09-02 16:03:57 +00:00
|
|
|
string systemPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
|
|
|
|
Environment.SetEnvironmentVariable("Path", $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")};{systemPath}");
|
2019-04-26 04:53:10 +00:00
|
|
|
|
2019-12-21 19:52:31 +00:00
|
|
|
GLib.ExceptionManager.UnhandledException += Glib_UnhandledException;
|
|
|
|
|
|
|
|
// Initialize the configuration
|
|
|
|
ConfigurationState.Initialize();
|
|
|
|
|
|
|
|
// Initialize the logger system
|
|
|
|
LoggerModule.Initialize();
|
|
|
|
|
|
|
|
// Initialize Discord integration
|
|
|
|
DiscordIntegrationModule.Initialize();
|
|
|
|
|
|
|
|
string configurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json");
|
|
|
|
|
|
|
|
// Now load the configuration as the other subsystems are now registered
|
|
|
|
if (File.Exists(configurationPath))
|
|
|
|
{
|
|
|
|
ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(configurationPath);
|
|
|
|
ConfigurationState.Instance.Load(configurationFileFormat);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No configuration, we load the default values and save it on disk
|
|
|
|
ConfigurationState.Instance.LoadDefault();
|
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(configurationPath);
|
|
|
|
}
|
|
|
|
|
2019-09-02 16:03:57 +00:00
|
|
|
Profile.Initialize();
|
2018-08-16 23:47:36 +00:00
|
|
|
|
2019-09-02 16:03:57 +00:00
|
|
|
Application.Init();
|
2019-04-26 04:53:10 +00:00
|
|
|
|
2020-01-05 11:49:44 +00:00
|
|
|
string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx", "system", "prod.keys");
|
2019-11-29 04:32:51 +00:00
|
|
|
string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys");
|
2020-01-05 15:39:35 +00:00
|
|
|
if (!File.Exists(appDataPath) && !File.Exists(userProfilePath) && !Migration.IsMigrationNeeded())
|
2019-11-29 04:32:51 +00:00
|
|
|
{
|
2020-01-05 11:49:44 +00:00
|
|
|
GtkDialog.CreateErrorDialog("Key file was not found. Please refer to `KEYS.md` for more info");
|
2019-11-29 04:32:51 +00:00
|
|
|
}
|
2018-02-04 23:08:20 +00:00
|
|
|
|
2019-11-29 04:32:51 +00:00
|
|
|
MainWindow mainWindow = new MainWindow();
|
2019-09-02 16:03:57 +00:00
|
|
|
mainWindow.Show();
|
2019-05-30 20:27:43 +00:00
|
|
|
|
2019-09-08 01:59:41 +00:00
|
|
|
if (args.Length == 1)
|
|
|
|
{
|
|
|
|
mainWindow.LoadApplication(args[0]);
|
|
|
|
}
|
|
|
|
|
2019-09-02 16:03:57 +00:00
|
|
|
Application.Run();
|
2018-02-04 23:08:20 +00:00
|
|
|
}
|
2018-11-15 02:22:50 +00: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 23:08:20 +00:00
|
|
|
}
|
2019-09-02 16:03:57 +00:00
|
|
|
}
|