diff options
Diffstat (limited to 'Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs')
-rw-r--r-- | Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs index cbba7fb9..232c9d43 100644 --- a/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs +++ b/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Runtime.InteropServices; +using System.Net.NetworkInformation; using TimeZone = Ryujinx.Ava.UI.Models.TimeZone; namespace Ryujinx.Ava.UI.ViewModels @@ -35,6 +36,8 @@ namespace Ryujinx.Ava.UI.ViewModels private readonly List<string> _validTzRegions; + private readonly Dictionary<string, string> _networkInterfaces; + private float _customResolutionScale; private int _resolutionScale; private int _graphicsBackendMultithreadingIndex; @@ -50,6 +53,7 @@ namespace Ryujinx.Ava.UI.ViewModels public event Action CloseWindow; public event Action SaveSettingsEvent; + private int _networkInterfaceIndex; public int ResolutionScale { @@ -240,6 +244,11 @@ namespace Ryujinx.Ava.UI.ViewModels public AvaloniaList<string> GameDirectories { get; set; } public ObservableCollection<ComboBoxItem> AvailableGpus { get; set; } + public AvaloniaList<string> NetworkInterfaceList + { + get => new AvaloniaList<string>(_networkInterfaces.Keys); + } + public KeyboardHotkeys KeyboardHotkeys { get => _keyboardHotkeys; @@ -251,6 +260,16 @@ namespace Ryujinx.Ava.UI.ViewModels } } + public int NetworkInterfaceIndex + { + get => _networkInterfaceIndex; + set + { + _networkInterfaceIndex = value != -1 ? value : 0; + ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[_networkInterfaceIndex]]; + } + } + public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this() { _virtualFileSystem = virtualFileSystem; @@ -267,8 +286,10 @@ namespace Ryujinx.Ava.UI.ViewModels TimeZones = new AvaloniaList<TimeZone>(); AvailableGpus = new ObservableCollection<ComboBoxItem>(); _validTzRegions = new List<string>(); + _networkInterfaces = new Dictionary<string, string>(); CheckSoundBackends(); + PopulateNetworkInterfaces(); if (Program.PreviewerDetached) { @@ -327,6 +348,17 @@ namespace Ryujinx.Ava.UI.ViewModels } } + private void PopulateNetworkInterfaces() + { + _networkInterfaces.Clear(); + _networkInterfaces.Add(LocaleManager.Instance[LocaleKeys.NetworkInterfaceDefault], "0"); + + foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces()) + { + _networkInterfaces.Add(networkInterface.Name, networkInterface.Id); + } + } + public void ValidateAndSetTimeZone(string location) { if (_validTzRegions.Contains(location)) @@ -414,6 +446,8 @@ namespace Ryujinx.Ava.UI.ViewModels EnableFsAccessLog = config.Logger.EnableFsAccessLog; FsGlobalAccessLogMode = config.System.FsGlobalAccessLogMode; OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value; + + NetworkInterfaceIndex = _networkInterfaces.Values.ToList().IndexOf(config.Multiplayer.LanInterfaceId.Value); } public void SaveSettings() @@ -515,6 +549,8 @@ namespace Ryujinx.Ava.UI.ViewModels config.System.FsGlobalAccessLogMode.Value = FsGlobalAccessLogMode; config.Logger.GraphicsDebugLevel.Value = (GraphicsDebugLevel)OpenglDebugLevel; + config.Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[NetworkInterfaceIndex]]; + config.ToFileFormat().SaveConfig(Program.ConfigurationPath); MainWindow.UpdateGraphicsConfig(); |