Completely comment out GUI play stats code

This commit is contained in:
Alex Barney 2019-11-18 21:36:43 -05:00
parent 92efd41197
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 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<string> 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<ApplicationData>();
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);
@ -384,67 +384,69 @@ namespace Ryujinx.UI
{
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"));
// }
// }
return playedData;
}
catch
{
return new string[] { "Unknown", "Unknown" };
}
// 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" };
//}
}
private static byte[] NspOrXciIcon(string applicationPath)

View file

@ -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,7 +269,7 @@ namespace Ryujinx.UI
new Thread(new ThreadStart(CreateGameWindow)).Start();
_gameLoaded = true;
_gameLoaded = true;
_stopEmulation.Sensitive = true;
if (DiscordIntegrationEnabled)
@ -297,59 +297,59 @@ 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);
}
return;
// 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,42 +360,44 @@ namespace Ryujinx.UI
private static void End()
{
if (false)
{
try
{
string savePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", _userId, _device.System.TitleId);
double currentPlayTime = 0;
// TODO: Update GUI to store these files in another location
using (FileStream stream = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
{
using (StreamReader reader = new StreamReader(stream))
{
DateTime startTime = DateTime.Parse(reader.ReadLine());
//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 lastPlayedStream = File.OpenRead(System.IO.Path.Combine(savePath, "TimePlayed.dat")))
{
using (StreamReader lastPlayedReader = new StreamReader(lastPlayedStream))
{
currentPlayTime = double.Parse(lastPlayedReader.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 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 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}");
// }
//}
Profile.FinishProfiling();
_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);
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)
{
@ -470,9 +472,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"
});
}
@ -521,7 +523,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");
}