diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index e0b7490dd8..334cba1260 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -565,18 +565,34 @@ namespace Ryujinx.HLE.HOS if (nacpSize != 0) { input.Seek(obj.FileSize + (long)nacpOffset, SeekOrigin.Begin); - using (MemoryStream stream = new MemoryStream(reader.ReadBytes((int)nacpSize))) { ControlData = new Nacp(stream); } + using (MemoryStream stream = new MemoryStream(reader.ReadBytes((int)nacpSize))) + { + ControlData = new Nacp(stream); + } metaData.TitleName = ControlData.Descriptions[(int)State.DesiredTitleLanguage].Title; + if (string.IsNullOrWhiteSpace(metaData.TitleName)) { metaData.TitleName = ControlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Title)).Title; } metaData.Aci0.TitleId = ControlData.PresenceGroupId; - if (metaData.Aci0.TitleId == 0) { metaData.Aci0.TitleId = ControlData.SaveDataOwnerId; } - if (metaData.Aci0.TitleId == 0) { metaData.Aci0.TitleId = ControlData.AddOnContentBaseId - 0x1000; } - if (metaData.Aci0.TitleId.ToString("x16") == "fffffffffffff000") { metaData.Aci0.TitleId = 0000000000000000; } + + if (metaData.Aci0.TitleId == 0) + { + metaData.Aci0.TitleId = ControlData.SaveDataOwnerId; + } + + if (metaData.Aci0.TitleId == 0) + { + metaData.Aci0.TitleId = ControlData.AddOnContentBaseId - 0x1000; + } + + if (metaData.Aci0.TitleId.ToString("x16") == "fffffffffffff000") + { + metaData.Aci0.TitleId = 0000000000000000; + } } } else @@ -702,7 +718,9 @@ namespace Ryujinx.HLE.HOS // It's only safe to release resources once all threads // have exited. ThreadCounter.Signal(); - //ThreadCounter.Wait(); + //ThreadCounter.Wait(); // FIXME: Uncomment this + // BODY: Right now, guest processes don't exit properly because the logic waits for them to exit. + // BODY: However, this doesn't happen when you close the main window so we need to find a way to make them exit gracefully Scheduler.Dispose(); diff --git a/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationInfo.cs b/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationInfo.cs index e992331023..7431d7dd25 100644 --- a/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationInfo.cs +++ b/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationInfo.cs @@ -4,8 +4,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { public string Name { get; private set; } - public int Category { get; private set; } - public ulong TitleId { get; private set; } + public int Category { get; private set; } + public ulong TitleId { get; private set; } public ulong CodeAddress { get; private set; } public int CodePagesCount { get; private set; } diff --git a/Ryujinx/Configuration.cs b/Ryujinx/Configuration.cs index 3a3815046d..53560521b8 100644 --- a/Ryujinx/Configuration.cs +++ b/Ryujinx/Configuration.cs @@ -184,8 +184,8 @@ namespace Ryujinx /// The path to the JSON configuration file public static async Task LoadAsync(string path) { - var resolver = CompositeResolver.Create( - new[] { new ConfigurationEnumFormatter() }, + IJsonFormatterResolver resolver = CompositeResolver.Create( + new[] { new ConfigurationEnumFormatter() }, new[] { StandardResolver.AllowPrivateSnakeCase } ); @@ -201,12 +201,12 @@ namespace Ryujinx /// The path to the JSON configuration file public static void SaveConfig(Configuration config, string path) { - var resolver = CompositeResolver.Create( - new[] { new ConfigurationEnumFormatter() }, + IJsonFormatterResolver resolver = CompositeResolver.Create( + new[] { new ConfigurationEnumFormatter() }, new[] { StandardResolver.AllowPrivateSnakeCase } ); - var data = JsonSerializer.Serialize(config, resolver); + byte[] data = JsonSerializer.Serialize(config, resolver); File.WriteAllText(path, Encoding.UTF8.GetString(data, 0, data.Length).PrettyPrintJson()); } @@ -245,12 +245,12 @@ namespace Ryujinx { GraphicsConfig.ShadersDumpPath = SwitchConfig.GraphicsShadersDumpPath; - Logger.SetEnable(LogLevel.Debug , SwitchConfig.LoggingEnableDebug ); - Logger.SetEnable(LogLevel.Stub , SwitchConfig.LoggingEnableStub ); - Logger.SetEnable(LogLevel.Info , SwitchConfig.LoggingEnableInfo ); - Logger.SetEnable(LogLevel.Warning , SwitchConfig.LoggingEnableWarn ); - Logger.SetEnable(LogLevel.Error , SwitchConfig.LoggingEnableError ); - Logger.SetEnable(LogLevel.Guest , SwitchConfig.LoggingEnableGuest ); + Logger.SetEnable(LogLevel.Debug, SwitchConfig.LoggingEnableDebug ); + Logger.SetEnable(LogLevel.Stub, SwitchConfig.LoggingEnableStub ); + Logger.SetEnable(LogLevel.Info, SwitchConfig.LoggingEnableInfo ); + Logger.SetEnable(LogLevel.Warning, SwitchConfig.LoggingEnableWarn ); + Logger.SetEnable(LogLevel.Error, SwitchConfig.LoggingEnableError ); + Logger.SetEnable(LogLevel.Guest, SwitchConfig.LoggingEnableGuest ); Logger.SetEnable(LogLevel.AccessLog, SwitchConfig.LoggingEnableFsAccessLog); if (SwitchConfig.LoggingFilteredClasses.Length > 0) diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs index c22994863c..2753962750 100644 --- a/Ryujinx/Program.cs +++ b/Ryujinx/Program.cs @@ -23,12 +23,12 @@ namespace Ryujinx Application.Init(); - Application gtkapp = new Application("Ryujinx.Ryujinx", GLib.ApplicationFlags.None); - MainWindow win = new MainWindow(args, gtkapp); + Application gtkApplication = new Application("Ryujinx.Ryujinx", GLib.ApplicationFlags.None); + MainWindow mainWindow = new MainWindow(args, gtkApplication); - gtkapp.Register(GLib.Cancellable.Current); - gtkapp.AddWindow(win); - win.Show(); + gtkApplication.Register(GLib.Cancellable.Current); + gtkApplication.AddWindow(mainWindow); + mainWindow.Show(); Application.Run(); } diff --git a/Ryujinx/Ui/AboutWindow.cs b/Ryujinx/Ui/AboutWindow.cs index 80966e16e9..f1d9f6b06d 100644 --- a/Ryujinx/Ui/AboutWindow.cs +++ b/Ryujinx/Ui/AboutWindow.cs @@ -55,7 +55,10 @@ namespace Ryujinx.UI _versionText.Text = $"Version {Information.InstallVersion} - {Information.InstallBranch} ({Information.InstallCommit})"; } - catch { _versionText.Text = "Unknown Version"; } + catch + { + _versionText.Text = "Unknown Version"; + } } public void OpenUrl(string url) diff --git a/Ryujinx/Ui/ApplicationLibrary.cs b/Ryujinx/Ui/ApplicationLibrary.cs index 9a306de9df..c4cbbe9337 100644 --- a/Ryujinx/Ui/ApplicationLibrary.cs +++ b/Ryujinx/Ui/ApplicationLibrary.cs @@ -8,13 +8,14 @@ using System.IO; using System.Linq; using System.Reflection; using System.Text; +using SystemState = Ryujinx.HLE.HOS.SystemState; namespace Ryujinx.UI { public class ApplicationLibrary { private static Keyset KeySet; - private static HLE.HOS.SystemState.TitleLanguage DesiredTitleLanguage; + private static SystemState.TitleLanguage DesiredTitleLanguage; private const double SecondsPerMinute = 60.0; private const double SecondsPerHour = SecondsPerMinute * 60; @@ -42,7 +43,7 @@ namespace Ryujinx.UI public string Path; } - public static void Init(List AppDirs, Keyset keySet, HLE.HOS.SystemState.TitleLanguage desiredTitleLanguage) + public static void Init(List AppDirs, Keyset keySet, SystemState.TitleLanguage desiredTitleLanguage) { KeySet = keySet; DesiredTitleLanguage = desiredTitleLanguage; @@ -66,7 +67,7 @@ namespace Ryujinx.UI } DirectoryInfo AppDirInfo = new DirectoryInfo(appDir); - foreach (var App in AppDirInfo.GetFiles()) + foreach (FileInfo App in AppDirInfo.GetFiles()) { if ((Path.GetExtension(App.ToString()) == ".xci") || (Path.GetExtension(App.ToString()) == ".nca") || @@ -84,12 +85,12 @@ namespace Ryujinx.UI ApplicationLibraryData = new List(); foreach (string applicationPath in applications) { - double filesize = new FileInfo(applicationPath).Length * 0.000000000931; - string titleName = null; - string titleId = null; - string developer = null; - string version = null; - byte[] applicationIcon = null; + double filesize = new FileInfo(applicationPath).Length * 0.000000000931; + string titleName = null; + string titleId = null; + string developer = null; + string version = null; + byte[] applicationIcon = null; using (FileStream file = new FileStream(applicationPath, FileMode.Open, FileAccess.Read)) { @@ -105,9 +106,13 @@ namespace Ryujinx.UI if (Path.GetExtension(applicationPath) == ".xci") { Xci xci = new Xci(KeySet, file.AsStorage()); + controlFs = GetControlFs(xci.OpenPartition(XciPartitionType.Secure)); } - else { controlFs = GetControlFs(new PartitionFileSystem(file.AsStorage())); } + else + { + controlFs = GetControlFs(new PartitionFileSystem(file.AsStorage())); + } // Creates NACP class from the NACP file IFile controlNacp = controlFs.OpenFile("/control.nacp", OpenMode.Read); @@ -117,16 +122,26 @@ namespace Ryujinx.UI version = controlData.DisplayVersion; titleName = controlData.Descriptions[(int)DesiredTitleLanguage].Title; + if (string.IsNullOrWhiteSpace(titleName)) { titleName = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Title)).Title; } titleId = controlData.PresenceGroupId.ToString("x16"); - if (string.IsNullOrWhiteSpace(titleId)) { titleId = controlData.SaveDataOwnerId.ToString("x16"); } - if (string.IsNullOrWhiteSpace(titleId)) { titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16"); } + + if (string.IsNullOrWhiteSpace(titleId)) + { + titleId = controlData.SaveDataOwnerId.ToString("x16"); + } + + if (string.IsNullOrWhiteSpace(titleId)) + { + titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16"); + } developer = controlData.Descriptions[(int)DesiredTitleLanguage].Developer; + if (string.IsNullOrWhiteSpace(developer)) { developer = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Developer)).Developer; @@ -136,10 +151,10 @@ namespace Ryujinx.UI try { IFile icon = controlFs.OpenFile($"/icon_{DesiredTitleLanguage}.dat", OpenMode.Read); - using (MemoryStream ms = new MemoryStream()) + using (MemoryStream stream = new MemoryStream()) { - icon.AsStream().CopyTo(ms); - applicationIcon = ms.ToArray(); + icon.AsStream().CopyTo(stream); + applicationIcon = stream.ToArray(); } } catch (HorizonResultException) @@ -147,22 +162,34 @@ namespace Ryujinx.UI IDirectory controlDir = controlFs.OpenDirectory("./", OpenDirectoryMode.All); foreach (DirectoryEntry entry in controlDir.Read()) { - if (entry.Name == "control.nacp") { continue; } - - IFile icon = controlFs.OpenFile(entry.FullPath, OpenMode.Read); - using (MemoryStream ms = new MemoryStream()) + if (entry.Name == "control.nacp") { - icon.AsStream().CopyTo(ms); - applicationIcon = ms.ToArray(); + continue; } - if (applicationIcon != null) { break; } + IFile icon = controlFs.OpenFile(entry.FullPath, OpenMode.Read); + using (MemoryStream stream = new MemoryStream()) + { + icon.AsStream().CopyTo(stream); + applicationIcon = stream.ToArray(); + } + + if (applicationIcon != null) + { + break; + } } if (applicationIcon == null) { - if (Path.GetExtension(applicationPath) == ".xci") { applicationIcon = RyujinxXciIcon; } - else { applicationIcon = RyujinxNspIcon; } + if (Path.GetExtension(applicationPath) == ".xci") + { + applicationIcon = RyujinxXciIcon; + } + else + { + applicationIcon = RyujinxNspIcon; + } } } } @@ -173,8 +200,14 @@ namespace Ryujinx.UI developer = "Unknown"; version = "?"; - if (Path.GetExtension(applicationPath) == ".xci") { applicationIcon = RyujinxXciIcon; } - else { applicationIcon = RyujinxNspIcon; } + if (Path.GetExtension(applicationPath) == ".xci") + { + applicationIcon = RyujinxXciIcon; + } + else + { + applicationIcon = RyujinxNspIcon; + } Logger.PrintError(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}"); } @@ -191,7 +224,6 @@ namespace Ryujinx.UI Logger.PrintError(LogClass.Application, $"The file is not an NCA file or the header key is incorrect. Errored File: {applicationPath}"); } } - else if (Path.GetExtension(applicationPath) == ".nro") { BinaryReader reader = new BinaryReader(file); @@ -199,6 +231,7 @@ namespace Ryujinx.UI byte[] Read(long Position, int Size) { file.Seek(Position, SeekOrigin.Begin); + return reader.ReadBytes(Size); } @@ -228,33 +261,55 @@ namespace Ryujinx.UI version = controlData.DisplayVersion; titleName = controlData.Descriptions[(int)DesiredTitleLanguage].Title; + if (string.IsNullOrWhiteSpace(titleName)) { titleName = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Title)).Title; } titleId = controlData.PresenceGroupId.ToString("x16"); - if (string.IsNullOrWhiteSpace(titleId)) { titleId = controlData.SaveDataOwnerId.ToString("x16"); } - if (string.IsNullOrWhiteSpace(titleId)) { titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16"); } + + if (string.IsNullOrWhiteSpace(titleId)) + { + titleId = controlData.SaveDataOwnerId.ToString("x16"); + } + + if (string.IsNullOrWhiteSpace(titleId)) { + titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16"); + } developer = controlData.Descriptions[(int)DesiredTitleLanguage].Developer; + if (string.IsNullOrWhiteSpace(developer)) { developer = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Developer)).Developer; } } } - else { applicationIcon = RyujinxNroIcon; titleName = "Application"; titleId = "0000000000000000"; developer = "Unknown"; version = "?"; } + else + { + applicationIcon = RyujinxNroIcon; + titleName = "Application"; + titleId = "0000000000000000"; + developer = "Unknown"; + version = "?"; + } } - // If its an NCA or NSO we just set defaults else if ((Path.GetExtension(applicationPath) == ".nca") || (Path.GetExtension(applicationPath) == ".nso")) { - if (Path.GetExtension(applicationPath) == ".nca") { applicationIcon = RyujinxNcaIcon; } - else if (Path.GetExtension(applicationPath) == ".nso") { applicationIcon = RyujinxNsoIcon; } + if (Path.GetExtension(applicationPath) == ".nca") + { + applicationIcon = RyujinxNcaIcon; + } + else if (Path.GetExtension(applicationPath) == ".nso") + { + applicationIcon = RyujinxNsoIcon; + } string fileName = Path.GetFileName(applicationPath); string fileExt = Path.GetExtension(applicationPath); + StringBuilder titlename = new StringBuilder(); titlename.Append(fileName); titlename.Remove(fileName.Length - fileExt.Length, fileExt.Length); @@ -335,7 +390,10 @@ namespace Ryujinx.UI if (File.Exists(Path.Combine(savePath, "TimePlayed.dat")) == false) { Directory.CreateDirectory(savePath); - using (FileStream file = File.OpenWrite(Path.Combine(savePath, "TimePlayed.dat"))) { file.Write(Encoding.ASCII.GetBytes("0")); } + using (FileStream file = File.OpenWrite(Path.Combine(savePath, "TimePlayed.dat"))) + { + file.Write(Encoding.ASCII.GetBytes("0")); + } } using (FileStream fs = File.OpenRead(Path.Combine(savePath, "TimePlayed.dat"))) { @@ -343,10 +401,22 @@ namespace Ryujinx.UI { float timePlayed = float.Parse(sr.ReadLine()); - if (timePlayed < SecondsPerMinute) { playedData[0] = $"{timePlayed}s"; } - else if (timePlayed < SecondsPerHour) { playedData[0] = $"{Math.Round(timePlayed / SecondsPerMinute, 2, MidpointRounding.AwayFromZero)} mins"; } - else if (timePlayed < SecondsPerDay) { playedData[0] = $"{Math.Round(timePlayed / SecondsPerHour , 2, MidpointRounding.AwayFromZero)} hrs"; } - else { playedData[0] = $"{Math.Round(timePlayed / SecondsPerDay , 2, MidpointRounding.AwayFromZero)} days"; } + if (timePlayed < SecondsPerMinute) + { + playedData[0] = $"{timePlayed}s"; + } + else if (timePlayed < SecondsPerHour) + { + playedData[0] = $"{Math.Round(timePlayed / SecondsPerMinute, 2, MidpointRounding.AwayFromZero)} mins"; + } + else if (timePlayed < SecondsPerDay) + { + playedData[0] = $"{Math.Round(timePlayed / SecondsPerHour , 2, MidpointRounding.AwayFromZero)} hrs"; + } + else + { + playedData[0] = $"{Math.Round(timePlayed / SecondsPerDay , 2, MidpointRounding.AwayFromZero)} days"; + } } } @@ -358,6 +428,7 @@ namespace Ryujinx.UI file.Write(Encoding.ASCII.GetBytes("Never")); } } + using (FileStream fs = File.OpenRead(Path.Combine(savePath, "LastPlayed.dat"))) { using (StreamReader sr = new StreamReader(fs)) @@ -368,7 +439,10 @@ namespace Ryujinx.UI return playedData; } - catch { return new string[] { "Unknown", "Unknown" }; } + catch + { + return new string[] { "Unknown", "Unknown" }; + } } } } diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index 90512aa7f7..bef372ace2 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -5,7 +5,6 @@ using Ryujinx.Audio; using Ryujinx.Common.Logging; using Ryujinx.Graphics.Gal; using Ryujinx.Graphics.Gal.OpenGL; -using Ryujinx.HLE.FileSystem; using Ryujinx.Profiler; using System; using System.Diagnostics; @@ -19,46 +18,48 @@ namespace Ryujinx.UI { public class MainWindow : Window { + internal static HLE.Switch _device; + + private static IGalRenderer _renderer; + + private static IAalOutput _audioOut; + + private static Application _gtkApplication; + + private static ListStore _tableStore; + + private static bool _gameLoaded = false; + + private static string _userId = "00000000000000000000000000000001"; + public static bool DiscordIntegrationEnabled { get; set; } public static DiscordRpcClient DiscordClient; public static RichPresence DiscordPresence; - private static IGalRenderer _renderer; - - private static IAalOutput _audioOut; - - internal static HLE.Switch _device; - - private static Application _gtkapp; - - private static ListStore _tableStore; - - private static bool _gameLoaded = false; - #pragma warning disable 649 - [GUI] Window _mainWin; - [GUI] CheckMenuItem _fullScreen; - [GUI] MenuItem _stopEmulation; - [GUI] CheckMenuItem _iconToggle; - [GUI] CheckMenuItem _titleToggle; - [GUI] CheckMenuItem _developerToggle; - [GUI] CheckMenuItem _versionToggle; - [GUI] CheckMenuItem _timePlayedToggle; - [GUI] CheckMenuItem _lastPlayedToggle; - [GUI] CheckMenuItem _fileExtToggle; - [GUI] CheckMenuItem _fileSizeToggle; - [GUI] CheckMenuItem _pathToggle; - [GUI] MenuItem _nfc; - [GUI] Box _box; - [GUI] TreeView _gameTable; - [GUI] GLArea _glScreen; + [GUI] Window _mainWin; + [GUI] CheckMenuItem _fullScreen; + [GUI] MenuItem _stopEmulation; + [GUI] CheckMenuItem _iconToggle; + [GUI] CheckMenuItem _titleToggle; + [GUI] CheckMenuItem _developerToggle; + [GUI] CheckMenuItem _versionToggle; + [GUI] CheckMenuItem _timePlayedToggle; + [GUI] CheckMenuItem _lastPlayedToggle; + [GUI] CheckMenuItem _fileExtToggle; + [GUI] CheckMenuItem _fileSizeToggle; + [GUI] CheckMenuItem _pathToggle; + [GUI] MenuItem _nfc; + [GUI] Box _box; + [GUI] TreeView _gameTable; + [GUI] GLArea _glScreen; #pragma warning restore 649 - public MainWindow(string[] args, Application gtkapp) : this(new Builder("Ryujinx.Ui.MainWindow.glade"), args, gtkapp) { } + public MainWindow(string[] args, Application gtkApplication) : this(new Builder("Ryujinx.Ui.MainWindow.glade"), args, gtkApplication) { } - private MainWindow(Builder builder, string[] args, Application gtkapp) : base(builder.GetObject("_mainWin").Handle) + private MainWindow(Builder builder, string[] args, Application gtkApplication) : base(builder.GetObject("_mainWin").Handle) { _renderer = new OglRenderer(); @@ -71,7 +72,7 @@ namespace Ryujinx.UI ApplicationLibrary.Init(SwitchSettings.SwitchConfig.GameDirs, _device.System.KeySet, _device.System.State.DesiredTitleLanguage); - _gtkapp = gtkapp; + _gtkApplication = gtkApplication; ApplyTheme(); @@ -116,17 +117,20 @@ namespace Ryujinx.UI { // Temporary code section start, remove this section when game is rendered to the GLArea in the GUI _box.Remove(_glScreen); - if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _gameTable.AppendColumn("Icon" , new CellRendererPixbuf(), "pixbuf", 0); } - if (SwitchSettings.SwitchConfig.GuiColumns[1]) { _gameTable.AppendColumn("Application", new CellRendererText() , "text" , 1); } - if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _gameTable.AppendColumn("Developer" , new CellRendererText() , "text" , 2); } - if (SwitchSettings.SwitchConfig.GuiColumns[3]) { _gameTable.AppendColumn("Version" , new CellRendererText() , "text" , 3); } - if (SwitchSettings.SwitchConfig.GuiColumns[4]) { _gameTable.AppendColumn("Time Played", new CellRendererText() , "text" , 4); } - if (SwitchSettings.SwitchConfig.GuiColumns[5]) { _gameTable.AppendColumn("Last Played", new CellRendererText() , "text" , 5); } - if (SwitchSettings.SwitchConfig.GuiColumns[6]) { _gameTable.AppendColumn("File Ext" , new CellRendererText() , "text" , 6); } - if (SwitchSettings.SwitchConfig.GuiColumns[7]) { _gameTable.AppendColumn("File Size" , new CellRendererText() , "text" , 7); } - if (SwitchSettings.SwitchConfig.GuiColumns[8]) { _gameTable.AppendColumn("Path" , new CellRendererText() , "text" , 8); } + + if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _gameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 0); } + if (SwitchSettings.SwitchConfig.GuiColumns[1]) { _gameTable.AppendColumn("Application", new CellRendererText(), "text", 1); } + if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _gameTable.AppendColumn("Developer", new CellRendererText(), "text", 2); } + if (SwitchSettings.SwitchConfig.GuiColumns[3]) { _gameTable.AppendColumn("Version", new CellRendererText(), "text", 3); } + if (SwitchSettings.SwitchConfig.GuiColumns[4]) { _gameTable.AppendColumn("Time Played", new CellRendererText(), "text", 4); } + if (SwitchSettings.SwitchConfig.GuiColumns[5]) { _gameTable.AppendColumn("Last Played", new CellRendererText(), "text", 5); } + if (SwitchSettings.SwitchConfig.GuiColumns[6]) { _gameTable.AppendColumn("File Ext", new CellRendererText(), "text", 6); } + if (SwitchSettings.SwitchConfig.GuiColumns[7]) { _gameTable.AppendColumn("File Size", new CellRendererText(), "text", 7); } + if (SwitchSettings.SwitchConfig.GuiColumns[8]) { _gameTable.AppendColumn("Path", new CellRendererText(), "text", 8); } + _tableStore = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string)); _gameTable.Model = _tableStore; + UpdateGameTable(); // Temporary code section end @@ -136,15 +140,15 @@ namespace Ryujinx.UI { _box.Remove(_glScreen); - if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _gameTable.AppendColumn("Icon" , new CellRendererPixbuf(), "pixbuf", 0); } - if (SwitchSettings.SwitchConfig.GuiColumns[1]) { _gameTable.AppendColumn("Application", new CellRendererText() , "text" , 1); } - if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _gameTable.AppendColumn("Developer" , new CellRendererText() , "text" , 2); } - if (SwitchSettings.SwitchConfig.GuiColumns[3]) { _gameTable.AppendColumn("Version" , new CellRendererText() , "text" , 3); } - if (SwitchSettings.SwitchConfig.GuiColumns[4]) { _gameTable.AppendColumn("Time Played", new CellRendererText() , "text" , 4); } - if (SwitchSettings.SwitchConfig.GuiColumns[5]) { _gameTable.AppendColumn("Last Played", new CellRendererText() , "text" , 5); } - if (SwitchSettings.SwitchConfig.GuiColumns[6]) { _gameTable.AppendColumn("File Ext" , new CellRendererText() , "text" , 6); } - if (SwitchSettings.SwitchConfig.GuiColumns[7]) { _gameTable.AppendColumn("File Size" , new CellRendererText() , "text" , 7); } - if (SwitchSettings.SwitchConfig.GuiColumns[8]) { _gameTable.AppendColumn("Path" , new CellRendererText() , "text" , 8); } + if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _gameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 0); } + if (SwitchSettings.SwitchConfig.GuiColumns[1]) { _gameTable.AppendColumn("Application", new CellRendererText(), "text", 1); } + if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _gameTable.AppendColumn("Developer", new CellRendererText(), "text", 2); } + if (SwitchSettings.SwitchConfig.GuiColumns[3]) { _gameTable.AppendColumn("Version", new CellRendererText(), "text", 3); } + if (SwitchSettings.SwitchConfig.GuiColumns[4]) { _gameTable.AppendColumn("Time Played", new CellRendererText(), "text", 4); } + if (SwitchSettings.SwitchConfig.GuiColumns[5]) { _gameTable.AppendColumn("Last Played", new CellRendererText(), "text", 5); } + if (SwitchSettings.SwitchConfig.GuiColumns[6]) { _gameTable.AppendColumn("File Ext", new CellRendererText(), "text", 6); } + if (SwitchSettings.SwitchConfig.GuiColumns[7]) { _gameTable.AppendColumn("File Size", new CellRendererText(), "text", 7); } + if (SwitchSettings.SwitchConfig.GuiColumns[8]) { _gameTable.AppendColumn("Path", new CellRendererText(), "text", 8); } _tableStore = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string)); _gameTable.Model = _tableStore; @@ -246,8 +250,14 @@ namespace Ryujinx.UI break; default: Logger.PrintInfo(LogClass.Application, "Loading as homebrew."); - try { _device.LoadProgram(path); } - catch (ArgumentOutOfRangeException) { Logger.PrintError(LogClass.Application, $"The file which you have specified is unsupported by Ryujinx"); } + try + { + _device.LoadProgram(path); + } + catch (ArgumentOutOfRangeException) + { + Logger.PrintError(LogClass.Application, $"The file which you have specified is unsupported by Ryujinx"); + } break; } } @@ -268,8 +278,27 @@ namespace Ryujinx.UI { DiscordPresence.Assets.LargeImageKey = _device.System.TitleID; } - DiscordPresence.Details = $"Playing {_device.System.TitleName}"; - DiscordPresence.State = string.IsNullOrWhiteSpace(_device.System.TitleID) ? string.Empty : _device.System.TitleID.ToUpper(); + + string state = _device.System.TitleID; + + if (state == null) + { + state = "Ryujinx"; + } + else + { + state = state.ToUpper(); + } + + string details = "Idling"; + + if (_device.System.TitleName != null) + { + details = $"Playing {_device.System.TitleName}"; + } + + DiscordPresence.Details = details; + DiscordPresence.State = state; DiscordPresence.Assets.LargeImageText = _device.System.TitleName; DiscordPresence.Assets.SmallImageKey = "ryujinx"; DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch"; @@ -278,24 +307,23 @@ namespace Ryujinx.UI DiscordClient.SetPresence(DiscordPresence); } - string userId = "00000000000000000000000000000001"; try { - string savePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", userId, _device.System.TitleID); + string savePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", _userId, _device.System.TitleID); if (File.Exists(System.IO.Path.Combine(savePath, "TimePlayed.dat")) == false) { Directory.CreateDirectory(savePath); - using (FileStream file = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) { file.Write(Encoding.ASCII.GetBytes("0")); } + using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) { stream.Write(Encoding.ASCII.GetBytes("0")); } } if (File.Exists(System.IO.Path.Combine(savePath, "LastPlayed.dat")) == false) { Directory.CreateDirectory(savePath); - using (FileStream file = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) { file.Write(Encoding.ASCII.GetBytes("Never")); } + using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) { stream.Write(Encoding.ASCII.GetBytes("Never")); } } - using (FileStream fs = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) + using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) { - using (StreamWriter sr = new StreamWriter(fs)) + using (StreamWriter sr = new StreamWriter(stream)) { sr.WriteLine(DateTime.UtcNow); } @@ -303,7 +331,7 @@ namespace Ryujinx.UI } catch (ArgumentNullException) { - Logger.PrintError(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {userId}, TitleID: {_device.System.TitleID}"); + Logger.PrintError(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleID}"); } } } @@ -322,33 +350,32 @@ namespace Ryujinx.UI private static void End() { - string userId = "00000000000000000000000000000001"; if (_gameLoaded) { try { - string savePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", userId, _device.System.TitleID); + string savePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", _userId, _device.System.TitleID); double currentPlayTime = 0; - using (FileStream fs = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) + using (FileStream stream = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) { - using (StreamReader sr = new StreamReader(fs)) + using (StreamReader reader = new StreamReader(stream)) { - DateTime startTime = DateTime.Parse(sr.ReadLine()); + DateTime startTime = DateTime.Parse(reader.ReadLine()); - using (FileStream lpfs = File.OpenRead(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) + using (FileStream lastPlayedStream = File.OpenRead(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) { - using (StreamReader lpsr = new StreamReader(lpfs)) + using (StreamReader lastPlayedReader = new StreamReader(lastPlayedStream)) { - currentPlayTime = double.Parse(lpsr.ReadLine()); + currentPlayTime = double.Parse(lastPlayedReader.ReadLine()); } } - using (FileStream tpfs = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) + using (FileStream timePlayedStream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) { - using (StreamWriter tpsr = new StreamWriter(tpfs)) + using (StreamWriter timePlayedWriter = new StreamWriter(timePlayedStream)) { - tpsr.WriteLine(currentPlayTime + Math.Round(DateTime.UtcNow.Subtract(startTime).TotalSeconds, MidpointRounding.AwayFromZero)); + timePlayedWriter.WriteLine(currentPlayTime + Math.Round(DateTime.UtcNow.Subtract(startTime).TotalSeconds, MidpointRounding.AwayFromZero)); } } } @@ -356,7 +383,7 @@ namespace Ryujinx.UI } catch (ArgumentNullException) { - Logger.PrintError(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {userId}, TitleID: {_device.System.TitleID}"); + Logger.PrintError(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleID}"); } } @@ -391,8 +418,8 @@ namespace Ryujinx.UI //Events private void Row_Activated(object o, RowActivatedArgs args) { - _tableStore.GetIter(out TreeIter treeiter, new TreePath(args.Path.ToString())); - string path = (string)_tableStore.GetValue(treeiter, 8); + _tableStore.GetIter(out TreeIter treeIter, new TreePath(args.Path.ToString())); + string path = (string)_tableStore.GetValue(treeIter, 8); LoadApplication(path); } @@ -400,7 +427,8 @@ namespace Ryujinx.UI private void Load_Application_File(object o, EventArgs args) { FileChooserDialog fc = new FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); - fc.Filter = new FileFilter(); + + fc.Filter = new FileFilter(); fc.Filter.AddPattern("*.nsp" ); fc.Filter.AddPattern("*.pfs0"); fc.Filter.AddPattern("*.xci" ); @@ -432,15 +460,21 @@ namespace Ryujinx.UI { Process.Start(new ProcessStartInfo() { - FileName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFs"), + FileName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFs"), UseShellExecute = true, - Verb = "open" + Verb = "open" }); } - private void Exit_Pressed(object o, EventArgs args) { End(); } + private void Exit_Pressed(object o, EventArgs args) + { + End(); + } - private void Window_Close(object o, DeleteEventArgs args) { End(); } + private void Window_Close(object o, DeleteEventArgs args) + { + End(); + } private void StopEmulation_Pressed(object o, EventArgs args) { @@ -449,22 +483,31 @@ namespace Ryujinx.UI private void FullScreen_Toggled(object o, EventArgs args) { - if (_fullScreen.Active == true) { Fullscreen(); } - else { Unfullscreen(); } + if (_fullScreen.Active == true) + { + Fullscreen(); + } + else + { + Unfullscreen(); + } } private void Settings_Pressed(object o, EventArgs args) { SwitchSettings SettingsWin = new SwitchSettings(_device); - _gtkapp.Register(GLib.Cancellable.Current); - _gtkapp.AddWindow(SettingsWin); + + _gtkApplication.Register(GLib.Cancellable.Current); + _gtkApplication.AddWindow(SettingsWin); + SettingsWin.Show(); } private void Nfc_Pressed(object o, EventArgs args) { FileChooserDialog fc = new FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); - fc.Filter = new FileFilter(); + + fc.Filter = new FileFilter(); fc.Filter.AddPattern("*.bin"); if (fc.Run() == (int)ResponseType.Accept) @@ -477,15 +520,24 @@ namespace Ryujinx.UI private void Update_Pressed(object o, EventArgs args) { string ryuUpdater = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "RyuUpdater.exe"); - try { Process.Start(new ProcessStartInfo(ryuUpdater, "/U") { UseShellExecute = true }); } - catch(System.ComponentModel.Win32Exception) { CreateErrorDialog("Update canceled by user or updater was not found"); } + + try + { + Process.Start(new ProcessStartInfo(ryuUpdater, "/U") { UseShellExecute = true }); + } + catch(System.ComponentModel.Win32Exception) + { + CreateErrorDialog("Update canceled by user or updater was not found"); + } } private void About_Pressed(object o, EventArgs args) { AboutWindow AboutWin = new AboutWindow(); - _gtkapp.Register(GLib.Cancellable.Current); - _gtkapp.AddWindow(AboutWin); + + _gtkApplication.Register(GLib.Cancellable.Current); + _gtkApplication.AddWindow(AboutWin); + AboutWin.Show(); } diff --git a/Ryujinx/Ui/SwitchSettings.cs b/Ryujinx/Ui/SwitchSettings.cs index 2fc08aeafd..b23dd430b9 100644 --- a/Ryujinx/Ui/SwitchSettings.cs +++ b/Ryujinx/Ui/SwitchSettings.cs @@ -172,7 +172,7 @@ namespace Ryujinx.UI _fsLogSpinAdjustment.Value = SwitchConfig.FsGlobalAccessLogMode; _gameDirsBox.AppendColumn("", new CellRendererText(), "text", 0); - _gameDirsBoxStore = new ListStore(typeof(string)); + _gameDirsBoxStore = new ListStore(typeof(string)); _gameDirsBox.Model = _gameDirsBoxStore; foreach (string gameDir in SwitchConfig.GameDirs) { @@ -197,6 +197,7 @@ namespace Ryujinx.UI if (_listeningForKeypress == false) { KeyPressEvent += On_KeyPress; + _listeningForKeypress = true; void On_KeyPress(object Obj, KeyPressEventArgs KeyPressed) @@ -204,35 +205,52 @@ namespace Ryujinx.UI string key = KeyPressed.Event.Key.ToString(); string capKey = key.First().ToString().ToUpper() + key.Substring(1); - if (Enum.IsDefined(typeof(OpenTK.Input.Key), capKey)) { Button.Label = capKey; } - else if (GdkToOpenTKInput.ContainsKey(key)) { Button.Label = GdkToOpenTKInput[key]; } - else { Button.Label = "Space"; } + if (Enum.IsDefined(typeof(OpenTK.Input.Key), capKey)) + { + Button.Label = capKey; + } + else if (GdkToOpenTKInput.ContainsKey(key)) + { + Button.Label = GdkToOpenTKInput[key]; + } + else + { + Button.Label = "Space"; + } Button.SetStateFlags(0, true); + KeyPressEvent -= On_KeyPress; + _listeningForKeypress = false; } } - else { Button.SetStateFlags(0, true); } + else + { + Button.SetStateFlags(0, true); + } } private void AddDir_Pressed(object obj, EventArgs args) { - if (Directory.Exists(_addGameDirBox.Buffer.Text)) { _gameDirsBoxStore.AppendValues(_addGameDirBox.Buffer.Text); } + if (Directory.Exists(_addGameDirBox.Buffer.Text)) + { + _gameDirsBoxStore.AppendValues(_addGameDirBox.Buffer.Text); + } _addDir.SetStateFlags(0, true); } private void BrowseDir_Pressed(object obj, EventArgs args) { - FileChooserDialog fc = new FileChooserDialog("Choose the game directory to add to the list", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Add", ResponseType.Accept); + FileChooserDialog fileChooser = new FileChooserDialog("Choose the game directory to add to the list", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Add", ResponseType.Accept); - if (fc.Run() == (int)ResponseType.Accept) + if (fileChooser.Run() == (int)ResponseType.Accept) { - _gameDirsBoxStore.AppendValues(fc.Filename); + _gameDirsBoxStore.AppendValues(fileChooser.Filename); } - fc.Destroy(); + fileChooser.Destroy(); _browseDir.SetStateFlags(0, true); } @@ -241,40 +259,32 @@ namespace Ryujinx.UI { TreeSelection selection = _gameDirsBox.Selection; - selection.GetSelected(out TreeIter treeiter); - _gameDirsBoxStore.Remove(ref treeiter); + selection.GetSelected(out TreeIter treeIter); + _gameDirsBoxStore.Remove(ref treeIter); _removeDir.SetStateFlags(0, true); } private void CustThemeToggle_Activated(object obj, EventArgs args) { - if (_custThemeToggle.Active == false) - { - _custThemePath.Sensitive = false; - _custThemePathLabel.Sensitive = false; - _browseThemePath.Sensitive = false; - } - else - { - _custThemePath.Sensitive = true; - _custThemePathLabel.Sensitive = true; - _browseThemePath.Sensitive = true; - } + _custThemePath.Sensitive = _custThemeToggle.Active; + _custThemePathLabel.Sensitive = _custThemeToggle.Active; + _browseThemePath.Sensitive = _custThemeToggle.Active; } private void BrowseThemeDir_Pressed(object obj, EventArgs args) { - FileChooserDialog fc = new FileChooserDialog("Choose the theme to load", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Select", ResponseType.Accept); - fc.Filter = new FileFilter(); - fc.Filter.AddPattern("*.css"); + FileChooserDialog fileChooser = new FileChooserDialog("Choose the theme to load", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Select", ResponseType.Accept); - if (fc.Run() == (int)ResponseType.Accept) + fileChooser.Filter = new FileFilter(); + fileChooser.Filter.AddPattern("*.css"); + + if (fileChooser.Run() == (int)ResponseType.Accept) { - _custThemePath.Buffer.Text = fc.Filename; + _custThemePath.Buffer.Text = fileChooser.Filename; } - fc.Destroy(); + fileChooser.Destroy(); _browseThemePath.SetStateFlags(0, true); } @@ -283,51 +293,33 @@ namespace Ryujinx.UI { List gameDirs = new List(); - _gameDirsBoxStore.GetIterFirst(out TreeIter iter); + _gameDirsBoxStore.GetIterFirst(out TreeIter treeIter); for (int i = 0; i < _gameDirsBoxStore.IterNChildren(); i++) { - _gameDirsBoxStore.GetValue(iter, i); + _gameDirsBoxStore.GetValue(treeIter, i); - gameDirs.Add((string)_gameDirsBoxStore.GetValue(iter, 0)); + gameDirs.Add((string)_gameDirsBoxStore.GetValue(treeIter, 0)); - _gameDirsBoxStore.IterNext(ref iter); + _gameDirsBoxStore.IterNext(ref treeIter); } - if (_errorLogToggle.Active) SwitchConfig.LoggingEnableError = true; - if (_warningLogToggle.Active) SwitchConfig.LoggingEnableWarn = true; - if (_infoLogToggle.Active) SwitchConfig.LoggingEnableInfo = true; - if (_stubLogToggle.Active) SwitchConfig.LoggingEnableStub = true; - if (_debugLogToggle.Active) SwitchConfig.LoggingEnableDebug = true; - if (_guestLogToggle.Active) SwitchConfig.LoggingEnableGuest = true; - if (_fsAccessLogToggle.Active) SwitchConfig.LoggingEnableFsAccessLog = true; - if (_fileLogToggle.Active) SwitchConfig.EnableFileLog = true; - if (_dockedModeToggle.Active) SwitchConfig.DockedMode = true; - if (_discordToggle.Active) SwitchConfig.EnableDiscordIntegration = true; - if (_vSyncToggle.Active) SwitchConfig.EnableVsync = true; - if (_multiSchedToggle.Active) SwitchConfig.EnableMulticoreScheduling = true; - if (_fsicToggle.Active) SwitchConfig.EnableFsIntegrityChecks = true; - if (_legacyJitToggle.Active) SwitchConfig.EnableLegacyJit = true; - if (_ignoreToggle.Active) SwitchConfig.IgnoreMissingServices = true; - if (_directKeyboardAccess.Active) SwitchConfig.EnableKeyboard = true; - if (_custThemeToggle.Active) SwitchConfig.EnableCustomTheme = true; - - if (!_errorLogToggle.Active) SwitchConfig.LoggingEnableError = false; - if (!_warningLogToggle.Active) SwitchConfig.LoggingEnableWarn = false; - if (!_infoLogToggle.Active) SwitchConfig.LoggingEnableInfo = false; - if (!_stubLogToggle.Active ) SwitchConfig.LoggingEnableStub = false; - if (!_debugLogToggle.Active) SwitchConfig.LoggingEnableDebug = false; - if (!_guestLogToggle.Active) SwitchConfig.LoggingEnableGuest = false; - if (!_fsAccessLogToggle.Active) SwitchConfig.LoggingEnableFsAccessLog = false; - if (!_fileLogToggle.Active) SwitchConfig.EnableFileLog = false; - if (!_dockedModeToggle.Active) SwitchConfig.DockedMode = false; - if (!_discordToggle.Active) SwitchConfig.EnableDiscordIntegration = false; - if (!_vSyncToggle.Active) SwitchConfig.EnableVsync = false; - if (!_multiSchedToggle.Active) SwitchConfig.EnableMulticoreScheduling = false; - if (!_fsicToggle.Active) SwitchConfig.EnableFsIntegrityChecks = false; - if (!_legacyJitToggle.Active) SwitchConfig.EnableLegacyJit = false; - if (!_ignoreToggle.Active) SwitchConfig.IgnoreMissingServices = false; - if (!_directKeyboardAccess.Active) SwitchConfig.EnableKeyboard = false; - if (!_custThemeToggle.Active) SwitchConfig.EnableCustomTheme = false; + SwitchConfig.LoggingEnableError = _errorLogToggle.Active; + SwitchConfig.LoggingEnableWarn = _warningLogToggle.Active; + SwitchConfig.LoggingEnableInfo = _infoLogToggle.Active; + SwitchConfig.LoggingEnableStub = _stubLogToggle.Active; + SwitchConfig.LoggingEnableDebug = _debugLogToggle.Active; + SwitchConfig.LoggingEnableGuest = _guestLogToggle.Active; + SwitchConfig.LoggingEnableFsAccessLog = _fsAccessLogToggle.Active; + SwitchConfig.EnableFileLog = _fileLogToggle.Active; + SwitchConfig.DockedMode = _dockedModeToggle.Active; + SwitchConfig.EnableDiscordIntegration = _discordToggle.Active; + SwitchConfig.EnableVsync = _vSyncToggle.Active; + SwitchConfig.EnableMulticoreScheduling = _multiSchedToggle.Active; + SwitchConfig.EnableFsIntegrityChecks = _fsicToggle.Active; + SwitchConfig.EnableLegacyJit = _legacyJitToggle.Active; + SwitchConfig.IgnoreMissingServices = _ignoreToggle.Active; + SwitchConfig.EnableKeyboard = _directKeyboardAccess.Active; + SwitchConfig.EnableCustomTheme = _custThemeToggle.Active; SwitchConfig.KeyboardControls.LeftJoycon = new NpadKeyboardLeft() { @@ -370,6 +362,7 @@ namespace Ryujinx.UI Configuration.SaveConfig(SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json")); Configuration.Configure(Device, SwitchConfig); + MainWindow.ApplyTheme(); MainWindow.UpdateGameTable(); @@ -383,49 +376,49 @@ namespace Ryujinx.UI public readonly Dictionary GdkToOpenTKInput = new Dictionary() { - { "Key_0" , "Number0" }, - { "Key_1" , "Number1" }, - { "Key_2" , "Number2" }, - { "Key_3" , "Number3" }, - { "Key_4" , "Number4" }, - { "Key_5" , "Number5" }, - { "Key_6" , "Number6" }, - { "Key_7" , "Number7" }, - { "Key_8" , "Number8" }, - { "Key_9" , "Number9" }, - { "equal" , "Plus" }, - { "uparrow" , "Up" }, - { "downarrow" , "Down" }, - { "leftarrow" , "Left" }, - { "rightarrow" , "Right" }, - { "Control_L" , "ControlLeft" }, - { "Control_R" , "ControlRight" }, - { "Shift_L" , "ShiftLeft" }, - { "Shift_R" , "ShiftRight" }, - { "Alt_L" , "AltLeft" }, - { "Alt_R" , "AltRight" }, - { "Page_Up" , "PageUp" }, - { "Page_Down" , "PageDown" }, - { "KP_Enter" , "KeypadEnter" }, - { "KP_Up" , "Up" }, - { "KP_Down" , "Down" }, - { "KP_Left" , "Left" }, - { "KP_Right" , "Right" }, - { "KP_Divide" , "KeypadDivide" }, + { "Key_0", "Number0" }, + { "Key_1", "Number1" }, + { "Key_2", "Number2" }, + { "Key_3", "Number3" }, + { "Key_4", "Number4" }, + { "Key_5", "Number5" }, + { "Key_6", "Number6" }, + { "Key_7", "Number7" }, + { "Key_8", "Number8" }, + { "Key_9", "Number9" }, + { "equal", "Plus" }, + { "uparrow", "Up" }, + { "downarrow", "Down" }, + { "leftarrow", "Left" }, + { "rightarrow", "Right" }, + { "Control_L", "ControlLeft" }, + { "Control_R", "ControlRight" }, + { "Shift_L", "ShiftLeft" }, + { "Shift_R", "ShiftRight" }, + { "Alt_L", "AltLeft" }, + { "Alt_R", "AltRight" }, + { "Page_Up", "PageUp" }, + { "Page_Down", "PageDown" }, + { "KP_Enter", "KeypadEnter" }, + { "KP_Up", "Up" }, + { "KP_Down", "Down" }, + { "KP_Left", "Left" }, + { "KP_Right", "Right" }, + { "KP_Divide", "KeypadDivide" }, { "KP_Multiply", "KeypadMultiply" }, { "KP_Subtract", "KeypadSubtract" }, - { "KP_Add" , "KeypadAdd" }, - { "KP_Decimal" , "KeypadDecimal" }, - { "KP_0" , "Keypad0" }, - { "KP_1" , "Keypad1" }, - { "KP_2" , "Keypad2" }, - { "KP_3" , "Keypad3" }, - { "KP_4" , "Keypad4" }, - { "KP_5" , "Keypad5" }, - { "KP_6" , "Keypad6" }, - { "KP_7" , "Keypad7" }, - { "KP_8" , "Keypad8" }, - { "KP_9" , "Keypad9" }, + { "KP_Add", "KeypadAdd" }, + { "KP_Decimal", "KeypadDecimal" }, + { "KP_0", "Keypad0" }, + { "KP_1", "Keypad1" }, + { "KP_2", "Keypad2" }, + { "KP_3", "Keypad3" }, + { "KP_4", "Keypad4" }, + { "KP_5", "Keypad5" }, + { "KP_6", "Keypad6" }, + { "KP_7", "Keypad7" }, + { "KP_8", "Keypad8" }, + { "KP_9", "Keypad9" }, }; } }