Completely comment out GUI play stats code

This commit is contained in:
Alex Barney 2019-11-18 21:36:43 -05:00
commit 50b07f3b92
2 changed files with 217 additions and 213 deletions

View file

@ -21,8 +21,8 @@ namespace Ryujinx.UI
private static SystemState.TitleLanguage DesiredTitleLanguage; private static SystemState.TitleLanguage DesiredTitleLanguage;
private const double SecondsPerMinute = 60.0; private const double SecondsPerMinute = 60.0;
private const double SecondsPerHour = SecondsPerMinute * 60; private const double SecondsPerHour = SecondsPerMinute * 60;
private const double SecondsPerDay = SecondsPerHour * 24; private const double SecondsPerDay = SecondsPerHour * 24;
public static byte[] RyujinxNspIcon { get; private set; } public static byte[] RyujinxNspIcon { get; private set; }
public static byte[] RyujinxXciIcon { get; private set; } public static byte[] RyujinxXciIcon { get; private set; }
@ -48,7 +48,7 @@ namespace Ryujinx.UI
public static void Init(List<string> AppDirs, Keyset keySet, SystemState.TitleLanguage desiredTitleLanguage) public static void Init(List<string> AppDirs, Keyset keySet, SystemState.TitleLanguage desiredTitleLanguage)
{ {
KeySet = keySet; KeySet = keySet;
DesiredTitleLanguage = desiredTitleLanguage; DesiredTitleLanguage = desiredTitleLanguage;
// Loads the default application Icons // Loads the default application Icons
@ -72,11 +72,11 @@ namespace Ryujinx.UI
DirectoryInfo AppDirInfo = new DirectoryInfo(appDir); DirectoryInfo AppDirInfo = new DirectoryInfo(appDir);
foreach (FileInfo App in AppDirInfo.GetFiles()) foreach (FileInfo App in AppDirInfo.GetFiles())
{ {
if ((Path.GetExtension(App.ToString()) == ".xci") || if ((Path.GetExtension(App.ToString()) == ".xci") ||
(Path.GetExtension(App.ToString()) == ".nca") || (Path.GetExtension(App.ToString()) == ".nca") ||
(Path.GetExtension(App.ToString()) == ".nsp") || (Path.GetExtension(App.ToString()) == ".nsp") ||
(Path.GetExtension(App.ToString()) == ".pfs0") || (Path.GetExtension(App.ToString()) == ".pfs0") ||
(Path.GetExtension(App.ToString()) == ".nro") || (Path.GetExtension(App.ToString()) == ".nro") ||
(Path.GetExtension(App.ToString()) == ".nso")) (Path.GetExtension(App.ToString()) == ".nso"))
{ {
applications.Add(App.ToString()); applications.Add(App.ToString());
@ -88,16 +88,16 @@ namespace Ryujinx.UI
ApplicationLibraryData = new List<ApplicationData>(); ApplicationLibraryData = new List<ApplicationData>();
foreach (string applicationPath in applications) foreach (string applicationPath in applications)
{ {
double filesize = new FileInfo(applicationPath).Length * 0.000000000931; double filesize = new FileInfo(applicationPath).Length * 0.000000000931;
string titleName = null; string titleName = null;
string titleId = null; string titleId = null;
string developer = null; string developer = null;
string version = null; string version = null;
byte[] applicationIcon = null; byte[] applicationIcon = null;
using (FileStream file = new FileStream(applicationPath, FileMode.Open, FileAccess.Read)) 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) == ".pfs0") ||
(Path.GetExtension(applicationPath) == ".xci")) (Path.GetExtension(applicationPath) == ".xci"))
{ {
@ -193,20 +193,20 @@ namespace Ryujinx.UI
} }
catch (MissingKeyException exception) catch (MissingKeyException exception)
{ {
titleName = "Unknown"; titleName = "Unknown";
titleId = "Unknown"; titleId = "Unknown";
developer = "Unknown"; developer = "Unknown";
version = "?"; version = "?";
applicationIcon = NspOrXciIcon(applicationPath); applicationIcon = NspOrXciIcon(applicationPath);
Logger.PrintWarning(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}"); Logger.PrintWarning(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
} }
catch (InvalidDataException) catch (InvalidDataException)
{ {
titleName = "Unknown"; titleName = "Unknown";
titleId = "Unknown"; titleId = "Unknown";
developer = "Unknown"; developer = "Unknown";
version = "?"; version = "?";
applicationIcon = NspOrXciIcon(applicationPath); applicationIcon = NspOrXciIcon(applicationPath);
Logger.PrintWarning(LogClass.Application, $"The file is not an NCA file or the header key is incorrect. Errored File: {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); byte[] IconSectionInfo = Read(AssetOffset + 8, 0x10);
long iconOffset = BitConverter.ToInt64(IconSectionInfo, 0); long iconOffset = BitConverter.ToInt64(IconSectionInfo, 0);
long iconSize = BitConverter.ToInt64(IconSectionInfo, 8); long iconSize = BitConverter.ToInt64(IconSectionInfo, 8);
ulong nacpOffset = reader.ReadUInt64(); ulong nacpOffset = reader.ReadUInt64();
ulong nacpSize = reader.ReadUInt64(); ulong nacpSize = reader.ReadUInt64();
// Reads and stores game icon as byte array // Reads and stores game icon as byte array
applicationIcon = Read(AssetOffset + iconOffset, (int)iconSize); applicationIcon = Read(AssetOffset + iconOffset, (int)iconSize);
@ -284,10 +284,10 @@ namespace Ryujinx.UI
else else
{ {
applicationIcon = RyujinxNroIcon; applicationIcon = RyujinxNroIcon;
titleName = "Application"; titleName = "Application";
titleId = "0000000000000000"; titleId = "0000000000000000";
developer = "Unknown"; developer = "Unknown";
version = "?"; version = "?";
} }
} }
// If its an NCA or NSO we just set defaults // If its an NCA or NSO we just set defaults
@ -303,15 +303,15 @@ namespace Ryujinx.UI
} }
string fileName = Path.GetFileName(applicationPath); string fileName = Path.GetFileName(applicationPath);
string fileExt = Path.GetExtension(applicationPath); string fileExt = Path.GetExtension(applicationPath);
StringBuilder titlename = new StringBuilder(); StringBuilder titlename = new StringBuilder();
titlename.Append(fileName); titlename.Append(fileName);
titlename.Remove(fileName.Length - fileExt.Length, fileExt.Length); titlename.Remove(fileName.Length - fileExt.Length, fileExt.Length);
titleName = titlename.ToString(); titleName = titlename.ToString();
titleId = "0000000000000000"; titleId = "0000000000000000";
version = "?"; version = "?";
developer = "Unknown"; developer = "Unknown";
} }
} }
@ -320,16 +320,16 @@ namespace Ryujinx.UI
ApplicationData data = new ApplicationData() ApplicationData data = new ApplicationData()
{ {
Icon = applicationIcon, Icon = applicationIcon,
TitleName = titleName, TitleName = titleName,
TitleId = titleId, TitleId = titleId,
Developer = developer, Developer = developer,
Version = version, Version = version,
TimePlayed = playedData[0], TimePlayed = playedData[0],
LastPlayed = playedData[1], LastPlayed = playedData[1],
FileExt = Path.GetExtension(applicationPath).ToUpper().Remove(0 ,1), FileExt = Path.GetExtension(applicationPath).ToUpper().Remove(0, 1),
FileSize = (filesize < 1) ? (filesize * 1024).ToString("0.##") + "MB" : filesize.ToString("0.##") + "GB", FileSize = (filesize < 1) ? (filesize * 1024).ToString("0.##") + "MB" : filesize.ToString("0.##") + "GB",
Path = applicationPath, Path = applicationPath,
}; };
ApplicationLibraryData.Add(data); ApplicationLibraryData.Add(data);
@ -338,7 +338,7 @@ namespace Ryujinx.UI
private static byte[] GetResourceBytes(string resourceName) private static byte[] GetResourceBytes(string resourceName)
{ {
Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName); Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
byte[] resourceByteArray = new byte[resourceStream.Length]; byte[] resourceByteArray = new byte[resourceStream.Length];
resourceStream.Read(resourceByteArray); resourceStream.Read(resourceByteArray);
@ -384,67 +384,69 @@ namespace Ryujinx.UI
{ {
return new string[] { "Unknown", "Unknown" }; return new string[] { "Unknown", "Unknown" };
try // TODO: Update GUI to store these files in another location
{
string[] playedData = new string[2];
string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", UserId, TitleId);
if (File.Exists(Path.Combine(savePath, "TimePlayed.dat")) == false) //try
{ //{
Directory.CreateDirectory(savePath); // string[] playedData = new string[2];
using (FileStream file = File.OpenWrite(Path.Combine(savePath, "TimePlayed.dat"))) // string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", UserId, TitleId);
{
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 (timePlayed < SecondsPerMinute) // if (File.Exists(Path.Combine(savePath, "TimePlayed.dat")) == false)
{ // {
playedData[0] = $"{timePlayed}s"; // Directory.CreateDirectory(savePath);
} // using (FileStream file = File.OpenWrite(Path.Combine(savePath, "TimePlayed.dat")))
else if (timePlayed < SecondsPerHour) // {
{ // file.Write(Encoding.ASCII.GetBytes("0"));
playedData[0] = $"{Math.Round(timePlayed / SecondsPerMinute, 2, MidpointRounding.AwayFromZero)} mins"; // }
} // }
else if (timePlayed < SecondsPerDay) // using (FileStream fs = File.OpenRead(Path.Combine(savePath, "TimePlayed.dat")))
{ // {
playedData[0] = $"{Math.Round(timePlayed / SecondsPerHour , 2, MidpointRounding.AwayFromZero)} hrs"; // using (StreamReader sr = new StreamReader(fs))
} // {
else // float timePlayed = float.Parse(sr.ReadLine());
{
playedData[0] = $"{Math.Round(timePlayed / SecondsPerDay , 2, MidpointRounding.AwayFromZero)} days";
}
}
}
if (File.Exists(Path.Combine(savePath, "LastPlayed.dat")) == false) // if (timePlayed < SecondsPerMinute)
{ // {
Directory.CreateDirectory(savePath); // playedData[0] = $"{timePlayed}s";
using (FileStream file = File.OpenWrite(Path.Combine(savePath, "LastPlayed.dat"))) // }
{ // else if (timePlayed < SecondsPerHour)
file.Write(Encoding.ASCII.GetBytes("Never")); // {
} // 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"))) // if (File.Exists(Path.Combine(savePath, "LastPlayed.dat")) == false)
{ // {
using (StreamReader sr = new StreamReader(fs)) // Directory.CreateDirectory(savePath);
{ // using (FileStream file = File.OpenWrite(Path.Combine(savePath, "LastPlayed.dat")))
playedData[1] = sr.ReadLine(); // {
} // file.Write(Encoding.ASCII.GetBytes("Never"));
} // }
// }
return playedData; // using (FileStream fs = File.OpenRead(Path.Combine(savePath, "LastPlayed.dat")))
} // {
catch // using (StreamReader sr = new StreamReader(fs))
{ // {
return new string[] { "Unknown", "Unknown" }; // playedData[1] = sr.ReadLine();
} // }
// }
// return playedData;
//}
//catch
//{
// return new string[] { "Unknown", "Unknown" };
//}
} }
private static byte[] NspOrXciIcon(string applicationPath) private static byte[] NspOrXciIcon(string applicationPath)

View file

@ -40,9 +40,9 @@ namespace Ryujinx.UI
public static RichPresence DiscordPresence; public static RichPresence DiscordPresence;
#pragma warning disable 649 #pragma warning disable 649
[GUI] Window _mainWin; [GUI] Window _mainWin;
[GUI] CheckMenuItem _fullScreen; [GUI] CheckMenuItem _fullScreen;
[GUI] MenuItem _stopEmulation; [GUI] MenuItem _stopEmulation;
[GUI] CheckMenuItem _iconToggle; [GUI] CheckMenuItem _iconToggle;
[GUI] CheckMenuItem _titleToggle; [GUI] CheckMenuItem _titleToggle;
[GUI] CheckMenuItem _developerToggle; [GUI] CheckMenuItem _developerToggle;
@ -52,9 +52,9 @@ namespace Ryujinx.UI
[GUI] CheckMenuItem _fileExtToggle; [GUI] CheckMenuItem _fileExtToggle;
[GUI] CheckMenuItem _fileSizeToggle; [GUI] CheckMenuItem _fileSizeToggle;
[GUI] CheckMenuItem _pathToggle; [GUI] CheckMenuItem _pathToggle;
[GUI] Box _box; [GUI] Box _box;
[GUI] TreeView _gameTable; [GUI] TreeView _gameTable;
[GUI] GLArea _glScreen; [GUI] GLArea _glScreen;
#pragma warning restore 649 #pragma warning restore 649
public MainWindow(string[] args, Application gtkApplication) : this(new Builder("Ryujinx.Ui.MainWindow.glade"), args, gtkApplication) { } public MainWindow(string[] args, Application gtkApplication) : this(new Builder("Ryujinx.Ui.MainWindow.glade"), args, gtkApplication) { }
@ -78,16 +78,16 @@ namespace Ryujinx.UI
if (DiscordIntegrationEnabled) if (DiscordIntegrationEnabled)
{ {
DiscordClient = new DiscordRpcClient("568815339807309834"); DiscordClient = new DiscordRpcClient("568815339807309834");
DiscordPresence = new RichPresence DiscordPresence = new RichPresence
{ {
Assets = new Assets Assets = new Assets
{ {
LargeImageKey = "ryujinx", LargeImageKey = "ryujinx",
LargeImageText = "Ryujinx is an emulator for the Nintendo Switch" LargeImageText = "Ryujinx is an emulator for the Nintendo Switch"
}, },
Details = "Main Menu", Details = "Main Menu",
State = "Idling", State = "Idling",
Timestamps = new Timestamps(DateTime.UtcNow) Timestamps = new Timestamps(DateTime.UtcNow)
}; };
@ -99,35 +99,35 @@ namespace Ryujinx.UI
DeleteEvent += Window_Close; 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; _stopEmulation.Sensitive = false;
if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _iconToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _iconToggle.Active = true; }
if (SwitchSettings.SwitchConfig.GuiColumns[1]) { _titleToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[1]) { _titleToggle.Active = true; }
if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _developerToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _developerToggle.Active = true; }
if (SwitchSettings.SwitchConfig.GuiColumns[3]) { _versionToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[3]) { _versionToggle.Active = true; }
if (SwitchSettings.SwitchConfig.GuiColumns[4]) { _timePlayedToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[4]) { _timePlayedToggle.Active = true; }
if (SwitchSettings.SwitchConfig.GuiColumns[5]) { _lastPlayedToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[5]) { _lastPlayedToggle.Active = true; }
if (SwitchSettings.SwitchConfig.GuiColumns[6]) { _fileExtToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[6]) { _fileExtToggle.Active = true; }
if (SwitchSettings.SwitchConfig.GuiColumns[7]) { _fileSizeToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[7]) { _fileSizeToggle.Active = true; }
if (SwitchSettings.SwitchConfig.GuiColumns[8]) { _pathToggle.Active = true; } if (SwitchSettings.SwitchConfig.GuiColumns[8]) { _pathToggle.Active = true; }
if (args.Length == 1) if (args.Length == 1)
{ {
// Temporary code section start, remove this section when game is rendered to the GLArea in the GUI // Temporary code section start, remove this section when game is rendered to the GLArea in the GUI
_box.Remove(_glScreen); _box.Remove(_glScreen);
if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _gameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 0); } 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[1]) { _gameTable.AppendColumn("Application", new CellRendererText(), "text", 1); }
if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _gameTable.AppendColumn("Developer", new CellRendererText(), "text", 2); } 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[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[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[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[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[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[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; _gameTable.Model = _tableStore;
UpdateGameTable(); UpdateGameTable();
@ -137,17 +137,17 @@ namespace Ryujinx.UI
{ {
_box.Remove(_glScreen); _box.Remove(_glScreen);
if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _gameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 0); } 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[1]) { _gameTable.AppendColumn("Application", new CellRendererText(), "text", 1); }
if (SwitchSettings.SwitchConfig.GuiColumns[2]) { _gameTable.AppendColumn("Developer", new CellRendererText(), "text", 2); } 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[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[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[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[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[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[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; _gameTable.Model = _tableStore;
UpdateGameTable(); UpdateGameTable();
@ -158,8 +158,8 @@ namespace Ryujinx.UI
{ {
MessageDialog errorDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, errorMessage) MessageDialog errorDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, errorMessage)
{ {
Title = "Ryujinx - Error", Title = "Ryujinx - Error",
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.ryujinxIcon.png"), Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.ryujinxIcon.png"),
WindowPosition = WindowPosition.Center WindowPosition = WindowPosition.Center
}; };
errorDialog.SetSizeRequest(100, 20); errorDialog.SetSizeRequest(100, 20);
@ -269,7 +269,7 @@ namespace Ryujinx.UI
new Thread(new ThreadStart(CreateGameWindow)).Start(); new Thread(new ThreadStart(CreateGameWindow)).Start();
_gameLoaded = true; _gameLoaded = true;
_stopEmulation.Sensitive = true; _stopEmulation.Sensitive = true;
if (DiscordIntegrationEnabled) if (DiscordIntegrationEnabled)
@ -297,52 +297,52 @@ namespace Ryujinx.UI
details = $"Playing {_device.System.TitleName}"; details = $"Playing {_device.System.TitleName}";
} }
DiscordPresence.Details = details; DiscordPresence.Details = details;
DiscordPresence.State = state; DiscordPresence.State = state;
DiscordPresence.Assets.LargeImageText = _device.System.TitleName; 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.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); DiscordClient.SetPresence(DiscordPresence);
} }
return; // TODO: Update GUI to store these files in another location
try //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) // if (File.Exists(System.IO.Path.Combine(savePath, "TimePlayed.dat")) == false)
{ // {
Directory.CreateDirectory(savePath); // Directory.CreateDirectory(savePath);
using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) // using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat")))
{ // {
stream.Write(Encoding.ASCII.GetBytes("0")); // stream.Write(Encoding.ASCII.GetBytes("0"));
} // }
} // }
if (File.Exists(System.IO.Path.Combine(savePath, "LastPlayed.dat")) == false) // if (File.Exists(System.IO.Path.Combine(savePath, "LastPlayed.dat")) == false)
{ // {
Directory.CreateDirectory(savePath); // Directory.CreateDirectory(savePath);
using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) // using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
{ // {
stream.Write(Encoding.ASCII.GetBytes("Never")); // stream.Write(Encoding.ASCII.GetBytes("Never"));
} // }
} // }
using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) // using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
{ // {
using (StreamWriter writer = new StreamWriter(stream)) // using (StreamWriter writer = new StreamWriter(stream))
{ // {
writer.WriteLine(DateTime.UtcNow); // writer.WriteLine(DateTime.UtcNow);
} // }
} // }
} //}
catch (ArgumentNullException) //catch (ArgumentNullException)
{ //{
Logger.PrintWarning(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleId}"); // Logger.PrintWarning(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleId}");
} //}
} }
} }
@ -360,42 +360,44 @@ namespace Ryujinx.UI
private static void End() private static void End()
{ {
if (false) // 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);
double currentPlayTime = 0;
using (FileStream stream = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) //if (_gameLoaded)
{ //{
using (StreamReader reader = new StreamReader(stream)) // try
{ // {
DateTime startTime = DateTime.Parse(reader.ReadLine()); // 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 lastPlayedStream = File.OpenRead(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) // using (FileStream stream = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
{ // {
using (StreamReader lastPlayedReader = new StreamReader(lastPlayedStream)) // using (StreamReader reader = new StreamReader(stream))
{ // {
currentPlayTime = double.Parse(lastPlayedReader.ReadLine()); // DateTime startTime = DateTime.Parse(reader.ReadLine());
}
}
using (FileStream timePlayedStream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) // using (FileStream lastPlayedStream = File.OpenRead(System.IO.Path.Combine(savePath, "TimePlayed.dat")))
{ // {
using (StreamWriter timePlayedWriter = new StreamWriter(timePlayedStream)) // using (StreamReader lastPlayedReader = new StreamReader(lastPlayedStream))
{ // {
timePlayedWriter.WriteLine(currentPlayTime + Math.Round(DateTime.UtcNow.Subtract(startTime).TotalSeconds, MidpointRounding.AwayFromZero)); // currentPlayTime = double.Parse(lastPlayedReader.ReadLine());
} // }
} // }
}
} // using (FileStream timePlayedStream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat")))
} // {
catch (ArgumentNullException) // using (StreamWriter timePlayedWriter = new StreamWriter(timePlayedStream))
{ // {
Logger.PrintWarning(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleId}"); // 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(); Profile.FinishProfiling();
_device.Dispose(); _device.Dispose();
@ -439,12 +441,12 @@ namespace Ryujinx.UI
FileChooserDialog fileChooser = new FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); FileChooserDialog fileChooser = new FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
fileChooser.Filter = new FileFilter(); fileChooser.Filter = new FileFilter();
fileChooser.Filter.AddPattern("*.nsp" ); fileChooser.Filter.AddPattern("*.nsp");
fileChooser.Filter.AddPattern("*.pfs0"); fileChooser.Filter.AddPattern("*.pfs0");
fileChooser.Filter.AddPattern("*.xci" ); fileChooser.Filter.AddPattern("*.xci");
fileChooser.Filter.AddPattern("*.nca" ); fileChooser.Filter.AddPattern("*.nca");
fileChooser.Filter.AddPattern("*.nro" ); fileChooser.Filter.AddPattern("*.nro");
fileChooser.Filter.AddPattern("*.nso" ); fileChooser.Filter.AddPattern("*.nso");
if (fileChooser.Run() == (int)ResponseType.Accept) if (fileChooser.Run() == (int)ResponseType.Accept)
{ {
@ -470,9 +472,9 @@ namespace Ryujinx.UI
{ {
Process.Start(new ProcessStartInfo() 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, UseShellExecute = true,
Verb = "open" Verb = "open"
}); });
} }
@ -521,7 +523,7 @@ namespace Ryujinx.UI
{ {
Process.Start(new ProcessStartInfo(ryuUpdater, "/U") { UseShellExecute = true }); 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"); CreateErrorDialog("Update canceled by user or updater was not found");
} }