misc: chore: More ObservableProperty usage

This commit is contained in:
Evan Husted 2025-01-30 20:16:30 -06:00
parent 9c12f52805
commit 3cf54987d2
7 changed files with 103 additions and 823 deletions

View File

@ -1,13 +1,13 @@
using Avalonia.Media; using Avalonia.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller; using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Configuration.Hid.Controller.Motion; using Ryujinx.Common.Configuration.Hid.Controller.Motion;
using System;
namespace Ryujinx.Ava.UI.Models.Input namespace Ryujinx.Ava.UI.Models.Input
{ {
public class GamepadInputConfig : BaseModel public partial class GamepadInputConfig : BaseModel
{ {
public bool EnableCemuHookMotion { get; set; } public bool EnableCemuHookMotion { get; set; }
public string DsuServerHost { get; set; } public string DsuServerHost { get; set; }
@ -25,402 +25,58 @@ namespace Ryujinx.Ava.UI.Models.Input
public ControllerType ControllerType { get; set; } public ControllerType ControllerType { get; set; }
public PlayerIndex PlayerIndex { get; set; } public PlayerIndex PlayerIndex { get; set; }
private StickInputId _leftJoystick; [ObservableProperty] private StickInputId _leftJoystick;
public StickInputId LeftJoystick [ObservableProperty] private bool _leftInvertStickX;
{ [ObservableProperty] private bool _leftInvertStickY;
get => _leftJoystick; [ObservableProperty] private bool _leftRotate90;
set [ObservableProperty] private GamepadInputId _leftStickButton;
{
_leftJoystick = value;
OnPropertyChanged();
}
}
private bool _leftInvertStickX; [ObservableProperty] private StickInputId _rightJoystick;
public bool LeftInvertStickX [ObservableProperty] private bool _rightInvertStickX;
{ [ObservableProperty] private bool _rightInvertStickY;
get => _leftInvertStickX; [ObservableProperty] private bool _rightRotate90;
set [ObservableProperty] private GamepadInputId _rightStickButton;
{
_leftInvertStickX = value;
OnPropertyChanged();
}
}
private bool _leftInvertStickY; [ObservableProperty] private GamepadInputId _dpadUp;
public bool LeftInvertStickY [ObservableProperty] private GamepadInputId _dpadDown;
{ [ObservableProperty] private GamepadInputId _dpadLeft;
get => _leftInvertStickY; [ObservableProperty] private GamepadInputId _dpadRight;
set
{
_leftInvertStickY = value;
OnPropertyChanged();
}
}
private bool _leftRotate90; [ObservableProperty] private GamepadInputId _buttonMinus;
public bool LeftRotate90 [ObservableProperty] private GamepadInputId _buttonPlus;
{
get => _leftRotate90;
set
{
_leftRotate90 = value;
OnPropertyChanged();
}
}
private GamepadInputId _leftStickButton; [ObservableProperty] private GamepadInputId _buttonA;
public GamepadInputId LeftStickButton [ObservableProperty] private GamepadInputId _buttonB;
{ [ObservableProperty] private GamepadInputId _buttonX;
get => _leftStickButton; [ObservableProperty] private GamepadInputId _buttonY;
set
{
_leftStickButton = value;
OnPropertyChanged();
}
}
private StickInputId _rightJoystick; [ObservableProperty] private GamepadInputId _buttonZl;
public StickInputId RightJoystick [ObservableProperty] private GamepadInputId _buttonZr;
{
get => _rightJoystick;
set
{
_rightJoystick = value;
OnPropertyChanged();
}
}
private bool _rightInvertStickX; [ObservableProperty] private GamepadInputId _buttonL;
public bool RightInvertStickX [ObservableProperty] private GamepadInputId _buttonR;
{
get => _rightInvertStickX;
set
{
_rightInvertStickX = value;
OnPropertyChanged();
}
}
private bool _rightInvertStickY; [ObservableProperty] private GamepadInputId _leftButtonSl;
public bool RightInvertStickY [ObservableProperty] private GamepadInputId _leftButtonSr;
{
get => _rightInvertStickY;
set
{
_rightInvertStickY = value;
OnPropertyChanged();
}
}
private bool _rightRotate90; [ObservableProperty] private GamepadInputId _rightButtonSl;
public bool RightRotate90 [ObservableProperty] private GamepadInputId _rightButtonSr;
{
get => _rightRotate90;
set
{
_rightRotate90 = value;
OnPropertyChanged();
}
}
private GamepadInputId _rightStickButton; [ObservableProperty] private float _deadzoneLeft;
public GamepadInputId RightStickButton [ObservableProperty] private float _deadzoneRight;
{
get => _rightStickButton;
set
{
_rightStickButton = value;
OnPropertyChanged();
}
}
private GamepadInputId _dpadUp; [ObservableProperty] private float _rangeLeft;
public GamepadInputId DpadUp [ObservableProperty] private float _rangeRight;
{
get => _dpadUp;
set
{
_dpadUp = value;
OnPropertyChanged();
}
}
private GamepadInputId _dpadDown; [ObservableProperty] private float _triggerThreshold;
public GamepadInputId DpadDown
{
get => _dpadDown;
set
{
_dpadDown = value;
OnPropertyChanged();
}
}
private GamepadInputId _dpadLeft; [ObservableProperty] private bool _enableMotion;
public GamepadInputId DpadLeft
{
get => _dpadLeft;
set
{
_dpadLeft = value;
OnPropertyChanged();
}
}
private GamepadInputId _dpadRight; [ObservableProperty] private bool _enableRumble;
public GamepadInputId DpadRight
{
get => _dpadRight;
set
{
_dpadRight = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonL; [ObservableProperty] private bool _enableLedChanging;
public GamepadInputId ButtonL
{
get => _buttonL;
set
{
_buttonL = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonMinus; [ObservableProperty] private Color _ledColor;
public GamepadInputId ButtonMinus
{
get => _buttonMinus;
set
{
_buttonMinus = value;
OnPropertyChanged();
}
}
private GamepadInputId _leftButtonSl;
public GamepadInputId LeftButtonSl
{
get => _leftButtonSl;
set
{
_leftButtonSl = value;
OnPropertyChanged();
}
}
private GamepadInputId _leftButtonSr;
public GamepadInputId LeftButtonSr
{
get => _leftButtonSr;
set
{
_leftButtonSr = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonZl;
public GamepadInputId ButtonZl
{
get => _buttonZl;
set
{
_buttonZl = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonA;
public GamepadInputId ButtonA
{
get => _buttonA;
set
{
_buttonA = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonB;
public GamepadInputId ButtonB
{
get => _buttonB;
set
{
_buttonB = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonX;
public GamepadInputId ButtonX
{
get => _buttonX;
set
{
_buttonX = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonY;
public GamepadInputId ButtonY
{
get => _buttonY;
set
{
_buttonY = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonR;
public GamepadInputId ButtonR
{
get => _buttonR;
set
{
_buttonR = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonPlus;
public GamepadInputId ButtonPlus
{
get => _buttonPlus;
set
{
_buttonPlus = value;
OnPropertyChanged();
}
}
private GamepadInputId _rightButtonSl;
public GamepadInputId RightButtonSl
{
get => _rightButtonSl;
set
{
_rightButtonSl = value;
OnPropertyChanged();
}
}
private GamepadInputId _rightButtonSr;
public GamepadInputId RightButtonSr
{
get => _rightButtonSr;
set
{
_rightButtonSr = value;
OnPropertyChanged();
}
}
private GamepadInputId _buttonZr;
public GamepadInputId ButtonZr
{
get => _buttonZr;
set
{
_buttonZr = value;
OnPropertyChanged();
}
}
private float _deadzoneLeft;
public float DeadzoneLeft
{
get => _deadzoneLeft;
set
{
_deadzoneLeft = MathF.Round(value, 3);
OnPropertyChanged();
}
}
private float _deadzoneRight;
public float DeadzoneRight
{
get => _deadzoneRight;
set
{
_deadzoneRight = MathF.Round(value, 3);
OnPropertyChanged();
}
}
private float _rangeLeft;
public float RangeLeft
{
get => _rangeLeft;
set
{
_rangeLeft = MathF.Round(value, 3);
OnPropertyChanged();
}
}
private float _rangeRight;
public float RangeRight
{
get => _rangeRight;
set
{
_rangeRight = MathF.Round(value, 3);
OnPropertyChanged();
}
}
private float _triggerThreshold;
public float TriggerThreshold
{
get => _triggerThreshold;
set
{
_triggerThreshold = MathF.Round(value, 3);
OnPropertyChanged();
}
}
private bool _enableMotion;
public bool EnableMotion
{
get => _enableMotion;
set
{
_enableMotion = value;
OnPropertyChanged();
}
}
private bool _enableRumble;
public bool EnableRumble
{
get => _enableRumble;
set
{
_enableRumble = value;
OnPropertyChanged();
}
}
private bool _enableLedChanging;
public bool EnableLedChanging
{
get => _enableLedChanging;
set
{
_enableLedChanging = value;
OnPropertyChanged();
}
}
public bool ShowLedColorPicker => !TurnOffLed && !UseRainbowLed; public bool ShowLedColorPicker => !TurnOffLed && !UseRainbowLed;
@ -450,18 +106,6 @@ namespace Ryujinx.Ava.UI.Models.Input
} }
} }
private Color _ledColor;
public Color LedColor
{
get => _ledColor;
set
{
_ledColor = value;
OnPropertyChanged();
}
}
public GamepadInputConfig(InputConfig config) public GamepadInputConfig(InputConfig config)
{ {
if (config != null) if (config != null)

View File

@ -1,322 +1,52 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Keyboard; using Ryujinx.Common.Configuration.Hid.Keyboard;
namespace Ryujinx.Ava.UI.Models.Input namespace Ryujinx.Ava.UI.Models.Input
{ {
public class KeyboardInputConfig : BaseModel public partial class KeyboardInputConfig : BaseModel
{ {
public string Id { get; set; } public string Id { get; set; }
public ControllerType ControllerType { get; set; } public ControllerType ControllerType { get; set; }
public PlayerIndex PlayerIndex { get; set; } public PlayerIndex PlayerIndex { get; set; }
private Key _leftStickUp; [ObservableProperty] private Key _leftStickUp;
public Key LeftStickUp [ObservableProperty] private Key _leftStickDown;
{ [ObservableProperty] private Key _leftStickLeft;
get => _leftStickUp; [ObservableProperty] private Key _leftStickRight;
set [ObservableProperty] private Key _leftStickButton;
{
_leftStickUp = value;
OnPropertyChanged();
}
}
private Key _leftStickDown; [ObservableProperty] private Key _rightStickUp;
public Key LeftStickDown [ObservableProperty] private Key _rightStickDown;
{ [ObservableProperty] private Key _rightStickLeft;
get => _leftStickDown; [ObservableProperty] private Key _rightStickRight;
set [ObservableProperty] private Key _rightStickButton;
{
_leftStickDown = value;
OnPropertyChanged();
}
}
private Key _leftStickLeft; [ObservableProperty] private Key _dpadUp;
public Key LeftStickLeft [ObservableProperty] private Key _dpadDown;
{ [ObservableProperty] private Key _dpadLeft;
get => _leftStickLeft; [ObservableProperty] private Key _dpadRight;
set
{
_leftStickLeft = value;
OnPropertyChanged();
}
}
private Key _leftStickRight; [ObservableProperty] private Key _buttonMinus;
public Key LeftStickRight [ObservableProperty] private Key _buttonPlus;
{
get => _leftStickRight;
set
{
_leftStickRight = value;
OnPropertyChanged();
}
}
private Key _leftStickButton; [ObservableProperty] private Key _buttonA;
public Key LeftStickButton [ObservableProperty] private Key _buttonB;
{ [ObservableProperty] private Key _buttonX;
get => _leftStickButton; [ObservableProperty] private Key _buttonY;
set
{
_leftStickButton = value;
OnPropertyChanged();
}
}
private Key _rightStickUp; [ObservableProperty] private Key _buttonL;
public Key RightStickUp [ObservableProperty] private Key _buttonR;
{
get => _rightStickUp;
set
{
_rightStickUp = value;
OnPropertyChanged();
}
}
private Key _rightStickDown; [ObservableProperty] private Key _buttonZl;
public Key RightStickDown [ObservableProperty] private Key _buttonZr;
{
get => _rightStickDown;
set
{
_rightStickDown = value;
OnPropertyChanged();
}
}
private Key _rightStickLeft; [ObservableProperty] private Key _leftButtonSl;
public Key RightStickLeft [ObservableProperty] private Key _leftButtonSr;
{
get => _rightStickLeft;
set
{
_rightStickLeft = value;
OnPropertyChanged();
}
}
private Key _rightStickRight; [ObservableProperty] private Key _rightButtonSl;
public Key RightStickRight [ObservableProperty] private Key _rightButtonSr;
{
get => _rightStickRight;
set
{
_rightStickRight = value;
OnPropertyChanged();
}
}
private Key _rightStickButton;
public Key RightStickButton
{
get => _rightStickButton;
set
{
_rightStickButton = value;
OnPropertyChanged();
}
}
private Key _dpadUp;
public Key DpadUp
{
get => _dpadUp;
set
{
_dpadUp = value;
OnPropertyChanged();
}
}
private Key _dpadDown;
public Key DpadDown
{
get => _dpadDown;
set
{
_dpadDown = value;
OnPropertyChanged();
}
}
private Key _dpadLeft;
public Key DpadLeft
{
get => _dpadLeft;
set
{
_dpadLeft = value;
OnPropertyChanged();
}
}
private Key _dpadRight;
public Key DpadRight
{
get => _dpadRight;
set
{
_dpadRight = value;
OnPropertyChanged();
}
}
private Key _buttonL;
public Key ButtonL
{
get => _buttonL;
set
{
_buttonL = value;
OnPropertyChanged();
}
}
private Key _buttonMinus;
public Key ButtonMinus
{
get => _buttonMinus;
set
{
_buttonMinus = value;
OnPropertyChanged();
}
}
private Key _leftButtonSl;
public Key LeftButtonSl
{
get => _leftButtonSl;
set
{
_leftButtonSl = value;
OnPropertyChanged();
}
}
private Key _leftButtonSr;
public Key LeftButtonSr
{
get => _leftButtonSr;
set
{
_leftButtonSr = value;
OnPropertyChanged();
}
}
private Key _buttonZl;
public Key ButtonZl
{
get => _buttonZl;
set
{
_buttonZl = value;
OnPropertyChanged();
}
}
private Key _buttonA;
public Key ButtonA
{
get => _buttonA;
set
{
_buttonA = value;
OnPropertyChanged();
}
}
private Key _buttonB;
public Key ButtonB
{
get => _buttonB;
set
{
_buttonB = value;
OnPropertyChanged();
}
}
private Key _buttonX;
public Key ButtonX
{
get => _buttonX;
set
{
_buttonX = value;
OnPropertyChanged();
}
}
private Key _buttonY;
public Key ButtonY
{
get => _buttonY;
set
{
_buttonY = value;
OnPropertyChanged();
}
}
private Key _buttonR;
public Key ButtonR
{
get => _buttonR;
set
{
_buttonR = value;
OnPropertyChanged();
}
}
private Key _buttonPlus;
public Key ButtonPlus
{
get => _buttonPlus;
set
{
_buttonPlus = value;
OnPropertyChanged();
}
}
private Key _rightButtonSl;
public Key RightButtonSl
{
get => _rightButtonSl;
set
{
_rightButtonSl = value;
OnPropertyChanged();
}
}
private Key _rightButtonSr;
public Key RightButtonSr
{
get => _rightButtonSr;
set
{
_rightButtonSr = value;
OnPropertyChanged();
}
}
private Key _buttonZr;
public Key ButtonZr
{
get => _buttonZr;
set
{
_buttonZr = value;
OnPropertyChanged();
}
}
public KeyboardInputConfig(InputConfig config) public KeyboardInputConfig(InputConfig config)
{ {

View File

@ -1,21 +1,12 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using System.Globalization; using System.Globalization;
namespace Ryujinx.Ava.UI.Models namespace Ryujinx.Ava.UI.Models
{ {
public class ModModel : BaseModel public partial class ModModel : BaseModel
{ {
private bool _enabled; [ObservableProperty] private bool _enabled;
public bool Enabled
{
get => _enabled;
set
{
_enabled = value;
OnPropertyChanged();
}
}
public bool InSd { get; } public bool InSd { get; }
public string Path { get; } public string Path { get; }

View File

@ -1,9 +1,10 @@
using Avalonia.Media; using Avalonia.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
namespace Ryujinx.Ava.UI.Models namespace Ryujinx.Ava.UI.Models
{ {
public class ProfileImageModel : BaseModel public partial class ProfileImageModel : BaseModel
{ {
public ProfileImageModel(string name, byte[] data) public ProfileImageModel(string name, byte[] data)
{ {
@ -14,19 +15,6 @@ namespace Ryujinx.Ava.UI.Models
public string Name { get; set; } public string Name { get; set; }
public byte[] Data { get; set; } public byte[] Data { get; set; }
private SolidColorBrush _backgroundColor = new(Colors.White); [ObservableProperty] private SolidColorBrush _backgroundColor = new(Colors.White);
public SolidColorBrush BackgroundColor
{
get
{
return _backgroundColor;
}
set
{
_backgroundColor = value;
OnPropertyChanged();
}
}
} }
} }

View File

@ -2,11 +2,9 @@ using Gommon;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Ncm; using LibHac.Ncm;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.Windows;
using Ryujinx.Ava.Utilities; using Ryujinx.Ava.Utilities;
using Ryujinx.Ava.Utilities.AppLibrary; using Ryujinx.Ava.Utilities.AppLibrary;
using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.FileSystem;
using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;

View File

@ -1,28 +1,18 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.HLE.HOS.Services.Account.Acc; using Ryujinx.HLE.HOS.Services.Account.Acc;
using System; using System;
namespace Ryujinx.Ava.UI.Models namespace Ryujinx.Ava.UI.Models
{ {
public class TempProfile : BaseModel public partial class TempProfile : BaseModel
{ {
private readonly UserProfile _profile; [ObservableProperty] private byte[] _image;
private byte[] _image; [ObservableProperty] private string _name = String.Empty;
private string _name = String.Empty;
private UserId _userId; private UserId _userId;
public static uint MaxProfileNameLength => 0x20; public static uint MaxProfileNameLength => 0x20;
public byte[] Image
{
get => _image;
set
{
_image = value;
OnPropertyChanged();
}
}
public UserId UserId public UserId UserId
{ {
get => _userId; get => _userId;
@ -36,21 +26,9 @@ namespace Ryujinx.Ava.UI.Models
public string UserIdString => _userId.ToString(); public string UserIdString => _userId.ToString();
public string Name
{
get => _name;
set
{
_name = value;
OnPropertyChanged();
}
}
public TempProfile(UserProfile profile) public TempProfile(UserProfile profile)
{ {
_profile = profile; if (profile != null)
if (_profile != null)
{ {
Image = profile.Image; Image = profile.Image;
Name = profile.Name; Name = profile.Name;

View File

@ -1,5 +1,6 @@
using Avalonia; using Avalonia;
using Avalonia.Media; using Avalonia.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.UI.Controls; using Ryujinx.Ava.UI.Controls;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.Views.User; using Ryujinx.Ava.UI.Views.User;
@ -8,65 +9,15 @@ using Profile = Ryujinx.HLE.HOS.Services.Account.Acc.UserProfile;
namespace Ryujinx.Ava.UI.Models namespace Ryujinx.Ava.UI.Models
{ {
public class UserProfile : BaseModel public partial class UserProfile : BaseModel
{ {
private readonly Profile _profile; private readonly Profile _profile;
private readonly NavigationDialogHost _owner; private readonly NavigationDialogHost _owner;
private byte[] _image; [ObservableProperty] private byte[] _image;
private string _name; [ObservableProperty] private string _name;
private UserId _userId; [ObservableProperty] private UserId _userId;
private bool _isPointerOver; [ObservableProperty] private bool _isPointerOver;
private IBrush _backgroundColor; [ObservableProperty] private IBrush _backgroundColor;
public byte[] Image
{
get => _image;
set
{
_image = value;
OnPropertyChanged();
}
}
public UserId UserId
{
get => _userId;
set
{
_userId = value;
OnPropertyChanged();
}
}
public string Name
{
get => _name;
set
{
_name = value;
OnPropertyChanged();
}
}
public bool IsPointerOver
{
get => _isPointerOver;
set
{
_isPointerOver = value;
OnPropertyChanged();
}
}
public IBrush BackgroundColor
{
get => _backgroundColor;
set
{
_backgroundColor = value;
OnPropertyChanged();
}
}
public UserProfile(Profile profile, NavigationDialogHost owner) public UserProfile(Profile profile, NavigationDialogHost owner)
{ {