Added 'Open Ryujinx Folder' button to the file menu and did some small fixes

This commit is contained in:
Xpl0itR 2019-07-08 18:48:02 +01:00
parent a42993d11d
commit 55eba3087f
No known key found for this signature in database
GPG key ID: 91798184109676AD
5 changed files with 66 additions and 28 deletions

View file

@ -39,7 +39,6 @@ namespace Ryujinx
public static void Init(List<string> AppDirs, Keyset keySet, HLE.HOS.SystemState.TitleLanguage desiredTitleLanguage)
{
// Load Variables
KeySet = keySet;
DesiredTitleLanguage = desiredTitleLanguage;
@ -129,9 +128,9 @@ namespace Ryujinx
titleName = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Title)).Title;
}
titleId = controlData.PresenceGroupId.ToString("X16");
if (string.IsNullOrWhiteSpace(titleId)) { titleId = controlData.SaveDataOwnerId.ToString("X16"); }
if (string.IsNullOrWhiteSpace(titleId)) { titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("X16"); }
titleId = controlData.PresenceGroupId.ToString("x16");
if (string.IsNullOrWhiteSpace(titleId)) { titleId = controlData.SaveDataOwnerId.ToString("x16"); }
if (string.IsNullOrWhiteSpace(titleId)) { titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16"); }
developer = controlData.Descriptions[(int)DesiredTitleLanguage].Developer;
if (string.IsNullOrWhiteSpace(developer))
@ -209,9 +208,9 @@ namespace Ryujinx
titleName = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Title)).Title;
}
titleId = controlData.PresenceGroupId.ToString("X16");
if (string.IsNullOrWhiteSpace(titleId)) { titleId = controlData.SaveDataOwnerId.ToString("X16"); }
if (string.IsNullOrWhiteSpace(titleId)) { titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("X16"); }
titleId = controlData.PresenceGroupId.ToString("x16");
if (string.IsNullOrWhiteSpace(titleId)) { titleId = controlData.SaveDataOwnerId.ToString("x16"); }
if (string.IsNullOrWhiteSpace(titleId)) { titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16"); }
developer = controlData.Descriptions[(int)DesiredTitleLanguage].Developer;
if (string.IsNullOrWhiteSpace(developer))
@ -240,6 +239,8 @@ namespace Ryujinx
}
}
string[] playedData = GetPlayedData(titleId, "00000000000000000000000000000001");
ApplicationData data = new ApplicationData()
{
Icon = applicationIcon,
@ -247,8 +248,8 @@ namespace Ryujinx
TitleId = titleId,
Developer = developer,
Version = version,
TimePlayed = GetPlayedData(titleId)[0],
LastPlayed = GetPlayedData(titleId)[1],
TimePlayed = playedData[0],
LastPlayed = playedData[1],
FileSize = (filesize < 1) ? (filesize * 1024).ToString("0.##") + "MB" : filesize.ToString("0.##") + "GB",
Path = applicationPath,
};
@ -286,11 +287,11 @@ namespace Ryujinx
return controlNca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None);
}
private static string[] GetPlayedData(string TitleId)
private static string[] GetPlayedData(string TitleId, string UserId)
{
string[] playedData = new string[2];
string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string savePath = Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", "savecommon", TitleId);
string savePath = Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", UserId, TitleId);
if (File.Exists(Path.Combine(savePath, "TimePlayed.dat")) == false)
{

View file

@ -4,9 +4,9 @@ using System.Text;
namespace Ryujinx.HLE.Loaders.Npdm
{
//https://github.com/SciresM/hactool/blob/master/npdm.c
//https://github.com/SciresM/hactool/blob/master/npdm.h
//http://switchbrew.org/index.php?title=NPDM
// https://github.com/SciresM/hactool/blob/master/npdm.c
// https://github.com/SciresM/hactool/blob/master/npdm.h
// http://switchbrew.org/index.php?title=NPDM
class Npdm
{
private const int MetaMagic = 'M' << 0 | 'E' << 8 | 'T' << 16 | 'A' << 24;

View file

@ -7,6 +7,7 @@ using Ryujinx.Graphics.Gal;
using Ryujinx.Graphics.Gal.OpenGL;
using Ryujinx.Profiler;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
@ -182,7 +183,7 @@ namespace Ryujinx.UI
MessageDialog eRrOr = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "A game has already been loaded, please unload the game and try again");
eRrOr.SetSizeRequest(100, 20);
eRrOr.Title = "Ryujinx - Error";
eRrOr.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png");
eRrOr.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.ryujinxIcon.png");
eRrOr.WindowPosition = WindowPosition.Center;
eRrOr.Run();
eRrOr.Destroy();
@ -262,10 +263,11 @@ namespace Ryujinx.UI
DiscordClient.SetPresence(DiscordPresence);
}
if (_device.System.TitleID != null)
string userId = "00000000000000000000000000000001";
try
{
string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string savePath = System.IO.Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", "savecommon", _device.System.TitleID);
string savePath = System.IO.Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", userId, _device.System.TitleID);
if (File.Exists(System.IO.Path.Combine(savePath, "TimePlayed.dat")) == false)
{
@ -275,15 +277,20 @@ namespace Ryujinx.UI
if (File.Exists(System.IO.Path.Combine(savePath, "LastPlayed.dat")) == false)
{
Directory.CreateDirectory(savePath);
using (FileStream file = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
using (FileStream file = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) { file.Write(Encoding.ASCII.GetBytes("Never")); }
}
using (FileStream fs = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
{
using (StreamWriter sr = new StreamWriter(fs))
{
using (StreamWriter sr = new StreamWriter(file))
{
sr.WriteLine(DateTime.UtcNow);
}
sr.WriteLine(DateTime.UtcNow);
}
}
}
catch (ArgumentNullException exception)
{
Logger.PrintError(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {userId}, TitleID: {_device.System.TitleID}\nException: {exception}");
}
}
}
@ -297,10 +304,11 @@ namespace Ryujinx.UI
private static void End()
{
if (_device.System.TitleID != null)
string userId = "00000000000000000000000000000001";
try
{
string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string savePath = System.IO.Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", "savecommon", _device.System.TitleID);
string savePath = System.IO.Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", userId, _device.System.TitleID);
double currentPlayTime = 0;
using (FileStream fs = File.OpenRead(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
@ -327,6 +335,10 @@ namespace Ryujinx.UI
}
}
}
catch (ArgumentNullException exception)
{
Logger.PrintError(LogClass.Application, $"Could not access save path to retrieve time/last played data using: UserID: {userId}, TitleID: {_device.System.TitleID}\nException: {exception}");
}
Profile.FinishProfiling();
_device.Dispose();
@ -337,7 +349,7 @@ namespace Ryujinx.UI
}
//Events
private void Row_Activated(object obj, RowActivatedArgs args)
private void Row_Activated(object o, RowActivatedArgs args)
{
_TableStore.GetIter(out TreeIter treeiter, new TreePath(args.Path.ToString()));
string path = (string)_TableStore.GetValue(treeiter, 7);
@ -384,6 +396,16 @@ namespace Ryujinx.UI
fc.Destroy();
}
private void Open_Ryu_Folder(object o, EventArgs args)
{
Process.Start(new ProcessStartInfo()
{
FileName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFs"),
UseShellExecute = true,
Verb = "open"
});
}
private void Exit_Pressed(object o, EventArgs args) { End(); }
private void Window_Close(object o, DeleteEventArgs args) { End(); }

View file

@ -53,6 +53,21 @@
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="OpenRyuFolder">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Open Ryujinx Folder</property>
<property name="use_underline">True</property>
<signal name="activate" handler="Open_Ryu_Folder" swapped="no"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="Exit">
<property name="visible">True</property>
@ -168,8 +183,6 @@
</child>
<child>
<object class="GtkScrolledWindow" id="GameTableWindow">
<property name="width_request">1280</property>
<property name="height_request">720</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
@ -178,6 +191,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_clickable">False</property>
<property name="reorderable">True</property>
<property name="hover_selection">True</property>
<signal name="row-activated" handler="Row_Activated" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection"/>

View file

@ -1393,7 +1393,7 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Controller</property>
<property name="label" translatable="yes">Input</property>
</object>
<packing>
<property name="position">1</property>