Merge branch ryujinx:master into input-mapping-simplification

This commit is contained in:
Neo
2025-11-17 02:42:40 -06:00
28 changed files with 469 additions and 269 deletions

View File

@@ -167,10 +167,7 @@ namespace Ryujinx.Ava.UI.Controls
private void Message_TextInput(object sender, TextInputEventArgs e)
{
if (_host != null)
{
_host.IsPrimaryButtonEnabled = _checkLength(Message.Length) && _checkInput(Message);
}
_host?.IsPrimaryButtonEnabled = _checkLength(Message.Length) && _checkInput(Message);
}
private void Message_KeyUp(object sender, KeyEventArgs e)

View File

@@ -10,6 +10,7 @@ using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Windows;
using Ryujinx.Common.Helper;
using Ryujinx.Common.Logging;
using System;
using System.Threading;
@@ -102,6 +103,25 @@ namespace Ryujinx.Ava.UI.Helpers
return await ShowContentDialog(title, content, primaryButton, secondaryButton, closeButton, primaryButtonResult, deferResetEvent, deferCloseAction);
}
public async static Task<UserResult> ShowTextDialogWithButton(
string title,
string primaryText,
string secondaryText,
string primaryButton,
string secondaryButton,
string closeButton,
int iconSymbol,
string buttonText,
Action onClick,
UserResult primaryButtonResult = UserResult.Ok,
ManualResetEvent deferResetEvent = null,
TypedEventHandler<ContentDialog, ContentDialogButtonClickEventArgs> deferCloseAction = null)
{
Grid content = CreateTextDialogContentWithButton(primaryText, secondaryText, iconSymbol, buttonText, onClick);
return await ShowContentDialog(title, content, primaryButton, secondaryButton, closeButton, primaryButtonResult, deferResetEvent, deferCloseAction);
}
public static async Task<UserResult> ShowDeferredContentDialog(
Window window,
@@ -173,43 +193,109 @@ namespace Ryujinx.Ava.UI.Helpers
MinHeight = 80,
};
SymbolIcon icon = new()
content.Children.Add(new SymbolIcon
{
Symbol = (Symbol)symbol,
Margin = new Thickness(10),
FontSize = 40,
FlowDirection = FlowDirection.LeftToRight,
VerticalAlignment = VerticalAlignment.Center,
};
GridColumn = 0,
GridRow = 0,
GridRowSpan = 2
});
Grid.SetColumn(icon, 0);
Grid.SetRowSpan(icon, 2);
Grid.SetRow(icon, 0);
TextBlock primaryLabel = new()
content.Children.Add(new TextBlock
{
Text = primaryText,
Margin = new Thickness(5),
TextWrapping = TextWrapping.Wrap,
MaxWidth = 450,
};
GridColumn = 1,
GridRow = 0
});
TextBlock secondaryLabel = new()
content.Children.Add(new TextBlock
{
Text = secondaryText,
Margin = new Thickness(5),
TextWrapping = TextWrapping.Wrap,
MaxWidth = 450,
GridColumn = 1,
GridRow = 1
});
return content;
}
private static Grid CreateTextDialogContentWithButton(string primaryText, string secondaryText, int symbol, string buttonName, Action onClick)
{
Grid content = new()
{
RowDefinitions = [new(), new(), new(GridLength.Star), new()],
ColumnDefinitions = [new(GridLength.Auto), new()],
MinHeight = 80,
};
Grid.SetColumn(primaryLabel, 1);
Grid.SetColumn(secondaryLabel, 1);
Grid.SetRow(primaryLabel, 0);
Grid.SetRow(secondaryLabel, 1);
content.Children.Add(new SymbolIcon
{
Symbol = (Symbol)symbol,
Margin = new Thickness(10),
FontSize = 40,
FlowDirection = FlowDirection.LeftToRight,
VerticalAlignment = VerticalAlignment.Center,
GridColumn = 0,
GridRow = 0,
GridRowSpan = 2
});
content.Children.Add(icon);
content.Children.Add(primaryLabel);
content.Children.Add(secondaryLabel);
StackPanel buttonContent = new()
{
Orientation = Orientation.Horizontal,
Spacing = 2
};
buttonContent.Children.Add(new TextBlock
{
Text = buttonName,
Margin = new Thickness(2)
});
buttonContent.Children.Add(new SymbolIcon
{
FlowDirection = FlowDirection.LeftToRight,
Symbol = Symbol.Open
});
content.Children.Add(new TextBlock
{
Text = primaryText,
Margin = new Thickness(5),
TextWrapping = TextWrapping.Wrap,
MaxWidth = 450,
GridColumn = 1,
GridRow = 0
});
content.Children.Add(new TextBlock
{
Text = secondaryText,
Margin = new Thickness(5),
TextWrapping = TextWrapping.Wrap,
MaxWidth = 450,
GridColumn = 1,
GridRow = 1
});
content.Children.Add(new Button
{
Content = buttonContent,
HorizontalAlignment = HorizontalAlignment.Center,
Command = Commands.Create(onClick),
GridRow = 2,
GridColumnSpan = 2,
});
return content;
}
@@ -282,15 +368,20 @@ namespace Ryujinx.Ava.UI.Helpers
LocaleManager.Instance[LocaleKeys.InputDialogOk],
(int)Symbol.Important);
internal static async Task<UserResult> CreateUpdaterUpToDateInfoDialog(string primary, string secondaryText)
=> await ShowTextDialog(
internal static async Task CreateUpdaterUpToDateInfoDialog(string primary, string secondaryText,
string changelogUrl)
{
await ShowTextDialogWithButton(
LocaleManager.Instance[LocaleKeys.DialogUpdaterTitle],
primary,
secondaryText,
LocaleManager.Instance[LocaleKeys.DialogUpdaterShowChangelogMessage],
string.Empty,
string.Empty,
LocaleManager.Instance[LocaleKeys.InputDialogOk],
(int)Symbol.Important);
(int)Symbol.Important,
LocaleManager.Instance[LocaleKeys.DialogUpdaterShowChangelogMessage],
() => OpenHelper.OpenUrl(changelogUrl));
}
internal static async Task CreateWarningDialog(string primary, string secondaryText)
=> await ShowTextDialog(
@@ -340,7 +431,7 @@ namespace Ryujinx.Ava.UI.Helpers
return response == UserResult.Yes;
}
internal static async Task<UserResult> CreateUpdaterChoiceDialog(string title, string primary, string secondaryText)
internal static async Task<UserResult> CreateUpdaterChoiceDialog(string title, string primary, string secondaryText, string changelogUrl)
{
if (_isChoiceDialogOpen)
{
@@ -349,14 +440,16 @@ namespace Ryujinx.Ava.UI.Helpers
_isChoiceDialogOpen = true;
UserResult response = await ShowTextDialog(
UserResult response = await ShowTextDialogWithButton(
title,
primary,
secondaryText,
LocaleManager.Instance[LocaleKeys.InputDialogYes],
LocaleManager.Instance[LocaleKeys.DialogUpdaterShowChangelogMessage],
string.Empty,
LocaleManager.Instance[LocaleKeys.InputDialogNo],
(int)Symbol.Help,
LocaleManager.Instance[LocaleKeys.DialogUpdaterShowChangelogMessage],
() => OpenHelper.OpenUrl(changelogUrl),
UserResult.Yes);
_isChoiceDialogOpen = false;

View File

@@ -0,0 +1,40 @@
using Avalonia.Controls;
namespace Ryujinx.Ava.UI.Helpers
{
public static class ControlExtensions
{
extension(Control ctrl)
{
public int GridRow
{
get => Grid.GetRow(ctrl);
set => Grid.SetRow(ctrl, value);
}
public int GridColumn
{
get => Grid.GetColumn(ctrl);
set => Grid.SetColumn(ctrl, value);
}
public int GridRowSpan
{
get => Grid.GetRowSpan(ctrl);
set => Grid.SetRowSpan(ctrl, value);
}
public int GridColumnSpan
{
get => Grid.GetColumnSpan(ctrl);
set => Grid.SetColumnSpan(ctrl, value);
}
public bool GridIsSharedSizeScope
{
get => Grid.GetIsSharedSizeScope(ctrl);
set => Grid.SetIsSharedSizeScope(ctrl, value);
}
}
}
}

View File

@@ -27,82 +27,136 @@ namespace Ryujinx.Ava.UI.Models.Input
public ControllerType ControllerType { get; set; }
public PlayerIndex PlayerIndex { get; set; }
[ObservableProperty] private StickInputId _leftJoystick;
[ObservableProperty] private bool _leftInvertStickX;
[ObservableProperty] private bool _leftInvertStickY;
[ObservableProperty] private bool _leftRotate90;
[ObservableProperty] private GamepadInputId _leftStickButton;
[ObservableProperty]
public partial StickInputId LeftJoystick { get; set; }
[ObservableProperty] private StickInputId _rightJoystick;
[ObservableProperty] private bool _rightInvertStickX;
[ObservableProperty] private bool _rightInvertStickY;
[ObservableProperty] private bool _rightRotate90;
[ObservableProperty] private GamepadInputId _rightStickButton;
[ObservableProperty]
public partial bool LeftInvertStickX { get; set; }
[ObservableProperty] private GamepadInputId _dpadUp;
[ObservableProperty] private GamepadInputId _dpadDown;
[ObservableProperty] private GamepadInputId _dpadLeft;
[ObservableProperty] private GamepadInputId _dpadRight;
[ObservableProperty]
public partial bool LeftInvertStickY { get; set; }
[ObservableProperty] private GamepadInputId _buttonMinus;
[ObservableProperty] private GamepadInputId _buttonPlus;
[ObservableProperty]
public partial bool LeftRotate90 { get; set; }
[ObservableProperty] private GamepadInputId _buttonA;
[ObservableProperty] private GamepadInputId _buttonB;
[ObservableProperty] private GamepadInputId _buttonX;
[ObservableProperty] private GamepadInputId _buttonY;
[ObservableProperty]
public partial GamepadInputId LeftStickButton { get; set; }
[ObservableProperty] private GamepadInputId _buttonZl;
[ObservableProperty] private GamepadInputId _buttonZr;
[ObservableProperty]
public partial StickInputId RightJoystick { get; set; }
[ObservableProperty] private GamepadInputId _buttonL;
[ObservableProperty] private GamepadInputId _buttonR;
[ObservableProperty]
public partial bool RightInvertStickX { get; set; }
[ObservableProperty] private GamepadInputId _leftButtonSl;
[ObservableProperty] private GamepadInputId _leftButtonSr;
[ObservableProperty]
public partial bool RightInvertStickY { get; set; }
[ObservableProperty] private GamepadInputId _rightButtonSl;
[ObservableProperty] private GamepadInputId _rightButtonSr;
[ObservableProperty]
public partial bool RightRotate90 { get; set; }
[ObservableProperty] private float _deadzoneLeft;
[ObservableProperty] private float _deadzoneRight;
[ObservableProperty]
public partial GamepadInputId RightStickButton { get; set; }
[ObservableProperty] private float _rangeLeft;
[ObservableProperty] private float _rangeRight;
[ObservableProperty]
public partial GamepadInputId DpadUp { get; set; }
[ObservableProperty] private float _triggerThreshold;
[ObservableProperty]
public partial GamepadInputId DpadDown { get; set; }
[ObservableProperty] private bool _enableMotion;
[ObservableProperty]
public partial GamepadInputId DpadLeft { get; set; }
[ObservableProperty] private bool _enableRumble;
[ObservableProperty]
public partial GamepadInputId DpadRight { get; set; }
[ObservableProperty] private bool _enableLedChanging;
[ObservableProperty]
public partial GamepadInputId ButtonMinus { get; set; }
[ObservableProperty] private Color _ledColor;
[ObservableProperty]
public partial GamepadInputId ButtonPlus { get; set; }
[ObservableProperty]
public partial GamepadInputId ButtonA { get; set; }
[ObservableProperty]
public partial GamepadInputId ButtonB { get; set; }
[ObservableProperty]
public partial GamepadInputId ButtonX { get; set; }
[ObservableProperty]
public partial GamepadInputId ButtonY { get; set; }
[ObservableProperty]
public partial GamepadInputId ButtonZl { get; set; }
[ObservableProperty]
public partial GamepadInputId ButtonZr { get; set; }
[ObservableProperty]
public partial GamepadInputId ButtonL { get; set; }
[ObservableProperty]
public partial GamepadInputId ButtonR { get; set; }
[ObservableProperty]
public partial GamepadInputId LeftButtonSl { get; set; }
[ObservableProperty]
public partial GamepadInputId LeftButtonSr { get; set; }
[ObservableProperty]
public partial GamepadInputId RightButtonSl { get; set; }
[ObservableProperty]
public partial GamepadInputId RightButtonSr { get; set; }
[ObservableProperty]
public partial float DeadzoneLeft { get; set; }
[ObservableProperty]
public partial float DeadzoneRight { get; set; }
[ObservableProperty]
public partial float RangeLeft { get; set; }
[ObservableProperty]
public partial float RangeRight { get; set; }
[ObservableProperty]
public partial float TriggerThreshold { get; set; }
[ObservableProperty]
public partial bool EnableMotion { get; set; }
[ObservableProperty]
public partial bool EnableRumble { get; set; }
[ObservableProperty]
public partial bool EnableLedChanging { get; set; }
[ObservableProperty]
public partial Color LedColor { get; set; }
public bool ShowLedColorPicker => !TurnOffLed && !UseRainbowLed;
private bool _turnOffLed;
public bool TurnOffLed
{
get => _turnOffLed;
get;
set
{
_turnOffLed = value;
field = value;
OnPropertyChanged();
OnPropertyChanged(nameof(ShowLedColorPicker));
}
}
private bool _useRainbowLed;
public bool UseRainbowLed
{
get => _useRainbowLed;
get;
set
{
_useRainbowLed = value;
field = value;
OnPropertyChanged();
OnPropertyChanged(nameof(ShowLedColorPicker));
}

View File

@@ -6,31 +6,44 @@ namespace Ryujinx.Ava.UI.Models.Input
{
public partial class HotkeyConfig : BaseModel
{
[ObservableProperty] private Key _toggleVSyncMode;
[ObservableProperty]
public partial Key ToggleVSyncMode { get; set; }
[ObservableProperty] private Key _screenshot;
[ObservableProperty]
public partial Key Screenshot { get; set; }
[ObservableProperty] private Key _showUI;
[ObservableProperty]
public partial Key ShowUI { get; set; }
[ObservableProperty] private Key _pause;
[ObservableProperty]
public partial Key Pause { get; set; }
[ObservableProperty] private Key _toggleMute;
[ObservableProperty]
public partial Key ToggleMute { get; set; }
[ObservableProperty] private Key _resScaleUp;
[ObservableProperty]
public partial Key ResScaleUp { get; set; }
[ObservableProperty] private Key _resScaleDown;
[ObservableProperty]
public partial Key ResScaleDown { get; set; }
[ObservableProperty] private Key _volumeUp;
[ObservableProperty]
public partial Key VolumeUp { get; set; }
[ObservableProperty] private Key _volumeDown;
[ObservableProperty]
public partial Key VolumeDown { get; set; }
[ObservableProperty] private Key _customVSyncIntervalIncrement;
[ObservableProperty]
public partial Key CustomVSyncIntervalIncrement { get; set; }
[ObservableProperty] private Key _customVSyncIntervalDecrement;
[ObservableProperty]
public partial Key CustomVSyncIntervalDecrement { get; set; }
[ObservableProperty] private Key _turboMode;
[ObservableProperty]
public partial Key TurboMode { get; set; }
[ObservableProperty] private bool _turboModeWhileHeld;
[ObservableProperty]
public partial bool TurboModeWhileHeld { get; set; }
public HotkeyConfig(KeyboardHotkeys config)
{

View File

@@ -12,42 +12,89 @@ namespace Ryujinx.Ava.UI.Models.Input
public ControllerType ControllerType { get; set; }
public PlayerIndex PlayerIndex { get; set; }
[ObservableProperty] private Key _leftStickUp;
[ObservableProperty] private Key _leftStickDown;
[ObservableProperty] private Key _leftStickLeft;
[ObservableProperty] private Key _leftStickRight;
[ObservableProperty] private Key _leftStickButton;
[ObservableProperty]
public partial Key LeftStickUp { get; set; }
[ObservableProperty] private Key _rightStickUp;
[ObservableProperty] private Key _rightStickDown;
[ObservableProperty] private Key _rightStickLeft;
[ObservableProperty] private Key _rightStickRight;
[ObservableProperty] private Key _rightStickButton;
[ObservableProperty]
public partial Key LeftStickDown { get; set; }
[ObservableProperty] private Key _dpadUp;
[ObservableProperty] private Key _dpadDown;
[ObservableProperty] private Key _dpadLeft;
[ObservableProperty] private Key _dpadRight;
[ObservableProperty]
public partial Key LeftStickLeft { get; set; }
[ObservableProperty] private Key _buttonMinus;
[ObservableProperty] private Key _buttonPlus;
[ObservableProperty]
public partial Key LeftStickRight { get; set; }
[ObservableProperty] private Key _buttonA;
[ObservableProperty] private Key _buttonB;
[ObservableProperty] private Key _buttonX;
[ObservableProperty] private Key _buttonY;
[ObservableProperty]
public partial Key LeftStickButton { get; set; }
[ObservableProperty] private Key _buttonL;
[ObservableProperty] private Key _buttonR;
[ObservableProperty]
public partial Key RightStickUp { get; set; }
[ObservableProperty] private Key _buttonZl;
[ObservableProperty] private Key _buttonZr;
[ObservableProperty]
public partial Key RightStickDown { get; set; }
[ObservableProperty] private Key _leftButtonSl;
[ObservableProperty] private Key _leftButtonSr;
[ObservableProperty]
public partial Key RightStickLeft { get; set; }
[ObservableProperty] private Key _rightButtonSl;
[ObservableProperty] private Key _rightButtonSr;
[ObservableProperty]
public partial Key RightStickRight { get; set; }
[ObservableProperty]
public partial Key RightStickButton { get; set; }
[ObservableProperty]
public partial Key DpadUp { get; set; }
[ObservableProperty]
public partial Key DpadDown { get; set; }
[ObservableProperty]
public partial Key DpadLeft { get; set; }
[ObservableProperty]
public partial Key DpadRight { get; set; }
[ObservableProperty]
public partial Key ButtonMinus { get; set; }
[ObservableProperty]
public partial Key ButtonPlus { get; set; }
[ObservableProperty]
public partial Key ButtonA { get; set; }
[ObservableProperty]
public partial Key ButtonB { get; set; }
[ObservableProperty]
public partial Key ButtonX { get; set; }
[ObservableProperty]
public partial Key ButtonY { get; set; }
[ObservableProperty]
public partial Key ButtonL { get; set; }
[ObservableProperty]
public partial Key ButtonR { get; set; }
[ObservableProperty]
public partial Key ButtonZl { get; set; }
[ObservableProperty]
public partial Key ButtonZr { get; set; }
[ObservableProperty]
public partial Key LeftButtonSl { get; set; }
[ObservableProperty]
public partial Key LeftButtonSr { get; set; }
[ObservableProperty]
public partial Key RightButtonSl { get; set; }
[ObservableProperty]
public partial Key RightButtonSr { get; set; }
public KeyboardInputConfig(InputConfig config)
{

View File

@@ -6,8 +6,8 @@ namespace Ryujinx.Ava.UI.Models
{
public partial class ModModel : BaseModel
{
[ObservableProperty] private bool _enabled;
[ObservableProperty]
public partial bool Enabled { get; set; }
public bool InSd { get; }
public string Path { get; }
public string Name { get; }

View File

@@ -15,6 +15,7 @@ namespace Ryujinx.Ava.UI.Models
public string Name { get; set; }
public byte[] Data { get; set; }
[ObservableProperty] private SolidColorBrush _backgroundColor = new(Colors.White);
[ObservableProperty]
public partial SolidColorBrush BackgroundColor { get; set; } = new(Colors.White);
}
}

View File

@@ -7,24 +7,26 @@ namespace Ryujinx.Ava.UI.Models
{
public partial class TempProfile : BaseModel
{
[ObservableProperty] private byte[] _image;
[ObservableProperty] private string _name = String.Empty;
private UserId _userId;
[ObservableProperty]
public partial byte[] Image { get; set; }
[ObservableProperty]
public partial string Name { get; set; } = string.Empty;
public static uint MaxProfileNameLength => 0x20;
public UserId UserId
{
get => _userId;
get;
set
{
_userId = value;
field = value;
OnPropertyChanged();
OnPropertyChanged(nameof(UserIdString));
}
}
public string UserIdString => _userId.ToString();
public string UserIdString => UserId.ToString();
public TempProfile(UserProfile profile)
{

View File

@@ -13,11 +13,20 @@ namespace Ryujinx.Ava.UI.Models
{
private readonly Profile _profile;
private readonly NavigationDialogHost _owner;
[ObservableProperty] private byte[] _image;
[ObservableProperty] private string _name;
[ObservableProperty] private UserId _userId;
[ObservableProperty] private bool _isPointerOver;
[ObservableProperty] private IBrush _backgroundColor;
[ObservableProperty]
public partial byte[] Image { get; set; }
[ObservableProperty]
public partial string Name { get; set; }
[ObservableProperty]
public partial UserId UserId { get; set; }
[ObservableProperty]
public partial bool IsPointerOver { get; set; }
[ObservableProperty]
public partial IBrush BackgroundColor { get; set; }
public UserProfile(Profile profile, NavigationDialogHost owner)
{
@@ -39,7 +48,7 @@ namespace Ryujinx.Ava.UI.Models
private void UpdateBackground()
{
Application currentApplication = Avalonia.Application.Current;
Application currentApplication = Application.Current;
currentApplication.Styles.TryGetResource("ControlFillColorSecondary", currentApplication.ActualThemeVariant, out object color);
if (color is not null)

View File

@@ -359,8 +359,9 @@ namespace Ryujinx.Ava.UI.ViewModels
}
}
[ObservableProperty] private bool _matchSystemTime;
[ObservableProperty]
public partial bool MatchSystemTime { get; set; }
public DateTimeOffset CurrentDate { get; set; }
public TimeSpan CurrentTime { get; set; }