diff --git a/src/Ryujinx/Assets/Locales/en_US.json b/src/Ryujinx/Assets/Locales/en_US.json index faa53230d..30c84ab14 100644 --- a/src/Ryujinx/Assets/Locales/en_US.json +++ b/src/Ryujinx/Assets/Locales/en_US.json @@ -413,6 +413,7 @@ "AvatarSetBackgroundColor": "Set Background Color", "AvatarClose": "Close", "ControllerSettingsLoadProfileToolTip": "Load Profile", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Add Profile", "ControllerSettingsRemoveProfileToolTip": "Remove Profile", "ControllerSettingsSaveProfileToolTip": "Save Profile", diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index a6a616c6a..31db628d3 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -30,6 +30,7 @@ namespace Ryujinx.Ava { internal partial class Program { + // public static double WindowScaleFactor { get; set; } public static double DesktopScaleFactor { get; set; } = 1.0; public static string Version { get; private set; } diff --git a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs index 67a3642a9..bd8c1e3a7 100644 --- a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs +++ b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs @@ -226,6 +226,24 @@ namespace Ryujinx.Ava.UI.Helpers (int)Symbol.Help, primaryButtonResult); + internal static async Task CreateConfirmationDialogExtended( + string primaryText, + string secondaryText, + string acceptButtonText, + string noacceptButtonText, + string cancelButtonText, + string title, + UserResult primaryButtonResult = UserResult.Yes) + => await ShowTextDialog( + string.IsNullOrWhiteSpace(title) ? LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle] : title, + primaryText, + secondaryText, + acceptButtonText, + noacceptButtonText, + cancelButtonText, + (int)Symbol.Help, + primaryButtonResult); + internal static async Task CreateLocalizedConfirmationDialog(string primaryText, string secondaryText) => await CreateConfirmationDialog( primaryText, diff --git a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs index c133f25fa..54f278cec 100644 --- a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs @@ -44,6 +44,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input private readonly MainWindow _mainWindow; private PlayerIndex _playerId; + private PlayerIndex _playerIdChoose; private int _controller; private string _controllerImage; private int _device; @@ -83,6 +84,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input } } + public PlayerIndex PlayerIdChoose + { + get => _playerIdChoose; + set { } + } + public PlayerIndex PlayerId { get => _playerId; @@ -90,6 +97,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input { if (IsModified) { + + _playerIdChoose = value; return; } @@ -99,7 +108,9 @@ namespace Ryujinx.Ava.UI.ViewModels.Input if (!Enum.IsDefined(typeof(PlayerIndex), _playerId)) { _playerId = PlayerIndex.Player1; + } + _isLoaded = false; LoadConfiguration(); LoadDevice(); diff --git a/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs b/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs index b76648da7..c900ea532 100644 --- a/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs +++ b/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs @@ -4,11 +4,14 @@ using Avalonia.Controls.Primitives; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.LogicalTree; +using DiscordRPC; using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.ViewModels.Input; using Ryujinx.Common.Configuration.Hid.Controller; +using Ryujinx.Common.Logging; using Ryujinx.Input; using Ryujinx.Input.Assigner; +using System; using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId; namespace Ryujinx.Ava.UI.Views.Input @@ -27,6 +30,16 @@ namespace Ryujinx.Ava.UI.Views.Input { button.IsCheckedChanged += Button_IsCheckedChanged; } + + if (visual is CheckBox check) + { + check.IsCheckedChanged += CheckBox_IsCheckedChanged; + } + + if (visual is Slider slider) + { + slider.PropertyChanged += Slider_IsCheckedChanged; + } } } @@ -40,9 +53,51 @@ namespace Ryujinx.Ava.UI.Views.Input } } + private float _changeSlider = -1.0f; + + private void Slider_IsCheckedChanged(object sender, AvaloniaPropertyChangedEventArgs e) + { + if (sender is Slider check) + { + if ((bool)check.IsPointerOver && _changeSlider == -1.0f) + { + _changeSlider = (float)check.Value; + + } + else if (!(bool)check.IsPointerOver) + { + _changeSlider = -1.0f; + } + + if (_changeSlider != -1.0f && _changeSlider != (float)check.Value) + { + + var viewModel = (DataContext as ControllerInputViewModel); + viewModel.ParentModel.IsModified = true; + _changeSlider = (float)check.Value; + } + } + } + + private void CheckBox_IsCheckedChanged(object sender, RoutedEventArgs e) + { + if (sender is CheckBox check) + { + if ((bool)check.IsPointerOver) + { + + var viewModel = (DataContext as ControllerInputViewModel); + viewModel.ParentModel.IsModified = true; + _currentAssigner?.Cancel(); + _currentAssigner = null; + } + } + } + + private void Button_IsCheckedChanged(object sender, RoutedEventArgs e) { - if (sender is ToggleButton button) + if (sender is ToggleButton button ) { if ((bool)button.IsChecked) { @@ -149,7 +204,7 @@ namespace Ryujinx.Ava.UI.Views.Input } else { - if (_currentAssigner != null) + if (_currentAssigner != null ) { _currentAssigner.Cancel(); _currentAssigner = null; diff --git a/src/Ryujinx/UI/Views/Input/InputView.axaml b/src/Ryujinx/UI/Views/Input/InputView.axaml index 851c9c626..b5bfa666d 100644 --- a/src/Ryujinx/UI/Views/Input/InputView.axaml +++ b/src/Ryujinx/UI/Views/Input/InputView.axaml @@ -108,7 +108,7 @@ ToolTip.Tip="{ext:Locale ControllerSettingsLoadProfileToolTip}" Command="{Binding LoadProfile}"> diff --git a/src/Ryujinx/UI/Views/Input/InputView.axaml.cs b/src/Ryujinx/UI/Views/Input/InputView.axaml.cs index 356381a8a..5fda7ef6a 100644 --- a/src/Ryujinx/UI/Views/Input/InputView.axaml.cs +++ b/src/Ryujinx/UI/Views/Input/InputView.axaml.cs @@ -25,17 +25,27 @@ namespace Ryujinx.Ava.UI.Views.Input private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { + if (PlayerIndexBox != null) + { + if (PlayerIndexBox.SelectedIndex != (int)ViewModel.PlayerId) + { + PlayerIndexBox.SelectedIndex = (int)ViewModel.PlayerId; + } + } + if (ViewModel.IsModified && !_dialogOpen) { _dialogOpen = true; - var result = await ContentDialogHelper.CreateConfirmationDialog( + var result = await ContentDialogHelper.CreateConfirmationDialogExtended( LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage], LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage], LocaleManager.Instance[LocaleKeys.InputDialogYes], LocaleManager.Instance[LocaleKeys.InputDialogNo], + LocaleManager.Instance[LocaleKeys.Cancel], LocaleManager.Instance[LocaleKeys.RyujinxConfirm]); + if (result == UserResult.Yes) { ViewModel.Save(); @@ -43,14 +53,30 @@ namespace Ryujinx.Ava.UI.Views.Input _dialogOpen = false; + if (result == UserResult.Cancel) + { + + return; + } + ViewModel.IsModified = false; - if (e.AddedItems.Count > 0) + if (result != UserResult.Cancel) { - var player = (PlayerModel)e.AddedItems[0]; - ViewModel.PlayerId = player.Id; + ViewModel.PlayerId = ViewModel.PlayerIdChoose; + } + + if (result == UserResult.Cancel) + { + if (e.AddedItems.Count > 0) + { + ViewModel.IsModified = true; + var player = (PlayerModel)e.AddedItems[0]; + ViewModel.PlayerId = player.Id; + } } } + } public void Dispose()