From f79cff8daac2ff36f7f898fa7c3788fd2c25d01e Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Wed, 28 Feb 2024 22:19:18 -0500 Subject: [PATCH] Require VFS and CM for SettingsViewModel Init --- .../UI/ViewModels/SettingsViewModel.cs | 23 ++++--------------- .../UI/Windows/SettingsWindow.axaml.cs | 9 -------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs index bcaa08600..ca4a593ef 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs @@ -273,24 +273,17 @@ namespace Ryujinx.Ava.UI.ViewModels } } - public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this() + public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) { _virtualFileSystem = virtualFileSystem; _contentManager = contentManager; - if (Program.PreviewerDetached) - { - Task.Run(LoadTimeZones); - } - } - - public SettingsViewModel() - { GameDirectories = new AvaloniaList(); TimeZones = new AvaloniaList(); AvailableGpus = new ObservableCollection(); - _validTzRegions = new List(); _networkInterfaces = new Dictionary(); + LoadTimeZones(); + Task.Run(CheckSoundBackends); Task.Run(PopulateNetworkInterfaces); @@ -346,7 +339,7 @@ namespace Ryujinx.Ava.UI.ViewModels Dispatcher.UIThread.Post(() => OnPropertyChanged(nameof(PreferredGpuIndex))); } - public async Task LoadTimeZones() + public void LoadTimeZones() { _timeZoneContentManager = new TimeZoneContentManager(); @@ -359,15 +352,9 @@ namespace Ryujinx.Ava.UI.ViewModels string abbr2 = abbr.StartsWith('+') || abbr.StartsWith('-') ? string.Empty : abbr; - await Dispatcher.UIThread.InvokeAsync(() => - { - TimeZones.Add(new TimeZone($"UTC{hours:+0#;-0#;+00}:{minutes:D2}", location, abbr2)); - - _validTzRegions.Add(location); - }); + TimeZones.Add(new TimeZone($"UTC{hours:+0#;-0#;+00}:{minutes:D2}", location, abbr2)); } - Dispatcher.UIThread.Post(() => OnPropertyChanged(nameof(TimeZone))); } private async Task PopulateNetworkInterfaces() diff --git a/src/Ryujinx.Ava/UI/Windows/SettingsWindow.axaml.cs b/src/Ryujinx.Ava/UI/Windows/SettingsWindow.axaml.cs index d7bb0b883..79ac1ee31 100644 --- a/src/Ryujinx.Ava/UI/Windows/SettingsWindow.axaml.cs +++ b/src/Ryujinx.Ava/UI/Windows/SettingsWindow.axaml.cs @@ -26,15 +26,6 @@ namespace Ryujinx.Ava.UI.Windows Load(); } - public SettingsWindow() - { - ViewModel = new SettingsViewModel(); - DataContext = ViewModel; - - InitializeComponent(); - Load(); - } - public void SaveSettings() { InputPage.ControllerSettings?.SaveCurrentProfile();