mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 02:53:04 +00:00
Cleanup SettingsViewModel usage
This commit is contained in:
parent
2281b3b59e
commit
2d73107dc0
6 changed files with 32 additions and 31 deletions
|
@ -5,7 +5,6 @@ using LibHac.Tools.FsSystem;
|
||||||
using Ryujinx.Audio.Backends.OpenAL;
|
using Ryujinx.Audio.Backends.OpenAL;
|
||||||
using Ryujinx.Audio.Backends.SDL2;
|
using Ryujinx.Audio.Backends.SDL2;
|
||||||
using Ryujinx.Audio.Backends.SoundIo;
|
using Ryujinx.Audio.Backends.SoundIo;
|
||||||
using Ryujinx.Ava;
|
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.Models.Input;
|
using Ryujinx.Ava.UI.Models.Input;
|
||||||
|
|
|
@ -5,20 +5,23 @@ using Avalonia.Interactivity;
|
||||||
using Avalonia.LogicalTree;
|
using Avalonia.LogicalTree;
|
||||||
using Ryujinx.Ava.Input;
|
using Ryujinx.Ava.Input;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
|
using Ryujinx.Ava.UI.ViewModels.Settings;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using Ryujinx.Input.Assigner;
|
using Ryujinx.Input.Assigner;
|
||||||
using Ryujinx.Ava.UI.ViewModels.Settings;
|
|
||||||
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Views.Settings
|
namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
public partial class SettingsHotkeysView : UserControl
|
public partial class SettingsHotkeysView : UserControl
|
||||||
{
|
{
|
||||||
|
private readonly SettingsViewModel _viewModel;
|
||||||
private ButtonKeyAssigner _currentAssigner;
|
private ButtonKeyAssigner _currentAssigner;
|
||||||
private readonly IGamepadDriver _avaloniaKeyboardDriver;
|
private readonly IGamepadDriver _avaloniaKeyboardDriver;
|
||||||
|
|
||||||
public SettingsHotkeysView()
|
public SettingsHotkeysView(SettingsViewModel viewModel)
|
||||||
{
|
{
|
||||||
|
_viewModel = viewModel;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
foreach (ILogical visual in SettingButtons.GetLogicalDescendants())
|
foreach (ILogical visual in SettingButtons.GetLogicalDescendants())
|
||||||
|
@ -77,37 +80,36 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
if (e.ButtonValue.HasValue)
|
if (e.ButtonValue.HasValue)
|
||||||
{
|
{
|
||||||
var viewModel = (DataContext) as SettingsViewModel;
|
|
||||||
var buttonValue = e.ButtonValue.Value;
|
var buttonValue = e.ButtonValue.Value;
|
||||||
|
|
||||||
switch (button.Name)
|
switch (button.Name)
|
||||||
{
|
{
|
||||||
case "ToggleVsync":
|
case "ToggleVsync":
|
||||||
viewModel.KeyboardHotkey.ToggleVsync = buttonValue.AsHidType<Key>();
|
_viewModel.KeyboardHotkey.ToggleVsync = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
case "Screenshot":
|
case "Screenshot":
|
||||||
viewModel.KeyboardHotkey.Screenshot = buttonValue.AsHidType<Key>();
|
_viewModel.KeyboardHotkey.Screenshot = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
case "ShowUI":
|
case "ShowUI":
|
||||||
viewModel.KeyboardHotkey.ShowUI = buttonValue.AsHidType<Key>();
|
_viewModel.KeyboardHotkey.ShowUI = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
case "Pause":
|
case "Pause":
|
||||||
viewModel.KeyboardHotkey.Pause = buttonValue.AsHidType<Key>();
|
_viewModel.KeyboardHotkey.Pause = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
case "ToggleMute":
|
case "ToggleMute":
|
||||||
viewModel.KeyboardHotkey.ToggleMute = buttonValue.AsHidType<Key>();
|
_viewModel.KeyboardHotkey.ToggleMute = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
case "ResScaleUp":
|
case "ResScaleUp":
|
||||||
viewModel.KeyboardHotkey.ResScaleUp = buttonValue.AsHidType<Key>();
|
_viewModel.KeyboardHotkey.ResScaleUp = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
case "ResScaleDown":
|
case "ResScaleDown":
|
||||||
viewModel.KeyboardHotkey.ResScaleDown = buttonValue.AsHidType<Key>();
|
_viewModel.KeyboardHotkey.ResScaleDown = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
case "VolumeUp":
|
case "VolumeUp":
|
||||||
viewModel.KeyboardHotkey.VolumeUp = buttonValue.AsHidType<Key>();
|
_viewModel.KeyboardHotkey.VolumeUp = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
case "VolumeDown":
|
case "VolumeDown":
|
||||||
viewModel.KeyboardHotkey.VolumeDown = buttonValue.AsHidType<Key>();
|
_viewModel.KeyboardHotkey.VolumeDown = buttonValue.AsHidType<Key>();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,23 +5,23 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
public partial class SettingsInputView : UserControl
|
public partial class SettingsInputView : UserControl
|
||||||
{
|
{
|
||||||
private SettingsInputViewModel ViewModel { get; set; }
|
private readonly SettingsInputViewModel _viewModel;
|
||||||
|
|
||||||
public SettingsInputView(SettingsViewModel viewModel)
|
public SettingsInputView(SettingsViewModel viewModel)
|
||||||
{
|
{
|
||||||
DataContext = ViewModel = new SettingsInputViewModel(this, viewModel);
|
DataContext = _viewModel = new SettingsInputViewModel(this, viewModel);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveCurrentProfile()
|
public void SaveCurrentProfile()
|
||||||
{
|
{
|
||||||
ViewModel.Save();
|
_viewModel.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
ViewModel.Dispose();
|
_viewModel.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
public partial class SettingsSystemView : UserControl
|
public partial class SettingsSystemView : UserControl
|
||||||
{
|
{
|
||||||
public SettingsViewModel ViewModel;
|
private readonly SettingsViewModel _viewModel;
|
||||||
|
|
||||||
public SettingsSystemView(SettingsViewModel viewModel)
|
public SettingsSystemView(SettingsViewModel viewModel)
|
||||||
{
|
{
|
||||||
ViewModel = viewModel;
|
_viewModel = viewModel;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
|
||||||
ViewModel.ValidateAndSetTimeZone(timeZone.Location);
|
_viewModel.ValidateAndSetTimeZone(timeZone.Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
if (sender is AutoCompleteBox box && box.SelectedItem is TimeZone timeZone)
|
if (sender is AutoCompleteBox box && box.SelectedItem is TimeZone timeZone)
|
||||||
{
|
{
|
||||||
ViewModel.ValidateAndSetTimeZone(timeZone.Location);
|
_viewModel.ValidateAndSetTimeZone(timeZone.Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
public partial class SettingsUiView : UserControl
|
public partial class SettingsUiView : UserControl
|
||||||
{
|
{
|
||||||
public SettingsViewModel ViewModel;
|
private readonly SettingsViewModel _viewModel;
|
||||||
|
|
||||||
public SettingsUiView(SettingsViewModel viewModel)
|
public SettingsUiView(SettingsViewModel viewModel)
|
||||||
{
|
{
|
||||||
ViewModel = viewModel;
|
_viewModel = viewModel;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
string path = PathBox.Text;
|
string path = PathBox.Text;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path) && !ViewModel.GameDirectories.Contains(path))
|
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path) && !_viewModel.GameDirectories.Contains(path))
|
||||||
{
|
{
|
||||||
ViewModel.GameDirectories.Add(path);
|
_viewModel.GameDirectories.Add(path);
|
||||||
ViewModel.DirectoryChanged = true;
|
_viewModel.DirectoryChanged = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -39,8 +39,8 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
|
|
||||||
if (result.Count > 0)
|
if (result.Count > 0)
|
||||||
{
|
{
|
||||||
ViewModel.GameDirectories.Add(result[0].Path.LocalPath);
|
_viewModel.GameDirectories.Add(result[0].Path.LocalPath);
|
||||||
ViewModel.DirectoryChanged = true;
|
_viewModel.DirectoryChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
|
|
||||||
foreach (string path in new List<string>(GameList.SelectedItems.Cast<string>()))
|
foreach (string path in new List<string>(GameList.SelectedItems.Cast<string>()))
|
||||||
{
|
{
|
||||||
ViewModel.GameDirectories.Remove(path);
|
_viewModel.GameDirectories.Remove(path);
|
||||||
ViewModel.DirectoryChanged = true;
|
_viewModel.DirectoryChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameList.ItemCount > 0)
|
if (GameList.ItemCount > 0)
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
UiPage = new SettingsUiView(ViewModel);
|
UiPage = new SettingsUiView(ViewModel);
|
||||||
InputPage = new SettingsInputView(ViewModel);
|
InputPage = new SettingsInputView(ViewModel);
|
||||||
HotkeysPage = new SettingsHotkeysView();
|
HotkeysPage = new SettingsHotkeysView(ViewModel);
|
||||||
SystemPage = new SettingsSystemView(ViewModel);
|
SystemPage = new SettingsSystemView(ViewModel);
|
||||||
CpuPage = new SettingsCPUView();
|
CpuPage = new SettingsCPUView();
|
||||||
GraphicsPage = new SettingsGraphicsView();
|
GraphicsPage = new SettingsGraphicsView();
|
||||||
|
|
Loading…
Reference in a new issue