Fix: Profile Text Covering Icon, Reset Keybinds switching to Default profile, Keybinds not updating properly with certain linked profiles

This commit is contained in:
_Neo_ 2026-07-17 04:30:17 +03:00 committed by Gabriel
parent ea4aed37ac
commit 5756546d96
3 changed files with 81 additions and 6 deletions

View file

@ -1188,6 +1188,16 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
}
}
private void ApplySelectedProfileSilently(string profileName)
{
SetSelectedProfileSilently(profileName);
if (TryLoadProfileConfiguration(profileName, out InputConfig profileConfig))
{
LoadConfiguration(profileConfig, false);
}
}
private void RefreshProfileBindingState()
{
OnPropertyChanged(nameof(CanBindSelectedProfile));
@ -1346,7 +1356,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
}
LoadConfiguration(LoadDefaultConfiguration(), false);
SetSelectedProfileSilently(GetCurrentProfileDefaultName());
RefreshProfileBindingState();
}
@ -1428,12 +1437,22 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{
bool duplicateDeviceAssignmentChanged = _allowDuplicateDeviceAssignment.HasValue &&
_allowDuplicateDeviceAssignment.Value != GetSavedAllowDuplicateDeviceAssignment();
bool configChanged = !ConfigsMatch(GetSelectedDeviceConfig(), GetDisplayedInputConfig(GetPersistedInputConfig()));
bool configChanged = !ConfigsMatch(GetSelectedDeviceConfig(), GetPersistedComparisonConfig());
bool playerAssignmentsChanged = !PlayerAssignmentsMatch(GetEditedPlayerInputAssignment(), GetPersistedPlayerInputAssignment());
return duplicateDeviceAssignmentChanged || configChanged || playerAssignmentsChanged;
}
private InputConfig GetPersistedComparisonConfig()
{
if (!IsDefaultProfileName(ProfileName) && TryLoadProfileConfiguration(ProfileName, out InputConfig profileConfig))
{
return profileConfig;
}
return GetDisplayedInputConfig(GetPersistedInputConfig());
}
private static bool ConfigsMatch(InputConfig currentConfig, InputConfig otherConfig)
{
if (currentConfig == null || otherConfig == null)
@ -1857,7 +1876,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
selectedProfile = GetCurrentProfileDefaultName();
}
SetSelectedProfileSilently(selectedProfile);
ApplySelectedProfileSilently(selectedProfile);
}
finally
{
@ -2130,7 +2149,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
ReplaceBoundProfileName(ProfileName, null);
LoadProfiles();
SetSelectedProfileSilently(ProfilesList[0].ToString());
ApplySelectedProfileSilently(ProfilesList[0].ToString());
RefreshModifiedState();
}
}

View file

@ -106,6 +106,8 @@
IsEnabled="{Binding ShowSettings}"
SelectedItem="{Binding ChosenProfile, Mode=TwoWay}"
SelectionChanged="ComboBox_SelectionChanged"
GotFocus="ProfileBox_OnGotFocus"
LostFocus="ProfileBox_OnLostFocus"
ItemsSource="{Binding ProfilesList}"
Text="{Binding ProfileName, Mode=TwoWay}">
<ui:FAComboBox.Styles>
@ -124,11 +126,12 @@
</ui:FAComboBox.Styles>
</ui:FAComboBox>
<ui:SymbolIcon
Name="ProfileLinkIcon"
Grid.Column="1"
Symbol="Link"
FontSize="12"
Opacity="0.6"
IsVisible="{Binding IsProfileLinked}"
IsHitTestVisible="False"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Margin="0,0,37,0" />

View file

@ -2,6 +2,7 @@ using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Avalonia.Interactivity;
using Avalonia;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Media;
using FluentAvalonia.UI.Controls;
@ -11,12 +12,15 @@ using Ryujinx.Ava.UI.Controls;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Models;
using Ryujinx.Ava.UI.ViewModels.Input;
using System.ComponentModel;
namespace Ryujinx.Ava.UI.Views.Input
{
public partial class InputView : RyujinxControl<InputViewModel>
{
private bool _dialogOpen;
private bool _isEditingProfileName;
private InputViewModel _subscribedViewModel;
public InputView()
{
@ -43,11 +47,24 @@ namespace Ryujinx.Ava.UI.Views.Input
private void ReplaceViewModel(bool useGlobalConfig)
{
ViewModel = new InputViewModel(this, useGlobalConfig); // Create new Input Page with the selected input config scope.
if (_subscribedViewModel != null)
{
_subscribedViewModel.PropertyChanged -= ViewModel_OnPropertyChanged;
_subscribedViewModel = null;
}
InputViewModel newViewModel = new InputViewModel(this, useGlobalConfig); // Create new Input Page with the selected input config scope.
newViewModel.PropertyChanged += ViewModel_OnPropertyChanged;
_subscribedViewModel = newViewModel;
ViewModel = newViewModel;
InitializeComponent();
SetupProfileBoxItemTemplate();
_isEditingProfileName = false;
UpdateProfileLinkIconVisibility();
if (VisualRoot is not null)
{
ViewModel.RetargetKeyboardDriver(this);
@ -232,8 +249,44 @@ namespace Ryujinx.Ava.UI.Views.Input
ViewModel?.LoadProfile();
}
private void ViewModel_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(InputViewModel.IsProfileLinked))
{
UpdateProfileLinkIconVisibility();
}
}
private void ProfileBox_OnGotFocus(object sender, GotFocusEventArgs e)
{
_isEditingProfileName = true;
UpdateProfileLinkIconVisibility();
}
private void ProfileBox_OnLostFocus(object sender, RoutedEventArgs e)
{
_isEditingProfileName = false;
UpdateProfileLinkIconVisibility();
}
private void UpdateProfileLinkIconVisibility()
{
if (ProfileLinkIcon == null)
{
return;
}
ProfileLinkIcon.IsVisible = !_isEditingProfileName && (ViewModel?.IsProfileLinked ?? false);
}
public void Dispose()
{
if (_subscribedViewModel != null)
{
_subscribedViewModel.PropertyChanged -= ViewModel_OnPropertyChanged;
_subscribedViewModel = null;
}
ViewModel.Dispose();
}
}