From 38519f3b9ade223983f7529f9b4f4b857c60f42b Mon Sep 17 00:00:00 2001 From: Isaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com> Date: Fri, 6 Jan 2023 18:35:21 -0500 Subject: Ava GUI: `SettingsWindow` Refactor (#4177) * Fix redundancies * Add back elses * Settings Refactor * Fix Disposal functions * Use `ReflectionBinding` instead of redundant funcs * Ac_K suggestions * Update Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs Co-authored-by: Ac_K * Update locale keys * Update Ryujinx.Ava/UI/Windows/SettingsWindow.axaml.cs Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com> * Update Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml.cs Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com> * Update Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml.cs Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com> * Update Ryujinx.Ava/UI/Windows/SettingsWindow.axaml.cs Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com> * Use block-scoped namespaces * Fix typo * Make `TimeZone` internal again Co-authored-by: Ac_K Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com> --- .../UI/Views/Settings/SettingsAudioView.axaml | 81 ++++++++ .../UI/Views/Settings/SettingsAudioView.axaml.cs | 12 ++ .../UI/Views/Settings/SettingsCPUView.axaml | 72 +++++++ .../UI/Views/Settings/SettingsCPUView.axaml.cs | 12 ++ .../UI/Views/Settings/SettingsGraphicsView.axaml | 218 +++++++++++++++++++++ .../Views/Settings/SettingsGraphicsView.axaml.cs | 12 ++ .../UI/Views/Settings/SettingsHotkeysView.axaml | 104 ++++++++++ .../UI/Views/Settings/SettingsHotkeysView.axaml.cs | 81 ++++++++ .../UI/Views/Settings/SettingsInputView.axaml | 46 +++++ .../UI/Views/Settings/SettingsInputView.axaml.cs | 17 ++ .../UI/Views/Settings/SettingsLoggingView.axaml | 118 +++++++++++ .../UI/Views/Settings/SettingsLoggingView.axaml.cs | 12 ++ .../UI/Views/Settings/SettingsNetworkView.axaml | 35 ++++ .../UI/Views/Settings/SettingsNetworkView.axaml.cs | 12 ++ .../UI/Views/Settings/SettingsSystemView.axaml | 195 ++++++++++++++++++ .../UI/Views/Settings/SettingsSystemView.axaml.cs | 52 +++++ Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml | 156 +++++++++++++++ .../UI/Views/Settings/SettingsUIView.axaml.cs | 82 ++++++++ 18 files changed, 1317 insertions(+) create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsAudioView.axaml create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsAudioView.axaml.cs create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsCPUView.axaml create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsCPUView.axaml.cs create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml.cs create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml.cs create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsInputView.axaml create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsInputView.axaml.cs create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsLoggingView.axaml create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsLoggingView.axaml.cs create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml.cs create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml.cs create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml create mode 100644 Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml.cs (limited to 'Ryujinx.Ava/UI/Views') diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsAudioView.axaml b/Ryujinx.Ava/UI/Views/Settings/SettingsAudioView.axaml new file mode 100644 index 00000000..35283353 --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsAudioView.axaml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsAudioView.axaml.cs b/Ryujinx.Ava/UI/Views/Settings/SettingsAudioView.axaml.cs new file mode 100644 index 00000000..026c7fdf --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsAudioView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace Ryujinx.Ava.UI.Views.Settings +{ + public partial class SettingsAudioView : UserControl + { + public SettingsAudioView() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsCPUView.axaml b/Ryujinx.Ava/UI/Views/Settings/SettingsCPUView.axaml new file mode 100644 index 00000000..a0cf3452 --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsCPUView.axaml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsCPUView.axaml.cs b/Ryujinx.Ava/UI/Views/Settings/SettingsCPUView.axaml.cs new file mode 100644 index 00000000..5c5b6079 --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsCPUView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace Ryujinx.Ava.UI.Views.Settings +{ + public partial class SettingsCPUView : UserControl + { + public SettingsCPUView() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml b/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml new file mode 100644 index 00000000..1f65155a --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml.cs b/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml.cs new file mode 100644 index 00000000..8fe08552 --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace Ryujinx.Ava.UI.Views.Settings +{ + public partial class SettingsGraphicsView : UserControl + { + public SettingsGraphicsView() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml b/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml new file mode 100644 index 00000000..361125bf --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml.cs b/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml.cs new file mode 100644 index 00000000..702f73e8 --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml.cs @@ -0,0 +1,81 @@ +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Input; +using Avalonia.Interactivity; +using Ryujinx.Ava.Input; +using Ryujinx.Ava.UI.Helpers; +using Ryujinx.Input; +using Ryujinx.Input.Assigner; + +namespace Ryujinx.Ava.UI.Views.Settings +{ + public partial class SettingsHotkeysView : UserControl + { + private ButtonKeyAssigner _currentAssigner; + private IGamepadDriver AvaloniaKeyboardDriver; + + public SettingsHotkeysView() + { + InitializeComponent(); + AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(this); + } + + private void MouseClick(object sender, PointerPressedEventArgs e) + { + bool shouldUnbind = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed; + + _currentAssigner?.Cancel(shouldUnbind); + + PointerPressed -= MouseClick; + } + + private void Button_Checked(object sender, RoutedEventArgs e) + { + if (sender is ToggleButton button) + { + if (_currentAssigner != null && button == _currentAssigner.ToggledButton) + { + return; + } + + if (_currentAssigner == null && button.IsChecked != null && (bool)button.IsChecked) + { + _currentAssigner = new ButtonKeyAssigner(button); + + FocusManager.Instance?.Focus(this, NavigationMethod.Pointer); + + PointerPressed += MouseClick; + + var keyboard = (IKeyboard)AvaloniaKeyboardDriver.GetGamepad(AvaloniaKeyboardDriver.GamepadsIds[0]); + IButtonAssigner assigner = new KeyboardKeyAssigner(keyboard); + + _currentAssigner.GetInputAndAssign(assigner); + } + else + { + if (_currentAssigner != null) + { + ToggleButton oldButton = _currentAssigner.ToggledButton; + + _currentAssigner.Cancel(); + _currentAssigner = null; + + button.IsChecked = false; + } + } + } + } + + private void Button_Unchecked(object sender, RoutedEventArgs e) + { + _currentAssigner?.Cancel(); + _currentAssigner = null; + } + + public void Dispose() + { + _currentAssigner?.Cancel(); + _currentAssigner = null; + } + } +} \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsInputView.axaml b/Ryujinx.Ava/UI/Views/Settings/SettingsInputView.axaml new file mode 100644 index 00000000..1c774bda --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsInputView.axaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsInputView.axaml.cs b/Ryujinx.Ava/UI/Views/Settings/SettingsInputView.axaml.cs new file mode 100644 index 00000000..0c2105ec --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsInputView.axaml.cs @@ -0,0 +1,17 @@ +using Avalonia.Controls; + +namespace Ryujinx.Ava.UI.Views.Settings +{ + public partial class SettingsInputView : UserControl + { + public SettingsInputView() + { + InitializeComponent(); + } + + public void Dispose() + { + ControllerSettings.Dispose(); + } + } +} \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsLoggingView.axaml b/Ryujinx.Ava/UI/Views/Settings/SettingsLoggingView.axaml new file mode 100644 index 00000000..2163dcda --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsLoggingView.axaml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsLoggingView.axaml.cs b/Ryujinx.Ava/UI/Views/Settings/SettingsLoggingView.axaml.cs new file mode 100644 index 00000000..2ec476ac --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsLoggingView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace Ryujinx.Ava.UI.Views.Settings +{ + public partial class SettingsLoggingView : UserControl + { + public SettingsLoggingView() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml b/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml new file mode 100644 index 00000000..8efd367d --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml.cs b/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml.cs new file mode 100644 index 00000000..d7407b9d --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace Ryujinx.Ava.UI.Views.Settings +{ + public partial class SettingsNetworkView : UserControl + { + public SettingsNetworkView() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml b/Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml new file mode 100644 index 00000000..ddcca39c --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml.cs b/Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml.cs new file mode 100644 index 00000000..d2ea59de --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsSystemView.axaml.cs @@ -0,0 +1,52 @@ +using Avalonia.Controls; +using Avalonia.Data; +using Avalonia.Data.Converters; +using Ryujinx.Ava.UI.ViewModels; +using System; +using System.Linq; +using TimeZone = Ryujinx.Ava.UI.Models.TimeZone; + +namespace Ryujinx.Ava.UI.Views.Settings +{ + public partial class SettingsSystemView : UserControl + { + public SettingsViewModel ViewModel; + + public SettingsSystemView() + { + InitializeComponent(); + + FuncMultiValueConverter converter = new(parts => string.Format("{0} {1} {2}", parts.ToArray()).Trim()); + MultiBinding tzMultiBinding = new() { Converter = converter }; + + tzMultiBinding.Bindings.Add(new Binding("UtcDifference")); + tzMultiBinding.Bindings.Add(new Binding("Location")); + tzMultiBinding.Bindings.Add(new Binding("Abbreviation")); + + TimeZoneBox.ValueMemberBinding = tzMultiBinding; + } + + private void TimeZoneBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (e.AddedItems != null && e.AddedItems.Count > 0) + { + if (e.AddedItems[0] is TimeZone timeZone) + { + e.Handled = true; + + ViewModel.ValidateAndSetTimeZone(timeZone.Location); + } + } + } + + private void TimeZoneBox_OnTextChanged(object sender, EventArgs e) + { + if (sender is AutoCompleteBox box && box.SelectedItem is TimeZone timeZone) + { + { + ViewModel.ValidateAndSetTimeZone(timeZone.Location); + } + } + } + } +} \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml b/Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml new file mode 100644 index 00000000..61b6c433 --- /dev/null +++ b/Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +