From 1ad9b27ed64bc59c15ab5ea32f74720cf51fcb38 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 18 Apr 2024 18:34:23 -0400 Subject: [PATCH] Remove InputViewModel.IsModified Format --- src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs | 13 +++++++------ .../UI/Views/Input/ControllerInputView.axaml.cs | 2 +- .../UI/Views/Input/KeyboardInputView.axaml.cs | 2 +- .../UI/Views/Settings/SettingsInputView.axaml.cs | 7 +++---- src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs | 7 ++++++- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs index a02bf42bd..910382aef 100644 --- a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs @@ -82,9 +82,10 @@ namespace Ryujinx.Ava.UI.ViewModels.Input public bool EnableKeyboard { get; set; } public bool EnableMouse { get; set; } - public bool IsModified { get; set; } public event Action NotifyChangesEvent; + public SettingsViewModel SettingsViewModel; + public object ConfigViewModel { get => _configViewModel; @@ -101,12 +102,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input get => _playerId; set { - if (IsModified) + if (SettingsViewModel.IsModified) { return; } - IsModified = false; + SettingsViewModel.IsModified = false; _playerId = value; if (!Enum.IsDefined(typeof(PlayerIndex), _playerId)) @@ -243,8 +244,10 @@ namespace Ryujinx.Ava.UI.ViewModels.Input public InputConfig Config { get; set; } - public InputViewModel(UserControl owner) : this() + public InputViewModel(UserControl owner, SettingsViewModel settingsViewModel) : this() { + SettingsViewModel = settingsViewModel; + if (Program.PreviewerDetached) { _mainWindow = @@ -819,8 +822,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input public void Save() { - IsModified = false; - List newConfig = new(); newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value); diff --git a/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs b/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs index b76648da7..477401eeb 100644 --- a/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs +++ b/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs @@ -71,7 +71,7 @@ namespace Ryujinx.Ava.UI.Views.Input if (e.ButtonValue.HasValue) { var buttonValue = e.ButtonValue.Value; - viewModel.ParentModel.IsModified = true; + viewModel.ParentModel.SettingsViewModel.IsModified = true; switch (button.Name) { diff --git a/src/Ryujinx/UI/Views/Input/KeyboardInputView.axaml.cs b/src/Ryujinx/UI/Views/Input/KeyboardInputView.axaml.cs index f17c7496c..1a792088e 100644 --- a/src/Ryujinx/UI/Views/Input/KeyboardInputView.axaml.cs +++ b/src/Ryujinx/UI/Views/Input/KeyboardInputView.axaml.cs @@ -68,7 +68,7 @@ namespace Ryujinx.Ava.UI.Views.Input if (e.ButtonValue.HasValue) { var buttonValue = e.ButtonValue.Value; - viewModel.ParentModel.IsModified = true; + viewModel.ParentModel.SettingsViewModel.IsModified = true; switch (button.Name) { diff --git a/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml.cs b/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml.cs index 29b8993d5..ff71da9c7 100644 --- a/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml.cs +++ b/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml.cs @@ -4,7 +4,6 @@ using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.Models; using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels.Input; -using Ryujinx.Ava.UI.Views.Input; namespace Ryujinx.Ava.UI.Views.Settings { @@ -19,7 +18,7 @@ namespace Ryujinx.Ava.UI.Views.Settings { SettingsViewModel = viewModel; - DataContext = ViewModel = new InputViewModel(this); + DataContext = ViewModel = new InputViewModel(this, viewModel); InitializeComponent(); } @@ -31,7 +30,7 @@ namespace Ryujinx.Ava.UI.Views.Settings private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { - if (ViewModel.IsModified && !_dialogOpen) + if (SettingsViewModel.IsModified && !_dialogOpen) { _dialogOpen = true; @@ -49,7 +48,7 @@ namespace Ryujinx.Ava.UI.Views.Settings _dialogOpen = false; - ViewModel.IsModified = false; + SettingsViewModel.IsModified = false; if (e.AddedItems.Count > 0) { diff --git a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs index 9d6fb6c7c..282f93176 100644 --- a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Ava.UI.Windows public readonly SettingsGraphicsView GraphicsPage; public readonly SettingsAudioView AudioPage; public readonly SettingsNetworkView NetworkPage; - public readonly SettingsLoggingView LoggingPage; + public readonly SettingsLoggingView LoggingPage; public SettingsWindow(VirtualFileSystem virtualFileSystem, ContentManager contentManager) { @@ -60,6 +60,11 @@ namespace Ryujinx.Ava.UI.Windows public void UpdateDirtyTitle(bool isDirty) { + if (!IsInitialized) + { + return; + } + if (isDirty) { Title = $"{LocaleManager.Instance[LocaleKeys.Settings]} - {LocaleManager.Instance[LocaleKeys.SettingsDirty]}";