diff --git a/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs b/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs index 876d51f718..72852192fb 100644 --- a/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs +++ b/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Ava.UI.Helpers } var timeZone = (TimeZone)value; - return string.Format("{0} {1} {2}", timeZone.UtcDifference, timeZone.Location, timeZone.Abbreviation); + return timeZone.ToString(); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/src/Ryujinx.Ava/UI/Models/TimeZone.cs b/src/Ryujinx.Ava/UI/Models/TimeZone.cs index 950fbce437..65fe6c8484 100644 --- a/src/Ryujinx.Ava/UI/Models/TimeZone.cs +++ b/src/Ryujinx.Ava/UI/Models/TimeZone.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Ava.UI.Models { - internal class TimeZone + public class TimeZone { public TimeZone(string utcDifference, string location, string abbreviation) { @@ -9,6 +9,21 @@ namespace Ryujinx.Ava.UI.Models Abbreviation = abbreviation; } + public string ToString() + { + // Prettifies location strings eg: + // "America/Costa_Rica" -> "Costa Rica" + var location = Location.Replace("_", " "); + + if (location.Contains("/")) + { + var parts = location.Split("/"); + location = parts[1]; + } + + return $"{UtcDifference} - {location}"; + } + public string UtcDifference { get; set; } public string Location { get; set; } public string Abbreviation { get; set; } diff --git a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs index bcaa086000..ca4a593efd 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 d7bb0b8837..79ac1ee31b 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();