mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-23 14:19:52 -06:00
UI: fix: when switching players, it would show old config (#122)
When switching between players' gamepads while saving settings, then returning to the previous player, the settings show the default settings instead of the actual settings applied
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user