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 CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Configuration.Hid.Controller.Motion;
using System;
namespace Ryujinx.Ava.UI.Models.Input
{
public class GamepadInputConfig : BaseModel
public partial class GamepadInputConfig : BaseModel
{
public bool EnableCemuHookMotion { get; set; }
public string DsuServerHost { get; set; }
@ -25,402 +25,58 @@ namespace Ryujinx.Ava.UI.Models.Input
public ControllerType ControllerType { get; set; }
public PlayerIndex PlayerIndex { get; set; }
private StickInputId _leftJoystick;
public StickInputId LeftJoystick
{
get => _leftJoystick;
set
{
_leftJoystick = value;
OnPropertyChanged();
}
}
[ObservableProperty] private StickInputId _leftJoystick;
[ObservableProperty] private bool _leftInvertStickX;
[ObservableProperty] private bool _leftInvertStickY;
[ObservableProperty] private bool _leftRotate90;
[ObservableProperty] private GamepadInputId _leftStickButton;
private bool _leftInvertStickX;
public bool LeftInvertStickX
{
get => _leftInvertStickX;
set
{
_leftInvertStickX = value;
OnPropertyChanged();
}
}
[ObservableProperty] private StickInputId _rightJoystick;
[ObservableProperty] private bool _rightInvertStickX;
[ObservableProperty] private bool _rightInvertStickY;
[ObservableProperty] private bool _rightRotate90;
[ObservableProperty] private GamepadInputId _rightStickButton;
private bool _leftInvertStickY;
public bool LeftInvertStickY
{
get => _leftInvertStickY;
set
{
_leftInvertStickY = value;
OnPropertyChanged();
}
}
[ObservableProperty] private GamepadInputId _dpadUp;
[ObservableProperty] private GamepadInputId _dpadDown;
[ObservableProperty] private GamepadInputId _dpadLeft;
[ObservableProperty] private GamepadInputId _dpadRight;
private bool _leftRotate90;
public bool LeftRotate90
{
get => _leftRotate90;
set
{
_leftRotate90 = value;
OnPropertyChanged();
}
}
[ObservableProperty] private GamepadInputId _buttonMinus;
[ObservableProperty] private GamepadInputId _buttonPlus;
private GamepadInputId _leftStickButton;
public GamepadInputId LeftStickButton
{
get => _leftStickButton;
set
{
_leftStickButton = value;
OnPropertyChanged();
}
}
[ObservableProperty] private GamepadInputId _buttonA;
[ObservableProperty] private GamepadInputId _buttonB;
[ObservableProperty] private GamepadInputId _buttonX;
[ObservableProperty] private GamepadInputId _buttonY;
private StickInputId _rightJoystick;
public StickInputId RightJoystick
{
get => _rightJoystick;
set
{
_rightJoystick = value;
OnPropertyChanged();
}
}
[ObservableProperty] private GamepadInputId _buttonZl;
[ObservableProperty] private GamepadInputId _buttonZr;
private bool _rightInvertStickX;
public bool RightInvertStickX
{
get => _rightInvertStickX;
set
{
_rightInvertStickX = value;
OnPropertyChanged();
}
}
[ObservableProperty] private GamepadInputId _buttonL;
[ObservableProperty] private GamepadInputId _buttonR;
private bool _rightInvertStickY;
public bool RightInvertStickY
{
get => _rightInvertStickY;
set
{
_rightInvertStickY = value;
OnPropertyChanged();
}
}
[ObservableProperty] private GamepadInputId _leftButtonSl;
[ObservableProperty] private GamepadInputId _leftButtonSr;
private bool _rightRotate90;
public bool RightRotate90
{
get => _rightRotate90;
set
{
_rightRotate90 = value;
OnPropertyChanged();
}
}
[ObservableProperty] private GamepadInputId _rightButtonSl;
[ObservableProperty] private GamepadInputId _rightButtonSr;
private GamepadInputId _rightStickButton;
public GamepadInputId RightStickButton
{
get => _rightStickButton;
set
{
_rightStickButton = value;
OnPropertyChanged();
}
}
[ObservableProperty] private float _deadzoneLeft;
[ObservableProperty] private float _deadzoneRight;
private GamepadInputId _dpadUp;
public GamepadInputId DpadUp
{
get => _dpadUp;
set
{
_dpadUp = value;
OnPropertyChanged();
}
}
[ObservableProperty] private float _rangeLeft;
[ObservableProperty] private float _rangeRight;
private GamepadInputId _dpadDown;
public GamepadInputId DpadDown
{
get => _dpadDown;
set
{
_dpadDown = value;
OnPropertyChanged();
}
}
[ObservableProperty] private float _triggerThreshold;
private GamepadInputId _dpadLeft;
public GamepadInputId DpadLeft
{
get => _dpadLeft;
set
{
_dpadLeft = value;
OnPropertyChanged();
}
}
[ObservableProperty] private bool _enableMotion;
private GamepadInputId _dpadRight;
public GamepadInputId DpadRight
{
get => _dpadRight;
set
{
_dpadRight = value;
OnPropertyChanged();
}
}
[ObservableProperty] private bool _enableRumble;
private GamepadInputId _buttonL;
public GamepadInputId ButtonL
{
get => _buttonL;
set
{
_buttonL = value;
OnPropertyChanged();
}
}
[ObservableProperty] private bool _enableLedChanging;
private GamepadInputId _buttonMinus;
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();
}
}
[ObservableProperty] private Color _ledColor;
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)
{
if (config != null)

View File

@ -1,322 +1,52 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Keyboard;
namespace Ryujinx.Ava.UI.Models.Input
{
public class KeyboardInputConfig : BaseModel
public partial class KeyboardInputConfig : BaseModel
{
public string Id { get; set; }
public ControllerType ControllerType { get; set; }
public PlayerIndex PlayerIndex { get; set; }
private Key _leftStickUp;
public Key LeftStickUp
{
get => _leftStickUp;
set
{
_leftStickUp = value;
OnPropertyChanged();
}
}
[ObservableProperty] private Key _leftStickUp;
[ObservableProperty] private Key _leftStickDown;
[ObservableProperty] private Key _leftStickLeft;
[ObservableProperty] private Key _leftStickRight;
[ObservableProperty] private Key _leftStickButton;
private Key _leftStickDown;
public Key LeftStickDown
{
get => _leftStickDown;
set
{
_leftStickDown = value;
OnPropertyChanged();
}
}
[ObservableProperty] private Key _rightStickUp;
[ObservableProperty] private Key _rightStickDown;
[ObservableProperty] private Key _rightStickLeft;
[ObservableProperty] private Key _rightStickRight;
[ObservableProperty] private Key _rightStickButton;
private Key _leftStickLeft;
public Key LeftStickLeft
{
get => _leftStickLeft;
set
{
_leftStickLeft = value;
OnPropertyChanged();
}
}
[ObservableProperty] private Key _dpadUp;
[ObservableProperty] private Key _dpadDown;
[ObservableProperty] private Key _dpadLeft;
[ObservableProperty] private Key _dpadRight;
private Key _leftStickRight;
public Key LeftStickRight
{
get => _leftStickRight;
set
{
_leftStickRight = value;
OnPropertyChanged();
}
}
[ObservableProperty] private Key _buttonMinus;
[ObservableProperty] private Key _buttonPlus;
private Key _leftStickButton;
public Key LeftStickButton
{
get => _leftStickButton;
set
{
_leftStickButton = value;
OnPropertyChanged();
}
}
[ObservableProperty] private Key _buttonA;
[ObservableProperty] private Key _buttonB;
[ObservableProperty] private Key _buttonX;
[ObservableProperty] private Key _buttonY;
private Key _rightStickUp;
public Key RightStickUp
{
get => _rightStickUp;
set
{
_rightStickUp = value;
OnPropertyChanged();
}
}
[ObservableProperty] private Key _buttonL;
[ObservableProperty] private Key _buttonR;
private Key _rightStickDown;
public Key RightStickDown
{
get => _rightStickDown;
set
{
_rightStickDown = value;
OnPropertyChanged();
}
}
[ObservableProperty] private Key _buttonZl;
[ObservableProperty] private Key _buttonZr;
private Key _rightStickLeft;
public Key RightStickLeft
{
get => _rightStickLeft;
set
{
_rightStickLeft = value;
OnPropertyChanged();
}
}
[ObservableProperty] private Key _leftButtonSl;
[ObservableProperty] private Key _leftButtonSr;
private Key _rightStickRight;
public Key RightStickRight
{
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();
}
}
[ObservableProperty] private Key _rightButtonSl;
[ObservableProperty] private Key _rightButtonSr;
public KeyboardInputConfig(InputConfig config)
{

View File

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

View File

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

View File

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

View File

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

View File

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