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
@@ -8,7 +8,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
protected void OnPropertiesChanged(string firstPropertyName, params ReadOnlySpan<string> propertyNames)
|
||||
{
|
||||
OnPropertyChanged(firstPropertyName);
|
||||
foreach (var propertyName in propertyNames)
|
||||
foreach (string propertyName in propertyNames)
|
||||
{
|
||||
OnPropertyChanged(propertyName);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = Devices[_device].Type;
|
||||
DeviceType selected = Devices[_device].Type;
|
||||
|
||||
if (selected != DeviceType.None)
|
||||
{
|
||||
@@ -308,7 +308,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
}
|
||||
else
|
||||
{
|
||||
var type = DeviceType.None;
|
||||
DeviceType type = DeviceType.None;
|
||||
|
||||
if (Config is StandardKeyboardInputConfig)
|
||||
{
|
||||
@@ -320,7 +320,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
type = DeviceType.Controller;
|
||||
}
|
||||
|
||||
var item = Devices.FirstOrDefault(x => x.Type == type && x.Id == Config.Id);
|
||||
(DeviceType Type, string Id, string Name) item = Devices.FirstOrDefault(x => x.Type == type && x.Id == Config.Id);
|
||||
if (item != default)
|
||||
{
|
||||
Device = Devices.ToList().FindIndex(x => x.Id == item.Id);
|
||||
@@ -340,7 +340,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
}
|
||||
|
||||
string id = GetCurrentGamepadId();
|
||||
var type = Devices[Device].Type;
|
||||
DeviceType type = Devices[Device].Type;
|
||||
|
||||
if (type == DeviceType.None)
|
||||
{
|
||||
@@ -388,7 +388,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var device = Devices[Device];
|
||||
(DeviceType Type, string Id, string Name) device = Devices[Device];
|
||||
|
||||
if (device.Type == DeviceType.None)
|
||||
{
|
||||
@@ -510,7 +510,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
private string GetProfileBasePath()
|
||||
{
|
||||
string path = AppDataManager.ProfilesDirPath;
|
||||
var type = Devices[Device == -1 ? 0 : Device].Type;
|
||||
DeviceType type = Devices[Device == -1 ? 0 : Device].Type;
|
||||
|
||||
if (type == DeviceType.Keyboard)
|
||||
{
|
||||
@@ -550,7 +550,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
|
||||
public InputConfig LoadDefaultConfiguration()
|
||||
{
|
||||
var activeDevice = Devices.FirstOrDefault();
|
||||
(DeviceType Type, string Id, string Name) activeDevice = Devices.FirstOrDefault();
|
||||
|
||||
if (Devices.Count > 0 && Device < Devices.Count && Device >= 0)
|
||||
{
|
||||
@@ -850,20 +850,20 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
}
|
||||
else
|
||||
{
|
||||
var device = Devices[Device];
|
||||
(DeviceType Type, string Id, string Name) device = Devices[Device];
|
||||
|
||||
if (device.Type == DeviceType.Keyboard)
|
||||
{
|
||||
var inputConfig = ((KeyboardInputViewModel)ConfigViewModel).Config;
|
||||
KeyboardInputConfig inputConfig = ((KeyboardInputViewModel)ConfigViewModel).Config;
|
||||
inputConfig.Id = device.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
var inputConfig = ((ControllerInputViewModel)ConfigViewModel).Config;
|
||||
GamepadInputConfig inputConfig = ((ControllerInputViewModel)ConfigViewModel).Config;
|
||||
inputConfig.Id = device.Id.Split(" ")[0];
|
||||
}
|
||||
|
||||
var config = !IsController
|
||||
InputConfig config = !IsController
|
||||
? ((KeyboardInputViewModel)ConfigViewModel).Config.GetConfig()
|
||||
: ((ControllerInputViewModel)ConfigViewModel).Config.GetConfig();
|
||||
config.ControllerType = Controllers[_controller].Type;
|
||||
|
||||
@@ -1056,9 +1056,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
private void PrepareLoadScreen()
|
||||
{
|
||||
using MemoryStream stream = new(SelectedIcon);
|
||||
using var gameIconBmp = SKBitmap.Decode(stream);
|
||||
using SKBitmap gameIconBmp = SKBitmap.Decode(stream);
|
||||
|
||||
var dominantColor = IconColorPicker.GetFilteredColor(gameIconBmp);
|
||||
SKColor dominantColor = IconColorPicker.GetFilteredColor(gameIconBmp);
|
||||
|
||||
const float ColorMultiple = 0.5f;
|
||||
|
||||
@@ -1167,7 +1167,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
OsUtils.SetCoreDumpable(true);
|
||||
|
||||
var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
IReadOnlyList<IStorageFolder> result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.OpenFolderDialogTitle],
|
||||
AllowMultiple = true,
|
||||
@@ -1175,10 +1175,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
if (result.Count > 0)
|
||||
{
|
||||
var dirs = result.Select(it => it.Path.LocalPath).ToList();
|
||||
var numAdded = onDirsSelected(dirs, out int numRemoved);
|
||||
List<string> dirs = result.Select(it => it.Path.LocalPath).ToList();
|
||||
int numAdded = onDirsSelected(dirs, out int numRemoved);
|
||||
|
||||
var msg = String.Join("\r\n", new[] {
|
||||
string msg = String.Join("\r\n", new[] {
|
||||
string.Format(LocaleManager.Instance[localeMessageRemovedKey], numRemoved),
|
||||
string.Format(LocaleManager.Instance[localeMessageAddedKey], numAdded)
|
||||
});
|
||||
@@ -1215,17 +1215,17 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public void LoadConfigurableHotKeys()
|
||||
{
|
||||
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI, out var showUiKey))
|
||||
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI, out Avalonia.Input.Key showUiKey))
|
||||
{
|
||||
ShowUiKey = new KeyGesture(showUiKey);
|
||||
}
|
||||
|
||||
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot, out var screenshotKey))
|
||||
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot, out Avalonia.Input.Key screenshotKey))
|
||||
{
|
||||
ScreenshotKey = new KeyGesture(screenshotKey);
|
||||
}
|
||||
|
||||
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Pause, out var pauseKey))
|
||||
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Pause, out Avalonia.Input.Key pauseKey))
|
||||
{
|
||||
PauseKey = new KeyGesture(pauseKey);
|
||||
}
|
||||
@@ -1275,7 +1275,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
OsUtils.SetCoreDumpable(true);
|
||||
|
||||
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
IReadOnlyList<IStorageFile> result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
@@ -1316,7 +1316,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
OsUtils.SetCoreDumpable(true);
|
||||
|
||||
var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
IReadOnlyList<IStorageFolder> result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
AllowMultiple = false,
|
||||
});
|
||||
@@ -1336,7 +1336,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
OsUtils.SetCoreDumpable(true);
|
||||
|
||||
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
IReadOnlyList<IStorageFile> result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
@@ -1377,7 +1377,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
OsUtils.SetCoreDumpable(true);
|
||||
|
||||
var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
IReadOnlyList<IStorageFolder> result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
AllowMultiple = false,
|
||||
});
|
||||
@@ -1494,7 +1494,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.OpenFileDialogTitle],
|
||||
AllowMultiple = false,
|
||||
@@ -1592,7 +1592,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
OsUtils.SetCoreDumpable(true);
|
||||
|
||||
var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
IReadOnlyList<IStorageFolder> result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.OpenFolderDialogTitle],
|
||||
AllowMultiple = false,
|
||||
@@ -1649,7 +1649,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
this,
|
||||
TopLevel);
|
||||
|
||||
CancellationTokenSource cts = new CancellationTokenSource();
|
||||
CancellationTokenSource cts = new();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1796,7 +1796,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
if (AppHost.Device.System.SearchingForAmiibo(out _) && IsGameRunning)
|
||||
{
|
||||
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
IReadOnlyList<IStorageFile> result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.OpenFileDialogTitle],
|
||||
AllowMultiple = false,
|
||||
@@ -2041,16 +2041,16 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
var trimmer = new XCIFileTrimmer(filename, new XCIFileTrimmerMainWindowLog(this));
|
||||
XCIFileTrimmer trimmer = new(filename, new XCIFileTrimmerMainWindowLog(this));
|
||||
|
||||
if (trimmer.CanBeTrimmed)
|
||||
{
|
||||
var savings = (double)trimmer.DiskSpaceSavingsB / 1024.0 / 1024.0;
|
||||
var currentFileSize = (double)trimmer.FileSizeB / 1024.0 / 1024.0;
|
||||
var cartDataSize = (double)trimmer.DataSizeB / 1024.0 / 1024.0;
|
||||
double savings = (double)trimmer.DiskSpaceSavingsB / 1024.0 / 1024.0;
|
||||
double currentFileSize = (double)trimmer.FileSizeB / 1024.0 / 1024.0;
|
||||
double cartDataSize = (double)trimmer.DataSizeB / 1024.0 / 1024.0;
|
||||
string secondaryText = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.TrimXCIFileDialogSecondaryText, currentFileSize, cartDataSize, savings);
|
||||
|
||||
var result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
LocaleManager.Instance[LocaleKeys.TrimXCIFileDialogPrimaryText],
|
||||
secondaryText,
|
||||
LocaleManager.Instance[LocaleKeys.Continue],
|
||||
|
||||
@@ -14,6 +14,8 @@ using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE.HOS;
|
||||
using Ryujinx.UI.App.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -90,44 +92,44 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
string[] modsBasePaths = [ModLoader.GetSdModsBasePath(), ModLoader.GetModsBasePath()];
|
||||
|
||||
foreach (var path in modsBasePaths)
|
||||
foreach (string path in modsBasePaths)
|
||||
{
|
||||
var inSd = path == ModLoader.GetSdModsBasePath();
|
||||
var modCache = new ModLoader.ModCache();
|
||||
bool inSd = path == ModLoader.GetSdModsBasePath();
|
||||
ModLoader.ModCache modCache = new();
|
||||
|
||||
ModLoader.QueryContentsDir(modCache, new DirectoryInfo(Path.Combine(path, "contents")), applicationId, installedDlcIds);
|
||||
|
||||
foreach (var mod in modCache.RomfsDirs)
|
||||
foreach (ModLoader.Mod<DirectoryInfo> mod in modCache.RomfsDirs)
|
||||
{
|
||||
var modModel = new ModModel(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||
ModModel modModel = new(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||
if (Mods.All(x => x.Path != mod.Path.Parent?.FullName))
|
||||
{
|
||||
Mods.Add(modModel);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var mod in modCache.RomfsContainers)
|
||||
foreach (ModLoader.Mod<FileInfo> mod in modCache.RomfsContainers)
|
||||
{
|
||||
Mods.Add(new ModModel(mod.Path.FullName, mod.Name, mod.Enabled, inSd));
|
||||
}
|
||||
|
||||
foreach (var mod in modCache.ExefsDirs)
|
||||
foreach (ModLoader.Mod<DirectoryInfo> mod in modCache.ExefsDirs)
|
||||
{
|
||||
var modModel = new ModModel(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||
ModModel modModel = new(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||
if (Mods.All(x => x.Path != mod.Path.Parent?.FullName))
|
||||
{
|
||||
Mods.Add(modModel);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var mod in modCache.ExefsContainers)
|
||||
foreach (ModLoader.Mod<FileInfo> mod in modCache.ExefsContainers)
|
||||
{
|
||||
Mods.Add(new ModModel(mod.Path.FullName, mod.Name, mod.Enabled, inSd));
|
||||
}
|
||||
|
||||
foreach (var mod in modCache.TextureDirs)
|
||||
foreach (ModLoader.Mod<DirectoryInfo> mod in modCache.TextureDirs)
|
||||
{
|
||||
var modModel = new ModModel(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||
ModModel modModel = new(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||
if (Mods.All(x => x.Path != mod.Path.Parent?.FullName))
|
||||
{
|
||||
Mods.Add(modModel);
|
||||
@@ -142,7 +144,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Mods.AsObservableChangeSet()
|
||||
.Filter(Filter)
|
||||
.Bind(out var view).AsObservableList();
|
||||
.Bind(out ReadOnlyObservableCollection<ModModel> view).AsObservableList();
|
||||
|
||||
Views.Clear();
|
||||
Views.AddRange(view);
|
||||
@@ -183,10 +185,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public void Delete(ModModel model, bool removeFromList = true)
|
||||
{
|
||||
var isSubdir = true;
|
||||
var pathToDelete = model.Path;
|
||||
var basePath = model.InSd ? ModLoader.GetSdModsBasePath() : ModLoader.GetModsBasePath();
|
||||
var modsDir = ModLoader.GetApplicationDir(basePath, _applicationId.ToString("x16"));
|
||||
bool isSubdir = true;
|
||||
string pathToDelete = model.Path;
|
||||
string basePath = model.InSd ? ModLoader.GetSdModsBasePath() : ModLoader.GetModsBasePath();
|
||||
string modsDir = ModLoader.GetApplicationDir(basePath, _applicationId.ToString("x16"));
|
||||
|
||||
if (new DirectoryInfo(model.Path).Parent?.FullName == modsDir)
|
||||
{
|
||||
@@ -195,9 +197,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
if (isSubdir)
|
||||
{
|
||||
var parentDir = String.Empty;
|
||||
string parentDir = String.Empty;
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(modsDir, "*", SearchOption.TopDirectoryOnly))
|
||||
foreach (string dir in Directory.GetDirectories(modsDir, "*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
if (Directory.GetDirectories(dir, "*", SearchOption.AllDirectories).Contains(model.Path))
|
||||
{
|
||||
@@ -249,10 +251,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
var destinationDir = ModLoader.GetApplicationDir(ModLoader.GetSdModsBasePath(), _applicationId.ToString("x16"));
|
||||
string destinationDir = ModLoader.GetApplicationDir(ModLoader.GetSdModsBasePath(), _applicationId.ToString("x16"));
|
||||
|
||||
// TODO: More robust checking for valid mod folders
|
||||
var isDirectoryValid = directories.Length != 0;
|
||||
bool isDirectoryValid = directories.Length != 0;
|
||||
|
||||
if (!isDirectoryValid)
|
||||
{
|
||||
@@ -263,7 +265,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var dir in directories)
|
||||
foreach (string dir in directories)
|
||||
{
|
||||
string dirToCreate = dir.Replace(directory.Parent?.ToString() ?? string.Empty, destinationDir);
|
||||
|
||||
@@ -284,9 +286,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
Directory.CreateDirectory(dirToCreate);
|
||||
}
|
||||
|
||||
var files = Directory.GetFiles(directory.ToString(), "*", SearchOption.AllDirectories);
|
||||
string[] files = Directory.GetFiles(directory.ToString(), "*", SearchOption.AllDirectories);
|
||||
|
||||
foreach (var file in files)
|
||||
foreach (string file in files)
|
||||
{
|
||||
File.Copy(file, file.Replace(directory.Parent?.ToString() ?? string.Empty, destinationDir), true);
|
||||
}
|
||||
@@ -298,13 +300,13 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
OsUtils.SetCoreDumpable(true);
|
||||
|
||||
var result = await _storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
IReadOnlyList<IStorageFolder> result = await _storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.SelectModDialogTitle],
|
||||
AllowMultiple = true,
|
||||
});
|
||||
|
||||
foreach (var folder in result)
|
||||
foreach (IStorageFolder folder in result)
|
||||
{
|
||||
AddMod(new DirectoryInfo(folder.Path.LocalPath));
|
||||
}
|
||||
@@ -317,7 +319,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public void DeleteAll()
|
||||
{
|
||||
foreach (var it in Mods) Delete(it, false);
|
||||
foreach (ModModel it in Mods) Delete(it, false);
|
||||
Mods.Clear();
|
||||
OnPropertyChanged(nameof(ModCount));
|
||||
Sort();
|
||||
|
||||
@@ -15,6 +15,7 @@ using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Configuration.Multiplayer;
|
||||
using Ryujinx.Common.GraphicsDriver;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
using Ryujinx.HLE;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
@@ -29,7 +30,10 @@ using System.Net.NetworkInformation;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using AntiAliasing = Ryujinx.Common.Configuration.AntiAliasing;
|
||||
using ScalingFilter = Ryujinx.Common.Configuration.ScalingFilter;
|
||||
using TimeZone = Ryujinx.Ava.UI.Models.TimeZone;
|
||||
using VSyncMode = Ryujinx.Common.Configuration.VSyncMode;
|
||||
|
||||
namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
@@ -475,7 +479,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
AvailableGpus.Clear();
|
||||
|
||||
var devices = VulkanRenderer.GetPhysicalDevices();
|
||||
DeviceInfo[] devices = VulkanRenderer.GetPhysicalDevices();
|
||||
|
||||
if (devices.Length == 0)
|
||||
{
|
||||
@@ -484,7 +488,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var device in devices)
|
||||
foreach (DeviceInfo device in devices)
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
private void LoadUpdates()
|
||||
{
|
||||
var updates = ApplicationLibrary.TitleUpdates.Items
|
||||
IEnumerable<(TitleUpdateModel TitleUpdate, bool IsSelected)> updates = ApplicationLibrary.TitleUpdates.Items
|
||||
.Where(it => it.TitleUpdate.TitleIdBase == ApplicationData.IdBase);
|
||||
|
||||
bool hasBundledContent = false;
|
||||
@@ -77,11 +77,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public void SortUpdates()
|
||||
{
|
||||
var sortedUpdates = TitleUpdates.OrderByDescending(update => update.Version);
|
||||
IOrderedEnumerable<TitleUpdateModel> sortedUpdates = TitleUpdates.OrderByDescending(update => update.Version);
|
||||
|
||||
// NOTE(jpr): this works around a bug where calling Views.Clear also clears SelectedUpdate for
|
||||
// some reason. so we save the item here and restore it after
|
||||
var selected = SelectedUpdate;
|
||||
object selected = SelectedUpdate;
|
||||
|
||||
Views.Clear();
|
||||
Views.Add(new TitleUpdateViewNoUpdateSentinal());
|
||||
@@ -109,18 +109,18 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ApplicationLibrary.TryGetTitleUpdatesFromFile(path, out var updates))
|
||||
if (!ApplicationLibrary.TryGetTitleUpdatesFromFile(path, out List<TitleUpdateModel> updates))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var updatesForThisGame = updates.Where(it => it.TitleIdBase == ApplicationData.Id).ToList();
|
||||
List<TitleUpdateModel> updatesForThisGame = updates.Where(it => it.TitleIdBase == ApplicationData.Id).ToList();
|
||||
if (updatesForThisGame.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var update in updatesForThisGame)
|
||||
foreach (TitleUpdateModel update in updatesForThisGame)
|
||||
{
|
||||
if (!TitleUpdates.Contains(update))
|
||||
{
|
||||
@@ -157,7 +157,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
OsUtils.SetCoreDumpable(true);
|
||||
|
||||
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
IReadOnlyList<IStorageFile> result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
AllowMultiple = true,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
@@ -171,10 +171,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
},
|
||||
});
|
||||
|
||||
var totalUpdatesAdded = 0;
|
||||
foreach (var file in result)
|
||||
int totalUpdatesAdded = 0;
|
||||
foreach (IStorageFile file in result)
|
||||
{
|
||||
if (!AddUpdate(file.Path.LocalPath, out var newUpdatesAdded))
|
||||
if (!AddUpdate(file.Path.LocalPath, out int newUpdatesAdded))
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogUpdateAddUpdateErrorMessage]);
|
||||
}
|
||||
@@ -195,13 +195,13 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public void Save()
|
||||
{
|
||||
var updates = TitleUpdates.Select(it => (it, it == SelectedUpdate as TitleUpdateModel)).ToList();
|
||||
List<(TitleUpdateModel it, bool)> updates = TitleUpdates.Select(it => (it, it == SelectedUpdate as TitleUpdateModel)).ToList();
|
||||
ApplicationLibrary.SaveTitleUpdatesForGame(ApplicationData, updates);
|
||||
}
|
||||
|
||||
private Task ShowNewUpdatesAddedDialog(int numAdded)
|
||||
{
|
||||
var msg = string.Format(LocaleManager.Instance[LocaleKeys.UpdateWindowUpdateAddedMessage], numAdded);
|
||||
string msg = string.Format(LocaleManager.Instance[LocaleKeys.UpdateWindowUpdateAddedMessage], numAdded);
|
||||
return Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
await ContentDialogHelper.ShowTextDialog(LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle], msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark);
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Images.Clear();
|
||||
|
||||
foreach (var image in _avatarStore)
|
||||
foreach (KeyValuePair<string, byte[]> image in _avatarStore)
|
||||
{
|
||||
Images.Add(new ProfileImageModel(image.Key, image.Value));
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
private void ChangeImageBackground()
|
||||
{
|
||||
foreach (var image in Images)
|
||||
foreach (ProfileImageModel image in Images)
|
||||
{
|
||||
image.BackgroundColor = new SolidColorBrush(BackgroundColor);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
// TODO: Parse DatabaseInfo.bin and table.bin files for more accuracy.
|
||||
if (item.Type == DirectoryEntryType.File && item.FullPath.Contains("chara") && item.FullPath.Contains("szs"))
|
||||
{
|
||||
using var file = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> file = new();
|
||||
|
||||
romfs.OpenFile(ref file.Ref, ("/" + item.FullPath).ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
Saves.AsObservableChangeSet()
|
||||
.Filter(Filter)
|
||||
.Sort(GetComparer())
|
||||
.Bind(out var view).AsObservableList();
|
||||
.Bind(out ReadOnlyObservableCollection<SaveModel> view).AsObservableList();
|
||||
|
||||
Views.Clear();
|
||||
Views.AddRange(view);
|
||||
|
||||
@@ -10,6 +10,7 @@ using Ryujinx.UI.App.Common;
|
||||
using Ryujinx.UI.Common.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using static Ryujinx.Common.Utilities.XCIFileTrimmer;
|
||||
@@ -56,10 +57,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
private void LoadXCIApplications()
|
||||
{
|
||||
var apps = _applicationLibrary.Applications.Items
|
||||
IEnumerable<ApplicationData> apps = _applicationLibrary.Applications.Items
|
||||
.Where(app => app.FileExtension == _FileExtXCI);
|
||||
|
||||
foreach (var xciApp in apps)
|
||||
foreach (ApplicationData xciApp in apps)
|
||||
AddOrUpdateXCITrimmerFile(CreateXCITrimmerFile(xciApp.Path));
|
||||
|
||||
ApplicationsChanged();
|
||||
@@ -69,7 +70,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
string path,
|
||||
OperationOutcome operationOutcome = OperationOutcome.Undetermined)
|
||||
{
|
||||
var xciApp = _applicationLibrary.Applications.Items.First(app => app.FileExtension == _FileExtXCI && app.Path == path);
|
||||
ApplicationData xciApp = _applicationLibrary.Applications.Items.First(app => app.FileExtension == _FileExtXCI && app.Path == path);
|
||||
return XCITrimmerFileModel.FromApplicationData(xciApp, _logger) with { ProcessingOutcome = operationOutcome };
|
||||
}
|
||||
|
||||
@@ -154,17 +155,17 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
_processingMode = processingMode;
|
||||
Processing = true;
|
||||
var cancellationToken = _cancellationTokenSource.Token;
|
||||
CancellationToken cancellationToken = _cancellationTokenSource.Token;
|
||||
|
||||
Thread XCIFileTrimThread = new(() =>
|
||||
{
|
||||
var toProcess = Sort(SelectedXCIFiles
|
||||
List<XCITrimmerFileModel> toProcess = Sort(SelectedXCIFiles
|
||||
.Where(xci =>
|
||||
(processingMode == ProcessingMode.Untrimming && xci.Untrimmable) ||
|
||||
(processingMode == ProcessingMode.Trimming && xci.Trimmable)
|
||||
)).ToList();
|
||||
|
||||
var viewsSaved = DisplayedXCIFiles.ToList();
|
||||
List<XCITrimmerFileModel> viewsSaved = DisplayedXCIFiles.ToList();
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
@@ -175,19 +176,19 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var xciApp in toProcess)
|
||||
foreach (XCITrimmerFileModel xciApp in toProcess)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
var trimmer = new XCIFileTrimmer(xciApp.Path, _logger);
|
||||
XCIFileTrimmer trimmer = new(xciApp.Path, _logger);
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
ProcessingApplication = xciApp;
|
||||
});
|
||||
|
||||
var outcome = OperationOutcome.Undetermined;
|
||||
OperationOutcome outcome = OperationOutcome.Undetermined;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -349,7 +350,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
Sort(AllXCIFiles)
|
||||
.AsObservableChangeSet()
|
||||
.Filter(Filter)
|
||||
.Bind(out var view).AsObservableList();
|
||||
.Bind(out ReadOnlyObservableCollection<XCITrimmerFileModel> view).AsObservableList();
|
||||
|
||||
_displayedXCIFiles.Clear();
|
||||
_displayedXCIFiles.AddRange(view);
|
||||
|
||||
Reference in new issue
Block a user