diff --git a/Ryujinx/Ryujinx.csproj b/Ryujinx/Ryujinx.csproj index abdef425c6..b8c4026cdb 100644 --- a/Ryujinx/Ryujinx.csproj +++ b/Ryujinx/Ryujinx.csproj @@ -65,7 +65,7 @@ - + diff --git a/Ryujinx/Ui/AboutWindow.cs b/Ryujinx/Ui/AboutWindow.cs index ccdd55186f..9d1fff68ed 100644 --- a/Ryujinx/Ui/AboutWindow.cs +++ b/Ryujinx/Ui/AboutWindow.cs @@ -110,7 +110,7 @@ namespace Ryujinx.UI private void CloseToggle_Activated(object obj, EventArgs args) { - Destroy(); + Dispose(); } } } diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index 31d99db000..6c311234a8 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -160,7 +160,7 @@ namespace Ryujinx.UI }; errorDialog.SetSizeRequest(100, 20); errorDialog.Run(); - errorDialog.Destroy(); + errorDialog.Dispose(); } public static void UpdateGameTable() @@ -171,6 +171,10 @@ namespace Ryujinx.UI foreach (ApplicationLibrary.ApplicationData AppData in ApplicationLibrary.ApplicationLibraryData) { _tableStore.AppendValues(new Gdk.Pixbuf(AppData.Icon, 75, 75), $"{AppData.TitleName}\n{AppData.TitleId.ToUpper()}", AppData.Developer, AppData.Version, AppData.TimePlayed, AppData.LastPlayed, AppData.FileExt, AppData.FileSize, AppData.Path); + + _tableStore.SetSortFunc(4, TimePlayedSort); + _tableStore.SetSortFunc(5, LastPlayedSort); + _tableStore.SetSortFunc(7, FileSizeSort); } } @@ -484,7 +488,7 @@ namespace Ryujinx.UI LoadApplication(fileChooser.Filename); } - fileChooser.Destroy(); + fileChooser.Dispose(); } private void Load_Application_Folder(object o, EventArgs args) @@ -496,7 +500,7 @@ namespace Ryujinx.UI LoadApplication(fileChooser.Filename); } - fileChooser.Destroy(); + fileChooser.Dispose(); } private void Open_Ryu_Folder(object o, EventArgs args) @@ -650,5 +654,82 @@ namespace Ryujinx.UI if (_firstLoadComplete) UpdateColumns(); } + + private static int TimePlayedSort(ITreeModel model, TreeIter a, TreeIter b) + { + string aValue = model.GetValue(a, 4).ToString(); + string bValue = model.GetValue(b, 4).ToString(); + + if (aValue.Length > 4 && aValue.Substring(aValue.Length - 4) == "mins") + { + aValue = (float.Parse(aValue.Substring(0, aValue.Length - 5)) * 60).ToString(); + } + else if (aValue.Length > 3 && aValue.Substring(aValue.Length - 3) == "hrs") + { + aValue = (float.Parse(aValue.Substring(0, aValue.Length - 4)) * 3600).ToString(); + } + else if (aValue.Length > 4 && aValue.Substring(aValue.Length - 4) == "days") + { + aValue = (float.Parse(aValue.Substring(0, aValue.Length - 5)) * 86400).ToString(); + } + else + { + aValue = aValue.Substring(0, aValue.Length - 1); + } + + if (bValue.Length > 4 && bValue.Substring(bValue.Length - 4) == "mins") + { + bValue = (float.Parse(bValue.Substring(0, bValue.Length - 5)) * 60).ToString(); + } + else if (bValue.Length > 3 && bValue.Substring(bValue.Length - 3) == "hrs") + { + bValue = (float.Parse(bValue.Substring(0, bValue.Length - 4)) * 3600).ToString(); + } + else if (bValue.Length > 4 && bValue.Substring(bValue.Length - 4) == "days") + { + bValue = (float.Parse(bValue.Substring(0, bValue.Length - 5)) * 86400).ToString(); + } + else + { + bValue = bValue.Substring(0, bValue.Length - 1); + } + + if (float.Parse(aValue) > float.Parse(bValue)) return -1; + else if (float.Parse(bValue) > float.Parse(aValue)) return 1; + else return 0; + } + + private static int LastPlayedSort(ITreeModel model, TreeIter a, TreeIter b) + { + string aValue = model.GetValue(a, 5).ToString(); + string bValue = model.GetValue(b, 5).ToString(); + + if (aValue == "Never") aValue = DateTime.UnixEpoch.ToString(); + if (bValue == "Never") bValue = DateTime.UnixEpoch.ToString(); + + return DateTime.Compare(DateTime.Parse(bValue), DateTime.Parse(aValue)); + } + + private static int FileSizeSort(ITreeModel model, TreeIter a, TreeIter b) + { + string aValue = model.GetValue(a, 7).ToString(); + string bValue = model.GetValue(b, 7).ToString(); + + if (aValue.Substring(aValue.Length - 2) == "GB") + { + aValue = (float.Parse(aValue.Substring(0, aValue.Length - 2)) * 1024).ToString(); + } + else aValue = aValue.Substring(0, aValue.Length - 2); + + if (bValue.Substring(bValue.Length - 2) == "GB") + { + bValue = (float.Parse(bValue.Substring(0, bValue.Length - 2)) * 1024).ToString(); + } + else bValue = bValue.Substring(0, bValue.Length - 2); + + if (float.Parse(aValue) > float.Parse(bValue)) return -1; + else if (float.Parse(bValue) > float.Parse(aValue)) return 1; + else return 0; + } } } diff --git a/Ryujinx/Ui/SwitchSettings.cs b/Ryujinx/Ui/SwitchSettings.cs index d2caba94a6..81e4181f08 100644 --- a/Ryujinx/Ui/SwitchSettings.cs +++ b/Ryujinx/Ui/SwitchSettings.cs @@ -270,7 +270,7 @@ namespace Ryujinx.UI _gameDirsBoxStore.AppendValues(fileChooser.Filename); } - fileChooser.Destroy(); + fileChooser.Dispose(); _browseDir.SetStateFlags(0, true); } @@ -304,7 +304,7 @@ namespace Ryujinx.UI _custThemePath.Buffer.Text = fileChooser.Filename; } - fileChooser.Destroy(); + fileChooser.Dispose(); _browseThemePath.SetStateFlags(0, true); } @@ -385,12 +385,12 @@ namespace Ryujinx.UI MainWindow.ApplyTheme(); MainWindow.UpdateGameTable(); - Destroy(); + Dispose(); } private void CloseToggle_Activated(object obj, EventArgs args) { - Destroy(); + Dispose(); } public readonly Dictionary GdkToOpenTKInput = new Dictionary()