mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-11-21 17:40:52 +01: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:
parent
b17e4f79fb
commit
299be822c4
7 changed files with 119 additions and 7 deletions
|
@ -413,6 +413,7 @@
|
||||||
"AvatarSetBackgroundColor": "Set Background Color",
|
"AvatarSetBackgroundColor": "Set Background Color",
|
||||||
"AvatarClose": "Close",
|
"AvatarClose": "Close",
|
||||||
"ControllerSettingsLoadProfileToolTip": "Load Profile",
|
"ControllerSettingsLoadProfileToolTip": "Load Profile",
|
||||||
|
"ControllerSettingsViewProfileToolTip": "View Profile",
|
||||||
"ControllerSettingsAddProfileToolTip": "Add Profile",
|
"ControllerSettingsAddProfileToolTip": "Add Profile",
|
||||||
"ControllerSettingsRemoveProfileToolTip": "Remove Profile",
|
"ControllerSettingsRemoveProfileToolTip": "Remove Profile",
|
||||||
"ControllerSettingsSaveProfileToolTip": "Save Profile",
|
"ControllerSettingsSaveProfileToolTip": "Save Profile",
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace Ryujinx.Ava
|
||||||
{
|
{
|
||||||
internal partial class Program
|
internal partial class Program
|
||||||
{
|
{
|
||||||
|
//
|
||||||
public static double WindowScaleFactor { get; set; }
|
public static double WindowScaleFactor { get; set; }
|
||||||
public static double DesktopScaleFactor { get; set; } = 1.0;
|
public static double DesktopScaleFactor { get; set; } = 1.0;
|
||||||
public static string Version { get; private set; }
|
public static string Version { get; private set; }
|
||||||
|
|
|
@ -226,6 +226,24 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
(int)Symbol.Help,
|
(int)Symbol.Help,
|
||||||
primaryButtonResult);
|
primaryButtonResult);
|
||||||
|
|
||||||
|
internal static async Task<UserResult> 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<UserResult> CreateLocalizedConfirmationDialog(string primaryText, string secondaryText)
|
internal static async Task<UserResult> CreateLocalizedConfirmationDialog(string primaryText, string secondaryText)
|
||||||
=> await CreateConfirmationDialog(
|
=> await CreateConfirmationDialog(
|
||||||
primaryText,
|
primaryText,
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
private readonly MainWindow _mainWindow;
|
private readonly MainWindow _mainWindow;
|
||||||
|
|
||||||
private PlayerIndex _playerId;
|
private PlayerIndex _playerId;
|
||||||
|
private PlayerIndex _playerIdChoose;
|
||||||
private int _controller;
|
private int _controller;
|
||||||
private string _controllerImage;
|
private string _controllerImage;
|
||||||
private int _device;
|
private int _device;
|
||||||
|
@ -83,6 +84,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerIndex PlayerIdChoose
|
||||||
|
{
|
||||||
|
get => _playerIdChoose;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerIndex PlayerId
|
public PlayerIndex PlayerId
|
||||||
{
|
{
|
||||||
get => _playerId;
|
get => _playerId;
|
||||||
|
@ -90,6 +97,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
{
|
{
|
||||||
if (IsModified)
|
if (IsModified)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
_playerIdChoose = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +108,9 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
if (!Enum.IsDefined(typeof(PlayerIndex), _playerId))
|
if (!Enum.IsDefined(typeof(PlayerIndex), _playerId))
|
||||||
{
|
{
|
||||||
_playerId = PlayerIndex.Player1;
|
_playerId = PlayerIndex.Player1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
_isLoaded = false;
|
||||||
|
|
||||||
LoadConfiguration();
|
LoadConfiguration();
|
||||||
LoadDevice();
|
LoadDevice();
|
||||||
|
|
|
@ -4,11 +4,14 @@ using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.LogicalTree;
|
using Avalonia.LogicalTree;
|
||||||
|
using DiscordRPC;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.ViewModels.Input;
|
using Ryujinx.Ava.UI.ViewModels.Input;
|
||||||
using Ryujinx.Common.Configuration.Hid.Controller;
|
using Ryujinx.Common.Configuration.Hid.Controller;
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using Ryujinx.Input.Assigner;
|
using Ryujinx.Input.Assigner;
|
||||||
|
using System;
|
||||||
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
|
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Views.Input
|
namespace Ryujinx.Ava.UI.Views.Input
|
||||||
|
@ -27,6 +30,16 @@ namespace Ryujinx.Ava.UI.Views.Input
|
||||||
{
|
{
|
||||||
button.IsCheckedChanged += Button_IsCheckedChanged;
|
button.IsCheckedChanged += Button_IsCheckedChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (visual is CheckBox check)
|
||||||
|
{
|
||||||
|
check.IsCheckedChanged += CheckBox_IsCheckedChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visual is Slider slider)
|
||||||
|
{
|
||||||
|
slider.PropertyChanged += Slider_IsCheckedChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +53,48 @@ 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)
|
private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is ToggleButton button )
|
if (sender is ToggleButton button )
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
ToolTip.Tip="{ext:Locale ControllerSettingsLoadProfileToolTip}"
|
ToolTip.Tip="{ext:Locale ControllerSettingsLoadProfileToolTip}"
|
||||||
Command="{Binding LoadProfile}">
|
Command="{Binding LoadProfile}">
|
||||||
<ui:SymbolIcon
|
<ui:SymbolIcon
|
||||||
Symbol="Upload"
|
Symbol="View"
|
||||||
FontSize="15"
|
FontSize="15"
|
||||||
Height="20" />
|
Height="20" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -25,17 +25,27 @@ namespace Ryujinx.Ava.UI.Views.Input
|
||||||
|
|
||||||
private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
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)
|
if (ViewModel.IsModified && !_dialogOpen)
|
||||||
{
|
{
|
||||||
_dialogOpen = true;
|
_dialogOpen = true;
|
||||||
|
|
||||||
var result = await ContentDialogHelper.CreateConfirmationDialog(
|
var result = await ContentDialogHelper.CreateConfirmationDialogExtended(
|
||||||
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage],
|
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage],
|
||||||
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage],
|
LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage],
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||||
|
LocaleManager.Instance[LocaleKeys.Cancel],
|
||||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
||||||
|
|
||||||
|
|
||||||
if (result == UserResult.Yes)
|
if (result == UserResult.Yes)
|
||||||
{
|
{
|
||||||
ViewModel.Save();
|
ViewModel.Save();
|
||||||
|
@ -43,16 +53,32 @@ namespace Ryujinx.Ava.UI.Views.Input
|
||||||
|
|
||||||
_dialogOpen = false;
|
_dialogOpen = false;
|
||||||
|
|
||||||
|
if (result == UserResult.Cancel)
|
||||||
|
{
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ViewModel.IsModified = false;
|
ViewModel.IsModified = false;
|
||||||
|
|
||||||
|
if (result != UserResult.Cancel)
|
||||||
|
{
|
||||||
|
ViewModel.PlayerId = ViewModel.PlayerIdChoose;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == UserResult.Cancel)
|
||||||
|
{
|
||||||
if (e.AddedItems.Count > 0)
|
if (e.AddedItems.Count > 0)
|
||||||
{
|
{
|
||||||
|
ViewModel.IsModified = true;
|
||||||
var player = (PlayerModel)e.AddedItems[0];
|
var player = (PlayerModel)e.AddedItems[0];
|
||||||
ViewModel.PlayerId = player.Id;
|
ViewModel.PlayerId = player.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
ViewModel.Dispose();
|
ViewModel.Dispose();
|
||||||
|
|
Loading…
Reference in a new issue