2020-06-16 20:28:02 +02:00
|
|
|
using ARMeilleure.Translation.PTC;
|
2019-09-02 18:03:57 +02:00
|
|
|
using Gtk;
|
2018-10-17 19:15:50 +02:00
|
|
|
using Ryujinx.Common.Logging;
|
2020-05-04 04:15:27 +02:00
|
|
|
using Ryujinx.Common.SystemInfo;
|
2019-12-21 20:52:31 +01:00
|
|
|
using Ryujinx.Configuration;
|
2020-02-06 12:25:47 +01:00
|
|
|
using Ryujinx.Debugger.Profiler;
|
2019-11-29 05:32:51 +01:00
|
|
|
using Ryujinx.Ui;
|
2020-02-12 01:56:19 +01:00
|
|
|
using OpenTK;
|
2018-02-05 00:08:20 +01:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
2020-02-12 14:35:39 +01:00
|
|
|
using System.Reflection;
|
2018-02-05 00:08:20 +01:00
|
|
|
|
|
|
|
namespace Ryujinx
|
|
|
|
{
|
|
|
|
class Program
|
|
|
|
{
|
2020-02-12 14:35:39 +01:00
|
|
|
public static string Version { get; private set; }
|
|
|
|
|
2020-02-14 20:19:13 +01:00
|
|
|
public static string ConfigurationPath { get; set; }
|
2020-04-25 15:01:32 +02:00
|
|
|
|
2018-02-05 00:08:20 +01:00
|
|
|
static void Main(string[] args)
|
|
|
|
{
|
2020-02-12 01:56:19 +01:00
|
|
|
Toolkit.Init(new ToolkitOptions
|
|
|
|
{
|
|
|
|
Backend = PlatformBackend.PreferNative,
|
|
|
|
EnableHighResolution = true
|
|
|
|
});
|
|
|
|
|
2020-02-12 14:35:39 +01:00
|
|
|
Version = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
|
|
|
|
2020-02-14 11:33:22 +01:00
|
|
|
Console.Title = $"Ryujinx Console {Version}";
|
|
|
|
|
2019-09-02 18:03:57 +02:00
|
|
|
string systemPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
|
|
|
|
Environment.SetEnvironmentVariable("Path", $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")};{systemPath}");
|
2019-04-26 06:53:10 +02:00
|
|
|
|
2019-12-21 20:52:31 +01:00
|
|
|
GLib.ExceptionManager.UnhandledException += Glib_UnhandledException;
|
|
|
|
|
|
|
|
// Initialize the configuration
|
|
|
|
ConfigurationState.Initialize();
|
|
|
|
|
|
|
|
// Initialize the logger system
|
|
|
|
LoggerModule.Initialize();
|
|
|
|
|
|
|
|
// Initialize Discord integration
|
|
|
|
DiscordIntegrationModule.Initialize();
|
|
|
|
|
2020-02-14 20:19:13 +01:00
|
|
|
string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json");
|
2020-02-14 23:07:22 +01:00
|
|
|
string globalBasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
|
|
|
|
string globalConfigurationPath = Path.Combine(globalBasePath, "Config.json");
|
2019-12-21 20:52:31 +01:00
|
|
|
|
|
|
|
// Now load the configuration as the other subsystems are now registered
|
2020-02-14 20:19:13 +01:00
|
|
|
if (File.Exists(localConfigurationPath))
|
2019-12-21 20:52:31 +01:00
|
|
|
{
|
2020-02-14 20:19:13 +01:00
|
|
|
ConfigurationPath = localConfigurationPath;
|
|
|
|
|
|
|
|
ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(localConfigurationPath);
|
|
|
|
|
2020-03-19 23:37:55 +01:00
|
|
|
ConfigurationState.Instance.Load(configurationFileFormat, ConfigurationPath);
|
2020-02-14 20:19:13 +01:00
|
|
|
}
|
|
|
|
else if (File.Exists(globalConfigurationPath))
|
|
|
|
{
|
|
|
|
ConfigurationPath = globalConfigurationPath;
|
|
|
|
|
|
|
|
ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(globalConfigurationPath);
|
|
|
|
|
2020-03-19 23:37:55 +01:00
|
|
|
ConfigurationState.Instance.Load(configurationFileFormat, ConfigurationPath);
|
2019-12-21 20:52:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No configuration, we load the default values and save it on disk
|
2020-02-14 20:19:13 +01:00
|
|
|
ConfigurationPath = globalConfigurationPath;
|
|
|
|
|
2020-02-14 23:07:22 +01:00
|
|
|
// Make sure to create the Ryujinx directory if needed.
|
|
|
|
Directory.CreateDirectory(globalBasePath);
|
|
|
|
|
2019-12-21 20:52:31 +01:00
|
|
|
ConfigurationState.Instance.LoadDefault();
|
2020-02-14 20:19:13 +01:00
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(globalConfigurationPath);
|
2019-12-21 20:52:31 +01:00
|
|
|
}
|
|
|
|
|
2020-05-07 15:24:33 +02:00
|
|
|
Logger.PrintInfo(LogClass.Application, $"Ryujinx Version: {Version}");
|
|
|
|
|
|
|
|
Logger.PrintInfo(LogClass.Application, $"Operating System: {SystemInfo.Instance.OsDescription}");
|
|
|
|
Logger.PrintInfo(LogClass.Application, $"CPU: {SystemInfo.Instance.CpuName}");
|
|
|
|
Logger.PrintInfo(LogClass.Application, $"Total RAM: {SystemInfo.Instance.RamSizeInMB}");
|
|
|
|
|
2019-09-02 18:03:57 +02:00
|
|
|
Profile.Initialize();
|
2018-08-17 01:47:36 +02:00
|
|
|
|
2019-09-02 18:03:57 +02:00
|
|
|
Application.Init();
|
2019-04-26 06:53:10 +02:00
|
|
|
|
2020-02-14 23:07:22 +01:00
|
|
|
string globalProdKeysPath = Path.Combine(globalBasePath, "system", "prod.keys");
|
|
|
|
string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys");
|
|
|
|
if (!File.Exists(globalProdKeysPath) && !File.Exists(userProfilePath) && !Migration.IsMigrationNeeded())
|
2019-11-29 05:32:51 +01:00
|
|
|
{
|
2020-02-06 12:38:24 +01:00
|
|
|
GtkDialog.CreateWarningDialog("Key file was not found", "Please refer to `KEYS.md` for more info");
|
2019-11-29 05:32:51 +01:00
|
|
|
}
|
2018-02-05 00:08:20 +01:00
|
|
|
|
2019-11-29 05:32:51 +01:00
|
|
|
MainWindow mainWindow = new MainWindow();
|
2019-09-02 18:03:57 +02:00
|
|
|
mainWindow.Show();
|
2019-05-30 22:27:43 +02:00
|
|
|
|
2019-09-08 03:59:41 +02:00
|
|
|
if (args.Length == 1)
|
|
|
|
{
|
|
|
|
mainWindow.LoadApplication(args[0]);
|
|
|
|
}
|
|
|
|
|
2019-09-02 18:03:57 +02:00
|
|
|
Application.Run();
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
2018-11-15 03:22:50 +01:00
|
|
|
|
2019-11-29 05:32:51 +01:00
|
|
|
private static void Glib_UnhandledException(GLib.UnhandledExceptionArgs e)
|
|
|
|
{
|
|
|
|
Exception exception = e.ExceptionObject as Exception;
|
|
|
|
|
|
|
|
Logger.PrintError(LogClass.Application, $"Unhandled exception caught: {exception}");
|
|
|
|
|
2020-06-16 20:28:02 +02:00
|
|
|
Ptc.Close();
|
|
|
|
PtcProfiler.Stop();
|
|
|
|
|
2019-11-29 05:32:51 +01:00
|
|
|
if (e.IsTerminating)
|
|
|
|
{
|
|
|
|
Logger.Shutdown();
|
2020-06-16 20:28:02 +02:00
|
|
|
|
|
|
|
Ptc.Dispose();
|
|
|
|
PtcProfiler.Dispose();
|
2019-11-29 05:32:51 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
2020-06-16 20:28:02 +02:00
|
|
|
}
|