diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index f93a4cf319..deb3833a0c 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS public string TitleName { get; private set; } - public string TitleId { get; private set; } + public string TitleID { get; private set; } public IntegrityCheckLevel FsIntegrityCheckLevel { get; set; } @@ -507,7 +507,7 @@ namespace Ryujinx.HLE.HOS LoadExeFs(codeFs, out Npdm metaData); - TitleId = metaData.Aci0.TitleId.ToString("x16"); + TitleID = metaData.Aci0.TitleId.ToString("x16"); if (controlNca != null) { @@ -515,7 +515,7 @@ namespace Ryujinx.HLE.HOS } else { - CurrentTitle = TitleId; + CurrentTitle = TitleID; } } @@ -555,7 +555,7 @@ namespace Ryujinx.HLE.HOS } } - TitleId = CurrentTitle = metaData.Aci0.TitleId.ToString("x16"); + TitleID = CurrentTitle = metaData.Aci0.TitleId.ToString("x16"); LoadNso("rtld"); LoadNso("main"); @@ -658,7 +658,7 @@ namespace Ryujinx.HLE.HOS ContentManager.LoadEntries(); TitleName = CurrentTitle = metaData.TitleName; - TitleId = metaData.Aci0.TitleId.ToString("x16"); + TitleID = metaData.Aci0.TitleId.ToString("x16"); ProgramLoader.LoadStaticObjects(this, metaData, new IExecutable[] { staticObject }); } diff --git a/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs b/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs index 4962e3ffdc..c1c6d26dc9 100644 --- a/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs +++ b/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs @@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Arp return new ApplicationLaunchProperty { - TitleId = BitConverter.ToInt64(StringUtils.HexToBytes(context.Device.System.TitleId), 0), + TitleId = BitConverter.ToInt64(StringUtils.HexToBytes(context.Device.System.TitleID), 0), Version = 0x00, BaseGameStorageId = (byte)StorageId.NandSystem, UpdateGameStorageId = (byte)StorageId.None diff --git a/Ryujinx/Ui/ApplicationLibrary.cs b/Ryujinx/Ui/ApplicationLibrary.cs index 6cc4bc33cc..1b697e4261 100644 --- a/Ryujinx/Ui/ApplicationLibrary.cs +++ b/Ryujinx/Ui/ApplicationLibrary.cs @@ -21,8 +21,8 @@ namespace Ryujinx.UI private static SystemState.TitleLanguage DesiredTitleLanguage; private const double SecondsPerMinute = 60.0; - private const double SecondsPerHour = SecondsPerMinute * 60; - private const double SecondsPerDay = SecondsPerHour * 24; + private const double SecondsPerHour = SecondsPerMinute * 60; + private const double SecondsPerDay = SecondsPerHour * 24; public static byte[] RyujinxNspIcon { get; private set; } public static byte[] RyujinxXciIcon { get; private set; } @@ -48,7 +48,7 @@ namespace Ryujinx.UI public static void Init(List AppDirs, Keyset keySet, SystemState.TitleLanguage desiredTitleLanguage) { - KeySet = keySet; + KeySet = keySet; DesiredTitleLanguage = desiredTitleLanguage; // Loads the default application Icons @@ -72,11 +72,11 @@ namespace Ryujinx.UI DirectoryInfo AppDirInfo = new DirectoryInfo(appDir); foreach (FileInfo App in AppDirInfo.GetFiles()) { - if ((Path.GetExtension(App.ToString()) == ".xci") || - (Path.GetExtension(App.ToString()) == ".nca") || - (Path.GetExtension(App.ToString()) == ".nsp") || + if ((Path.GetExtension(App.ToString()) == ".xci") || + (Path.GetExtension(App.ToString()) == ".nca") || + (Path.GetExtension(App.ToString()) == ".nsp") || (Path.GetExtension(App.ToString()) == ".pfs0") || - (Path.GetExtension(App.ToString()) == ".nro") || + (Path.GetExtension(App.ToString()) == ".nro") || (Path.GetExtension(App.ToString()) == ".nso")) { applications.Add(App.ToString()); @@ -88,16 +88,16 @@ 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; + 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)) { - if ((Path.GetExtension(applicationPath) == ".nsp") || + if ((Path.GetExtension(applicationPath) == ".nsp") || (Path.GetExtension(applicationPath) == ".pfs0") || (Path.GetExtension(applicationPath) == ".xci")) { @@ -193,20 +193,20 @@ namespace Ryujinx.UI } catch (MissingKeyException exception) { - titleName = "Unknown"; - titleId = "Unknown"; - developer = "Unknown"; - version = "?"; + titleName = "Unknown"; + titleId = "Unknown"; + developer = "Unknown"; + version = "?"; applicationIcon = NspOrXciIcon(applicationPath); Logger.PrintWarning(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}"); } catch (InvalidDataException) { - titleName = "Unknown"; - titleId = "Unknown"; - developer = "Unknown"; - version = "?"; + titleName = "Unknown"; + titleId = "Unknown"; + developer = "Unknown"; + version = "?"; applicationIcon = NspOrXciIcon(applicationPath); Logger.PrintWarning(LogClass.Application, $"The file is not an NCA file or the header key is incorrect. Errored File: {applicationPath}"); @@ -237,10 +237,10 @@ namespace Ryujinx.UI byte[] IconSectionInfo = Read(AssetOffset + 8, 0x10); long iconOffset = BitConverter.ToInt64(IconSectionInfo, 0); - long iconSize = BitConverter.ToInt64(IconSectionInfo, 8); + long iconSize = BitConverter.ToInt64(IconSectionInfo, 8); ulong nacpOffset = reader.ReadUInt64(); - ulong nacpSize = reader.ReadUInt64(); + ulong nacpSize = reader.ReadUInt64(); // Reads and stores game icon as byte array applicationIcon = Read(AssetOffset + iconOffset, (int)iconSize); @@ -284,10 +284,10 @@ namespace Ryujinx.UI else { applicationIcon = RyujinxNroIcon; - titleName = "Application"; - titleId = "0000000000000000"; - developer = "Unknown"; - version = "?"; + titleName = "Application"; + titleId = "0000000000000000"; + developer = "Unknown"; + version = "?"; } } // If its an NCA or NSO we just set defaults @@ -303,15 +303,15 @@ namespace Ryujinx.UI } string fileName = Path.GetFileName(applicationPath); - string fileExt = Path.GetExtension(applicationPath); + string fileExt = Path.GetExtension(applicationPath); StringBuilder titlename = new StringBuilder(); titlename.Append(fileName); titlename.Remove(fileName.Length - fileExt.Length, fileExt.Length); titleName = titlename.ToString(); - titleId = "0000000000000000"; - version = "?"; + titleId = "0000000000000000"; + version = "?"; developer = "Unknown"; } } @@ -320,16 +320,16 @@ namespace Ryujinx.UI ApplicationData data = new ApplicationData() { - Icon = applicationIcon, - TitleName = titleName, - TitleId = titleId, - Developer = developer, - Version = version, + Icon = applicationIcon, + TitleName = titleName, + TitleId = titleId, + Developer = developer, + Version = version, TimePlayed = playedData[0], LastPlayed = playedData[1], - FileExt = Path.GetExtension(applicationPath).ToUpper().Remove(0, 1), - FileSize = (filesize < 1) ? (filesize * 1024).ToString("0.##") + "MB" : filesize.ToString("0.##") + "GB", - Path = applicationPath, + FileExt = Path.GetExtension(applicationPath).ToUpper().Remove(0 ,1), + FileSize = (filesize < 1) ? (filesize * 1024).ToString("0.##") + "MB" : filesize.ToString("0.##") + "GB", + Path = applicationPath, }; ApplicationLibraryData.Add(data); @@ -338,7 +338,7 @@ namespace Ryujinx.UI private static byte[] GetResourceBytes(string resourceName) { - Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName); + Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName); byte[] resourceByteArray = new byte[resourceStream.Length]; resourceStream.Read(resourceByteArray); @@ -382,71 +382,67 @@ namespace Ryujinx.UI private static string[] GetPlayedData(string TitleId, string UserId) { - return new string[] { "Unknown", "Unknown" }; + try + { + string[] playedData = new string[2]; + string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", UserId, TitleId); - // TODO: Update GUI to store these files in another location + 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 fs = File.OpenRead(Path.Combine(savePath, "TimePlayed.dat"))) + { + using (StreamReader sr = new StreamReader(fs)) + { + float timePlayed = float.Parse(sr.ReadLine()); - //try - //{ - // string[] playedData = new string[2]; - // string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", UserId, TitleId); + 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 (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 fs = File.OpenRead(Path.Combine(savePath, "TimePlayed.dat"))) - // { - // using (StreamReader sr = new StreamReader(fs)) - // { - // float timePlayed = float.Parse(sr.ReadLine()); + if (File.Exists(Path.Combine(savePath, "LastPlayed.dat")) == false) + { + Directory.CreateDirectory(savePath); + using (FileStream file = File.OpenWrite(Path.Combine(savePath, "LastPlayed.dat"))) + { + file.Write(Encoding.ASCII.GetBytes("Never")); + } + } - // 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"; - // } - // } - // } + using (FileStream fs = File.OpenRead(Path.Combine(savePath, "LastPlayed.dat"))) + { + using (StreamReader sr = new StreamReader(fs)) + { + playedData[1] = sr.ReadLine(); + } + } - // if (File.Exists(Path.Combine(savePath, "LastPlayed.dat")) == false) - // { - // Directory.CreateDirectory(savePath); - // using (FileStream file = File.OpenWrite(Path.Combine(savePath, "LastPlayed.dat"))) - // { - // file.Write(Encoding.ASCII.GetBytes("Never")); - // } - // } - - // using (FileStream fs = File.OpenRead(Path.Combine(savePath, "LastPlayed.dat"))) - // { - // using (StreamReader sr = new StreamReader(fs)) - // { - // playedData[1] = sr.ReadLine(); - // } - // } - - // return playedData; - //} - //catch - //{ - // return new string[] { "Unknown", "Unknown" }; - //} + return playedData; + } + catch + { + return new string[] { "Unknown", "Unknown" }; + } } private static byte[] NspOrXciIcon(string applicationPath) diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index e158c70a36..6332b046fc 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -40,9 +40,9 @@ namespace Ryujinx.UI public static RichPresence DiscordPresence; #pragma warning disable 649 - [GUI] Window _mainWin; + [GUI] Window _mainWin; [GUI] CheckMenuItem _fullScreen; - [GUI] MenuItem _stopEmulation; + [GUI] MenuItem _stopEmulation; [GUI] CheckMenuItem _iconToggle; [GUI] CheckMenuItem _titleToggle; [GUI] CheckMenuItem _developerToggle; @@ -52,9 +52,9 @@ namespace Ryujinx.UI [GUI] CheckMenuItem _fileExtToggle; [GUI] CheckMenuItem _fileSizeToggle; [GUI] CheckMenuItem _pathToggle; - [GUI] Box _box; - [GUI] TreeView _gameTable; - [GUI] GLArea _glScreen; + [GUI] Box _box; + [GUI] TreeView _gameTable; + [GUI] GLArea _glScreen; #pragma warning restore 649 public MainWindow(string[] args, Application gtkApplication) : this(new Builder("Ryujinx.Ui.MainWindow.glade"), args, gtkApplication) { } @@ -78,16 +78,16 @@ namespace Ryujinx.UI if (DiscordIntegrationEnabled) { - DiscordClient = new DiscordRpcClient("568815339807309834"); + DiscordClient = new DiscordRpcClient("568815339807309834"); DiscordPresence = new RichPresence { Assets = new Assets { - LargeImageKey = "ryujinx", + LargeImageKey = "ryujinx", LargeImageText = "Ryujinx is an emulator for the Nintendo Switch" }, - Details = "Main Menu", - State = "Idling", + Details = "Main Menu", + State = "Idling", Timestamps = new Timestamps(DateTime.UtcNow) }; @@ -99,35 +99,35 @@ namespace Ryujinx.UI DeleteEvent += Window_Close; - _mainWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.ryujinxIcon.png"); + _mainWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.ryujinxIcon.png"); _stopEmulation.Sensitive = false; - if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _iconToggle.Active = true; } - if (SwitchSettings.SwitchConfig.GuiColumns[1]) { _titleToggle.Active = true; } - if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _developerToggle.Active = true; } - if (SwitchSettings.SwitchConfig.GuiColumns[3]) { _versionToggle.Active = true; } + if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _iconToggle.Active = true; } + if (SwitchSettings.SwitchConfig.GuiColumns[1]) { _titleToggle.Active = true; } + if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _developerToggle.Active = true; } + if (SwitchSettings.SwitchConfig.GuiColumns[3]) { _versionToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[4]) { _timePlayedToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[5]) { _lastPlayedToggle.Active = true; } - if (SwitchSettings.SwitchConfig.GuiColumns[6]) { _fileExtToggle.Active = true; } - if (SwitchSettings.SwitchConfig.GuiColumns[7]) { _fileSizeToggle.Active = true; } - if (SwitchSettings.SwitchConfig.GuiColumns[8]) { _pathToggle.Active = true; } + if (SwitchSettings.SwitchConfig.GuiColumns[6]) { _fileExtToggle.Active = true; } + if (SwitchSettings.SwitchConfig.GuiColumns[7]) { _fileSizeToggle.Active = true; } + if (SwitchSettings.SwitchConfig.GuiColumns[8]) { _pathToggle.Active = true; } if (args.Length == 1) { // 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)); + _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(); @@ -137,17 +137,17 @@ 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)); + _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(); @@ -158,8 +158,8 @@ namespace Ryujinx.UI { MessageDialog errorDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, errorMessage) { - Title = "Ryujinx - Error", - Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.ryujinxIcon.png"), + Title = "Ryujinx - Error", + Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.ryujinxIcon.png"), WindowPosition = WindowPosition.Center }; errorDialog.SetSizeRequest(100, 20); @@ -269,17 +269,17 @@ namespace Ryujinx.UI new Thread(new ThreadStart(CreateGameWindow)).Start(); - _gameLoaded = true; + _gameLoaded = true; _stopEmulation.Sensitive = true; if (DiscordIntegrationEnabled) { - if (File.ReadAllLines(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RPsupported.dat")).Contains(_device.System.TitleId)) + if (File.ReadAllLines(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RPsupported.dat")).Contains(_device.System.TitleID)) { - DiscordPresence.Assets.LargeImageKey = _device.System.TitleId; + DiscordPresence.Assets.LargeImageKey = _device.System.TitleID; } - string state = _device.System.TitleId; + string state = _device.System.TitleID; if (state == null) { @@ -297,59 +297,57 @@ namespace Ryujinx.UI details = $"Playing {_device.System.TitleName}"; } - DiscordPresence.Details = details; - DiscordPresence.State = state; + DiscordPresence.Details = details; + DiscordPresence.State = state; DiscordPresence.Assets.LargeImageText = _device.System.TitleName; - DiscordPresence.Assets.SmallImageKey = "ryujinx"; + DiscordPresence.Assets.SmallImageKey = "ryujinx"; DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch"; - DiscordPresence.Timestamps = new Timestamps(DateTime.UtcNow); + DiscordPresence.Timestamps = new Timestamps(DateTime.UtcNow); DiscordClient.SetPresence(DiscordPresence); } - // TODO: Update GUI to store these files in another location + try + { + string savePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", _userId, _device.System.TitleID); - //try - //{ - // 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 stream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) + { + stream.Write(Encoding.ASCII.GetBytes("0")); + } + } - // if (File.Exists(System.IO.Path.Combine(savePath, "TimePlayed.dat")) == false) - // { - // Directory.CreateDirectory(savePath); - // 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 stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) + { + stream.Write(Encoding.ASCII.GetBytes("Never")); + } + } - // if (File.Exists(System.IO.Path.Combine(savePath, "LastPlayed.dat")) == false) - // { - // Directory.CreateDirectory(savePath); - // using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) - // { - // stream.Write(Encoding.ASCII.GetBytes("Never")); - // } - // } - - // using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) - // { - // using (StreamWriter writer = new StreamWriter(stream)) - // { - // writer.WriteLine(DateTime.UtcNow); - // } - // } - //} - //catch (ArgumentNullException) - //{ - // Logger.PrintWarning(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleId}"); - //} + using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) + { + using (StreamWriter writer = new StreamWriter(stream)) + { + writer.WriteLine(DateTime.UtcNow); + } + } + } + catch (ArgumentNullException) + { + Logger.PrintWarning(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleID}"); + } } } private static void CreateGameWindow() { Configuration.ConfigureHid(_device, SwitchSettings.SwitchConfig); - + using (GlScreen screen = new GlScreen(_device, _renderer)) { screen.MainLoop(); @@ -360,44 +358,42 @@ namespace Ryujinx.UI private static void End() { - // TODO: Update GUI to store these files in another location + if (_gameLoaded) + { + try + { + string savePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", _userId, _device.System.TitleID); + double currentPlayTime = 0; - //if (_gameLoaded) - //{ - // try - // { - // 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 stream = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) + { + using (StreamReader reader = new StreamReader(stream)) + { + DateTime startTime = DateTime.Parse(reader.ReadLine()); - // using (FileStream stream = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) - // { - // using (StreamReader reader = new StreamReader(stream)) - // { - // DateTime startTime = DateTime.Parse(reader.ReadLine()); + using (FileStream lastPlayedStream = File.OpenRead(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) + { + using (StreamReader lastPlayedReader = new StreamReader(lastPlayedStream)) + { + currentPlayTime = double.Parse(lastPlayedReader.ReadLine()); + } + } - // using (FileStream lastPlayedStream = File.OpenRead(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) - // { - // using (StreamReader lastPlayedReader = new StreamReader(lastPlayedStream)) - // { - // currentPlayTime = double.Parse(lastPlayedReader.ReadLine()); - // } - // } - - // using (FileStream timePlayedStream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) - // { - // using (StreamWriter timePlayedWriter = new StreamWriter(timePlayedStream)) - // { - // timePlayedWriter.WriteLine(currentPlayTime + Math.Round(DateTime.UtcNow.Subtract(startTime).TotalSeconds, MidpointRounding.AwayFromZero)); - // } - // } - // } - // } - // } - // catch (ArgumentNullException) - // { - // Logger.PrintWarning(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleId}"); - // } - //} + using (FileStream timePlayedStream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) + { + using (StreamWriter timePlayedWriter = new StreamWriter(timePlayedStream)) + { + timePlayedWriter.WriteLine(currentPlayTime + Math.Round(DateTime.UtcNow.Subtract(startTime).TotalSeconds, MidpointRounding.AwayFromZero)); + } + } + } + } + } + catch (ArgumentNullException) + { + Logger.PrintWarning(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleID}"); + } + } Profile.FinishProfiling(); _device.Dispose(); @@ -441,12 +437,12 @@ namespace Ryujinx.UI FileChooserDialog fileChooser = new FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); fileChooser.Filter = new FileFilter(); - fileChooser.Filter.AddPattern("*.nsp"); + fileChooser.Filter.AddPattern("*.nsp" ); fileChooser.Filter.AddPattern("*.pfs0"); - fileChooser.Filter.AddPattern("*.xci"); - fileChooser.Filter.AddPattern("*.nca"); - fileChooser.Filter.AddPattern("*.nro"); - fileChooser.Filter.AddPattern("*.nso"); + fileChooser.Filter.AddPattern("*.xci" ); + fileChooser.Filter.AddPattern("*.nca" ); + fileChooser.Filter.AddPattern("*.nro" ); + fileChooser.Filter.AddPattern("*.nso" ); if (fileChooser.Run() == (int)ResponseType.Accept) { @@ -472,9 +468,9 @@ 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" }); } @@ -523,7 +519,7 @@ namespace Ryujinx.UI { Process.Start(new ProcessStartInfo(ryuUpdater, "/U") { UseShellExecute = true }); } - catch (System.ComponentModel.Win32Exception) + catch(System.ComponentModel.Win32Exception) { CreateErrorDialog("Update canceled by user or updater was not found"); }