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:
Vladimir Sokolov
2024-11-10 15:24:17 +10:00
committed by GitHub
parent b17e4f79fb
commit 299be822c4
7 changed files with 119 additions and 7 deletions

View File

@ -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()