From 8282c7b6c67d43255591048405a8b10e4263d7ab Mon Sep 17 00:00:00 2001 From: Luke44565 Date: Wed, 13 Mar 2024 18:43:54 -0400 Subject: [PATCH] fixed path history and the reload button --- .../App/ApplicationLibrary.cs | 21 +------------------ .../UI/ViewModels/MainWindowViewModel.cs | 14 +++++++------ src/Ryujinx/UI/Windows/MainWindow.axaml.cs | 12 ++++++++++- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs index 508794127..013ff3607 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs @@ -191,26 +191,7 @@ namespace Ryujinx.UI.App.Common return; } - var fileInfo = new FileInfo(applicationPath); - - if ((fileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory) - { - Console.WriteLine($"Found directory 2: {fileInfo.Name}"); - ApplicationData folder = new() - { - TitleName = fileInfo.Name, - FileExtension = "Folder", - Developer = "null", - Path = applicationPath, - Icon = _nsoIcon, - }; - OnApplicationAdded(new ApplicationAddedEventArgs - { - AppData = folder, - }); - } - - long fileSize = fileInfo.Length; + long fileSize = new FileInfo(applicationPath).Length; string titleName = "Unknown"; string titleId = "0000000000000000"; string developer = "Unknown"; diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index 8a49dee05..94f7dc800 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -51,7 +51,7 @@ namespace Ryujinx.Ava.UI.ViewModels private const int HotKeyPressDelayMs = 500; private ObservableCollection _applications; - private readonly Queue _pathHistory; + private readonly Stack _pathHistory; private string _aspectStatusText; private string _loadHeading; @@ -122,7 +122,7 @@ namespace Ryujinx.Ava.UI.ViewModels .Bind(out _appsObservableList).AsObservableList(); _rendererWaitEvent = new AutoResetEvent(false); - _pathHistory = new Queue(); + _pathHistory = new Stack(); if (Program.PreviewerDetached) { @@ -217,6 +217,8 @@ namespace Ryujinx.Ava.UI.ViewModels } } + public Stack PathHistory => _pathHistory; + public bool IsPaused { get => _isPaused; @@ -1296,7 +1298,7 @@ namespace Ryujinx.Ava.UI.ViewModels public void OpenFolder(string path) { - _pathHistory.Enqueue(path); + _pathHistory.Push(path); IsInFolder = _pathHistory.Count != 0; Applications.Clear(); @@ -1309,7 +1311,7 @@ namespace Ryujinx.Ava.UI.ViewModels { if (_pathHistory.Count != 0) { - string path = _pathHistory.Dequeue(); + _pathHistory.Pop(); Applications.Clear(); if (_pathHistory.Count == 0) { @@ -1317,8 +1319,8 @@ namespace Ryujinx.Ava.UI.ViewModels } else { - List SearchPaths = new List(); - SearchPaths.Add(path); + List SearchPaths = new(); + SearchPaths.Add(_pathHistory.Peek()); ApplicationLibrary.LoadApplications(SearchPaths, ConfigurationState.Instance.System.Language); } } diff --git a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs index def449a1d..792fe2444 100644 --- a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs @@ -23,6 +23,7 @@ using Ryujinx.UI.Common; using Ryujinx.UI.Common.Configuration; using Ryujinx.UI.Common.Helper; using System; +using System.Collections.Generic; using System.IO; using System.Runtime.Versioning; using System.Threading; @@ -542,7 +543,16 @@ namespace Ryujinx.Ava.UI.Windows Thread applicationLibraryThread = new(() => { - ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs, ConfigurationState.Instance.System.Language); + if (ViewModel.IsInFolder) + { + List SearchPaths = new(); + SearchPaths.Add(ViewModel.PathHistory.Peek()); + ApplicationLibrary.LoadApplications(SearchPaths, ConfigurationState.Instance.System.Language); + } + else + { + ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs, ConfigurationState.Instance.System.Language); + } _isLoading = false; })