Remove InputViewModel.IsModified

Format
This commit is contained in:
Isaac Marovitz 2024-04-18 18:34:23 -04:00
parent 9167833f0a
commit 1ad9b27ed6
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
5 changed files with 18 additions and 13 deletions

View file

@ -82,9 +82,10 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public bool EnableKeyboard { get; set; } public bool EnableKeyboard { get; set; }
public bool EnableMouse { get; set; } public bool EnableMouse { get; set; }
public bool IsModified { get; set; }
public event Action NotifyChangesEvent; public event Action NotifyChangesEvent;
public SettingsViewModel SettingsViewModel;
public object ConfigViewModel public object ConfigViewModel
{ {
get => _configViewModel; get => _configViewModel;
@ -101,12 +102,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
get => _playerId; get => _playerId;
set set
{ {
if (IsModified) if (SettingsViewModel.IsModified)
{ {
return; return;
} }
IsModified = false; SettingsViewModel.IsModified = false;
_playerId = value; _playerId = value;
if (!Enum.IsDefined(typeof(PlayerIndex), _playerId)) if (!Enum.IsDefined(typeof(PlayerIndex), _playerId))
@ -243,8 +244,10 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public InputConfig Config { get; set; } public InputConfig Config { get; set; }
public InputViewModel(UserControl owner) : this() public InputViewModel(UserControl owner, SettingsViewModel settingsViewModel) : this()
{ {
SettingsViewModel = settingsViewModel;
if (Program.PreviewerDetached) if (Program.PreviewerDetached)
{ {
_mainWindow = _mainWindow =
@ -819,8 +822,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public void Save() public void Save()
{ {
IsModified = false;
List<InputConfig> newConfig = new(); List<InputConfig> newConfig = new();
newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value); newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value);

View file

@ -71,7 +71,7 @@ namespace Ryujinx.Ava.UI.Views.Input
if (e.ButtonValue.HasValue) if (e.ButtonValue.HasValue)
{ {
var buttonValue = e.ButtonValue.Value; var buttonValue = e.ButtonValue.Value;
viewModel.ParentModel.IsModified = true; viewModel.ParentModel.SettingsViewModel.IsModified = true;
switch (button.Name) switch (button.Name)
{ {

View file

@ -68,7 +68,7 @@ namespace Ryujinx.Ava.UI.Views.Input
if (e.ButtonValue.HasValue) if (e.ButtonValue.HasValue)
{ {
var buttonValue = e.ButtonValue.Value; var buttonValue = e.ButtonValue.Value;
viewModel.ParentModel.IsModified = true; viewModel.ParentModel.SettingsViewModel.IsModified = true;
switch (button.Name) switch (button.Name)
{ {

View file

@ -4,7 +4,6 @@ using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Models; using Ryujinx.Ava.UI.Models;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.ViewModels.Input; using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.Ava.UI.Views.Input;
namespace Ryujinx.Ava.UI.Views.Settings namespace Ryujinx.Ava.UI.Views.Settings
{ {
@ -19,7 +18,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
{ {
SettingsViewModel = viewModel; SettingsViewModel = viewModel;
DataContext = ViewModel = new InputViewModel(this); DataContext = ViewModel = new InputViewModel(this, viewModel);
InitializeComponent(); InitializeComponent();
} }
@ -31,7 +30,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (ViewModel.IsModified && !_dialogOpen) if (SettingsViewModel.IsModified && !_dialogOpen)
{ {
_dialogOpen = true; _dialogOpen = true;
@ -49,7 +48,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
_dialogOpen = false; _dialogOpen = false;
ViewModel.IsModified = false; SettingsViewModel.IsModified = false;
if (e.AddedItems.Count > 0) if (e.AddedItems.Count > 0)
{ {

View file

@ -21,7 +21,7 @@ namespace Ryujinx.Ava.UI.Windows
public readonly SettingsGraphicsView GraphicsPage; public readonly SettingsGraphicsView GraphicsPage;
public readonly SettingsAudioView AudioPage; public readonly SettingsAudioView AudioPage;
public readonly SettingsNetworkView NetworkPage; public readonly SettingsNetworkView NetworkPage;
public readonly SettingsLoggingView LoggingPage; public readonly SettingsLoggingView LoggingPage;
public SettingsWindow(VirtualFileSystem virtualFileSystem, ContentManager contentManager) public SettingsWindow(VirtualFileSystem virtualFileSystem, ContentManager contentManager)
{ {
@ -60,6 +60,11 @@ namespace Ryujinx.Ava.UI.Windows
public void UpdateDirtyTitle(bool isDirty) public void UpdateDirtyTitle(bool isDirty)
{ {
if (!IsInitialized)
{
return;
}
if (isDirty) if (isDirty)
{ {
Title = $"{LocaleManager.Instance[LocaleKeys.Settings]} - {LocaleManager.Instance[LocaleKeys.SettingsDirty]}"; Title = $"{LocaleManager.Instance[LocaleKeys.Settings]} - {LocaleManager.Instance[LocaleKeys.SettingsDirty]}";