misc: chore: Fix numerous NullReferenceExceptions, InvalidOperationExceptions

This commit is contained in:
KeatonTheBot
2025-06-18 02:25:06 -05:00
parent a90db3464d
commit d2a532f971
90 changed files with 667 additions and 533 deletions
@@ -25,9 +25,9 @@ namespace Ryujinx.Ava.UI.Applet
{
_parent = parent;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).KeyPressed += AvaloniaDynamicTextInputHandler_KeyPressed;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).KeyRelease += AvaloniaDynamicTextInputHandler_KeyRelease;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).TextInput += AvaloniaDynamicTextInputHandler_TextInput;
((AvaloniaKeyboardDriver)_parent.InputManager.KeyboardDriver).KeyPressed += AvaloniaDynamicTextInputHandler_KeyPressed;
((AvaloniaKeyboardDriver)_parent.InputManager.KeyboardDriver).KeyRelease += AvaloniaDynamicTextInputHandler_KeyRelease;
((AvaloniaKeyboardDriver)_parent.InputManager.KeyboardDriver).TextInput += AvaloniaDynamicTextInputHandler_TextInput;
_hiddenTextBox = _parent.HiddenTextBox;
@@ -118,9 +118,9 @@ namespace Ryujinx.Ava.UI.Applet
public void Dispose()
{
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).KeyPressed -= AvaloniaDynamicTextInputHandler_KeyPressed;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).KeyRelease -= AvaloniaDynamicTextInputHandler_KeyRelease;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).TextInput -= AvaloniaDynamicTextInputHandler_TextInput;
((AvaloniaKeyboardDriver)_parent.InputManager.KeyboardDriver).KeyPressed -= AvaloniaDynamicTextInputHandler_KeyPressed;
((AvaloniaKeyboardDriver)_parent.InputManager.KeyboardDriver).KeyRelease -= AvaloniaDynamicTextInputHandler_KeyRelease;
((AvaloniaKeyboardDriver)_parent.InputManager.KeyboardDriver).TextInput -= AvaloniaDynamicTextInputHandler_TextInput;
_textChangedSubscription?.Dispose();
_selectionStartChangedSubscription?.Dispose();
@@ -111,7 +111,7 @@ namespace Ryujinx.Ava.UI.Controls
viewModel.VirtualFileSystem,
viewModel.SelectedApplication.IdString,
viewModel.SelectedApplication.Name,
viewModel.SelectedApplication.Path).ShowDialog(viewModel.TopLevel as Window);
viewModel.SelectedApplication.Path).ShowDialog((Window)viewModel.TopLevel);
}
}
@@ -396,9 +396,12 @@ namespace Ryujinx.Ava.UI.Controls
viewModel.SelectedApplication.Name);
var iconFile = await result[0].CreateFileAsync(selectedApp.IdString + ".png");
await using var fileStream = await iconFile.OpenWriteAsync();
if (iconFile != null)
{
await using var fileStream = await iconFile.OpenWriteAsync();
fileStream.Write(selectedApp.Icon);
fileStream.Write(selectedApp.Icon);
}
}
}
@@ -37,7 +37,7 @@ namespace Ryujinx.Ava.UI.Controls
private void SearchBox_OnKeyUp(object sender, KeyEventArgs args)
{
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox)?.Text;
}
}
}
@@ -38,7 +38,7 @@ namespace Ryujinx.Ava.UI.Controls
private void SearchBox_OnKeyUp(object sender, KeyEventArgs args)
{
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox)?.Text;
}
private async void IdString_OnClick(object sender, RoutedEventArgs e)
+2 -2
View File
@@ -52,8 +52,8 @@ namespace Ryujinx.Ava.UI.Models
if (InGameList)
{
Icon = appData.Icon;
Title = appData.Name;
Icon = appData?.Icon;
Title = appData?.Name;
}
else
{
+1 -1
View File
@@ -88,7 +88,7 @@ namespace Ryujinx.Ava.UI.Models
private void UpdateBackground()
{
var currentApplication = Avalonia.Application.Current;
currentApplication.Styles.TryGetResource("ControlFillColorSecondary", currentApplication.ActualThemeVariant, out object color);
currentApplication!.Styles.TryGetResource("ControlFillColorSecondary", currentApplication.ActualThemeVariant, out object color);
if (color is not null)
{
+5 -2
View File
@@ -127,8 +127,11 @@ namespace Ryujinx.Ava.UI.Renderer
X11Window = PlatformHelper.CreateOpenGLWindow(new FramebufferFormat(new ColorFormat(8, 8, 8, 0), 16, 0, ColorFormat.Zero, 0, 2, false), 0, 0, 100, 100) as GLXWindow;
}
WindowHandle = X11Window.WindowHandle.RawHandle;
X11Display = X11Window.DisplayHandle.RawHandle;
if (X11Window != null)
{
WindowHandle = X11Window.WindowHandle.RawHandle;
X11Display = X11Window.DisplayHandle.RawHandle;
}
return new PlatformHandle(WindowHandle, "X11");
}
@@ -37,7 +37,7 @@ namespace Ryujinx.Ava.UI.ViewModels
return app.Favorite ? -1 : 1;
}
throw new InvalidCastException($"Cannot cast {o.GetType()} to {nameof(AppListFavoriteComparable)}");
throw new InvalidCastException($"Cannot cast {o?.GetType()} to {nameof(AppListFavoriteComparable)}");
}
}
}
@@ -92,9 +92,9 @@ namespace Ryujinx.Ava.UI.ViewModels
_applicationData = applicationData;
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
_storageProvider = desktop.MainWindow.StorageProvider;
_storageProvider = desktop.MainWindow?.StorageProvider;
}
LoadDownloadableContents();
@@ -254,10 +254,13 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner);
_mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
_mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
if (_mainWindow != null)
{
_mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
_mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
_mainWindow.ViewModel.AppHost?.NpadManager.BlockInputUpdates();
_mainWindow.ViewModel.AppHost?.NpadManager.BlockInputUpdates();
}
_isLoaded = false;
@@ -783,11 +786,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
config = (ConfigViewModel as ControllerInputViewModel)?.Config.GetConfig();
}
config.ControllerType = Controllers[_controller].Type;
if (config != null)
{
config.ControllerType = Controllers[_controller].Type;
string jsonString = JsonHelper.Serialize(config, _serializerContext.InputConfig);
string jsonString = JsonHelper.Serialize(config, _serializerContext.InputConfig);
await File.WriteAllTextAsync(path, jsonString);
await File.WriteAllTextAsync(path, jsonString);
}
LoadProfiles();
}
@@ -1332,7 +1332,7 @@ namespace Ryujinx.Ava.UI.ViewModels
}
catch (MissingKeyException ex)
{
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
Logger.Error?.Print(LogClass.Application, ex.ToString());
@@ -1553,7 +1553,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{
Dispatcher.UIThread.InvokeAsync(() =>
{
Application.Current.Styles.TryGetResource(args.VSyncMode,
Application.Current!.Styles.TryGetResource(args.VSyncMode,
Application.Current.ActualThemeVariant,
out object color);
@@ -279,7 +279,7 @@ namespace Ryujinx.Ava.UI.ViewModels
foreach (var dir in directories)
{
string dirToCreate = dir.Replace(directory.Parent.ToString(), destinationDir);
string dirToCreate = dir.Replace(directory.Parent?.ToString() ?? string.Empty, destinationDir);
// Mod already exists
if (Directory.Exists(dirToCreate))
@@ -302,7 +302,7 @@ namespace Ryujinx.Ava.UI.ViewModels
foreach (var file in files)
{
File.Copy(file, file.Replace(directory.Parent.ToString(), destinationDir), true);
File.Copy(file, file.Replace(directory.Parent?.ToString() ?? string.Empty, destinationDir), true);
}
LoadMods(_applicationId, _installedDlcIds);
@@ -75,9 +75,9 @@ namespace Ryujinx.Ava.UI.ViewModels
ApplicationData = applicationData;
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
StorageProvider = desktop.MainWindow.StorageProvider;
StorageProvider = desktop.MainWindow?.StorageProvider;
}
LoadUpdates();
@@ -268,7 +268,11 @@ namespace Ryujinx.Ava.UI.ViewModels
result = String.Compare(x?.Name, y?.Name, StringComparison.Ordinal);
break;
case SortField.Saved:
result = x.PotentialSavingsB.CompareTo(y.PotentialSavingsB);
if (x != null && y != null)
{
result = x.PotentialSavingsB.CompareTo(y.PotentialSavingsB);
}
break;
}
@@ -70,8 +70,12 @@ namespace Ryujinx.Ava.UI.Views.Input
{
var viewModel = (DataContext as ControllerInputViewModel);
viewModel.ParentModel.IsModified = true;
_changeSlider = (float)check.Value;
if (viewModel != null)
{
viewModel.ParentModel.IsModified = true;
}
_changeSlider = (float)check.Value;
}
}
}
@@ -82,9 +86,11 @@ namespace Ryujinx.Ava.UI.Views.Input
{
if ((bool)check.IsPointerOver)
{
if (DataContext is ControllerInputViewModel viewModel)
{
viewModel.ParentModel.IsModified = true;
}
var viewModel = (DataContext as ControllerInputViewModel);
viewModel.ParentModel.IsModified = true;
_currentAssigner?.Cancel();
_currentAssigner = null;
}
@@ -96,7 +102,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{
if (sender is ToggleButton button )
{
if ((bool)button.IsChecked)
if (button.IsChecked != null && (bool)button.IsChecked)
{
if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
{
@@ -233,7 +239,7 @@ namespace Ryujinx.Ava.UI.Views.Input
var controllerInputViewModel = DataContext as ControllerInputViewModel;
assigner = new GamepadButtonAssigner(
controllerInputViewModel.ParentModel.SelectedGamepad,
controllerInputViewModel?.ParentModel.SelectedGamepad,
(controllerInputViewModel.ParentModel.Config as StandardControllerInputConfig).TriggerThreshold,
forStick);
@@ -72,7 +72,10 @@ namespace Ryujinx.Ava.UI.Views.Input
{
ViewModel.IsModified = true;
var player = (PlayerModel)e.AddedItems[0];
ViewModel.PlayerId = player.Id;
if (player != null)
{
ViewModel.PlayerId = player.Id;
}
}
}
}
@@ -43,7 +43,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{
if (sender is ToggleButton button)
{
if ((bool)button.IsChecked)
if (button.IsChecked != null && (bool)button.IsChecked)
{
if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
{
@@ -60,107 +60,110 @@ namespace Ryujinx.Ava.UI.Views.Input
var viewModel = (DataContext as KeyboardInputViewModel);
IKeyboard keyboard = (IKeyboard)viewModel.ParentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations.
IButtonAssigner assigner = CreateButtonAssigner();
_currentAssigner.ButtonAssigned += (sender, e) =>
if (viewModel != null)
{
if (e.ButtonValue.HasValue)
IKeyboard keyboard = (IKeyboard)viewModel.ParentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations.
IButtonAssigner assigner = CreateButtonAssigner();
_currentAssigner.ButtonAssigned += (sender, e) =>
{
var buttonValue = e.ButtonValue.Value;
viewModel.ParentModel.IsModified = true;
switch (button.Name)
if (e.ButtonValue.HasValue)
{
case "ButtonZl":
viewModel.Config.ButtonZl = buttonValue.AsHidType<Key>();
break;
case "ButtonL":
viewModel.Config.ButtonL = buttonValue.AsHidType<Key>();
break;
case "ButtonMinus":
viewModel.Config.ButtonMinus = buttonValue.AsHidType<Key>();
break;
case "LeftStickButton":
viewModel.Config.LeftStickButton = buttonValue.AsHidType<Key>();
break;
case "LeftStickUp":
viewModel.Config.LeftStickUp = buttonValue.AsHidType<Key>();
break;
case "LeftStickDown":
viewModel.Config.LeftStickDown = buttonValue.AsHidType<Key>();
break;
case "LeftStickRight":
viewModel.Config.LeftStickRight = buttonValue.AsHidType<Key>();
break;
case "LeftStickLeft":
viewModel.Config.LeftStickLeft = buttonValue.AsHidType<Key>();
break;
case "DpadUp":
viewModel.Config.DpadUp = buttonValue.AsHidType<Key>();
break;
case "DpadDown":
viewModel.Config.DpadDown = buttonValue.AsHidType<Key>();
break;
case "DpadLeft":
viewModel.Config.DpadLeft = buttonValue.AsHidType<Key>();
break;
case "DpadRight":
viewModel.Config.DpadRight = buttonValue.AsHidType<Key>();
break;
case "LeftButtonSr":
viewModel.Config.LeftButtonSr = buttonValue.AsHidType<Key>();
break;
case "LeftButtonSl":
viewModel.Config.LeftButtonSl = buttonValue.AsHidType<Key>();
break;
case "RightButtonSr":
viewModel.Config.RightButtonSr = buttonValue.AsHidType<Key>();
break;
case "RightButtonSl":
viewModel.Config.RightButtonSl = buttonValue.AsHidType<Key>();
break;
case "ButtonZr":
viewModel.Config.ButtonZr = buttonValue.AsHidType<Key>();
break;
case "ButtonR":
viewModel.Config.ButtonR = buttonValue.AsHidType<Key>();
break;
case "ButtonPlus":
viewModel.Config.ButtonPlus = buttonValue.AsHidType<Key>();
break;
case "ButtonA":
viewModel.Config.ButtonA = buttonValue.AsHidType<Key>();
break;
case "ButtonB":
viewModel.Config.ButtonB = buttonValue.AsHidType<Key>();
break;
case "ButtonX":
viewModel.Config.ButtonX = buttonValue.AsHidType<Key>();
break;
case "ButtonY":
viewModel.Config.ButtonY = buttonValue.AsHidType<Key>();
break;
case "RightStickButton":
viewModel.Config.RightStickButton = buttonValue.AsHidType<Key>();
break;
case "RightStickUp":
viewModel.Config.RightStickUp = buttonValue.AsHidType<Key>();
break;
case "RightStickDown":
viewModel.Config.RightStickDown = buttonValue.AsHidType<Key>();
break;
case "RightStickRight":
viewModel.Config.RightStickRight = buttonValue.AsHidType<Key>();
break;
case "RightStickLeft":
viewModel.Config.RightStickLeft = buttonValue.AsHidType<Key>();
break;
}
}
};
var buttonValue = e.ButtonValue.Value;
viewModel.ParentModel.IsModified = true;
_currentAssigner.GetInputAndAssign(assigner, keyboard);
switch (button.Name)
{
case "ButtonZl":
viewModel.Config.ButtonZl = buttonValue.AsHidType<Key>();
break;
case "ButtonL":
viewModel.Config.ButtonL = buttonValue.AsHidType<Key>();
break;
case "ButtonMinus":
viewModel.Config.ButtonMinus = buttonValue.AsHidType<Key>();
break;
case "LeftStickButton":
viewModel.Config.LeftStickButton = buttonValue.AsHidType<Key>();
break;
case "LeftStickUp":
viewModel.Config.LeftStickUp = buttonValue.AsHidType<Key>();
break;
case "LeftStickDown":
viewModel.Config.LeftStickDown = buttonValue.AsHidType<Key>();
break;
case "LeftStickRight":
viewModel.Config.LeftStickRight = buttonValue.AsHidType<Key>();
break;
case "LeftStickLeft":
viewModel.Config.LeftStickLeft = buttonValue.AsHidType<Key>();
break;
case "DpadUp":
viewModel.Config.DpadUp = buttonValue.AsHidType<Key>();
break;
case "DpadDown":
viewModel.Config.DpadDown = buttonValue.AsHidType<Key>();
break;
case "DpadLeft":
viewModel.Config.DpadLeft = buttonValue.AsHidType<Key>();
break;
case "DpadRight":
viewModel.Config.DpadRight = buttonValue.AsHidType<Key>();
break;
case "LeftButtonSr":
viewModel.Config.LeftButtonSr = buttonValue.AsHidType<Key>();
break;
case "LeftButtonSl":
viewModel.Config.LeftButtonSl = buttonValue.AsHidType<Key>();
break;
case "RightButtonSr":
viewModel.Config.RightButtonSr = buttonValue.AsHidType<Key>();
break;
case "RightButtonSl":
viewModel.Config.RightButtonSl = buttonValue.AsHidType<Key>();
break;
case "ButtonZr":
viewModel.Config.ButtonZr = buttonValue.AsHidType<Key>();
break;
case "ButtonR":
viewModel.Config.ButtonR = buttonValue.AsHidType<Key>();
break;
case "ButtonPlus":
viewModel.Config.ButtonPlus = buttonValue.AsHidType<Key>();
break;
case "ButtonA":
viewModel.Config.ButtonA = buttonValue.AsHidType<Key>();
break;
case "ButtonB":
viewModel.Config.ButtonB = buttonValue.AsHidType<Key>();
break;
case "ButtonX":
viewModel.Config.ButtonX = buttonValue.AsHidType<Key>();
break;
case "ButtonY":
viewModel.Config.ButtonY = buttonValue.AsHidType<Key>();
break;
case "RightStickButton":
viewModel.Config.RightStickButton = buttonValue.AsHidType<Key>();
break;
case "RightStickUp":
viewModel.Config.RightStickUp = buttonValue.AsHidType<Key>();
break;
case "RightStickDown":
viewModel.Config.RightStickDown = buttonValue.AsHidType<Key>();
break;
case "RightStickRight":
viewModel.Config.RightStickRight = buttonValue.AsHidType<Key>();
break;
case "RightStickLeft":
viewModel.Config.RightStickLeft = buttonValue.AsHidType<Key>();
break;
}
}
};
_currentAssigner.GetInputAndAssign(assigner, keyboard);
}
}
else
{
@@ -193,7 +196,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{
IButtonAssigner assigner;
assigner = new KeyboardKeyAssigner((IKeyboard)(DataContext as KeyboardInputViewModel).ParentModel.SelectedGamepad);
assigner = new KeyboardKeyAssigner((IKeyboard)(DataContext as KeyboardInputViewModel)?.ParentModel.SelectedGamepad);
return assigner;
}
@@ -34,7 +34,7 @@ namespace Ryujinx.Ava.UI.Views.Main
{
if (sender is RadioButton button)
{
ViewModel.Sort(Enum.Parse<ApplicationSort>(button.Tag.ToString()));
ViewModel.Sort(Enum.Parse<ApplicationSort>(button.Tag?.ToString() ?? string.Empty));
}
}
@@ -42,7 +42,7 @@ namespace Ryujinx.Ava.UI.Views.Main
{
if (sender is RadioButton button)
{
ViewModel.Sort(button.Tag.ToString() != "Descending");
ViewModel.Sort(button.Tag?.ToString() != "Descending");
}
}
@@ -46,7 +46,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
{
if (sender is ToggleButton button)
{
if ((bool)button.IsChecked)
if (button.IsChecked != null && (bool)button.IsChecked)
{
if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
{
@@ -69,41 +69,44 @@ namespace Ryujinx.Ava.UI.Views.Settings
var viewModel = (DataContext) as SettingsViewModel;
var buttonValue = e.ButtonValue.Value;
switch (button.Name)
if (viewModel != null)
{
case "ToggleVSyncMode":
viewModel.KeyboardHotkey.ToggleVSyncMode = buttonValue.AsHidType<Key>();
break;
case "Screenshot":
viewModel.KeyboardHotkey.Screenshot = buttonValue.AsHidType<Key>();
break;
case "ShowUI":
viewModel.KeyboardHotkey.ShowUI = buttonValue.AsHidType<Key>();
break;
case "Pause":
viewModel.KeyboardHotkey.Pause = buttonValue.AsHidType<Key>();
break;
case "ToggleMute":
viewModel.KeyboardHotkey.ToggleMute = buttonValue.AsHidType<Key>();
break;
case "ResScaleUp":
viewModel.KeyboardHotkey.ResScaleUp = buttonValue.AsHidType<Key>();
break;
case "ResScaleDown":
viewModel.KeyboardHotkey.ResScaleDown = buttonValue.AsHidType<Key>();
break;
case "VolumeUp":
viewModel.KeyboardHotkey.VolumeUp = buttonValue.AsHidType<Key>();
break;
case "VolumeDown":
viewModel.KeyboardHotkey.VolumeDown = buttonValue.AsHidType<Key>();
break;
case "CustomVSyncIntervalIncrement":
viewModel.KeyboardHotkey.CustomVSyncIntervalIncrement = buttonValue.AsHidType<Key>();
break;
case "CustomVSyncIntervalDecrement":
viewModel.KeyboardHotkey.CustomVSyncIntervalDecrement = buttonValue.AsHidType<Key>();
break;
switch (button.Name)
{
case "ToggleVSyncMode":
viewModel.KeyboardHotkey.ToggleVSyncMode = buttonValue.AsHidType<Key>();
break;
case "Screenshot":
viewModel.KeyboardHotkey.Screenshot = buttonValue.AsHidType<Key>();
break;
case "ShowUI":
viewModel.KeyboardHotkey.ShowUI = buttonValue.AsHidType<Key>();
break;
case "Pause":
viewModel.KeyboardHotkey.Pause = buttonValue.AsHidType<Key>();
break;
case "ToggleMute":
viewModel.KeyboardHotkey.ToggleMute = buttonValue.AsHidType<Key>();
break;
case "ResScaleUp":
viewModel.KeyboardHotkey.ResScaleUp = buttonValue.AsHidType<Key>();
break;
case "ResScaleDown":
viewModel.KeyboardHotkey.ResScaleDown = buttonValue.AsHidType<Key>();
break;
case "VolumeUp":
viewModel.KeyboardHotkey.VolumeUp = buttonValue.AsHidType<Key>();
break;
case "VolumeDown":
viewModel.KeyboardHotkey.VolumeDown = buttonValue.AsHidType<Key>();
break;
case "CustomVSyncIntervalIncrement":
viewModel.KeyboardHotkey.CustomVSyncIntervalIncrement = buttonValue.AsHidType<Key>();
break;
case "CustomVSyncIntervalDecrement":
viewModel.KeyboardHotkey.CustomVSyncIntervalDecrement = buttonValue.AsHidType<Key>();
break;
}
}
}
};
@@ -64,7 +64,7 @@ namespace Ryujinx.Ava.UI.Views.User
private async void Import_OnClick(object sender, RoutedEventArgs e)
{
var window = this.GetVisualRoot() as Window;
var result = await window.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
var result = await window?.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
{
AllowMultiple = false,
FileTypeFilter = new List<FilePickerFileType>
@@ -123,7 +123,7 @@ namespace Ryujinx.Ava.UI.Views.User
private void Close(object sender, RoutedEventArgs e)
{
((ContentDialog)_parent.Parent).Hide();
((ContentDialog)_parent.Parent)?.Hide();
}
}
}
+1 -1
View File
@@ -120,7 +120,7 @@ namespace Ryujinx.Ava.UI.Windows
}
}
Directory.CreateDirectory(Path.GetDirectoryName(_enabledCheatsPath));
Directory.CreateDirectory(Path.GetDirectoryName(_enabledCheatsPath) ?? string.Empty);
File.WriteAllLines(_enabledCheatsPath, enabledCheats);
@@ -53,12 +53,12 @@ namespace Ryujinx.Ava.UI.Windows
private void SaveAndClose(object sender, RoutedEventArgs routedEventArgs)
{
ViewModel.Save();
((ContentDialog)Parent).Hide();
((ContentDialog)Parent)?.Hide();
}
private void Close(object sender, RoutedEventArgs e)
{
((ContentDialog)Parent).Hide();
((ContentDialog)Parent)?.Hide();
}
private void RemoveDLC(object sender, RoutedEventArgs e)
+5 -2
View File
@@ -494,7 +494,10 @@ namespace Ryujinx.Ava.UI.Windows
/// <summary>
/// Subscribe to the ColorValuesChanged event
/// </summary>
PlatformSettings.ColorValuesChanged += OnPlatformColorValuesChanged;
if (PlatformSettings != null)
{
PlatformSettings.ColorValuesChanged += OnPlatformColorValuesChanged;
}
ViewModel.Initialize(
ContentManager,
@@ -578,7 +581,7 @@ namespace Ryujinx.Ava.UI.Windows
var volumeSplitButton = sender as ToggleSplitButton;
if (ViewModel.IsGameRunning)
{
if (!volumeSplitButton.IsChecked)
if (volumeSplitButton is not { IsChecked: true })
{
ViewModel.AppHost.Device.SetVolume(ViewModel.VolumeBeforeMute);
}
@@ -53,12 +53,12 @@ namespace Ryujinx.Ava.UI.Windows
private void SaveAndClose(object sender, RoutedEventArgs e)
{
ViewModel.Save();
((ContentDialog)Parent).Hide();
((ContentDialog)Parent)?.Hide();
}
private void Close(object sender, RoutedEventArgs e)
{
((ContentDialog)Parent).Hide();
((ContentDialog)Parent)?.Hide();
}
private async void DeleteMod(object sender, RoutedEventArgs e)
@@ -50,14 +50,14 @@ namespace Ryujinx.Ava.UI.Windows
private void Close(object sender, RoutedEventArgs e)
{
((ContentDialog)Parent).Hide();
((ContentDialog)Parent)?.Hide();
}
public void Save(object sender, RoutedEventArgs e)
{
ViewModel.Save();
((ContentDialog)Parent).Hide();
((ContentDialog)Parent)?.Hide();
}
private void OpenLocation(object sender, RoutedEventArgs e)
@@ -59,7 +59,7 @@ namespace Ryujinx.Ava.UI.Windows
private void Close(object sender, RoutedEventArgs e)
{
((ContentDialog)Parent).Hide();
((ContentDialog)Parent)?.Hide();
}
private void Cancel(Object sender, RoutedEventArgs e)