mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-23 23:57:10 +02:00
misc: chore: Use collection expressions in Avalonia project
This commit is contained in:
parent
46a5cafaa8
commit
ae90db2040
28 changed files with 114 additions and 112 deletions
|
@ -146,7 +146,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||
DirectoryInfo mainDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "cpu", "0"));
|
||||
DirectoryInfo backupDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "cpu", "1"));
|
||||
|
||||
List<FileInfo> cacheFiles = new();
|
||||
List<FileInfo> cacheFiles = [];
|
||||
|
||||
if (mainDir.Exists)
|
||||
{
|
||||
|
@ -189,8 +189,8 @@ namespace Ryujinx.Ava.UI.Controls
|
|||
{
|
||||
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "shader"));
|
||||
|
||||
List<DirectoryInfo> oldCacheDirectories = new();
|
||||
List<FileInfo> newCacheFiles = new();
|
||||
List<DirectoryInfo> oldCacheDirectories = [];
|
||||
List<FileInfo> newCacheFiles = [];
|
||||
|
||||
if (shaderCacheDir.Exists)
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||
|
||||
Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10];
|
||||
|
||||
HashSet<UserId> lostAccounts = new();
|
||||
HashSet<UserId> lostAccounts = [];
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.Ava.UI.Models
|
|||
public class CheatNode : BaseModel
|
||||
{
|
||||
private bool _isEnabled = false;
|
||||
public ObservableCollection<CheatNode> SubNodes { get; } = new();
|
||||
public ObservableCollection<CheatNode> SubNodes { get; } = [];
|
||||
public string CleanName => Name[1..^7];
|
||||
public string BuildIdKey => $"{BuildId}-{Name}";
|
||||
public bool IsRootNode { get; }
|
||||
|
|
|
@ -64,9 +64,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
Directory.CreateDirectory(Path.Join(AppDataManager.BaseDirPath, "system", "amiibo"));
|
||||
|
||||
_amiiboJsonPath = Path.Join(AppDataManager.BaseDirPath, "system", "amiibo", "Amiibo.json");
|
||||
_amiiboList = new List<AmiiboApi>();
|
||||
_amiiboSeries = new ObservableCollection<string>();
|
||||
_amiibos = new AvaloniaList<AmiiboApi>();
|
||||
_amiiboList = [];
|
||||
_amiiboSeries = [];
|
||||
_amiibos = [];
|
||||
|
||||
_amiiboLogoBytes = EmbeddedResources.Read("Ryujinx/Assets/UIImages/Logo_Amiibo.png");
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
public partial class DownloadableContentManagerViewModel : BaseModel
|
||||
{
|
||||
private readonly ApplicationLibrary _applicationLibrary;
|
||||
private AvaloniaList<DownloadableContentModel> _downloadableContents = new();
|
||||
[ObservableProperty] private AvaloniaList<DownloadableContentModel> _selectedDownloadableContents = new();
|
||||
[ObservableProperty] private AvaloniaList<DownloadableContentModel> _views = new();
|
||||
private AvaloniaList<DownloadableContentModel> _downloadableContents = [];
|
||||
[ObservableProperty] private AvaloniaList<DownloadableContentModel> _selectedDownloadableContents = [];
|
||||
[ObservableProperty] private AvaloniaList<DownloadableContentModel> _views = [];
|
||||
[ObservableProperty] private bool _showBundledContentNotice = false;
|
||||
|
||||
private string _search;
|
||||
|
@ -139,9 +139,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
new("NSP")
|
||||
{
|
||||
Patterns = new[] { "*.nsp" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" },
|
||||
MimeTypes = new[] { "application/x-nx-nsp" },
|
||||
Patterns = ["*.nsp"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.nsp"],
|
||||
MimeTypes = ["application/x-nx-nsp"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -257,11 +257,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
|
||||
public InputViewModel()
|
||||
{
|
||||
PlayerIndexes = new ObservableCollection<PlayerModel>();
|
||||
Controllers = new ObservableCollection<ControllerModel>();
|
||||
Devices = new ObservableCollection<(DeviceType Type, string Id, string Name)>();
|
||||
ProfilesList = new AvaloniaList<string>();
|
||||
DeviceList = new AvaloniaList<string>();
|
||||
PlayerIndexes = [];
|
||||
Controllers = [];
|
||||
Devices = [];
|
||||
ProfilesList = [];
|
||||
DeviceList = [];
|
||||
|
||||
ControllerImage = ProControllerResource;
|
||||
|
||||
|
@ -810,7 +810,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
{
|
||||
IsModified = false;
|
||||
|
||||
List<InputConfig> newConfig = new();
|
||||
List<InputConfig> newConfig = [];
|
||||
|
||||
newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value);
|
||||
|
||||
|
|
|
@ -1245,21 +1245,21 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes])
|
||||
{
|
||||
Patterns = new[] { "*.xci", "*.zip" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci", "public.zip-archive" },
|
||||
MimeTypes = new[] { "application/x-nx-xci", "application/zip" },
|
||||
Patterns = ["*.xci", "*.zip"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.xci", "public.zip-archive"],
|
||||
MimeTypes = ["application/x-nx-xci", "application/zip"],
|
||||
},
|
||||
new("XCI")
|
||||
{
|
||||
Patterns = new[] { "*.xci" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" },
|
||||
MimeTypes = new[] { "application/x-nx-xci" },
|
||||
Patterns = ["*.xci"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.xci"],
|
||||
MimeTypes = ["application/x-nx-xci"],
|
||||
},
|
||||
new("ZIP")
|
||||
{
|
||||
Patterns = new[] { "*.zip" },
|
||||
AppleUniformTypeIdentifiers = new[] { "public.zip-archive" },
|
||||
MimeTypes = new[] { "application/zip" },
|
||||
Patterns = ["*.zip"],
|
||||
AppleUniformTypeIdentifiers = ["public.zip-archive"],
|
||||
MimeTypes = ["application/zip"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -1292,21 +1292,21 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes])
|
||||
{
|
||||
Patterns = new[] { "*.keys", "*.zip" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci", "public.zip-archive" },
|
||||
MimeTypes = new[] { "application/keys", "application/zip" },
|
||||
Patterns = ["*.keys", "*.zip"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.xci", "public.zip-archive"],
|
||||
MimeTypes = ["application/keys", "application/zip"],
|
||||
},
|
||||
new("KEYS")
|
||||
{
|
||||
Patterns = new[] { "*.keys" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" },
|
||||
MimeTypes = new[] { "application/keys" },
|
||||
Patterns = ["*.keys"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.xci"],
|
||||
MimeTypes = ["application/keys"],
|
||||
},
|
||||
new("ZIP")
|
||||
{
|
||||
Patterns = new[] { "*.zip" },
|
||||
AppleUniformTypeIdentifiers = new[] { "public.zip-archive" },
|
||||
MimeTypes = new[] { "application/zip" },
|
||||
Patterns = ["*.zip"],
|
||||
AppleUniformTypeIdentifiers = ["public.zip-archive"],
|
||||
MimeTypes = ["application/zip"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -1418,53 +1418,53 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
|
||||
{
|
||||
Patterns = new[] { "*.nsp", "*.xci", "*.nca", "*.nro", "*.nso" },
|
||||
AppleUniformTypeIdentifiers = new[]
|
||||
{
|
||||
Patterns = ["*.nsp", "*.xci", "*.nca", "*.nro", "*.nso"],
|
||||
AppleUniformTypeIdentifiers =
|
||||
[
|
||||
"com.ryujinx.nsp",
|
||||
"com.ryujinx.xci",
|
||||
"com.ryujinx.nca",
|
||||
"com.ryujinx.nro",
|
||||
"com.ryujinx.nso",
|
||||
},
|
||||
MimeTypes = new[]
|
||||
{
|
||||
"com.ryujinx.nso"
|
||||
],
|
||||
MimeTypes =
|
||||
[
|
||||
"application/x-nx-nsp",
|
||||
"application/x-nx-xci",
|
||||
"application/x-nx-nca",
|
||||
"application/x-nx-nro",
|
||||
"application/x-nx-nso",
|
||||
},
|
||||
"application/x-nx-nso"
|
||||
],
|
||||
},
|
||||
new("NSP")
|
||||
{
|
||||
Patterns = new[] { "*.nsp" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" },
|
||||
MimeTypes = new[] { "application/x-nx-nsp" },
|
||||
Patterns = ["*.nsp"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.nsp"],
|
||||
MimeTypes = ["application/x-nx-nsp"],
|
||||
},
|
||||
new("XCI")
|
||||
{
|
||||
Patterns = new[] { "*.xci" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" },
|
||||
MimeTypes = new[] { "application/x-nx-xci" },
|
||||
Patterns = ["*.xci"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.xci"],
|
||||
MimeTypes = ["application/x-nx-xci"],
|
||||
},
|
||||
new("NCA")
|
||||
{
|
||||
Patterns = new[] { "*.nca" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nca" },
|
||||
MimeTypes = new[] { "application/x-nx-nca" },
|
||||
Patterns = ["*.nca"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.nca"],
|
||||
MimeTypes = ["application/x-nx-nca"],
|
||||
},
|
||||
new("NRO")
|
||||
{
|
||||
Patterns = new[] { "*.nro" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nro" },
|
||||
MimeTypes = new[] { "application/x-nx-nro" },
|
||||
Patterns = ["*.nro"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.nro"],
|
||||
MimeTypes = ["application/x-nx-nro"],
|
||||
},
|
||||
new("NSO")
|
||||
{
|
||||
Patterns = new[] { "*.nso" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nso" },
|
||||
MimeTypes = new[] { "application/x-nx-nso" },
|
||||
Patterns = ["*.nso"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.nso"],
|
||||
MimeTypes = ["application/x-nx-nso"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -1690,7 +1690,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
|
||||
{
|
||||
Patterns = new[] { "*.bin" },
|
||||
Patterns = ["*.bin"],
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -23,9 +23,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
private readonly string _modJsonPath;
|
||||
|
||||
private AvaloniaList<ModModel> _mods = new();
|
||||
[ObservableProperty] private AvaloniaList<ModModel> _views = new();
|
||||
[ObservableProperty] private AvaloniaList<ModModel> _selectedMods = new();
|
||||
private AvaloniaList<ModModel> _mods = [];
|
||||
[ObservableProperty] private AvaloniaList<ModModel> _views = [];
|
||||
[ObservableProperty] private AvaloniaList<ModModel> _selectedMods = [];
|
||||
|
||||
private string _search;
|
||||
private readonly ulong _applicationId;
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
[ObservableProperty] private bool _isVulkanAvailable = true;
|
||||
[ObservableProperty] private bool _gameDirectoryChanged;
|
||||
[ObservableProperty] private bool _autoloadDirectoryChanged;
|
||||
private readonly List<string> _gpuIds = new();
|
||||
private readonly List<string> _gpuIds = [];
|
||||
private int _graphicsBackendIndex;
|
||||
private int _scalingFilter;
|
||||
private int _scalingFilterLevel;
|
||||
|
|
|
@ -21,8 +21,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
private ApplicationLibrary ApplicationLibrary { get; }
|
||||
private ApplicationData ApplicationData { get; }
|
||||
|
||||
[ObservableProperty] private AvaloniaList<TitleUpdateModel> _titleUpdates = new();
|
||||
[ObservableProperty] private AvaloniaList<object> _views = new();
|
||||
[ObservableProperty] private AvaloniaList<TitleUpdateModel> _titleUpdates = [];
|
||||
[ObservableProperty] private AvaloniaList<object> _views = [];
|
||||
[ObservableProperty] private object _selectedUpdate = new TitleUpdateViewModelNoUpdate();
|
||||
[ObservableProperty] private bool _showBundledContentNotice;
|
||||
|
||||
|
@ -149,9 +149,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
|
||||
{
|
||||
Patterns = new[] { "*.nsp" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" },
|
||||
MimeTypes = new[] { "application/x-nx-nsp" },
|
||||
Patterns = ["*.nsp"],
|
||||
AppleUniformTypeIdentifiers = ["com.ryujinx.nsp"],
|
||||
MimeTypes = ["application/x-nx-nsp"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
|
||||
public UserFirmwareAvatarSelectorViewModel()
|
||||
{
|
||||
_images = new ObservableCollection<ProfileImageModel>();
|
||||
_images = [];
|
||||
|
||||
LoadImagesFromStore();
|
||||
PropertyChanged += (_, args) =>
|
||||
|
|
|
@ -9,8 +9,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
public UserProfileViewModel()
|
||||
{
|
||||
Profiles = new ObservableCollection<BaseModel>();
|
||||
LostProfiles = new ObservableCollection<UserProfile>();
|
||||
Profiles = [];
|
||||
LostProfiles = [];
|
||||
IsEmpty = !LostProfiles.Any();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
[ObservableProperty] private int _sortIndex;
|
||||
[ObservableProperty] private int _orderIndex;
|
||||
[ObservableProperty] private string _search;
|
||||
[ObservableProperty] private ObservableCollection<SaveModel> _saves = new();
|
||||
[ObservableProperty] private ObservableCollection<SaveModel> _views = new();
|
||||
[ObservableProperty] private ObservableCollection<SaveModel> _saves = [];
|
||||
[ObservableProperty] private ObservableCollection<SaveModel> _views = [];
|
||||
private readonly AccountManager _accountManager;
|
||||
|
||||
public string SaveManagerHeading => LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SaveManagerHeading, _accountManager.LastOpenedUser.Name, _accountManager.LastOpenedUser.UserId);
|
||||
|
|
|
@ -36,9 +36,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
private readonly Ryujinx.Common.Logging.XCIFileTrimmerLog _logger;
|
||||
private ApplicationLibrary ApplicationLibrary => _mainWindowViewModel.ApplicationLibrary;
|
||||
private Optional<XCITrimmerFileModel> _processingApplication = null;
|
||||
private AvaloniaList<XCITrimmerFileModel> _allXCIFiles = new();
|
||||
private AvaloniaList<XCITrimmerFileModel> _selectedXCIFiles = new();
|
||||
private AvaloniaList<XCITrimmerFileModel> _displayedXCIFiles = new();
|
||||
private AvaloniaList<XCITrimmerFileModel> _allXCIFiles = [];
|
||||
private AvaloniaList<XCITrimmerFileModel> _selectedXCIFiles = [];
|
||||
private AvaloniaList<XCITrimmerFileModel> _displayedXCIFiles = [];
|
||||
private MainWindowViewModel _mainWindowViewModel;
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
private string _search;
|
||||
|
|
|
@ -70,9 +70,9 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
{
|
||||
new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
|
||||
{
|
||||
Patterns = new[] { "*.jpg", "*.jpeg", "*.png", "*.bmp" },
|
||||
AppleUniformTypeIdentifiers = new[] { "public.jpeg", "public.png", "com.microsoft.bmp" },
|
||||
MimeTypes = new[] { "image/jpeg", "image/png", "image/bmp" },
|
||||
Patterns = ["*.jpg", "*.jpeg", "*.png", "*.bmp"],
|
||||
AppleUniformTypeIdentifiers = ["public.jpeg", "public.png", "com.microsoft.bmp"],
|
||||
MimeTypes = ["image/jpeg", "image/png", "image/bmp"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
public void LoadSaves()
|
||||
{
|
||||
ViewModel.Saves.Clear();
|
||||
ObservableCollection<SaveModel> saves = new();
|
||||
ObservableCollection<SaveModel> saves = [];
|
||||
SaveDataFilter saveDataFilter = SaveDataFilter.Make(
|
||||
programId: default,
|
||||
saveType: SaveDataType.Account,
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
public CheatWindow(VirtualFileSystem virtualFileSystem, string titleId, string titleName, string titlePath)
|
||||
{
|
||||
LoadedCheats = new AvaloniaList<CheatNode>();
|
||||
LoadedCheats = [];
|
||||
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
|
||||
? IntegrityCheckLevel.ErrorOnInvalid
|
||||
: IntegrityCheckLevel.None;
|
||||
|
|
|
@ -712,12 +712,13 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
private void ShowNewContentAddedDialog(int numDlcAdded, int numDlcRemoved, int numUpdatesAdded, int numUpdatesRemoved)
|
||||
{
|
||||
string[] messages = {
|
||||
string[] messages =
|
||||
[
|
||||
numDlcRemoved > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcRemovedMessage], numDlcRemoved): null,
|
||||
numDlcAdded > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAddedMessage], numDlcAdded): null,
|
||||
numUpdatesRemoved > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateRemovedMessage], numUpdatesRemoved): null,
|
||||
numUpdatesAdded > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateAddedMessage], numUpdatesAdded) : null
|
||||
};
|
||||
];
|
||||
|
||||
string msg = String.Join("\r\n", messages);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue