Run formatter

This commit is contained in:
Jimmy Reichley 2024-08-16 23:28:30 -04:00
parent 7850a2b2aa
commit 47e2cc6f02
No known key found for this signature in database
GPG Key ID: 67715DC5A329803C
7 changed files with 43 additions and 40 deletions

View File

@ -294,7 +294,7 @@ namespace Ryujinx.UI.App.Common
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
Logger.Warning?.Print(LogClass.Application, $"The file was not found: '{applicationPath}'"); Logger.Warning?.Print(LogClass.Application, $"The file was not found: '{applicationPath}'");
return false; return false;
} }
@ -492,7 +492,7 @@ namespace Ryujinx.UI.App.Common
return true; return true;
} }
public bool TryGetDownloadableContentFromFile(string filePath, out List<DownloadableContentModel> titleUpdates) public bool TryGetDownloadableContentFromFile(string filePath, out List<DownloadableContentModel> titleUpdates)
{ {
titleUpdates = []; titleUpdates = [];
@ -511,9 +511,9 @@ namespace Ryujinx.UI.App.Common
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
? IntegrityCheckLevel.ErrorOnInvalid ? IntegrityCheckLevel.ErrorOnInvalid
: IntegrityCheckLevel.None; : IntegrityCheckLevel.None;
using IFileSystem pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(filePath, _virtualFileSystem); using IFileSystem pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(filePath, _virtualFileSystem);
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca")) foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
{ {
using var ncaFile = new UniqueRef<IFile>(); using var ncaFile = new UniqueRef<IFile>();
@ -554,7 +554,7 @@ namespace Ryujinx.UI.App.Common
} }
return false; return false;
} }
public bool TryGetTitleUpdatesFromFile(string filePath, out List<TitleUpdateModel> titleUpdates) public bool TryGetTitleUpdatesFromFile(string filePath, out List<TitleUpdateModel> titleUpdates)
{ {
titleUpdates = []; titleUpdates = [];
@ -579,7 +579,7 @@ namespace Ryujinx.UI.App.Common
Dictionary<ulong, ContentMetaData> updates = Dictionary<ulong, ContentMetaData> updates =
pfs.GetContentData(ContentMetaType.Patch, _virtualFileSystem, checkLevel); pfs.GetContentData(ContentMetaType.Patch, _virtualFileSystem, checkLevel);
if (updates.Count == 0) if (updates.Count == 0)
{ {
return false; return false;
@ -609,7 +609,7 @@ namespace Ryujinx.UI.App.Common
titleUpdates.Add(update); titleUpdates.Add(update);
} }
} }
return true; return true;
} }
} }
@ -737,7 +737,7 @@ namespace Ryujinx.UI.App.Common
AppData = application, AppData = application,
}); });
} }
_applications.Edit(it => _applications.Edit(it =>
{ {
foreach (var application in applications) foreach (var application in applications)
@ -783,7 +783,7 @@ namespace Ryujinx.UI.App.Common
_downloadableContents.Edit(it => _downloadableContents.Edit(it =>
{ {
it.Clear(); it.Clear();
foreach (ApplicationData application in Applications.Items) foreach (ApplicationData application in Applications.Items)
{ {
var res = DownloadableContentsHelper.LoadDownloadableContentsJson(_virtualFileSystem, application.IdBase); var res = DownloadableContentsHelper.LoadDownloadableContentsJson(_virtualFileSystem, application.IdBase);
@ -791,18 +791,18 @@ namespace Ryujinx.UI.App.Common
} }
}); });
} }
public void SaveDownloadableContentsForGame(ApplicationData application, List<(DownloadableContentModel, bool IsEnabled)> dlcs) public void SaveDownloadableContentsForGame(ApplicationData application, List<(DownloadableContentModel, bool IsEnabled)> dlcs)
{ {
_downloadableContents.Edit(it => _downloadableContents.Edit(it =>
{ {
DownloadableContentsHelper.SaveDownloadableContentsJson(_virtualFileSystem, application.IdBase, dlcs); DownloadableContentsHelper.SaveDownloadableContentsJson(_virtualFileSystem, application.IdBase, dlcs);
it.Remove(it.Items.Where(item => item.Dlc.TitleIdBase == application.IdBase)); it.Remove(it.Items.Where(item => item.Dlc.TitleIdBase == application.IdBase));
it.AddOrUpdate(dlcs); it.AddOrUpdate(dlcs);
}); });
} }
// public void LoadTitleUpdates() // public void LoadTitleUpdates()
// { // {
// //
@ -812,7 +812,7 @@ namespace Ryujinx.UI.App.Common
{ {
_cancellationToken = new CancellationTokenSource(); _cancellationToken = new CancellationTokenSource();
_downloadableContents.Clear(); _downloadableContents.Clear();
// Builds the applications list with paths to found applications // Builds the applications list with paths to found applications
List<string> applicationPaths = new(); List<string> applicationPaths = new();
@ -837,7 +837,8 @@ namespace Ryujinx.UI.App.Common
{ {
EnumerationOptions options = new() EnumerationOptions options = new()
{ {
RecurseSubdirectories = true, IgnoreInaccessible = false, RecurseSubdirectories = true,
IgnoreInaccessible = false,
}; };
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", options).Where( IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", options).Where(
@ -896,7 +897,7 @@ namespace Ryujinx.UI.App.Common
DownloadableContent = downloadableContent, DownloadableContent = downloadableContent,
}); });
} }
_downloadableContents.Edit(it => _downloadableContents.Edit(it =>
{ {
foreach (var downloadableContent in downloadableContents) foreach (var downloadableContent in downloadableContents)
@ -918,7 +919,7 @@ namespace Ryujinx.UI.App.Common
{ {
_cancellationToken = new CancellationTokenSource(); _cancellationToken = new CancellationTokenSource();
_titleUpdates.Clear(); _titleUpdates.Clear();
// Builds the applications list with paths to found applications // Builds the applications list with paths to found applications
List<string> applicationPaths = new(); List<string> applicationPaths = new();
@ -943,7 +944,8 @@ namespace Ryujinx.UI.App.Common
{ {
EnumerationOptions options = new() EnumerationOptions options = new()
{ {
RecurseSubdirectories = true, IgnoreInaccessible = false, RecurseSubdirectories = true,
IgnoreInaccessible = false,
}; };
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", options) IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", options)
@ -1003,7 +1005,7 @@ namespace Ryujinx.UI.App.Common
TitleUpdate = titleUpdate, TitleUpdate = titleUpdate,
}); });
} }
_titleUpdates.Edit(it => _titleUpdates.Edit(it =>
{ {
foreach (var titleUpdate in titleUpdates) foreach (var titleUpdate in titleUpdates)
@ -1030,12 +1032,12 @@ namespace Ryujinx.UI.App.Common
{ {
ApplicationCountUpdated?.Invoke(null, e); ApplicationCountUpdated?.Invoke(null, e);
} }
protected void OnTitleUpdateAdded(TitleUpdateAddedEventArgs e) protected void OnTitleUpdateAdded(TitleUpdateAddedEventArgs e)
{ {
TitleUpdateAdded?.Invoke(null, e); TitleUpdateAdded?.Invoke(null, e);
} }
protected void OnDownloadableContentAdded(DownloadableContentAddedEventArgs e) protected void OnDownloadableContentAdded(DownloadableContentAddedEventArgs e)
{ {
DownloadableContentAdded?.Invoke(null, e); DownloadableContentAdded?.Invoke(null, e);
@ -1357,7 +1359,7 @@ namespace Ryujinx.UI.App.Common
return false; return false;
} }
private Nca TryOpenNca(IStorage ncaStorage) private Nca TryOpenNca(IStorage ncaStorage)
{ {
try try

View File

@ -19,7 +19,7 @@ namespace Ryujinx.UI.Common.Helper
public static class DownloadableContentsHelper public static class DownloadableContentsHelper
{ {
private static readonly DownloadableContentJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); private static readonly DownloadableContentJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
public static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContentsJson(VirtualFileSystem vfs, ulong applicationIdBase) public static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContentsJson(VirtualFileSystem vfs, ulong applicationIdBase)
{ {
// _downloadableContentJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationData.IdBaseString, "dlc.json"); // _downloadableContentJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationData.IdBaseString, "dlc.json");
@ -86,7 +86,7 @@ namespace Ryujinx.UI.Common.Helper
private static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContents(VirtualFileSystem vfs, List<DownloadableContentContainer> downloadableContentContainers) private static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContents(VirtualFileSystem vfs, List<DownloadableContentContainer> downloadableContentContainers)
{ {
var result = new List<(DownloadableContentModel, bool IsEnabled)>(); var result = new List<(DownloadableContentModel, bool IsEnabled)>();
foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers) foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers)
{ {
if (!File.Exists(downloadableContentContainer.ContainerPath)) if (!File.Exists(downloadableContentContainer.ContainerPath))
@ -127,7 +127,7 @@ namespace Ryujinx.UI.Common.Helper
return result; return result;
} }
private static Nca TryOpenNca(VirtualFileSystem vfs, IStorage ncaStorage) private static Nca TryOpenNca(VirtualFileSystem vfs, IStorage ncaStorage)
{ {
try try

View File

@ -19,7 +19,7 @@ namespace Ryujinx.Ava.UI.Helpers
{ {
return BindingOperations.DoNothing; return BindingOperations.DoNothing;
} }
if (values.Count != 2 || !targetType.IsAssignableFrom(typeof(string))) if (values.Count != 2 || !targetType.IsAssignableFrom(typeof(string)))
{ {
return null; return null;
@ -29,7 +29,7 @@ namespace Ryujinx.Ava.UI.Helpers
{ {
return null; return null;
} }
return isBundled ? $"{LocaleManager.Instance[LocaleKeys.TitleBundledDlcLabel]} {label}" : label; return isBundled ? $"{LocaleManager.Instance[LocaleKeys.TitleBundledDlcLabel]} {label}" : label;
} }

View File

@ -12,14 +12,14 @@ namespace Ryujinx.Ava.UI.Helpers
internal class TitleUpdateLabelConverter : IMultiValueConverter internal class TitleUpdateLabelConverter : IMultiValueConverter
{ {
public static TitleUpdateLabelConverter Instance = new(); public static TitleUpdateLabelConverter Instance = new();
public object Convert(IList<object> values, Type targetType, object parameter, CultureInfo culture) public object Convert(IList<object> values, Type targetType, object parameter, CultureInfo culture)
{ {
if (values.Any(it => it is UnsetValueType)) if (values.Any(it => it is UnsetValueType))
{ {
return BindingOperations.DoNothing; return BindingOperations.DoNothing;
} }
if (values.Count != 2 || !targetType.IsAssignableFrom(typeof(string))) if (values.Count != 2 || !targetType.IsAssignableFrom(typeof(string)))
{ {
return null; return null;
@ -29,7 +29,7 @@ namespace Ryujinx.Ava.UI.Helpers
{ {
return null; return null;
} }
var key = isBundled ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel; var key = isBundled ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel;
return LocaleManager.Instance.UpdateAndGetDynamicValue(key, label); return LocaleManager.Instance.UpdateAndGetDynamicValue(key, label);
} }

View File

@ -134,12 +134,12 @@ namespace Ryujinx.Ava.UI.ViewModels
foreach ((DownloadableContentModel dlc, bool isEnabled) in _applicationLibrary.DownloadableContents.Items.Where(it => it.Dlc.TitleIdBase == _applicationData.IdBase)) foreach ((DownloadableContentModel dlc, bool isEnabled) in _applicationLibrary.DownloadableContents.Items.Where(it => it.Dlc.TitleIdBase == _applicationData.IdBase))
{ {
DownloadableContents.Add(dlc); DownloadableContents.Add(dlc);
if (isEnabled) if (isEnabled)
{ {
SelectedDownloadableContents.Add(dlc); SelectedDownloadableContents.Add(dlc);
} }
OnPropertyChanged(nameof(UpdateCount)); OnPropertyChanged(nameof(UpdateCount));
} }
@ -163,12 +163,12 @@ namespace Ryujinx.Ava.UI.ViewModels
_views.Clear(); _views.Clear();
_views.AddRange(view); _views.AddRange(view);
foreach (DownloadableContentModel item in items) foreach (DownloadableContentModel item in items)
{ {
SelectedDownloadableContents.ReplaceOrAdd(item, item); SelectedDownloadableContents.ReplaceOrAdd(item, item);
} }
OnPropertyChanged(nameof(Views)); OnPropertyChanged(nameof(Views));
} }
@ -291,7 +291,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
SelectedDownloadableContents.ReplaceOrAdd(model, model); SelectedDownloadableContents.ReplaceOrAdd(model, model);
} }
public void Disable(DownloadableContentModel model) public void Disable(DownloadableContentModel model)
{ {
SelectedDownloadableContents.Remove(model); SelectedDownloadableContents.Remove(model);

View File

@ -22,10 +22,10 @@ using Path = System.IO.Path;
namespace Ryujinx.Ava.UI.ViewModels namespace Ryujinx.Ava.UI.ViewModels
{ {
public record TitleUpdateViewNoUpdateSentinal(); public record TitleUpdateViewNoUpdateSentinal();
public class TitleUpdateViewModel : BaseModel public class TitleUpdateViewModel : BaseModel
{ {
public TitleUpdateMetadata TitleUpdateWindowData; public TitleUpdateMetadata TitleUpdateWindowData;
public readonly string TitleUpdateJsonPath; public readonly string TitleUpdateJsonPath;
private VirtualFileSystem VirtualFileSystem { get; } private VirtualFileSystem VirtualFileSystem { get; }
@ -146,7 +146,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
return; return;
} }
try try
{ {
if (!ApplicationLibrary.TryGetTitleUpdatesFromFile(path, out var titleUpdates)) if (!ApplicationLibrary.TryGetTitleUpdatesFromFile(path, out var titleUpdates))
@ -175,7 +175,8 @@ namespace Ryujinx.Ava.UI.ViewModels
Dispatcher.UIThread.InvokeAsync(() => SelectedUpdate = titleUpdate); Dispatcher.UIThread.InvokeAsync(() => SelectedUpdate = titleUpdate);
} }
} }
} catch (Exception ex) }
catch (Exception ex)
{ {
Dispatcher.UIThread.InvokeAsync(() => ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogLoadFileErrorMessage, ex.Message, path))); Dispatcher.UIThread.InvokeAsync(() => ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogLoadFileErrorMessage, ex.Message, path)));
} }

View File

@ -149,7 +149,7 @@ namespace Ryujinx.Ava.UI.Windows
var it = e.DownloadableContent; var it = e.DownloadableContent;
Console.WriteLine("[{0}]: {1} ({2})", it.TitleIdBase, it.ContainerPath, it.FullPath); Console.WriteLine("[{0}]: {1} ({2})", it.TitleIdBase, it.ContainerPath, it.FullPath);
} }
private void ApplicationLibrary_TitleUpdateAdded(object sender, TitleUpdateAddedEventArgs e) private void ApplicationLibrary_TitleUpdateAdded(object sender, TitleUpdateAddedEventArgs e)
{ {
var it = e.TitleUpdate; var it = e.TitleUpdate;
@ -664,7 +664,7 @@ namespace Ryujinx.Ava.UI.Windows
}; };
applicationLibraryThread.Start(); applicationLibraryThread.Start();
} }
private static void TimeIt(string tag, Action act) private static void TimeIt(string tag, Action act)
{ {
var watch = System.Diagnostics.Stopwatch.StartNew(); var watch = System.Diagnostics.Stopwatch.StartNew();