requested changes changed

This commit is contained in:
Xpl0itR 2019-08-29 12:26:59 +01:00
parent 504459199f
commit 240da0a9ac
No known key found for this signature in database
GPG key ID: 91798184109676AD
8 changed files with 113 additions and 150 deletions

View file

@ -24,7 +24,7 @@ namespace Ryujinx
Application.Init();
Application gtkApplication = new Application("Ryujinx.Ryujinx", GLib.ApplicationFlags.None);
MainWindow mainWindow = new MainWindow(args, gtkApplication);
MainWindow mainWindow = new MainWindow(args, gtkApplication);
gtkApplication.Register(GLib.Cancellable.Current);
gtkApplication.AddWindow(mainWindow);

View file

@ -46,7 +46,7 @@ namespace Ryujinx.UI
try
{
var resolver = CompositeResolver.Create(new[] { StandardResolver.AllowPrivateSnakeCase });
IJsonFormatterResolver resolver = CompositeResolver.Create(new[] { StandardResolver.AllowPrivateSnakeCase });
using (Stream stream = File.OpenRead(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "Installer", "Config", "Config.json")))
{

View file

@ -6,6 +6,7 @@
<property name="can_focus">False</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="default_width">800</property>
<property name="default_height">350</property>
<property name="type_hint">dialog</property>

View file

@ -18,8 +18,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; }
@ -182,44 +182,27 @@ namespace Ryujinx.UI
if (applicationIcon == null)
{
if (Path.GetExtension(applicationPath) == ".xci")
{
applicationIcon = RyujinxXciIcon;
}
else
{
applicationIcon = RyujinxNspIcon;
}
applicationIcon = NspOrXciIcon(applicationPath);
}
}
}
catch (MissingKeyException exception)
{
titleName = "Unknown";
titleId = "Unknown";
developer = "Unknown";
version = "?";
if (Path.GetExtension(applicationPath) == ".xci")
{
applicationIcon = RyujinxXciIcon;
}
else
{
applicationIcon = RyujinxNspIcon;
}
titleName = "Unknown";
titleId = "Unknown";
developer = "Unknown";
version = "?";
applicationIcon = NspOrXciIcon(applicationPath);
Logger.PrintError(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
}
catch (InvalidDataException)
{
titleName = "Unknown";
titleId = "Unknown";
developer = "Unknown";
version = "?";
if (Path.GetExtension(applicationPath) == ".xci") { applicationIcon = RyujinxXciIcon; }
else { applicationIcon = RyujinxNspIcon; }
titleName = "Unknown";
titleId = "Unknown";
developer = "Unknown";
version = "?";
applicationIcon = NspOrXciIcon(applicationPath);
Logger.PrintError(LogClass.Application, $"The file is not an NCA file or the header key is incorrect. Errored File: {applicationPath}");
}
@ -274,7 +257,8 @@ namespace Ryujinx.UI
titleId = controlData.SaveDataOwnerId.ToString("x16");
}
if (string.IsNullOrWhiteSpace(titleId)) {
if (string.IsNullOrWhiteSpace(titleId))
{
titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16");
}
@ -385,7 +369,7 @@ namespace Ryujinx.UI
try
{
string[] playedData = new string[2];
string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "nand", "user", "save", "0000000000000000", UserId, TitleId);
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)
{
@ -444,5 +428,17 @@ namespace Ryujinx.UI
return new string[] { "Unknown", "Unknown" };
}
}
private static byte[] NspOrXciIcon(string applicationPath)
{
if (Path.GetExtension(applicationPath) == ".xci")
{
return RyujinxXciIcon;
}
else
{
return RyujinxNspIcon;
}
}
}
}

View file

@ -51,7 +51,6 @@ namespace Ryujinx.UI
[GUI] CheckMenuItem _fileExtToggle;
[GUI] CheckMenuItem _fileSizeToggle;
[GUI] CheckMenuItem _pathToggle;
[GUI] MenuItem _nfc;
[GUI] Box _box;
[GUI] TreeView _gameTable;
[GUI] GLArea _glScreen;
@ -100,7 +99,6 @@ namespace Ryujinx.UI
DeleteEvent += Window_Close;
_mainWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.RyujinxIcon.png");
_nfc.Sensitive = false;
_stopEmulation.Sensitive = false;
if (SwitchSettings.SwitchConfig.GuiColumns[0]) { _iconToggle.Active = true; }
@ -159,11 +157,13 @@ namespace Ryujinx.UI
public static void CreateErrorDialog(string errorMessage)
{
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",
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.RyujinxIcon.png"),
WindowPosition = WindowPosition.Center
};
errorDialog.SetSizeRequest(100, 20);
errorDialog.Title = "Ryujinx - Error";
errorDialog.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.RyujinxIcon.png");
errorDialog.WindowPosition = WindowPosition.Center;
errorDialog.Run();
errorDialog.Destroy();
}
@ -297,8 +297,8 @@ 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.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch";
@ -316,16 +316,18 @@ namespace Ryujinx.UI
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")); }
}
using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
{
using (StreamWriter sr = new StreamWriter(stream))
using (StreamWriter writer = new StreamWriter(stream))
{
sr.WriteLine(DateTime.UtcNow);
writer.WriteLine(DateTime.UtcNow);
}
}
}
@ -426,34 +428,34 @@ namespace Ryujinx.UI
private void Load_Application_File(object o, EventArgs args)
{
FileChooserDialog fc = 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);
fc.Filter = new FileFilter();
fc.Filter.AddPattern("*.nsp" );
fc.Filter.AddPattern("*.pfs0");
fc.Filter.AddPattern("*.xci" );
fc.Filter.AddPattern("*.nca" );
fc.Filter.AddPattern("*.nro" );
fc.Filter.AddPattern("*.nso" );
fileChooser.Filter = new FileFilter();
fileChooser.Filter.AddPattern("*.nsp" );
fileChooser.Filter.AddPattern("*.pfs0");
fileChooser.Filter.AddPattern("*.xci" );
fileChooser.Filter.AddPattern("*.nca" );
fileChooser.Filter.AddPattern("*.nro" );
fileChooser.Filter.AddPattern("*.nso" );
if (fc.Run() == (int)ResponseType.Accept)
if (fileChooser.Run() == (int)ResponseType.Accept)
{
LoadApplication(fc.Filename);
LoadApplication(fileChooser.Filename);
}
fc.Destroy();
fileChooser.Destroy();
}
private void Load_Application_Folder(object o, EventArgs args)
{
FileChooserDialog fc = new FileChooserDialog("Choose the folder to open", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
FileChooserDialog fileChooser = new FileChooserDialog("Choose the folder to open", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
if (fc.Run() == (int)ResponseType.Accept)
if (fileChooser.Run() == (int)ResponseType.Accept)
{
LoadApplication(fc.Filename);
LoadApplication(fileChooser.Filename);
}
fc.Destroy();
fileChooser.Destroy();
}
private void Open_Ryu_Folder(object o, EventArgs args)
@ -483,7 +485,7 @@ namespace Ryujinx.UI
private void FullScreen_Toggled(object o, EventArgs args)
{
if (_fullScreen.Active == true)
if (_fullScreen.Active)
{
Fullscreen();
}
@ -503,20 +505,6 @@ namespace Ryujinx.UI
SettingsWin.Show();
}
private void Nfc_Pressed(object o, EventArgs args)
{
FileChooserDialog fc = new FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
fc.Filter = new FileFilter();
fc.Filter.AddPattern("*.bin");
if (fc.Run() == (int)ResponseType.Accept)
{
// TODO: Write logic to emulate reading an NFC tag
}
fc.Destroy();
}
private void Update_Pressed(object o, EventArgs args)
{
string ryuUpdater = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "RyuUpdater.exe");
@ -543,72 +531,63 @@ namespace Ryujinx.UI
private void Icon_Toggled(object o, EventArgs args)
{
if (_iconToggle.Active) SwitchSettings.SwitchConfig.GuiColumns[0] = true;
else SwitchSettings.SwitchConfig.GuiColumns[0] = false;
SwitchSettings.SwitchConfig.GuiColumns[0] = _iconToggle.Active;
Configuration.SaveConfig(SwitchSettings.SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}
private void Title_Toggled(object o, EventArgs args)
{
if (_titleToggle.Active) SwitchSettings.SwitchConfig.GuiColumns[1] = true;
else SwitchSettings.SwitchConfig.GuiColumns[1] = false;
SwitchSettings.SwitchConfig.GuiColumns[1] = _titleToggle.Active;
Configuration.SaveConfig(SwitchSettings.SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}
private void Developer_Toggled(object o, EventArgs args)
{
if (_developerToggle.Active) SwitchSettings.SwitchConfig.GuiColumns[2] = true;
else SwitchSettings.SwitchConfig.GuiColumns[2] = false;
SwitchSettings.SwitchConfig.GuiColumns[2] = _developerToggle.Active;
Configuration.SaveConfig(SwitchSettings.SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}
private void Version_Toggled(object o, EventArgs args)
{
if (_versionToggle.Active) SwitchSettings.SwitchConfig.GuiColumns[3] = true;
else SwitchSettings.SwitchConfig.GuiColumns[3] = false;
SwitchSettings.SwitchConfig.GuiColumns[3] = _versionToggle.Active;
Configuration.SaveConfig(SwitchSettings.SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}
private void TimePlayed_Toggled(object o, EventArgs args)
{
if (_timePlayedToggle.Active) SwitchSettings.SwitchConfig.GuiColumns[4] = true;
else SwitchSettings.SwitchConfig.GuiColumns[4] = false;
SwitchSettings.SwitchConfig.GuiColumns[4] = _timePlayedToggle.Active;
Configuration.SaveConfig(SwitchSettings.SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}
private void LastPlayed_Toggled(object o, EventArgs args)
{
if (_lastPlayedToggle.Active) SwitchSettings.SwitchConfig.GuiColumns[5] = true;
else SwitchSettings.SwitchConfig.GuiColumns[5] = false;
SwitchSettings.SwitchConfig.GuiColumns[5] = _lastPlayedToggle.Active;
Configuration.SaveConfig(SwitchSettings.SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}
private void FileExt_Toggled(object o, EventArgs args)
{
if (_fileExtToggle.Active) SwitchSettings.SwitchConfig.GuiColumns[6] = true;
else SwitchSettings.SwitchConfig.GuiColumns[6] = false;
SwitchSettings.SwitchConfig.GuiColumns[6] = _fileExtToggle.Active;
Configuration.SaveConfig(SwitchSettings.SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}
private void FileSize_Toggled(object o, EventArgs args)
{
if (_fileSizeToggle.Active) SwitchSettings.SwitchConfig.GuiColumns[7] = true;
else SwitchSettings.SwitchConfig.GuiColumns[7] = false;
SwitchSettings.SwitchConfig.GuiColumns[7] = _fileSizeToggle.Active;
Configuration.SaveConfig(SwitchSettings.SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}
private void Path_Toggled(object o, EventArgs args)
{
if (_pathToggle.Active) SwitchSettings.SwitchConfig.GuiColumns[8] = true;
else SwitchSettings.SwitchConfig.GuiColumns[8] = false;
SwitchSettings.SwitchConfig.GuiColumns[8] = _pathToggle.Active;
Configuration.SaveConfig(SwitchSettings.SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
}

View file

@ -5,6 +5,7 @@
<object class="GtkApplicationWindow" id="_mainWin">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Ryujinx</property>
<property name="window_position">center</property>
<property name="default_width">1280</property>
<property name="default_height">750</property>
<child>
@ -245,21 +246,6 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes">Tools</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="_nfc">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Scan NFC Tag from File</property>
<property name="use_underline">True</property>
<signal name="activate" handler="Nfc_Pressed" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>

View file

@ -376,49 +376,49 @@ namespace Ryujinx.UI
public readonly Dictionary<string, string> GdkToOpenTKInput = new Dictionary<string, string>()
{
{ "Key_0", "Number0" },
{ "Key_1", "Number1" },
{ "Key_2", "Number2" },
{ "Key_3", "Number3" },
{ "Key_4", "Number4" },
{ "Key_5", "Number5" },
{ "Key_6", "Number6" },
{ "Key_7", "Number7" },
{ "Key_8", "Number8" },
{ "Key_9", "Number9" },
{ "equal", "Plus" },
{ "uparrow", "Up" },
{ "downarrow", "Down" },
{ "leftarrow", "Left" },
{ "rightarrow", "Right" },
{ "Control_L", "ControlLeft" },
{ "Control_R", "ControlRight" },
{ "Shift_L", "ShiftLeft" },
{ "Shift_R", "ShiftRight" },
{ "Alt_L", "AltLeft" },
{ "Alt_R", "AltRight" },
{ "Page_Up", "PageUp" },
{ "Page_Down", "PageDown" },
{ "KP_Enter", "KeypadEnter" },
{ "KP_Up", "Up" },
{ "KP_Down", "Down" },
{ "KP_Left", "Left" },
{ "KP_Right", "Right" },
{ "KP_Divide", "KeypadDivide" },
{ "KP_Multiply", "KeypadMultiply" },
{ "KP_Subtract", "KeypadSubtract" },
{ "KP_Add", "KeypadAdd" },
{ "KP_Decimal", "KeypadDecimal" },
{ "KP_0", "Keypad0" },
{ "KP_1", "Keypad1" },
{ "KP_2", "Keypad2" },
{ "KP_3", "Keypad3" },
{ "KP_4", "Keypad4" },
{ "KP_5", "Keypad5" },
{ "KP_6", "Keypad6" },
{ "KP_7", "Keypad7" },
{ "KP_8", "Keypad8" },
{ "KP_9", "Keypad9" },
{ "Key_0", "Number0" },
{ "Key_1", "Number1" },
{ "Key_2", "Number2" },
{ "Key_3", "Number3" },
{ "Key_4", "Number4" },
{ "Key_5", "Number5" },
{ "Key_6", "Number6" },
{ "Key_7", "Number7" },
{ "Key_8", "Number8" },
{ "Key_9", "Number9" },
{ "equal", "Plus" },
{ "uparrow", "Up" },
{ "downarrow", "Down" },
{ "leftarrow", "Left" },
{ "rightarrow", "Right" },
{ "Control_L", "ControlLeft" },
{ "Control_R", "ControlRight" },
{ "Shift_L", "ShiftLeft" },
{ "Shift_R", "ShiftRight" },
{ "Alt_L", "AltLeft" },
{ "Alt_R", "AltRight" },
{ "Page_Up", "PageUp" },
{ "Page_Down", "PageDown" },
{ "KP_Enter", "KeypadEnter" },
{ "KP_Up", "Up" },
{ "KP_Down", "Down" },
{ "KP_Left", "Left" },
{ "KP_Right", "Right" },
{ "KP_Divide", "KeypadDivide" },
{ "KP_Multiply", "KeypadMultiply" },
{ "KP_Subtract", "KeypadSubtract" },
{ "KP_Add", "KeypadAdd" },
{ "KP_Decimal", "KeypadDecimal" },
{ "KP_0", "Keypad0" },
{ "KP_1", "Keypad1" },
{ "KP_2", "Keypad2" },
{ "KP_3", "Keypad3" },
{ "KP_4", "Keypad4" },
{ "KP_5", "Keypad5" },
{ "KP_6", "Keypad6" },
{ "KP_7", "Keypad7" },
{ "KP_8", "Keypad8" },
{ "KP_9", "Keypad9" },
};
}
}

View file

@ -11,6 +11,7 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">Ryujinx - Settings</property>
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="default_width">910</property>
<property name="default_height">790</property>
<property name="type_hint">dialog</property>