Revert UI changes

This commit is contained in:
Alex Barney 2019-11-29 15:56:29 -06:00
commit 64eacabe8f
4 changed files with 221 additions and 229 deletions

View file

@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS
public string TitleName { get; private set; } public string TitleName { get; private set; }
public string TitleId { get; private set; } public string TitleID { get; private set; }
public IntegrityCheckLevel FsIntegrityCheckLevel { get; set; } public IntegrityCheckLevel FsIntegrityCheckLevel { get; set; }
@ -507,7 +507,7 @@ namespace Ryujinx.HLE.HOS
LoadExeFs(codeFs, out Npdm metaData); LoadExeFs(codeFs, out Npdm metaData);
TitleId = metaData.Aci0.TitleId.ToString("x16"); TitleID = metaData.Aci0.TitleId.ToString("x16");
if (controlNca != null) if (controlNca != null)
{ {
@ -515,7 +515,7 @@ namespace Ryujinx.HLE.HOS
} }
else 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("rtld");
LoadNso("main"); LoadNso("main");
@ -658,7 +658,7 @@ namespace Ryujinx.HLE.HOS
ContentManager.LoadEntries(); ContentManager.LoadEntries();
TitleName = CurrentTitle = metaData.TitleName; TitleName = CurrentTitle = metaData.TitleName;
TitleId = metaData.Aci0.TitleId.ToString("x16"); TitleID = metaData.Aci0.TitleId.ToString("x16");
ProgramLoader.LoadStaticObjects(this, metaData, new IExecutable[] { staticObject }); ProgramLoader.LoadStaticObjects(this, metaData, new IExecutable[] { staticObject });
} }

View file

@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Arp
return new ApplicationLaunchProperty 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, Version = 0x00,
BaseGameStorageId = (byte)StorageId.NandSystem, BaseGameStorageId = (byte)StorageId.NandSystem,
UpdateGameStorageId = (byte)StorageId.None UpdateGameStorageId = (byte)StorageId.None

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);
@ -382,71 +382,67 @@ namespace Ryujinx.UI
private static string[] GetPlayedData(string TitleId, string UserId) 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 if (timePlayed < SecondsPerMinute)
//{ {
// string[] playedData = new string[2]; playedData[0] = $"{timePlayed}s";
// string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", UserId, TitleId); }
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) if (File.Exists(Path.Combine(savePath, "LastPlayed.dat")) == false)
// { {
// Directory.CreateDirectory(savePath); Directory.CreateDirectory(savePath);
// using (FileStream file = File.OpenWrite(Path.Combine(savePath, "TimePlayed.dat"))) using (FileStream file = File.OpenWrite(Path.Combine(savePath, "LastPlayed.dat")))
// { {
// file.Write(Encoding.ASCII.GetBytes("0")); file.Write(Encoding.ASCII.GetBytes("Never"));
// } }
// } }
// 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) using (FileStream fs = File.OpenRead(Path.Combine(savePath, "LastPlayed.dat")))
// { {
// playedData[0] = $"{timePlayed}s"; using (StreamReader sr = new StreamReader(fs))
// } {
// else if (timePlayed < SecondsPerHour) playedData[1] = sr.ReadLine();
// { }
// 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, "LastPlayed.dat")) == false) return playedData;
// { }
// Directory.CreateDirectory(savePath); catch
// using (FileStream file = File.OpenWrite(Path.Combine(savePath, "LastPlayed.dat"))) {
// { return new string[] { "Unknown", "Unknown" };
// 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" };
//}
} }
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,17 +269,17 @@ 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)
{ {
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) if (state == null)
{ {
@ -297,59 +297,57 @@ 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);
} }
// 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 if (File.Exists(System.IO.Path.Combine(savePath, "TimePlayed.dat")) == false)
//{ {
// string savePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", _userId, _device.System.TitleId); 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) 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, "TimePlayed.dat"))) using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
// { {
// stream.Write(Encoding.ASCII.GetBytes("0")); stream.Write(Encoding.ASCII.GetBytes("Never"));
// } }
// } }
// if (File.Exists(System.IO.Path.Combine(savePath, "LastPlayed.dat")) == false) using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
// { {
// Directory.CreateDirectory(savePath); using (StreamWriter writer = new StreamWriter(stream))
// using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) {
// { writer.WriteLine(DateTime.UtcNow);
// stream.Write(Encoding.ASCII.GetBytes("Never")); }
// } }
// } }
catch (ArgumentNullException)
// using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) {
// { Logger.PrintWarning(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleID}");
// 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() private static void CreateGameWindow()
{ {
Configuration.ConfigureHid(_device, SwitchSettings.SwitchConfig); Configuration.ConfigureHid(_device, SwitchSettings.SwitchConfig);
using (GlScreen screen = new GlScreen(_device, _renderer)) using (GlScreen screen = new GlScreen(_device, _renderer))
{ {
screen.MainLoop(); screen.MainLoop();
@ -360,44 +358,42 @@ namespace Ryujinx.UI
private static void End() 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) using (FileStream stream = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
//{ {
// try using (StreamReader reader = new StreamReader(stream))
// { {
// string savePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", _userId, _device.System.TitleId); DateTime startTime = DateTime.Parse(reader.ReadLine());
// double currentPlayTime = 0;
// using (FileStream stream = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) using (FileStream lastPlayedStream = File.OpenRead(System.IO.Path.Combine(savePath, "TimePlayed.dat")))
// { {
// using (StreamReader reader = new StreamReader(stream)) using (StreamReader lastPlayedReader = new StreamReader(lastPlayedStream))
// { {
// DateTime startTime = DateTime.Parse(reader.ReadLine()); currentPlayTime = double.Parse(lastPlayedReader.ReadLine());
}
}
// using (FileStream lastPlayedStream = File.OpenRead(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) using (FileStream timePlayedStream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat")))
// { {
// using (StreamReader lastPlayedReader = new StreamReader(lastPlayedStream)) using (StreamWriter timePlayedWriter = new StreamWriter(timePlayedStream))
// { {
// currentPlayTime = double.Parse(lastPlayedReader.ReadLine()); timePlayedWriter.WriteLine(currentPlayTime + Math.Round(DateTime.UtcNow.Subtract(startTime).TotalSeconds, MidpointRounding.AwayFromZero));
// } }
// } }
}
// using (FileStream timePlayedStream = File.OpenWrite(System.IO.Path.Combine(savePath, "TimePlayed.dat"))) }
// { }
// using (StreamWriter timePlayedWriter = new StreamWriter(timePlayedStream)) catch (ArgumentNullException)
// { {
// timePlayedWriter.WriteLine(currentPlayTime + Math.Round(DateTime.UtcNow.Subtract(startTime).TotalSeconds, MidpointRounding.AwayFromZero)); Logger.PrintWarning(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {_userId}, TitleID: {_device.System.TitleID}");
// } }
// } }
// }
// }
// }
// 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();
@ -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); 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)
{ {
@ -472,9 +468,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"
}); });
} }
@ -523,7 +519,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");
} }