Initial Implementation

This commit is contained in:
Luke44565 2024-03-12 20:57:23 -04:00
parent 8354434a37
commit 22d77f03ff
8 changed files with 99 additions and 2 deletions

View file

@ -41,6 +41,7 @@ namespace Ryujinx.UI.App.Common
private readonly byte[] _ncaIcon;
private readonly byte[] _nroIcon;
private readonly byte[] _nsoIcon;
private readonly byte[] _folderIcon;
private readonly VirtualFileSystem _virtualFileSystem;
private Language _desiredTitleLanguage;
@ -58,6 +59,7 @@ namespace Ryujinx.UI.App.Common
_ncaIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_NCA.png");
_nroIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_NRO.png");
_nsoIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_NSO.png");
_folderIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_Folder.png");
}
private static byte[] GetResourceBytes(string resourceName)
@ -113,7 +115,31 @@ namespace Ryujinx.UI.App.Common
try
{
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", SearchOption.AllDirectories).Where(file =>
IEnumerable<string> folders = Directory.EnumerateDirectories(appDir, "*", SearchOption.TopDirectoryOnly);
foreach (string folder in folders)
{
if (_cancellationToken.Token.IsCancellationRequested)
{
return;
}
var fileInfo = new FileInfo(folder);
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
ApplicationData folderData = new()
{
TitleName = fileInfo.Name,
FileExtension = "Folder",
Path = fullPath,
Icon = _folderIcon,
};
OnApplicationAdded(new ApplicationAddedEventArgs
{
AppData = folderData,
});
}
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", SearchOption.TopDirectoryOnly).Where(file =>
{
return
(Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Instance.UI.ShownFileTypes.NSP.Value) ||
@ -163,7 +189,26 @@ namespace Ryujinx.UI.App.Common
return;
}
long fileSize = new FileInfo(applicationPath).Length;
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;
string titleName = "Unknown";
string titleId = "0000000000000000";
string developer = "Unknown";

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -15,6 +15,7 @@
<None Remove="Resources\Icon_NSO.png" />
<None Remove="Resources\Icon_NSP.png" />
<None Remove="Resources\Icon_XCI.png" />
<None Remove="Resources\Icon_Folder.png" />
<None Remove="Resources\Logo_Amiibo.png" />
<None Remove="Resources\Logo_Discord.png" />
<None Remove="Resources\Logo_GitHub.png" />
@ -33,6 +34,7 @@
<EmbeddedResource Include="Resources\Icon_NSO.png" />
<EmbeddedResource Include="Resources\Icon_NSP.png" />
<EmbeddedResource Include="Resources\Icon_XCI.png" />
<EmbeddedResource Include="Resources\Icon_Folder.png" />
<EmbeddedResource Include="Resources\Logo_Amiibo.png" />
<EmbeddedResource Include="Resources\Logo_Ryujinx.png" />
<EmbeddedResource Include="Resources\Logo_Discord_Dark.png" />

View file

@ -4,6 +4,7 @@ namespace Ryujinx.Ava.UI.Helpers
{
List,
Grid,
Back,
Chip,
}
}

View file

@ -13,6 +13,7 @@ namespace Ryujinx.Ava.UI.Helpers
{
{ Glyph.List, char.ConvertFromUtf32((int)Symbol.List) },
{ Glyph.Grid, char.ConvertFromUtf32((int)Symbol.ViewAll) },
{ Glyph.Back, char.ConvertFromUtf32((int)Symbol.Back) },
{ Glyph.Chip, char.ConvertFromUtf32(59748) },
};

View file

@ -51,6 +51,7 @@ namespace Ryujinx.Ava.UI.ViewModels
private const int HotKeyPressDelayMs = 500;
private ObservableCollection<ApplicationData> _applications;
private Queue<string> _pathHistory;
private string _aspectStatusText;
private string _loadHeading;
@ -120,6 +121,7 @@ namespace Ryujinx.Ava.UI.ViewModels
.Bind(out _appsObservableList).AsObservableList();
_rendererWaitEvent = new AutoResetEvent(false);
_pathHistory = new Queue<string>();
if (Program.PreviewerDetached)
{
@ -1281,6 +1283,34 @@ namespace Ryujinx.Ava.UI.ViewModels
ShowConsole = !ShowConsole;
}
public void OpenFolder(string path)
{
_pathHistory.Enqueue(path);
Applications.Clear();
List<string> SearchPaths = new List<string>();
SearchPaths.Add(path);
ApplicationLibrary.LoadApplications(SearchPaths, ConfigurationState.Instance.System.Language);
}
public void NavigateBack()
{
if (_pathHistory.Count != 0)
{
string path = _pathHistory.Dequeue();
Applications.Clear();
if (_pathHistory.Count == 0)
{
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs, ConfigurationState.Instance.System.Language);
}
else
{
List<string> SearchPaths = new List<string>();
SearchPaths.Add(path);
ApplicationLibrary.LoadApplications(SearchPaths, ConfigurationState.Instance.System.Language);
}
}
}
public void SetListMode()
{
Glyph = Glyph.List;

View file

@ -18,6 +18,19 @@
Margin="0,0,0,5"
Height="35"
HorizontalAlignment="Stretch">
<Button
Width="80"
MinWidth="80"
Margin="5,2,0,2"
VerticalAlignment="Stretch"
Command="{Binding NavigateBack}">
<ui:FontIcon
Margin="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
FontFamily="avares://FluentAvalonia/Fonts#Symbols"
Glyph="{helpers:GlyphValueConverter Back}" />
</Button>
<Button
Width="40"
MinWidth="40"

View file

@ -137,6 +137,11 @@ namespace Ryujinx.Ava.UI.Windows
{
if (args.Application != null)
{
if (args.Application.FileExtension == "Folder")
{
ViewModel.OpenFolder(args.Application.Path);
return;
}
ViewModel.SelectedIcon = args.Application.Icon;
string path = new FileInfo(args.Application.Path).FullName;