From b53e7ffd46b5c4ac5c4ac3dcc24385b2c9dc4fa4 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com> Date: Mon, 22 May 2023 00:16:20 +0100 Subject: Ava UI: Input Menu Redesign (#4990) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Cleanup * Remove redundant locales * Start SVG Fixes… Better +/- buttons Fix the grips Bumpers Better directional pad More SVG stuff Grip adjustments Final stuff * Make image bigger * Border radius * More cleanup * Restructure * Restructure Rumble View * Use compiled bindings where possible * Round those pesky corners * Ack Suggestions * More suggestions * Update src/Ryujinx.Ava/UI/Views/Input/RumbleInputView.axaml.cs Co-authored-by: Ac_K --------- Co-authored-by: Ac_K --- .../UI/Windows/ControllerSettingsWindow.axaml | 1122 -------------------- .../UI/Windows/ControllerSettingsWindow.axaml.cs | 181 ---- .../UI/Windows/MotionSettingsWindow.axaml | 141 --- .../UI/Windows/MotionSettingsWindow.axaml.cs | 71 -- .../UI/Windows/RumbleSettingsWindow.axaml | 57 - .../UI/Windows/RumbleSettingsWindow.axaml.cs | 57 - 6 files changed, 1629 deletions(-) delete mode 100644 src/Ryujinx.Ava/UI/Windows/ControllerSettingsWindow.axaml delete mode 100644 src/Ryujinx.Ava/UI/Windows/ControllerSettingsWindow.axaml.cs delete mode 100644 src/Ryujinx.Ava/UI/Windows/MotionSettingsWindow.axaml delete mode 100644 src/Ryujinx.Ava/UI/Windows/MotionSettingsWindow.axaml.cs delete mode 100644 src/Ryujinx.Ava/UI/Windows/RumbleSettingsWindow.axaml delete mode 100644 src/Ryujinx.Ava/UI/Windows/RumbleSettingsWindow.axaml.cs (limited to 'src/Ryujinx.Ava/UI/Windows') diff --git a/src/Ryujinx.Ava/UI/Windows/ControllerSettingsWindow.axaml b/src/Ryujinx.Ava/UI/Windows/ControllerSettingsWindow.axaml deleted file mode 100644 index 1a11a8ff..00000000 --- a/src/Ryujinx.Ava/UI/Windows/ControllerSettingsWindow.axaml +++ /dev/null @@ -1,1122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Ryujinx.Ava/UI/Windows/ControllerSettingsWindow.axaml.cs b/src/Ryujinx.Ava/UI/Windows/ControllerSettingsWindow.axaml.cs deleted file mode 100644 index 2864b6da..00000000 --- a/src/Ryujinx.Ava/UI/Windows/ControllerSettingsWindow.axaml.cs +++ /dev/null @@ -1,181 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Controls.Primitives; -using Avalonia.Input; -using Avalonia.Interactivity; -using Avalonia.LogicalTree; -using Ryujinx.Ava.Common.Locale; -using Ryujinx.Ava.UI.Controls; -using Ryujinx.Ava.UI.Helpers; -using Ryujinx.Ava.UI.Models; -using Ryujinx.Ava.UI.ViewModels; -using Ryujinx.Common.Configuration.Hid.Controller; -using Ryujinx.Input; -using Ryujinx.Input.Assigner; -using System; - -namespace Ryujinx.Ava.UI.Windows -{ - public partial class ControllerSettingsWindow : UserControl - { - private bool _dialogOpen; - - private ButtonKeyAssigner _currentAssigner; - internal ControllerSettingsViewModel ViewModel { get; set; } - - public ControllerSettingsWindow() - { - DataContext = ViewModel = new ControllerSettingsViewModel(this); - - InitializeComponent(); - - foreach (ILogical visual in SettingButtons.GetLogicalDescendants()) - { - if (visual is ToggleButton button && !(visual is CheckBox)) - { - button.Checked += Button_Checked; - button.Unchecked += Button_Unchecked; - } - } - } - - protected override void OnPointerReleased(PointerReleasedEventArgs e) - { - base.OnPointerReleased(e); - - if (_currentAssigner != null && _currentAssigner.ToggledButton != null && !_currentAssigner.ToggledButton.IsPointerOver) - { - _currentAssigner.Cancel(); - } - } - - private void Button_Checked(object sender, RoutedEventArgs e) - { - if (sender is ToggleButton button) - { - if (_currentAssigner != null && button == _currentAssigner.ToggledButton) - { - return; - } - - bool isStick = button.Tag != null && button.Tag.ToString() == "stick"; - - if (_currentAssigner == null && (bool)button.IsChecked) - { - _currentAssigner = new ButtonKeyAssigner(button); - - FocusManager.Instance.Focus(this, NavigationMethod.Pointer); - - PointerPressed += MouseClick; - - IKeyboard keyboard = (IKeyboard)ViewModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations. - IButtonAssigner assigner = CreateButtonAssigner(isStick); - - _currentAssigner.ButtonAssigned += (sender, e) => - { - if (e.IsAssigned) - { - ViewModel.IsModified = true; - } - }; - - _currentAssigner.GetInputAndAssign(assigner, keyboard); - } - else - { - if (_currentAssigner != null) - { - ToggleButton oldButton = _currentAssigner.ToggledButton; - - _currentAssigner.Cancel(); - _currentAssigner = null; - button.IsChecked = false; - } - } - } - } - - public void SaveCurrentProfile() - { - ViewModel.Save(); - } - - private IButtonAssigner CreateButtonAssigner(bool forStick) - { - IButtonAssigner assigner; - - var device = ViewModel.Devices[ViewModel.Device]; - - if (device.Type == DeviceType.Keyboard) - { - assigner = new KeyboardKeyAssigner((IKeyboard)ViewModel.SelectedGamepad); - } - else if (device.Type == DeviceType.Controller) - { - assigner = new GamepadButtonAssigner(ViewModel.SelectedGamepad, (ViewModel.Config as StandardControllerInputConfig).TriggerThreshold, forStick); - } - else - { - throw new Exception("Controller not supported"); - } - - return assigner; - } - - private void Button_Unchecked(object sender, RoutedEventArgs e) - { - _currentAssigner?.Cancel(); - _currentAssigner = null; - } - - private void MouseClick(object sender, PointerPressedEventArgs e) - { - bool shouldUnbind = false; - - if (e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed) - { - shouldUnbind = true; - } - - _currentAssigner?.Cancel(shouldUnbind); - - PointerPressed -= MouseClick; - } - - private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (ViewModel.IsModified && !_dialogOpen) - { - _dialogOpen = true; - - var result = await ContentDialogHelper.CreateConfirmationDialog( - LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage], - LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage], - LocaleManager.Instance[LocaleKeys.InputDialogYes], - LocaleManager.Instance[LocaleKeys.InputDialogNo], - LocaleManager.Instance[LocaleKeys.RyujinxConfirm]); - - if (result == UserResult.Yes) - { - ViewModel.Save(); - } - - _dialogOpen = false; - - ViewModel.IsModified = false; - - if (e.AddedItems.Count > 0) - { - var player = (PlayerModel)e.AddedItems[0]; - ViewModel.PlayerId = player.Id; - } - } - } - - public void Dispose() - { - _currentAssigner?.Cancel(); - _currentAssigner = null; - ViewModel.Dispose(); - } - } -} \ No newline at end of file diff --git a/src/Ryujinx.Ava/UI/Windows/MotionSettingsWindow.axaml b/src/Ryujinx.Ava/UI/Windows/MotionSettingsWindow.axaml deleted file mode 100644 index 862998ac..00000000 --- a/src/Ryujinx.Ava/UI/Windows/MotionSettingsWindow.axaml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Ryujinx.Ava/UI/Windows/MotionSettingsWindow.axaml.cs b/src/Ryujinx.Ava/UI/Windows/MotionSettingsWindow.axaml.cs deleted file mode 100644 index c686e7c3..00000000 --- a/src/Ryujinx.Ava/UI/Windows/MotionSettingsWindow.axaml.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Avalonia.Controls; -using FluentAvalonia.UI.Controls; -using Ryujinx.Ava.Common.Locale; -using Ryujinx.Ava.UI.Models; -using Ryujinx.Ava.UI.ViewModels; -using Ryujinx.Common.Configuration.Hid.Controller; -using System.Threading.Tasks; - -namespace Ryujinx.Ava.UI.Windows -{ - public partial class MotionSettingsWindow : UserControl - { - private readonly InputConfiguration _viewmodel; - - public MotionSettingsWindow() - { - InitializeComponent(); - DataContext = _viewmodel; - } - - public MotionSettingsWindow(ControllerSettingsViewModel viewmodel) - { - var config = viewmodel.Configuration as InputConfiguration; - - _viewmodel = new InputConfiguration() - { - Slot = config.Slot, - AltSlot = config.AltSlot, - DsuServerHost = config.DsuServerHost, - DsuServerPort = config.DsuServerPort, - MirrorInput = config.MirrorInput, - EnableMotion = config.EnableMotion, - Sensitivity = config.Sensitivity, - GyroDeadzone = config.GyroDeadzone, - EnableCemuHookMotion = config.EnableCemuHookMotion - }; - - InitializeComponent(); - DataContext = _viewmodel; - } - - public static async Task Show(ControllerSettingsViewModel viewmodel) - { - MotionSettingsWindow content = new MotionSettingsWindow(viewmodel); - - ContentDialog contentDialog = new ContentDialog - { - Title = LocaleManager.Instance[LocaleKeys.ControllerMotionTitle], - PrimaryButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsSave], - SecondaryButtonText = "", - CloseButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsClose], - Content = content - }; - contentDialog.PrimaryButtonClick += (sender, args) => - { - var config = viewmodel.Configuration as InputConfiguration; - config.Slot = content._viewmodel.Slot; - config.EnableMotion = content._viewmodel.EnableMotion; - config.Sensitivity = content._viewmodel.Sensitivity; - config.GyroDeadzone = content._viewmodel.GyroDeadzone; - config.AltSlot = content._viewmodel.AltSlot; - config.DsuServerHost = content._viewmodel.DsuServerHost; - config.DsuServerPort = content._viewmodel.DsuServerPort; - config.EnableCemuHookMotion = content._viewmodel.EnableCemuHookMotion; - config.MirrorInput = content._viewmodel.MirrorInput; - }; - - await contentDialog.ShowAsync(); - } - } -} \ No newline at end of file diff --git a/src/Ryujinx.Ava/UI/Windows/RumbleSettingsWindow.axaml b/src/Ryujinx.Ava/UI/Windows/RumbleSettingsWindow.axaml deleted file mode 100644 index e47cc5bd..00000000 --- a/src/Ryujinx.Ava/UI/Windows/RumbleSettingsWindow.axaml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Ryujinx.Ava/UI/Windows/RumbleSettingsWindow.axaml.cs b/src/Ryujinx.Ava/UI/Windows/RumbleSettingsWindow.axaml.cs deleted file mode 100644 index 178109d6..00000000 --- a/src/Ryujinx.Ava/UI/Windows/RumbleSettingsWindow.axaml.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Avalonia.Controls; -using FluentAvalonia.UI.Controls; -using Ryujinx.Ava.Common.Locale; -using Ryujinx.Ava.UI.Models; -using Ryujinx.Ava.UI.ViewModels; -using Ryujinx.Common.Configuration.Hid.Controller; -using System.Threading.Tasks; - -namespace Ryujinx.Ava.UI.Windows -{ - public partial class RumbleSettingsWindow : UserControl - { - private readonly InputConfiguration _viewmodel; - - public RumbleSettingsWindow() - { - InitializeComponent(); - DataContext = _viewmodel; - } - - public RumbleSettingsWindow(ControllerSettingsViewModel viewmodel) - { - var config = viewmodel.Configuration as InputConfiguration; - - _viewmodel = new InputConfiguration() - { - StrongRumble = config.StrongRumble, WeakRumble = config.WeakRumble - }; - - InitializeComponent(); - DataContext = _viewmodel; - } - - public static async Task Show(ControllerSettingsViewModel viewmodel) - { - RumbleSettingsWindow content = new RumbleSettingsWindow(viewmodel); - - ContentDialog contentDialog = new ContentDialog - { - Title = LocaleManager.Instance[LocaleKeys.ControllerRumbleTitle], - PrimaryButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsSave], - SecondaryButtonText = "", - CloseButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsClose], - Content = content, - }; - - contentDialog.PrimaryButtonClick += (sender, args) => - { - var config = viewmodel.Configuration as InputConfiguration; - config.StrongRumble = content._viewmodel.StrongRumble; - config.WeakRumble = content._viewmodel.WeakRumble; - }; - - await contentDialog.ShowAsync(); - } - } -} \ No newline at end of file -- cgit v1.2.3