misc: chore: Use explicit types & fix object creation

This commit is contained in:
KeatonTheBot
2026-05-30 16:26:50 -05:00
parent 9d3fecf334
commit 76a123b81d
454 changed files with 3042 additions and 2961 deletions
+2 -2
View File
@@ -44,7 +44,7 @@ namespace Ryujinx.Ava.UI.Applet
Dispatcher.UIThread.InvokeAsync(async () =>
{
var response = await ControllerAppletDialog.ShowControllerAppletDialog(_parent, args);
UserResult response = await ControllerAppletDialog.ShowControllerAppletDialog(_parent, args);
if (response == UserResult.Ok)
{
okPressed = true;
@@ -132,7 +132,7 @@ namespace Ryujinx.Ava.UI.Applet
try
{
_parent.ViewModel.AppHost.NpadManager.BlockInputUpdates();
var response = await SwkbdAppletDialog.ShowInputDialog(LocaleManager.Instance[LocaleKeys.SoftwareKeyboard], args);
(UserResult Result, string Input) response = await SwkbdAppletDialog.ShowInputDialog(LocaleManager.Instance[LocaleKeys.SoftwareKeyboard], args);
if (response.Result == UserResult.Ok)
{
@@ -62,7 +62,7 @@ namespace Ryujinx.Ava.UI.Applet
private void AvaloniaDynamicTextInputHandler_KeyRelease(object sender, KeyEventArgs e)
{
var key = (HidKey)AvaloniaKeyboardMappingHelper.ToInputKey(e.Key);
HidKey key = (HidKey)AvaloniaKeyboardMappingHelper.ToInputKey(e.Key);
if (!(KeyReleasedEvent?.Invoke(key)).GetValueOrDefault(true))
{
@@ -82,7 +82,7 @@ namespace Ryujinx.Ava.UI.Applet
private void AvaloniaDynamicTextInputHandler_KeyPressed(object sender, KeyEventArgs e)
{
var key = (HidKey)AvaloniaKeyboardMappingHelper.ToInputKey(e.Key);
HidKey key = (HidKey)AvaloniaKeyboardMappingHelper.ToInputKey(e.Key);
if (!(KeyPressedEvent?.Invoke(key)).GetValueOrDefault(true))
{
+1 -1
View File
@@ -50,7 +50,7 @@ namespace Ryujinx.Ava.UI.Applet
private string GetWindowsFontByLanguage()
{
var culture = CultureInfo.CurrentUICulture;
CultureInfo culture = CultureInfo.CurrentUICulture;
string langCode = culture.Name;
return culture.TwoLetterISOLanguageName switch
@@ -36,7 +36,7 @@ namespace Ryujinx.Ava.UI.Controls
public void ToggleFavorite_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -61,14 +61,14 @@ namespace Ryujinx.Ava.UI.Controls
public void OpenDeviceSaveDirectory_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
OpenSaveDirectory(viewModel, SaveDataType.Device, default);
}
public void OpenBcatSaveDirectory_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
OpenSaveDirectory(viewModel, SaveDataType.Bcat, default);
}
@@ -77,7 +77,7 @@ namespace Ryujinx.Ava.UI.Controls
{
if (viewModel?.SelectedApplication != null)
{
var saveDataFilter = SaveDataFilter.Make(viewModel.SelectedApplication.Id, saveDataType, userId, saveDataId: default, index: default);
SaveDataFilter saveDataFilter = SaveDataFilter.Make(viewModel.SelectedApplication.Id, saveDataType, userId, saveDataId: default, index: default);
ApplicationHelper.OpenSaveDir(in saveDataFilter, viewModel.SelectedApplication.Id, viewModel.SelectedApplication.ControlHolder, viewModel.SelectedApplication.Name);
}
@@ -85,7 +85,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void OpenTitleUpdateManager_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -95,7 +95,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void OpenDownloadableContentManager_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -105,7 +105,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void OpenCheatManager_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -119,7 +119,7 @@ namespace Ryujinx.Ava.UI.Controls
public void OpenModsDirectory_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -132,7 +132,7 @@ namespace Ryujinx.Ava.UI.Controls
public void OpenSdModsDirectory_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -145,7 +145,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void OpenModManager_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -159,7 +159,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void PurgePtcCache_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -253,7 +253,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void PurgeShaderCache_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -310,7 +310,7 @@ namespace Ryujinx.Ava.UI.Controls
public void OpenPtcDirectory_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -331,7 +331,7 @@ namespace Ryujinx.Ava.UI.Controls
public void OpenShaderCacheDirectory_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -348,7 +348,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void ExtractApplicationExeFs_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -362,7 +362,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void ExtractApplicationRomFs_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -394,11 +394,11 @@ namespace Ryujinx.Ava.UI.Controls
{
OsUtils.SetCoreDumpable(true);
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication is { } selectedApp)
{
var result = await viewModel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
IReadOnlyList<IStorageFolder> result = await viewModel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
{
Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle],
AllowMultiple = false,
@@ -415,10 +415,10 @@ namespace Ryujinx.Ava.UI.Controls
viewModel.SelectedApplication.Path,
viewModel.SelectedApplication.Name);
var iconFile = await result[0].CreateFileAsync(selectedApp.IdString + ".png");
IStorageFile iconFile = await result[0].CreateFileAsync(selectedApp.IdString + ".png");
if (iconFile != null)
{
await using var fileStream = await iconFile.OpenWriteAsync();
await using Stream fileStream = await iconFile.OpenWriteAsync();
fileStream.Write(selectedApp.Icon);
}
@@ -432,7 +432,7 @@ namespace Ryujinx.Ava.UI.Controls
public void CreateApplicationShortcut_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -443,7 +443,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void RunApplication_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -453,7 +453,7 @@ namespace Ryujinx.Ava.UI.Controls
public async void TrimXCI_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
MainWindowViewModel viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
@@ -1,5 +1,6 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Interactivity;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels;
@@ -49,10 +50,10 @@ namespace Ryujinx.Ava.UI.Controls
if (sender is not Button { Content: TextBlock idText })
return;
if (!App.IsClipboardAvailable(out var clipboard))
if (!App.IsClipboardAvailable(out IClipboard clipboard))
return;
var appData = mwvm.Applications.FirstOrDefault(it => it.IdString == idText.Text);
ApplicationData appData = mwvm.Applications.FirstOrDefault(it => it.IdString == idText.Text);
if (appData is null)
return;
@@ -109,16 +109,16 @@ namespace Ryujinx.Ava.UI.Controls
ViewModel.Profiles.Clear();
ViewModel.LostProfiles.Clear();
var profiles = AccountManager.GetAllUsers().OrderBy(x => x.Name);
IOrderedEnumerable<HLE.HOS.Services.Account.Acc.UserProfile> profiles = AccountManager.GetAllUsers().OrderBy(x => x.Name);
foreach (var profile in profiles)
foreach (HLE.HOS.Services.Account.Acc.UserProfile profile in profiles)
{
ViewModel.Profiles.Add(new UserProfile(profile, this));
}
var saveDataFilter = SaveDataFilter.Make(programId: default, saveType: SaveDataType.Account, default, saveDataId: default, index: default);
SaveDataFilter saveDataFilter = SaveDataFilter.Make(programId: default, saveType: SaveDataType.Account, default, saveDataId: default, index: default);
using var saveDataIterator = new UniqueRef<SaveDataIterator>();
using UniqueRef<SaveDataIterator> saveDataIterator = new();
HorizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
@@ -137,8 +137,8 @@ namespace Ryujinx.Ava.UI.Controls
for (int i = 0; i < readCount; i++)
{
var save = saveDataInfo[i];
var id = new UserId((long)save.UserId.Id.Low, (long)save.UserId.Id.High);
SaveDataInfo save = saveDataInfo[i];
UserId id = new((long)save.UserId.Id.Low, (long)save.UserId.Id.High);
if (ViewModel.Profiles.Cast<UserProfile>().FirstOrDefault(x => x.UserId == id) == null)
{
lostAccounts.Add(id);
@@ -146,7 +146,7 @@ namespace Ryujinx.Ava.UI.Controls
}
}
foreach (var account in lostAccounts)
foreach (UserId account in lostAccounts)
{
ViewModel.LostProfiles.Add(new UserProfile(new HLE.HOS.Services.Account.Acc.UserProfile(account, "", null), this));
}
@@ -156,12 +156,12 @@ namespace Ryujinx.Ava.UI.Controls
public async void DeleteUser(UserProfile userProfile)
{
var lastUserId = AccountManager.LastOpenedUser.UserId;
UserId lastUserId = AccountManager.LastOpenedUser.UserId;
if (userProfile.UserId == lastUserId)
{
// If we are deleting the currently open profile, then we must open something else before deleting.
var profile = ViewModel.Profiles.Cast<UserProfile>().FirstOrDefault(x => x.UserId != lastUserId);
UserProfile profile = ViewModel.Profiles.Cast<UserProfile>().FirstOrDefault(x => x.UserId != lastUserId);
if (profile == null)
{
@@ -178,7 +178,7 @@ namespace Ryujinx.Ava.UI.Controls
AccountManager.OpenUser(profile.UserId);
}
var result = await ContentDialogHelper.CreateConfirmationDialog(
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
LocaleManager.Instance[LocaleKeys.DialogUserProfileDeletionConfirmMessage],
"",
LocaleManager.Instance[LocaleKeys.InputDialogYes],
@@ -10,7 +10,7 @@ namespace Ryujinx.Ava.UI.Controls
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
{
var newValue = Value + e.Delta.Y * TickFrequency;
double newValue = Value + e.Delta.Y * TickFrequency;
if (newValue < Minimum)
{
@@ -21,7 +21,7 @@ namespace Ryujinx.Ava.UI.Helpers
/// </remarks>
public static bool ReplaceWith<T>(this AvaloniaList<T> list, T item, bool addIfNotFound = true)
{
var index = list.IndexOf(item);
int index = list.IndexOf(item);
if (index != -1)
{
@@ -45,9 +45,9 @@ namespace Ryujinx.Ava.UI.Helpers
/// <param name="matchingList">The items to use as matching records to search for in the `sourceList', if not found this item will be added instead</param>
public static void AddOrReplaceMatching<T>(this AvaloniaList<T> list, IList<T> sourceList, IList<T> matchingList)
{
foreach (var match in matchingList)
foreach (T match in matchingList)
{
var index = sourceList.IndexOf(match);
int index = sourceList.IndexOf(match);
if (index != -1)
{
list.ReplaceWith(sourceList[index]);
@@ -121,7 +121,7 @@ namespace Ryujinx.Ava.UI.Helpers
startedDeferring = true;
var deferral = args.GetDeferral();
Deferral deferral = args.GetDeferral();
sender.PrimaryButtonClick -= DeferClose;
@@ -26,7 +26,7 @@ namespace Ryujinx.Ava.UI.Helpers
{
get
{
if (_glyphs.TryGetValue(Enum.Parse<Glyph>(key), out var val))
if (_glyphs.TryGetValue(Enum.Parse<Glyph>(key), out string val))
{
return val;
}
+3 -3
View File
@@ -49,8 +49,8 @@ namespace Ryujinx.Ava.UI.Helpers
private static string Format(AvaLogLevel level, string area, string template, object source, object[] v)
{
var result = new StringBuilder();
var r = new CharacterReader(template.AsSpan());
StringBuilder result = new();
CharacterReader r = new(template.AsSpan());
int i = 0;
result.Append('[');
@@ -63,7 +63,7 @@ namespace Ryujinx.Ava.UI.Helpers
while (!r.End)
{
var c = r.Take();
char c = r.Take();
if (c != '{')
{
+2 -2
View File
@@ -28,7 +28,7 @@ namespace Ryujinx.Ava.UI.Helpers
Margin = new Thickness(0, 0, 15, 40),
};
var maybeAsyncWorkQueue = new Lazy<AsyncWorkQueue<Notification>>(
Lazy<AsyncWorkQueue<Notification>> maybeAsyncWorkQueue = new(
() => new AsyncWorkQueue<Notification>(notification =>
{
Dispatcher.UIThread.Post(() =>
@@ -57,7 +57,7 @@ namespace Ryujinx.Ava.UI.Helpers
public static void Show(string title, string text, NotificationType type, bool waitingExit = false, Action onClick = null, Action onClose = null)
{
var delay = waitingExit ? TimeSpan.FromMilliseconds(0) : TimeSpan.FromMilliseconds(NotificationDelayInMs);
TimeSpan delay = waitingExit ? TimeSpan.FromMilliseconds(0) : TimeSpan.FromMilliseconds(NotificationDelayInMs);
_notifications.Add(new Notification(title, text, type, delay, onClick, onClose));
}
+1 -1
View File
@@ -16,7 +16,7 @@ namespace Ryujinx.Ava.UI.Helpers
return null;
}
var timeZone = (TimeZone)value;
TimeZone timeZone = (TimeZone)value;
return string.Format("{0} {1} {2}", timeZone.UtcDifference, timeZone.Location, timeZone.Abbreviation);
}
@@ -30,7 +30,7 @@ namespace Ryujinx.Ava.UI.Helpers
return null;
}
var key = isBundled ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel;
LocaleKeys key = isBundled ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel;
return LocaleManager.Instance.UpdateAndGetDynamicValue(key, label);
}
+1 -1
View File
@@ -74,7 +74,7 @@ namespace Ryujinx.Ava.UI.Helpers
string setupButtonLabel = isInSetupGuide ? LocaleManager.Instance[LocaleKeys.OpenSetupGuideMessage] : "";
var result = await ContentDialogHelper.CreateInfoDialog(
UserResult result = await ContentDialogHelper.CreateInfoDialog(
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogUserErrorDialogMessage, errorCode, GetErrorTitle(error)),
GetErrorDescription(error) + (isInSetupGuide
? LocaleManager.Instance[LocaleKeys.DialogUserErrorDialogInfoMessage]
+1 -1
View File
@@ -28,7 +28,7 @@ namespace Ryujinx.Ava.UI.Models
}
set
{
foreach (var cheat in SubNodes)
foreach (CheatNode cheat in SubNodes)
{
cheat.IsEnabled = value;
cheat.OnPropertyChanged();
@@ -208,7 +208,7 @@ namespace Ryujinx.Ava.UI.Models.Input
public InputConfig GetConfig()
{
var config = new StandardControllerInputConfig
StandardControllerInputConfig config = new()
{
Id = Id,
Backend = InputBackendType.GamepadSDL3,
+1 -1
View File
@@ -66,7 +66,7 @@ namespace Ryujinx.Ava.UI.Models.Input
public KeyboardHotkeys GetConfig()
{
var config = new KeyboardHotkeys
KeyboardHotkeys config = new()
{
ToggleVSyncMode = ToggleVSyncMode,
Screenshot = Screenshot,
@@ -144,7 +144,7 @@ namespace Ryujinx.Ava.UI.Models.Input
public InputConfig GetConfig()
{
var config = new StandardKeyboardInputConfig
StandardKeyboardInputConfig config = new()
{
Id = Id,
Backend = InputBackendType.WindowKeyboard,
+6 -6
View File
@@ -46,7 +46,7 @@ namespace Ryujinx.Ava.UI.Models
TitleId = info.ProgramId;
UserId = info.UserId;
var appData = MainWindow.MainWindowViewModel.Applications.FirstOrDefault(x => x.IdString.ToUpper() == TitleIdString);
ApplicationData appData = MainWindow.MainWindowViewModel.Applications.FirstOrDefault(x => x.IdString.ToUpper() == TitleIdString);
InGameList = appData != null;
@@ -70,7 +70,7 @@ namespace Ryujinx.Ava.UI.Models
Task.Run(() =>
{
var saveRoot = Path.Combine(VirtualFileSystem.GetNandPath(), $"user/save/{info.SaveDataId:x16}");
string saveRoot = Path.Combine(VirtualFileSystem.GetNandPath(), $"user/save/{info.SaveDataId:x16}");
long totalSize = GetDirectorySize(saveRoot);
@@ -79,14 +79,14 @@ namespace Ryujinx.Ava.UI.Models
long size = 0;
if (Directory.Exists(path))
{
var directories = Directory.GetDirectories(path);
foreach (var directory in directories)
string[] directories = Directory.GetDirectories(path);
foreach (string directory in directories)
{
size += GetDirectorySize(directory);
}
var files = Directory.GetFiles(path);
foreach (var file in files)
string[] files = Directory.GetFiles(path);
foreach (string file in files)
{
size += new FileInfo(file).Length;
}
+2 -1
View File
@@ -1,3 +1,4 @@
using Avalonia;
using Avalonia.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.UI.Controls;
@@ -48,7 +49,7 @@ namespace Ryujinx.Ava.UI.Models
private void UpdateBackground()
{
var currentApplication = Avalonia.Application.Current;
Application currentApplication = Avalonia.Application.Current;
object color = null;
currentApplication?.Styles.TryGetResource("ControlFillColorSecondary", currentApplication.ActualThemeVariant, out color);
@@ -44,13 +44,13 @@ namespace Ryujinx.Ava.UI.Renderer
throw new PlatformNotSupportedException();
}
var flags = OpenGLContextFlags.Compat;
OpenGLContextFlags flags = OpenGLContextFlags.Compat;
if (ConfigurationState.Instance.Logger.GraphicsDebugLevel != GraphicsDebugLevel.None)
{
flags |= OpenGLContextFlags.Debug;
}
var graphicsMode = Environment.OSVersion.Platform == PlatformID.Unix ? new FramebufferFormat(new ColorFormat(8, 8, 8, 0), 16, 0, ColorFormat.Zero, 0, 2, false) : FramebufferFormat.Default;
FramebufferFormat graphicsMode = Environment.OSVersion.Platform == PlatformID.Unix ? new FramebufferFormat(new ColorFormat(8, 8, 8, 0), 16, 0, ColorFormat.Zero, 0, 2, false) : FramebufferFormat.Default;
Context = PlatformHelper.CreateOpenGLContext(graphicsMode, 3, 3, flags);
+1 -1
View File
@@ -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);
@@ -9,6 +9,7 @@ using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Input;
using Ryujinx.Input.Assigner;
using Button = Ryujinx.Input.Button;
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
namespace Ryujinx.Ava.UI.Views.Input
@@ -68,7 +69,7 @@ namespace Ryujinx.Ava.UI.Views.Input
if (_changeSlider != -1.0f && _changeSlider != (float)check.Value)
{
var viewModel = (DataContext as ControllerInputViewModel);
ControllerInputViewModel viewModel = (DataContext as ControllerInputViewModel);
viewModel?.ParentModel.IsModified = true;
_changeSlider = (float)check.Value;
@@ -127,7 +128,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{
if (e.ButtonValue.HasValue)
{
var buttonValue = e.ButtonValue.Value;
Button buttonValue = e.ButtonValue.Value;
viewModel.ParentModel.IsModified = true;
switch (button.Name)
@@ -37,7 +37,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{
_dialogOpen = true;
var result = await ContentDialogHelper.CreateConfirmationDialogExtended(
UserResult result = await ContentDialogHelper.CreateConfirmationDialogExtended(
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage],
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage],
LocaleManager.Instance[LocaleKeys.InputDialogYes],
@@ -71,7 +71,7 @@ namespace Ryujinx.Ava.UI.Views.Input
if (e.AddedItems.Count > 0)
{
ViewModel.IsModified = true;
var player = (PlayerModel)e.AddedItems[0];
PlayerModel player = (PlayerModel)e.AddedItems[0];
if (player != null)
{
ViewModel.PlayerId = player.Id;
@@ -8,6 +8,7 @@ using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.Input;
using Ryujinx.Input.Assigner;
using Button = Ryujinx.Input.Button;
using Key = Ryujinx.Common.Configuration.Hid.Key;
namespace Ryujinx.Ava.UI.Views.Input
@@ -58,7 +59,7 @@ namespace Ryujinx.Ava.UI.Views.Input
PointerPressed += MouseClick;
var viewModel = (DataContext as KeyboardInputViewModel);
KeyboardInputViewModel viewModel = (DataContext as KeyboardInputViewModel);
if (viewModel != null)
{
@@ -69,7 +70,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{
if (e.ButtonValue.HasValue)
{
var buttonValue = e.ButtonValue.Value;
Button buttonValue = e.ButtonValue.Value;
viewModel.ParentModel.IsModified = true;
switch (button.Name)
@@ -1,6 +1,7 @@
using Avalonia.Controls;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Models.Input;
using Ryujinx.Ava.UI.ViewModels.Input;
using System.Threading.Tasks;
@@ -17,7 +18,7 @@ namespace Ryujinx.Ava.UI.Views.Input
public MotionInputView(ControllerInputViewModel viewModel)
{
var config = viewModel.Config;
GamepadInputConfig config = viewModel.Config;
_viewModel = new MotionInputViewModel
{
@@ -49,7 +50,7 @@ namespace Ryujinx.Ava.UI.Views.Input
};
contentDialog.PrimaryButtonClick += (_, _) =>
{
var config = viewModel.Config;
GamepadInputConfig config = viewModel.Config;
config.Slot = content._viewModel.Slot;
config.Sensitivity = content._viewModel.Sensitivity;
config.GyroDeadzone = content._viewModel.GyroDeadzone;
@@ -1,6 +1,7 @@
using Avalonia.Controls;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Models.Input;
using Ryujinx.Ava.UI.ViewModels.Input;
using System.Threading.Tasks;
@@ -17,7 +18,7 @@ namespace Ryujinx.Ava.UI.Views.Input
public RumbleInputView(ControllerInputViewModel viewModel)
{
var config = viewModel.Config;
GamepadInputConfig config = viewModel.Config;
_viewModel = new RumbleInputViewModel
{
@@ -45,7 +46,7 @@ namespace Ryujinx.Ava.UI.Views.Input
contentDialog.PrimaryButtonClick += (_, _) =>
{
var config = viewModel.Config;
GamepadInputConfig config = viewModel.Config;
config.StrongRumble = content._viewModel.StrongRumble;
config.WeakRumble = content._viewModel.WeakRumble;
};
@@ -40,7 +40,7 @@ namespace Ryujinx.Ava.UI.Views.Main
{
List<CheckBox> checkBoxes = [];
foreach (var item in Enum.GetValues(typeof(FileTypes)))
foreach (object item in Enum.GetValues(typeof(FileTypes)))
{
string fileName = Enum.GetName(typeof(FileTypes), item);
checkBoxes.Add(new CheckBox
@@ -69,7 +69,7 @@ namespace Ryujinx.Ava.UI.Views.Main
{
string languageCode = Path.GetFileNameWithoutExtension(locale).Split('.').Last();
string languageJson = EmbeddedResources.ReadAllText($"{localePath}/{languageCode}{localeExt}");
var strings = JsonHelper.Deserialize(languageJson, CommonJsonContext.Default.StringDictionary);
Dictionary<string, string> strings = JsonHelper.Deserialize(languageJson, CommonJsonContext.Default.StringDictionary);
if (!strings.TryGetValue("Language", out string languageName))
{
@@ -8,6 +8,7 @@ using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Input;
using Ryujinx.Input.Assigner;
using Button = Ryujinx.Input.Button;
using Key = Ryujinx.Common.Configuration.Hid.Key;
namespace Ryujinx.Ava.UI.Views.Settings
@@ -59,15 +60,15 @@ namespace Ryujinx.Ava.UI.Views.Settings
this.Focus(NavigationMethod.Pointer);
var keyboard = (IKeyboard)_avaloniaKeyboardDriver.GetGamepad("0");
IKeyboard keyboard = (IKeyboard)_avaloniaKeyboardDriver.GetGamepad("0");
IButtonAssigner assigner = new KeyboardKeyAssigner(keyboard);
_currentAssigner.ButtonAssigned += (_, e) =>
{
if (e.ButtonValue.HasValue)
{
var viewModel = (DataContext) as SettingsViewModel;
var buttonValue = e.ButtonValue.Value;
SettingsViewModel viewModel = (DataContext) as SettingsViewModel;
Button buttonValue = e.ButtonValue.Value;
if (viewModel != null)
{
@@ -34,7 +34,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
{
if (this.GetVisualRoot() is Window window)
{
var result = await window.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
IReadOnlyList<IStorageFolder> result = await window.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
{
AllowMultiple = false,
});
@@ -84,7 +84,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
{
if (this.GetVisualRoot() is Window window)
{
var result = await window.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
IReadOnlyList<IStorageFolder> result = await window.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
{
AllowMultiple = false,
});
@@ -39,7 +39,7 @@ namespace Ryujinx.Ava.UI.Views.User
switch (arg.NavigationMode)
{
case NavigationMode.New:
var (parent, profile, isNewUser) = ((NavigationDialogHost parent, UserProfile profile, bool isNewUser))arg.Parameter;
(NavigationDialogHost parent, UserProfile profile, bool isNewUser) = ((NavigationDialogHost parent, UserProfile profile, bool isNewUser))arg.Parameter;
_isNewUser = isNewUser;
_profile = profile;
TempProfile = new TempProfile(_profile);
@@ -66,11 +66,11 @@ namespace Ryujinx.Ava.UI.Views.User
{
if (ViewModel.SelectedImage != null)
{
using var streamJpg = new MemoryStream();
using var bitmap = SKBitmap.Decode(ViewModel.SelectedImage);
using var newBitmap = new SKBitmap(bitmap.Width, bitmap.Height);
using MemoryStream streamJpg = new();
using SKBitmap bitmap = SKBitmap.Decode(ViewModel.SelectedImage);
using SKBitmap newBitmap = new(bitmap.Width, bitmap.Height);
using (var canvas = new SKCanvas(newBitmap))
using (SKCanvas canvas = new(newBitmap))
{
canvas.Clear(new SKColor(
ViewModel.BackgroundColor.R,
@@ -80,8 +80,8 @@ namespace Ryujinx.Ava.UI.Views.User
canvas.DrawBitmap(bitmap, 0, 0);
}
using (var image = SKImage.FromBitmap(newBitmap))
using (var dataJpeg = image.Encode(SKEncodedImageFormat.Jpeg, 100))
using (SKImage image = SKImage.FromBitmap(newBitmap))
using (SKData dataJpeg = image.Encode(SKEncodedImageFormat.Jpeg, 100))
{
dataJpeg.SaveTo(streamJpg);
}
@@ -68,7 +68,7 @@ namespace Ryujinx.Ava.UI.Views.User
if (this.GetVisualRoot() is Window window)
{
var result = await window.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
IReadOnlyList<IStorageFile> result = await window.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
{
AllowMultiple = false,
FileTypeFilter = new List<FilePickerFileType>
@@ -110,16 +110,16 @@ namespace Ryujinx.Ava.UI.Views.User
private static byte[] ProcessProfileImage(byte[] buffer)
{
using var bitmap = SKBitmap.Decode(buffer);
using SKBitmap bitmap = SKBitmap.Decode(buffer);
var resizedBitmap = bitmap.Resize(new SKImageInfo(256, 256), new SKSamplingOptions(SKFilterMode.Linear));
SKBitmap resizedBitmap = bitmap.Resize(new SKImageInfo(256, 256), new SKSamplingOptions(SKFilterMode.Linear));
using var streamJpg = new MemoryStream();
using MemoryStream streamJpg = new();
if (resizedBitmap != null)
{
using var image = SKImage.FromBitmap(resizedBitmap);
using var dataJpeg = image.Encode(SKEncodedImageFormat.Jpeg, 100);
using SKImage image = SKImage.FromBitmap(resizedBitmap);
using SKData dataJpeg = image.Encode(SKEncodedImageFormat.Jpeg, 100);
dataJpeg.SaveTo(streamJpg);
}
@@ -27,7 +27,7 @@ namespace Ryujinx.Ava.UI.Views.User
switch (arg.NavigationMode)
{
case NavigationMode.New:
var parent = (NavigationDialogHost)arg.Parameter;
NavigationDialogHost parent = (NavigationDialogHost)arg.Parameter;
_parent = parent;
@@ -48,7 +48,7 @@ namespace Ryujinx.Ava.UI.Views.User
switch (arg.NavigationMode)
{
case NavigationMode.New:
var (parent, accountManager, client, virtualFileSystem) = ((NavigationDialogHost parent, AccountManager accountManager, HorizonClient client, VirtualFileSystem virtualFileSystem))arg.Parameter;
(NavigationDialogHost parent, AccountManager accountManager, HorizonClient client, VirtualFileSystem virtualFileSystem) = ((NavigationDialogHost parent, AccountManager accountManager, HorizonClient client, VirtualFileSystem virtualFileSystem))arg.Parameter;
_accountManager = accountManager;
_horizonClient = client;
_virtualFileSystem = virtualFileSystem;
@@ -67,15 +67,15 @@ namespace Ryujinx.Ava.UI.Views.User
public void LoadSaves()
{
ViewModel.Saves.Clear();
var saves = new ObservableCollection<SaveModel>();
var saveDataFilter = SaveDataFilter.Make(
ObservableCollection<SaveModel> saves = new();
SaveDataFilter saveDataFilter = SaveDataFilter.Make(
programId: default,
saveType: SaveDataType.Account,
new UserId((ulong)_accountManager.LastOpenedUser.UserId.High, (ulong)_accountManager.LastOpenedUser.UserId.Low),
saveDataId: default,
index: default);
using var saveDataIterator = new UniqueRef<SaveDataIterator>();
using UniqueRef<SaveDataIterator> saveDataIterator = new();
_horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
@@ -92,10 +92,10 @@ namespace Ryujinx.Ava.UI.Views.User
for (int i = 0; i < readCount; i++)
{
var save = saveDataInfo[i];
SaveDataInfo save = saveDataInfo[i];
if (save.ProgramId.Value != 0)
{
var saveModel = new SaveModel(save);
SaveModel saveModel = new(save);
saves.Add(saveModel);
}
}
@@ -130,7 +130,7 @@ namespace Ryujinx.Ava.UI.Views.User
{
if (button.DataContext is SaveModel saveModel)
{
var result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DeleteUserSave],
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DeleteUserSave],
LocaleManager.Instance[LocaleKeys.IrreversibleActionNote],
LocaleManager.Instance[LocaleKeys.InputDialogYes],
LocaleManager.Instance[LocaleKeys.InputDialogNo], "");
+5 -5
View File
@@ -62,7 +62,7 @@ namespace Ryujinx.Ava.UI.Windows
int cheatAdded = 0;
var mods = new ModLoader.ModCache();
ModLoader.ModCache mods = new();
ModLoader.QueryContentsDir(mods, new DirectoryInfo(Path.Combine(modsBasePath, "contents")), titleIdValue, []);
@@ -71,7 +71,7 @@ namespace Ryujinx.Ava.UI.Windows
CheatNode currentGroup = null;
foreach (var cheat in mods.Cheats)
foreach (ModLoader.Cheat cheat in mods.Cheats)
{
if (cheat.Path.FullName != currentCheatFile)
{
@@ -84,7 +84,7 @@ namespace Ryujinx.Ava.UI.Windows
LoadedCheats.Add(currentGroup);
}
var model = new CheatNode(cheat.Name, buildId, "", false, enabled.Contains($"{buildId}-{cheat.Name}"));
CheatNode model = new(cheat.Name, buildId, "", false, enabled.Contains($"{buildId}-{cheat.Name}"));
currentGroup?.SubNodes.Add(model);
cheatAdded++;
@@ -109,9 +109,9 @@ namespace Ryujinx.Ava.UI.Windows
List<string> enabledCheats = [];
foreach (var cheats in LoadedCheats)
foreach (CheatNode cheats in LoadedCheats)
{
foreach (var cheat in cheats.SubNodes)
foreach (CheatNode cheat in cheats.SubNodes)
{
if (cheat.IsEnabled)
{
@@ -83,7 +83,7 @@ namespace Ryujinx.Ava.UI.Windows
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (var content in e.AddedItems)
foreach (object content in e.AddedItems)
{
if (content is DownloadableContentModel model)
{
@@ -91,7 +91,7 @@ namespace Ryujinx.Ava.UI.Windows
}
}
foreach (var content in e.RemovedItems)
foreach (object content in e.RemovedItems)
{
if (content is DownloadableContentModel model)
{
+14 -14
View File
@@ -37,7 +37,7 @@ namespace Ryujinx.Ava.UI.Windows
public static SKColor GetFilteredColor(SKBitmap image)
{
var color = GetColor(image);
SKColor color = GetColor(image);
// We don't want colors that are too dark.
@@ -57,10 +57,10 @@ namespace Ryujinx.Ava.UI.Windows
public static SKColor GetColor(SKBitmap image)
{
var colors = new PaletteColor[TotalColors];
var dominantColorBin = new Dictionary<int, int>();
PaletteColor[] colors = new PaletteColor[TotalColors];
Dictionary<int, int> dominantColorBin = new();
var buffer = GetBuffer(image);
SKColor[] buffer = GetBuffer(image);
int w = image.Width;
int w8 = w << 8;
@@ -87,7 +87,7 @@ namespace Ryujinx.Ava.UI.Windows
byte cg = pixel.Green;
byte cb = pixel.Blue;
var qck = GetQuantizedColorKey(cr, cg, cb);
int qck = GetQuantizedColorKey(cr, cg, cb);
if (dominantColorBin.TryGetValue(qck, out int hitCount))
{
@@ -112,7 +112,7 @@ namespace Ryujinx.Ava.UI.Windows
for (i = 0; i < TotalColors; i++)
{
var score = GetColorScore(dominantColorBin, maxHitCount, colors[i]);
int score = GetColorScore(dominantColorBin, maxHitCount, colors[i]);
if (highScore < score)
{
@@ -126,7 +126,7 @@ namespace Ryujinx.Ava.UI.Windows
public static SKColor[] GetBuffer(SKBitmap image)
{
var pixels = new SKColor[image.Width * image.Height];
SKColor[] pixels = new SKColor[image.Width * image.Height];
for (int y = 0; y < image.Height; y++)
{
@@ -141,17 +141,17 @@ namespace Ryujinx.Ava.UI.Windows
private static int GetColorScore(Dictionary<int, int> dominantColorBin, int maxHitCount, PaletteColor color)
{
var hitCount = dominantColorBin[color.Qck];
var balancedHitCount = BalanceHitCount(hitCount, maxHitCount);
var quantSat = (GetColorSaturation(color) >> SatQuantShift) << SatQuantShift;
var value = GetColorValue(color);
int hitCount = dominantColorBin[color.Qck];
int balancedHitCount = BalanceHitCount(hitCount, maxHitCount);
int quantSat = (GetColorSaturation(color) >> SatQuantShift) << SatQuantShift;
int value = GetColorValue(color);
// If the color is rarely used on the image,
// then chances are that theres a better candidate, even if the saturation value
// is high. By multiplying the saturation value with a weight, we can lower
// it if the color is almost never used (hit count is low).
var satWeighted = quantSat;
var satWeight = balancedHitCount << 5;
int satWeighted = quantSat;
int satWeight = balancedHitCount << 5;
if (satWeight < 0x100)
{
satWeighted = (satWeighted * satWeight) >> 8;
@@ -159,7 +159,7 @@ namespace Ryujinx.Ava.UI.Windows
// Compute score from saturation and dominance of the color.
// We prefer more vivid colors over dominant ones, so give more weight to the saturation.
var score = ((satWeighted << 1) + balancedHitCount) * value;
int score = ((satWeighted << 1) + balancedHitCount) * value;
return score;
}
+6 -6
View File
@@ -179,9 +179,9 @@ namespace Ryujinx.Ava.UI.Windows
{
Dispatcher.UIThread.Post(() =>
{
var ldnGameDataArray = e.LdnData;
IEnumerable<LdnGameData> ldnGameDataArray = e.LdnData;
ViewModel.LastLdnGameData = ldnGameDataArray;
foreach (var application in ViewModel.Applications)
foreach (ApplicationData application in ViewModel.Applications)
{
UpdateApplicationWithLdnData(application);
}
@@ -584,7 +584,7 @@ namespace Ryujinx.Ava.UI.Windows
private void VolumeStatus_CheckedChanged(object sender, RoutedEventArgs e)
{
var volumeSplitButton = sender as ToggleSplitButton;
ToggleSplitButton volumeSplitButton = sender as ToggleSplitButton;
if (ViewModel.IsGameRunning)
{
if (volumeSplitButton is { IsChecked: false })
@@ -708,11 +708,11 @@ namespace Ryujinx.Ava.UI.Windows
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs);
var autoloadDirs = ConfigurationState.Instance.UI.AutoloadDirs.Value;
List<string> autoloadDirs = ConfigurationState.Instance.UI.AutoloadDirs.Value;
if (autoloadDirs.Count > 0)
{
var updatesLoaded = ApplicationLibrary.AutoLoadTitleUpdates(autoloadDirs, out int updatesRemoved);
var dlcLoaded = ApplicationLibrary.AutoLoadDownloadableContents(autoloadDirs, out int dlcRemoved);
int updatesLoaded = ApplicationLibrary.AutoLoadTitleUpdates(autoloadDirs, out int updatesRemoved);
int dlcLoaded = ApplicationLibrary.AutoLoadDownloadableContents(autoloadDirs, out int dlcRemoved);
ShowNewContentAddedDialog(dlcLoaded, dlcRemoved, updatesLoaded, updatesRemoved);
}
@@ -67,7 +67,7 @@ namespace Ryujinx.Ava.UI.Windows
{
if (button.DataContext is ModModel model)
{
var result = await ContentDialogHelper.CreateConfirmationDialog(
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
LocaleManager.Instance[LocaleKeys.DialogWarning],
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogModManagerDeletionWarningMessage, model.Name),
LocaleManager.Instance[LocaleKeys.InputDialogYes],
@@ -84,7 +84,7 @@ namespace Ryujinx.Ava.UI.Windows
private async void DeleteAll(object sender, RoutedEventArgs e)
{
var result = await ContentDialogHelper.CreateConfirmationDialog(
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
LocaleManager.Instance[LocaleKeys.DialogWarning],
LocaleManager.Instance[LocaleKeys.DialogModManagerDeletionAllWarningMessage],
LocaleManager.Instance[LocaleKeys.InputDialogYes],
@@ -110,11 +110,11 @@ namespace Ryujinx.Ava.UI.Windows
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (var content in e.AddedItems)
foreach (object content in e.AddedItems)
{
if (content is ModModel model)
{
var index = ViewModel.Mods.IndexOf(model);
int index = ViewModel.Mods.IndexOf(model);
if (index != -1)
{
@@ -123,11 +123,11 @@ namespace Ryujinx.Ava.UI.Windows
}
}
foreach (var content in e.RemovedItems)
foreach (object content in e.RemovedItems)
{
if (content is ModModel model)
{
var index = ViewModel.Mods.IndexOf(model);
int index = ViewModel.Mods.IndexOf(model);
if (index != -1)
{
@@ -81,7 +81,7 @@ namespace Ryujinx.Ava.UI.Windows
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (var content in e.AddedItems)
foreach (object content in e.AddedItems)
{
if (content is XCITrimmerFileModel applicationData)
{
@@ -89,7 +89,7 @@ namespace Ryujinx.Ava.UI.Windows
}
}
foreach (var content in e.RemovedItems)
foreach (object content in e.RemovedItems)
{
if (content is XCITrimmerFileModel applicationData)
{