big rewrite
This commit is contained in:
parent
38155b747a
commit
03274fea09
4 changed files with 236 additions and 262 deletions
|
@ -221,7 +221,7 @@ namespace Ryujinx
|
||||||
if (Instance.EnableFileLog)
|
if (Instance.EnableFileLog)
|
||||||
{
|
{
|
||||||
Logger.AddTarget(new AsyncLogTargetWrapper(
|
Logger.AddTarget(new AsyncLogTargetWrapper(
|
||||||
new FileLogTarget(Path.Combine(Program.ApplicationDirectory, "Ryujinx.log")),
|
new FileLogTarget(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx.log")),
|
||||||
1000,
|
1000,
|
||||||
AsyncLogTargetOverflowAction.Block
|
AsyncLogTargetOverflowAction.Block
|
||||||
));
|
));
|
||||||
|
@ -253,7 +253,7 @@ namespace Ryujinx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Program.DiscordIntegrationEnabled = SwitchConfig.EnableDiscordIntegration;
|
MainMenu.DiscordIntegrationEnabled = SwitchConfig.EnableDiscordIntergration;
|
||||||
|
|
||||||
device.EnableDeviceVsync = SwitchConfig.EnableVsync;
|
device.EnableDeviceVsync = SwitchConfig.EnableVsync;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx
|
||||||
{
|
{
|
||||||
public class GeneralSettings : Window
|
public class GeneralSettings : Window
|
||||||
{
|
{
|
||||||
internal HLE.Switch device { get; private set; }
|
private HLE.Switch device { get; set; }
|
||||||
|
|
||||||
internal static Configuration SwitchConfig { get; private set; }
|
internal static Configuration SwitchConfig { get; private set; }
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,35 @@
|
||||||
using Gtk;
|
using DiscordRPC;
|
||||||
|
using Gtk;
|
||||||
using GUI = Gtk.Builder.ObjectAttribute;
|
using GUI = Gtk.Builder.ObjectAttribute;
|
||||||
|
using Ryujinx.Audio;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Graphics.Gal;
|
||||||
|
using Ryujinx.Graphics.Gal.OpenGL;
|
||||||
|
using Ryujinx.Profiler;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Ryujinx
|
namespace Ryujinx
|
||||||
{
|
{
|
||||||
public class MainMenu : Window
|
public class MainMenu : Window
|
||||||
{
|
{
|
||||||
internal HLE.Switch device { get; private set; }
|
public static bool DiscordIntegrationEnabled { get; set; }
|
||||||
|
|
||||||
internal Application gtkapp { get; private set; }
|
public static DiscordRpcClient DiscordClient;
|
||||||
|
|
||||||
internal ListStore TableStore { get; private set; }
|
public static RichPresence DiscordPresence;
|
||||||
|
|
||||||
|
private static IGalRenderer renderer;
|
||||||
|
|
||||||
|
private static IAalOutput audioOut;
|
||||||
|
|
||||||
|
private static HLE.Switch device { get; set; }
|
||||||
|
|
||||||
|
private static Application gtkapp { get; set; }
|
||||||
|
|
||||||
|
private static ListStore TableStore { get; set; }
|
||||||
|
|
||||||
//UI Controls
|
//UI Controls
|
||||||
[GUI] Window MainWin;
|
[GUI] Window MainWin;
|
||||||
|
@ -23,36 +39,71 @@ namespace Ryujinx
|
||||||
[GUI] ScrolledWindow GameTableWindow;
|
[GUI] ScrolledWindow GameTableWindow;
|
||||||
[GUI] GLArea GLScreen;
|
[GUI] GLArea GLScreen;
|
||||||
|
|
||||||
public MainMenu(HLE.Switch _device, Application _gtkapp) : this(new Builder("Ryujinx.GUI.MainMenu.glade"), _device, _gtkapp) { }
|
public MainMenu(string[] args, Application _gtkapp) : this(new Builder("Ryujinx.GUI.MainMenu.glade"), args, _gtkapp) { }
|
||||||
|
|
||||||
private MainMenu(Builder builder, HLE.Switch _device, Application _gtkapp) : base(builder.GetObject("MainWin").Handle)
|
private MainMenu(Builder builder, string[] args, Application _gtkapp) : base(builder.GetObject("MainWin").Handle)
|
||||||
{
|
{
|
||||||
device = _device;
|
renderer = new OglRenderer();
|
||||||
|
|
||||||
|
audioOut = InitializeAudioEngine();
|
||||||
|
|
||||||
|
device = new HLE.Switch(renderer, audioOut);
|
||||||
|
|
||||||
|
Configuration.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.jsonc"));
|
||||||
|
Configuration.InitialConfigure(device);
|
||||||
|
|
||||||
gtkapp = _gtkapp;
|
gtkapp = _gtkapp;
|
||||||
|
|
||||||
if (Program.DiscordIntergrationEnabled)
|
|
||||||
{
|
|
||||||
Program.DiscordPresence.Details = "Main Menu";
|
|
||||||
Program.DiscordPresence.State = "Idling";
|
|
||||||
Program.DiscordPresence.Timestamps = new DiscordRPC.Timestamps(DateTime.UtcNow);
|
|
||||||
|
|
||||||
Program.DiscordClient.SetPresence(Program.DiscordPresence);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.Autoconnect(this);
|
|
||||||
MainWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png");
|
|
||||||
GameTableWindow.Show();
|
|
||||||
GLScreen.Hide();
|
|
||||||
|
|
||||||
ApplyTheme();
|
ApplyTheme();
|
||||||
|
|
||||||
DeleteEvent += Window_Close;
|
DeleteEvent += Window_Close;
|
||||||
|
|
||||||
//disable some buttons
|
if (DiscordIntegrationEnabled)
|
||||||
|
{
|
||||||
|
DiscordClient = new DiscordRpcClient("568815339807309834");
|
||||||
|
DiscordPresence = new RichPresence
|
||||||
|
{
|
||||||
|
Assets = new Assets
|
||||||
|
{
|
||||||
|
LargeImageKey = "ryujinx",
|
||||||
|
LargeImageText = "Ryujinx is an emulator for the Nintendo Switch"
|
||||||
|
},
|
||||||
|
Details = "Main Menu",
|
||||||
|
State = "Idling",
|
||||||
|
Timestamps = new Timestamps(DateTime.UtcNow)
|
||||||
|
};
|
||||||
|
|
||||||
|
DiscordClient.Initialize();
|
||||||
|
DiscordClient.SetPresence(DiscordPresence);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Autoconnect(this);
|
||||||
|
MainWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png");
|
||||||
|
|
||||||
|
if (args.Length == 1)
|
||||||
|
{
|
||||||
|
GameTableWindow.Hide();
|
||||||
|
GLScreen.Show();
|
||||||
|
|
||||||
|
LoadApplication(args[0]);
|
||||||
|
|
||||||
|
using (GlScreen screen = new GlScreen(device, renderer))
|
||||||
|
{
|
||||||
|
screen.MainLoop();
|
||||||
|
|
||||||
|
Profile.FinishProfiling();
|
||||||
|
|
||||||
|
device.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GameTableWindow.Show();
|
||||||
|
GLScreen.Hide();
|
||||||
|
|
||||||
NFC.Sensitive = false;
|
NFC.Sensitive = false;
|
||||||
ControlSettingsMenu.Sensitive = false;
|
ControlSettingsMenu.Sensitive = false;
|
||||||
|
|
||||||
//Games grid thing
|
|
||||||
GameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 0);
|
GameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 0);
|
||||||
GameTable.AppendColumn("Game", new CellRendererText(), "text", 1);
|
GameTable.AppendColumn("Game", new CellRendererText(), "text", 1);
|
||||||
GameTable.AppendColumn("Version", new CellRendererText(), "text", 2);
|
GameTable.AppendColumn("Version", new CellRendererText(), "text", 2);
|
||||||
|
@ -70,6 +121,7 @@ namespace Ryujinx
|
||||||
|
|
||||||
GameTable.Model = TableStore;
|
GameTable.Model = TableStore;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void ApplyTheme()
|
public static void ApplyTheme()
|
||||||
{
|
{
|
||||||
|
@ -93,12 +145,30 @@ namespace Ryujinx
|
||||||
StyleContext.AddProviderForScreen(Gdk.Screen.Default, css_provider, 800);
|
StyleContext.AddProviderForScreen(Gdk.Screen.Default, css_provider, 800);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Events
|
private static void LoadApplication(string path)
|
||||||
private void Row_Activated(object obj, RowActivatedArgs args)
|
|
||||||
{
|
{
|
||||||
TableStore.GetIter(out TreeIter treeiter, new TreePath(args.Path.ToString()));
|
if (Directory.Exists(path))
|
||||||
string path = (string)TableStore.GetValue(treeiter, 6);
|
{
|
||||||
|
string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
|
||||||
|
|
||||||
|
if (romFsFiles.Length == 0)
|
||||||
|
{
|
||||||
|
romFsFiles = Directory.GetFiles(path, "*.romfs");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (romFsFiles.Length > 0)
|
||||||
|
{
|
||||||
|
Logger.PrintInfo(LogClass.Application, "Loading as cart with RomFS.");
|
||||||
|
device.LoadCart(path, romFsFiles[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.PrintInfo(LogClass.Application, "Loading as cart WITHOUT RomFS.");
|
||||||
|
device.LoadCart(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (File.Exists(path))
|
||||||
|
{
|
||||||
switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
|
switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
|
||||||
{
|
{
|
||||||
case ".xci":
|
case ".xci":
|
||||||
|
@ -119,12 +189,54 @@ namespace Ryujinx
|
||||||
device.LoadProgram(path);
|
device.LoadProgram(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.PrintWarning(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DiscordIntegrationEnabled)
|
||||||
|
{
|
||||||
|
if (File.ReadAllLines(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RPsupported.dat")).Contains(device.System.TitleID))
|
||||||
|
{
|
||||||
|
DiscordPresence.Assets.LargeImageKey = device.System.TitleID;
|
||||||
|
}
|
||||||
|
|
||||||
|
DiscordPresence.Details = $"Playing {device.System.TitleName}";
|
||||||
|
DiscordPresence.State = device.System.TitleID.ToUpper();
|
||||||
|
DiscordPresence.Assets.LargeImageText = device.System.TitleName;
|
||||||
|
DiscordPresence.Assets.SmallImageKey = "ryujinx";
|
||||||
|
DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch";
|
||||||
|
DiscordPresence.Timestamps = new Timestamps(DateTime.UtcNow);
|
||||||
|
|
||||||
|
DiscordClient.SetPresence(DiscordPresence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Events
|
||||||
|
private void Row_Activated(object obj, RowActivatedArgs args)
|
||||||
|
{
|
||||||
|
TableStore.GetIter(out TreeIter treeiter, new TreePath(args.Path.ToString()));
|
||||||
|
string path = (string)TableStore.GetValue(treeiter, 6);
|
||||||
|
|
||||||
|
LoadApplication(path);
|
||||||
|
|
||||||
GameTableWindow.Hide();
|
GameTableWindow.Hide();
|
||||||
GLScreen.Show();
|
GLScreen.Show();
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
Application.Quit();
|
|
||||||
|
using (GlScreen screen = new GlScreen(device, renderer))
|
||||||
|
{
|
||||||
|
screen.MainLoop();
|
||||||
|
|
||||||
|
Profile.FinishProfiling();
|
||||||
|
|
||||||
|
device.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
audioOut.Dispose();
|
||||||
|
Logger.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Load_Application_File(object o, EventArgs args)
|
private void Load_Application_File(object o, EventArgs args)
|
||||||
|
@ -139,32 +251,24 @@ namespace Ryujinx
|
||||||
|
|
||||||
if (fc.Run() == (int)ResponseType.Accept)
|
if (fc.Run() == (int)ResponseType.Accept)
|
||||||
{
|
{
|
||||||
switch (System.IO.Path.GetExtension(fc.Filename).ToLowerInvariant())
|
LoadApplication(fc.Filename);
|
||||||
{
|
|
||||||
case ".xci":
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as XCI.");
|
|
||||||
device.LoadXci(fc.Filename);
|
|
||||||
break;
|
|
||||||
case ".nca":
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as NCA.");
|
|
||||||
device.LoadNca(fc.Filename);
|
|
||||||
break;
|
|
||||||
case ".nsp":
|
|
||||||
case ".pfs0":
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as NSP.");
|
|
||||||
device.LoadNsp(fc.Filename);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as homebrew.");
|
|
||||||
device.LoadProgram(fc.Filename);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameTableWindow.Hide();
|
GameTableWindow.Hide();
|
||||||
GLScreen.Show();
|
GLScreen.Show();
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
Application.Quit();
|
|
||||||
|
using (GlScreen screen = new GlScreen(device, renderer))
|
||||||
|
{
|
||||||
|
screen.MainLoop();
|
||||||
|
|
||||||
|
Profile.FinishProfiling();
|
||||||
|
|
||||||
|
device.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
audioOut.Dispose();
|
||||||
|
Logger.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
fc.Destroy();
|
fc.Destroy();
|
||||||
|
@ -176,29 +280,24 @@ namespace Ryujinx
|
||||||
|
|
||||||
if (fc.Run() == (int)ResponseType.Accept)
|
if (fc.Run() == (int)ResponseType.Accept)
|
||||||
{
|
{
|
||||||
string[] romFsFiles = Directory.GetFiles(fc.Filename, "*.istorage");
|
LoadApplication(fc.Filename);
|
||||||
|
|
||||||
if (romFsFiles.Length == 0)
|
|
||||||
{
|
|
||||||
romFsFiles = Directory.GetFiles(fc.Filename, "*.romfs");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (romFsFiles.Length > 0)
|
|
||||||
{
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as cart with RomFS.");
|
|
||||||
device.LoadCart(fc.Filename, romFsFiles[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as cart WITHOUT RomFS.");
|
|
||||||
device.LoadCart(fc.Filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameTableWindow.Hide();
|
GameTableWindow.Hide();
|
||||||
GLScreen.Show();
|
GLScreen.Show();
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
Application.Quit();
|
|
||||||
|
using (GlScreen screen = new GlScreen(device, renderer))
|
||||||
|
{
|
||||||
|
screen.MainLoop();
|
||||||
|
|
||||||
|
Profile.FinishProfiling();
|
||||||
|
|
||||||
|
device.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
audioOut.Dispose();
|
||||||
|
Logger.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
fc.Destroy();
|
fc.Destroy();
|
||||||
|
@ -206,11 +305,17 @@ namespace Ryujinx
|
||||||
|
|
||||||
private void Exit_Pressed(object o, EventArgs args)
|
private void Exit_Pressed(object o, EventArgs args)
|
||||||
{
|
{
|
||||||
|
audioOut.Dispose();
|
||||||
|
DiscordClient.Dispose();
|
||||||
|
Logger.Shutdown();
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Close(object obj, DeleteEventArgs args)
|
private void Window_Close(object obj, DeleteEventArgs args)
|
||||||
{
|
{
|
||||||
|
audioOut.Dispose();
|
||||||
|
DiscordClient.Dispose();
|
||||||
|
Logger.Shutdown();
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,5 +357,25 @@ namespace Ryujinx
|
||||||
about.Run();
|
about.Run();
|
||||||
about.Destroy();
|
about.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Picks an <see cref="IAalOutput"/> audio output renderer supported on this machine
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An <see cref="IAalOutput"/> supported by this machine</returns>
|
||||||
|
private static IAalOutput InitializeAudioEngine()
|
||||||
|
{
|
||||||
|
if (SoundIoAudioOut.IsSupported)
|
||||||
|
{
|
||||||
|
return new SoundIoAudioOut();
|
||||||
|
}
|
||||||
|
else if (OpenALAudioOut.IsSupported)
|
||||||
|
{
|
||||||
|
return new OpenALAudioOut();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new DummyAudioOut();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,12 @@
|
||||||
using DiscordRPC;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Audio;
|
|
||||||
using Ryujinx.Common.Logging;
|
|
||||||
using Ryujinx.Graphics.Gal;
|
|
||||||
using Ryujinx.Graphics.Gal.OpenGL;
|
|
||||||
using Ryujinx.HLE;
|
|
||||||
using Ryujinx.Profiler;
|
using Ryujinx.Profiler;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Ryujinx
|
namespace Ryujinx
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
public static DiscordRpcClient DiscordClient;
|
|
||||||
|
|
||||||
public static RichPresence DiscordPresence;
|
|
||||||
|
|
||||||
public static bool DiscordIntegrationEnabled { get; set; }
|
|
||||||
|
|
||||||
public static string ApplicationDirectory => AppDomain.CurrentDomain.BaseDirectory;
|
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.Title = "Ryujinx Console";
|
Console.Title = "Ryujinx Console";
|
||||||
|
@ -29,44 +15,15 @@ namespace Ryujinx
|
||||||
string systemPATH = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
|
string systemPATH = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
|
||||||
Environment.SetEnvironmentVariable("Path", $"{Path.Combine(parentDir, "bin")};{systemPATH}");
|
Environment.SetEnvironmentVariable("Path", $"{Path.Combine(parentDir, "bin")};{systemPATH}");
|
||||||
|
|
||||||
IGalRenderer renderer = new OglRenderer();
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
|
||||||
IAalOutput audioOut = InitializeAudioEngine();
|
|
||||||
|
|
||||||
Switch device = new Switch(renderer, audioOut);
|
|
||||||
|
|
||||||
Configuration.Load(Path.Combine(ApplicationDirectory, "Config.jsonc"));
|
|
||||||
Configuration.InitialConfigure(device);
|
|
||||||
|
|
||||||
Profile.Initialize();
|
Profile.Initialize();
|
||||||
|
|
||||||
ApplicationLibrary.Init();
|
ApplicationLibrary.Init();
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
||||||
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
|
|
||||||
|
|
||||||
if (DiscordIntegrationEnabled)
|
|
||||||
{
|
|
||||||
DiscordClient = new DiscordRpcClient("568815339807309834");
|
|
||||||
DiscordPresence = new RichPresence
|
|
||||||
{
|
|
||||||
Assets = new Assets
|
|
||||||
{
|
|
||||||
LargeImageKey = "ryujinx",
|
|
||||||
LargeImageText = "Ryujinx is an emulator for the Nintendo Switch"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DiscordClient.Initialize();
|
|
||||||
DiscordClient.SetPresence(DiscordPresence);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.Length == 0)
|
|
||||||
{
|
|
||||||
Gtk.Application.Init();
|
|
||||||
|
|
||||||
var gtkapp = new Gtk.Application("Ryujinx.Ryujinx", GLib.ApplicationFlags.None);
|
var gtkapp = new Gtk.Application("Ryujinx.Ryujinx", GLib.ApplicationFlags.None);
|
||||||
var win = new MainMenu(device, gtkapp);
|
var win = new MainMenu(args, gtkapp);
|
||||||
|
|
||||||
gtkapp.Register(GLib.Cancellable.Current);
|
gtkapp.Register(GLib.Cancellable.Current);
|
||||||
gtkapp.AddWindow(win);
|
gtkapp.AddWindow(win);
|
||||||
|
@ -75,95 +32,9 @@ namespace Ryujinx
|
||||||
Gtk.Application.Run();
|
Gtk.Application.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Directory.Exists(args[0]))
|
|
||||||
{
|
|
||||||
string[] romFsFiles = Directory.GetFiles(args[0], "*.istorage");
|
|
||||||
|
|
||||||
if (romFsFiles.Length == 0)
|
|
||||||
{
|
|
||||||
romFsFiles = Directory.GetFiles(args[0], "*.romfs");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (romFsFiles.Length > 0)
|
|
||||||
{
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as cart with RomFS.");
|
|
||||||
device.LoadCart(args[0], romFsFiles[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as cart WITHOUT RomFS.");
|
|
||||||
device.LoadCart(args[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (File.Exists(args[0]))
|
|
||||||
{
|
|
||||||
switch (Path.GetExtension(args[0]).ToLowerInvariant())
|
|
||||||
{
|
|
||||||
case ".xci":
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as XCI.");
|
|
||||||
device.LoadXci(args[0]);
|
|
||||||
break;
|
|
||||||
case ".nca":
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as NCA.");
|
|
||||||
device.LoadNca(args[0]);
|
|
||||||
break;
|
|
||||||
case ".nsp":
|
|
||||||
case ".pfs0":
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as NSP.");
|
|
||||||
device.LoadNsp(args[0]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Logger.PrintInfo(LogClass.Application, "Loading as homebrew.");
|
|
||||||
device.LoadProgram(args[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.PrintWarning(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DiscordIntegrationEnabled)
|
|
||||||
{
|
|
||||||
if (File.ReadAllLines(Path.Combine(ApplicationDirectory, "RPsupported.dat")).Contains(device.System.TitleID))
|
|
||||||
{
|
|
||||||
DiscordPresence.Assets.LargeImageKey = device.System.TitleID;
|
|
||||||
}
|
|
||||||
|
|
||||||
DiscordPresence.Details = $"Playing {device.System.TitleName}";
|
|
||||||
DiscordPresence.State = device.System.TitleID.ToUpper();
|
|
||||||
DiscordPresence.Assets.LargeImageText = device.System.TitleName;
|
|
||||||
DiscordPresence.Assets.SmallImageKey = "ryujinx";
|
|
||||||
DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch";
|
|
||||||
DiscordPresence.Timestamps = new Timestamps(DateTime.UtcNow);
|
|
||||||
|
|
||||||
DiscordClient.SetPresence(DiscordPresence);
|
|
||||||
}
|
|
||||||
|
|
||||||
using (GlScreen screen = new GlScreen(device, renderer))
|
|
||||||
{
|
|
||||||
screen.MainLoop();
|
|
||||||
|
|
||||||
Profile.FinishProfiling();
|
|
||||||
|
|
||||||
device.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
audioOut.Dispose();
|
|
||||||
|
|
||||||
Logger.Shutdown();
|
|
||||||
|
|
||||||
DiscordClient.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
|
private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Logger.Shutdown();
|
Logger.Shutdown();
|
||||||
|
|
||||||
DiscordClient.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
@ -175,28 +46,6 @@ namespace Ryujinx
|
||||||
if (e.IsTerminating)
|
if (e.IsTerminating)
|
||||||
{
|
{
|
||||||
Logger.Shutdown();
|
Logger.Shutdown();
|
||||||
|
|
||||||
DiscordClient.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Picks an <see cref="IAalOutput"/> audio output renderer supported on this machine
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>An <see cref="IAalOutput"/> supported by this machine</returns>
|
|
||||||
private static IAalOutput InitializeAudioEngine()
|
|
||||||
{
|
|
||||||
if (SoundIoAudioOut.IsSupported)
|
|
||||||
{
|
|
||||||
return new SoundIoAudioOut();
|
|
||||||
}
|
|
||||||
else if (OpenALAudioOut.IsSupported)
|
|
||||||
{
|
|
||||||
return new OpenALAudioOut();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new DummyAudioOut();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue