diff --git a/src/Ryujinx/UI/Models/Input/GamepadInputConfig.cs b/src/Ryujinx/UI/Models/Input/GamepadInputConfig.cs index 6f0f7f47f..300d7977c 100644 --- a/src/Ryujinx/UI/Models/Input/GamepadInputConfig.cs +++ b/src/Ryujinx/UI/Models/Input/GamepadInputConfig.cs @@ -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(); - } - } - - private GamepadInputId _leftStickButton; - public GamepadInputId LeftStickButton - { - get => _leftStickButton; - set - { - _leftStickButton = value; - OnPropertyChanged(); - } - } - - private StickInputId _rightJoystick; - public StickInputId RightJoystick - { - get => _rightJoystick; - set - { - _rightJoystick = value; - OnPropertyChanged(); - } - } - - private bool _rightInvertStickX; - public bool RightInvertStickX - { - get => _rightInvertStickX; - set - { - _rightInvertStickX = value; - OnPropertyChanged(); - } - } - - private bool _rightInvertStickY; - public bool RightInvertStickY - { - get => _rightInvertStickY; - set - { - _rightInvertStickY = value; - OnPropertyChanged(); - } - } - - private bool _rightRotate90; - public bool RightRotate90 - { - get => _rightRotate90; - set - { - _rightRotate90 = value; - OnPropertyChanged(); - } - } - - private GamepadInputId _rightStickButton; - public GamepadInputId RightStickButton - { - get => _rightStickButton; - set - { - _rightStickButton = value; - OnPropertyChanged(); - } - } - - private GamepadInputId _dpadUp; - public GamepadInputId DpadUp - { - get => _dpadUp; - set - { - _dpadUp = value; - OnPropertyChanged(); - } - } - - private GamepadInputId _dpadDown; - public GamepadInputId DpadDown - { - get => _dpadDown; - set - { - _dpadDown = value; - OnPropertyChanged(); - } - } - - private GamepadInputId _dpadLeft; - public GamepadInputId DpadLeft - { - get => _dpadLeft; - set - { - _dpadLeft = value; - OnPropertyChanged(); - } - } - - private GamepadInputId _dpadRight; - public GamepadInputId DpadRight - { - get => _dpadRight; - set - { - _dpadRight = value; - OnPropertyChanged(); - } - } - - private GamepadInputId _buttonL; - public GamepadInputId ButtonL - { - get => _buttonL; - set - { - _buttonL = value; - OnPropertyChanged(); - } - } - - 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(); - } - } + [ObservableProperty] private GamepadInputId _buttonMinus; + [ObservableProperty] private GamepadInputId _buttonPlus; - private bool _enableLedChanging; + [ObservableProperty] private GamepadInputId _buttonA; + [ObservableProperty] private GamepadInputId _buttonB; + [ObservableProperty] private GamepadInputId _buttonX; + [ObservableProperty] private GamepadInputId _buttonY; + + [ObservableProperty] private GamepadInputId _buttonZl; + [ObservableProperty] private GamepadInputId _buttonZr; + + [ObservableProperty] private GamepadInputId _buttonL; + [ObservableProperty] private GamepadInputId _buttonR; + + [ObservableProperty] private GamepadInputId _leftButtonSl; + [ObservableProperty] private GamepadInputId _leftButtonSr; + + [ObservableProperty] private GamepadInputId _rightButtonSl; + [ObservableProperty] private GamepadInputId _rightButtonSr; - public bool EnableLedChanging - { - get => _enableLedChanging; - set - { - _enableLedChanging = value; - OnPropertyChanged(); - } - } + [ObservableProperty] private float _deadzoneLeft; + [ObservableProperty] private float _deadzoneRight; + + [ObservableProperty] private float _rangeLeft; + [ObservableProperty] private float _rangeRight; + + [ObservableProperty] private float _triggerThreshold; + + [ObservableProperty] private bool _enableMotion; + + [ObservableProperty] private bool _enableRumble; + + [ObservableProperty] private bool _enableLedChanging; + + [ObservableProperty] private Color _ledColor; public bool ShowLedColorPicker => !TurnOffLed && !UseRainbowLed; @@ -449,18 +105,6 @@ namespace Ryujinx.Ava.UI.Models.Input OnPropertyChanged(nameof(ShowLedColorPicker)); } } - - private Color _ledColor; - - public Color LedColor - { - get => _ledColor; - set - { - _ledColor = value; - OnPropertyChanged(); - } - } public GamepadInputConfig(InputConfig config) { diff --git a/src/Ryujinx/UI/Models/Input/KeyboardInputConfig.cs b/src/Ryujinx/UI/Models/Input/KeyboardInputConfig.cs index a71c85eba..2d2e95773 100644 --- a/src/Ryujinx/UI/Models/Input/KeyboardInputConfig.cs +++ b/src/Ryujinx/UI/Models/Input/KeyboardInputConfig.cs @@ -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(); - } - } - - private Key _leftStickRight; - public Key LeftStickRight - { - get => _leftStickRight; - set - { - _leftStickRight = value; - OnPropertyChanged(); - } - } - - private Key _leftStickButton; - public Key LeftStickButton - { - get => _leftStickButton; - set - { - _leftStickButton = value; - OnPropertyChanged(); - } - } - - private Key _rightStickUp; - public Key RightStickUp - { - get => _rightStickUp; - set - { - _rightStickUp = value; - OnPropertyChanged(); - } - } - - private Key _rightStickDown; - public Key RightStickDown - { - get => _rightStickDown; - set - { - _rightStickDown = value; - OnPropertyChanged(); - } - } - - private Key _rightStickLeft; - public Key RightStickLeft - { - get => _rightStickLeft; - set - { - _rightStickLeft = value; - OnPropertyChanged(); - } - } - - 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 _dpadUp; + [ObservableProperty] private Key _dpadDown; + [ObservableProperty] private Key _dpadLeft; + [ObservableProperty] private Key _dpadRight; + + [ObservableProperty] private Key _buttonMinus; + [ObservableProperty] private Key _buttonPlus; + + [ObservableProperty] private Key _buttonA; + [ObservableProperty] private Key _buttonB; + [ObservableProperty] private Key _buttonX; + [ObservableProperty] private Key _buttonY; + + [ObservableProperty] private Key _buttonL; + [ObservableProperty] private Key _buttonR; + + [ObservableProperty] private Key _buttonZl; + [ObservableProperty] private Key _buttonZr; + + [ObservableProperty] private Key _leftButtonSl; + [ObservableProperty] private Key _leftButtonSr; + + [ObservableProperty] private Key _rightButtonSl; + [ObservableProperty] private Key _rightButtonSr; public KeyboardInputConfig(InputConfig config) { diff --git a/src/Ryujinx/UI/Models/ModModel.cs b/src/Ryujinx/UI/Models/ModModel.cs index a713f8e36..577c52410 100644 --- a/src/Ryujinx/UI/Models/ModModel.cs +++ b/src/Ryujinx/UI/Models/ModModel.cs @@ -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; } diff --git a/src/Ryujinx/UI/Models/ProfileImageModel.cs b/src/Ryujinx/UI/Models/ProfileImageModel.cs index 99365dfc7..f12aa7bd4 100644 --- a/src/Ryujinx/UI/Models/ProfileImageModel.cs +++ b/src/Ryujinx/UI/Models/ProfileImageModel.cs @@ -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); } } diff --git a/src/Ryujinx/UI/Models/SaveModel.cs b/src/Ryujinx/UI/Models/SaveModel.cs index 81be5ee93..d50aabc4e 100644 --- a/src/Ryujinx/UI/Models/SaveModel.cs +++ b/src/Ryujinx/UI/Models/SaveModel.cs @@ -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; diff --git a/src/Ryujinx/UI/Models/TempProfile.cs b/src/Ryujinx/UI/Models/TempProfile.cs index 659092e6d..51e86fb7f 100644 --- a/src/Ryujinx/UI/Models/TempProfile.cs +++ b/src/Ryujinx/UI/Models/TempProfile.cs @@ -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; diff --git a/src/Ryujinx/UI/Models/UserProfile.cs b/src/Ryujinx/UI/Models/UserProfile.cs index 7aa365e36..f14e74d07 100644 --- a/src/Ryujinx/UI/Models/UserProfile.cs +++ b/src/Ryujinx/UI/Models/UserProfile.cs @@ -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) {