mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-11-19 09:21:15 +01:00
misc: chore: Use explicit types & fix object creation
This commit is contained in:
1 parent
9d3fecf334
commit
76a123b81d
454 files changed
+3042
-2961
No files matched your search
@@ -11,6 +11,7 @@ using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.UI.App.Common;
|
||||
using Ryujinx.UI.Common.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -79,7 +80,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
private void LoadDownloadableContents()
|
||||
{
|
||||
var dlcs = _applicationLibrary.DownloadableContents.Items
|
||||
IEnumerable<(DownloadableContentModel Dlc, bool IsEnabled)> dlcs = _applicationLibrary.DownloadableContents.Items
|
||||
.Where(it => it.Dlc.TitleIdBase == _applicationData.IdBase);
|
||||
|
||||
bool hasBundledContent = false;
|
||||
@@ -109,11 +110,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
.ThenBy(it => it.TitleId)
|
||||
.AsObservableChangeSet()
|
||||
.Filter(Filter)
|
||||
.Bind(out var view).AsObservableList();
|
||||
.Bind(out ReadOnlyObservableCollection<DownloadableContentModel> view).AsObservableList();
|
||||
|
||||
// NOTE(jpr): this works around a bug where calling _views.Clear also clears SelectedDownloadableContents for
|
||||
// some reason. so we save the items here and add them back after
|
||||
var items = SelectedDownloadableContents.ToArray();
|
||||
DownloadableContentModel[] items = SelectedDownloadableContents.ToArray();
|
||||
|
||||
Views.Clear();
|
||||
Views.AddRange(view);
|
||||
@@ -140,7 +141,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
OsUtils.SetCoreDumpable(true);
|
||||
|
||||
var result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
IReadOnlyList<IStorageFile> result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.SelectDlcDialogTitle],
|
||||
AllowMultiple = true,
|
||||
@@ -155,10 +156,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
},
|
||||
});
|
||||
|
||||
var totalDlcAdded = 0;
|
||||
foreach (var file in result)
|
||||
int totalDlcAdded = 0;
|
||||
foreach (IStorageFile file in result)
|
||||
{
|
||||
if (!AddDownloadableContent(file.Path.LocalPath, out var newDlcAdded))
|
||||
if (!AddDownloadableContent(file.Path.LocalPath, out int newDlcAdded))
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogDlcNoDlcErrorMessage]);
|
||||
}
|
||||
@@ -186,18 +187,18 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_applicationLibrary.TryGetDownloadableContentFromFile(path, out var dlcs) || dlcs.Count == 0)
|
||||
if (!_applicationLibrary.TryGetDownloadableContentFromFile(path, out List<DownloadableContentModel> dlcs) || dlcs.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var dlcsForThisGame = dlcs.Where(it => it.TitleIdBase == _applicationData.IdBase).ToList();
|
||||
List<DownloadableContentModel> dlcsForThisGame = dlcs.Where(it => it.TitleIdBase == _applicationData.IdBase).ToList();
|
||||
if (dlcsForThisGame.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var dlc in dlcsForThisGame)
|
||||
foreach (DownloadableContentModel dlc in dlcsForThisGame)
|
||||
{
|
||||
if (!DownloadableContents.Contains(dlc))
|
||||
{
|
||||
@@ -261,13 +262,13 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public void Save()
|
||||
{
|
||||
var dlcs = DownloadableContents.Select(it => (it, SelectedDownloadableContents.Contains(it))).ToList();
|
||||
List<(DownloadableContentModel it, bool)> dlcs = DownloadableContents.Select(it => (it, SelectedDownloadableContents.Contains(it))).ToList();
|
||||
_applicationLibrary.SaveDownloadableContentsForGame(_applicationData, dlcs);
|
||||
}
|
||||
|
||||
private Task ShowNewDlcAddedDialog(int numAdded)
|
||||
{
|
||||
var msg = string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowDlcAddedMessage], numAdded);
|
||||
string msg = string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowDlcAddedMessage], numAdded);
|
||||
return Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
await ContentDialogHelper.ShowTextDialog(LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle], msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark);
|
||||
|
||||
Reference in new issue
Block a user