mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-03-11 17:45:43 +00:00
* Avalonia's built-in color picker is now used when selecting a firmware avatar * Update Avalonia to 11.3.11, Svg.Controls.Avalonia group to 11.3.9.2, FluentAvalonia to 2.5.0
79 lines
2.6 KiB
C#
79 lines
2.6 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using FluentAvalonia.UI.Controls;
|
|
using Ryujinx.Ava.Common.Locale;
|
|
using Ryujinx.Ava.UI.Controls;
|
|
using Ryujinx.Ava.UI.Models.Input;
|
|
using Ryujinx.Ava.UI.ViewModels.Input;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Ryujinx.UI.Views.Input
|
|
{
|
|
public partial class LedInputView : RyujinxControl<LedInputViewModel>
|
|
{
|
|
//Fix compiler warning
|
|
public LedInputView()
|
|
{
|
|
|
|
}
|
|
|
|
public LedInputView(ControllerInputViewModel viewModel)
|
|
{
|
|
ViewModel = new LedInputViewModel
|
|
{
|
|
ParentModel = viewModel.ParentModel,
|
|
TurnOffLed = viewModel.Config.TurnOffLed,
|
|
EnableLedChanging = viewModel.Config.EnableLedChanging,
|
|
LedColor = viewModel.Config.LedColor,
|
|
UseRainbowLed = viewModel.Config.UseRainbowLed,
|
|
};
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void ColorPicker_OnColorChanged(object sender, ColorChangedEventArgs args)
|
|
{
|
|
if (!ViewModel.EnableLedChanging)
|
|
return;
|
|
if (ViewModel.TurnOffLed)
|
|
return;
|
|
|
|
ViewModel.ParentModel.SelectedGamepad.SetLed(args.NewColor.ToUInt32());
|
|
}
|
|
|
|
private void ColorPicker_OnAttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e)
|
|
{
|
|
if (!ViewModel.EnableLedChanging)
|
|
return;
|
|
if (ViewModel.TurnOffLed)
|
|
return;
|
|
|
|
ViewModel.ParentModel.SelectedGamepad.SetLed(ViewModel.LedColor.ToUInt32());
|
|
}
|
|
|
|
public static async Task Show(ControllerInputViewModel viewModel)
|
|
{
|
|
LedInputView content = new(viewModel);
|
|
|
|
ContentDialog contentDialog = new()
|
|
{
|
|
Title = LocaleManager.Instance[LocaleKeys.ControllerLedTitle],
|
|
PrimaryButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsSave],
|
|
SecondaryButtonText = string.Empty,
|
|
CloseButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsClose],
|
|
Content = content,
|
|
};
|
|
contentDialog.PrimaryButtonClick += (_, _) =>
|
|
{
|
|
GamepadInputConfig config = viewModel.Config;
|
|
config.EnableLedChanging = content.ViewModel.EnableLedChanging;
|
|
config.LedColor = content.ViewModel.LedColor;
|
|
config.UseRainbowLed = content.ViewModel.UseRainbowLed;
|
|
config.TurnOffLed = content.ViewModel.TurnOffLed;
|
|
};
|
|
|
|
await contentDialog.ShowAsync();
|
|
}
|
|
}
|
|
}
|
|
|