This commit is contained in:
Isaac Marovitz 2024-02-29 03:24:39 +00:00 committed by GitHub
commit 82747d798a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 29 deletions

View file

@ -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)

View file

@ -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; }

View file

@ -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<string>();
TimeZones = new AvaloniaList<TimeZone>();
AvailableGpus = new ObservableCollection<ComboBoxItem>();
_validTzRegions = new List<string>();
_networkInterfaces = new Dictionary<string, string>();
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()

View file

@ -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();