From 286aebf70f57ee2d95d2d71934b3eaceeb6ed6aa Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 18 Apr 2024 18:42:47 -0400 Subject: [PATCH] Move confimration dialogue to SettingsWindow --- src/Ryujinx/Assets/Locales/en_US.json | 4 +- .../UI/ViewModels/SettingsViewModel.cs | 10 ----- .../UI/Views/Settings/SettingsInputView.axaml | 1 - .../Views/Settings/SettingsInputView.axaml.cs | 38 ------------------- src/Ryujinx/UI/Windows/SettingsWindow.axaml | 2 +- .../UI/Windows/SettingsWindow.axaml.cs | 29 ++++++++++++++ 6 files changed, 32 insertions(+), 52 deletions(-) diff --git a/src/Ryujinx/Assets/Locales/en_US.json b/src/Ryujinx/Assets/Locales/en_US.json index 30936a2a1b..6218fffd4c 100644 --- a/src/Ryujinx/Assets/Locales/en_US.json +++ b/src/Ryujinx/Assets/Locales/en_US.json @@ -490,8 +490,8 @@ "DialogUserProfileUnsavedChangesTitle": "Warning - Unsaved Changes", "DialogUserProfileUnsavedChangesMessage": "You have made changes to this user profile that have not been saved.", "DialogUserProfileUnsavedChangesSubMessage": "Do you want to discard your changes?", - "DialogControllerSettingsModifiedConfirmMessage": "The current controller settings has been updated.", - "DialogControllerSettingsModifiedConfirmSubMessage": "Do you want to save?", + "DialogSettingsUnsavedChangesMessage": "You have made changes to settings that have not been saved.", + "DialogSettingsUnsavedChangesSubMessage": "Do you want to discard your changes?", "DialogLoadFileErrorMessage": "{0}. Errored File: {1}", "DialogModAlreadyExistsMessage": "Mod already exists", "DialogModInvalidMessage": "The specified directory does not contain a mod!", diff --git a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs index d1f5530968..9f2589071f 100644 --- a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs @@ -591,10 +591,6 @@ namespace Ryujinx.Ava.UI.ViewModels _directoryChanged = false; } - private static void RevertIfNotSaved() - { - Program.ReloadConfig(); - } public void ApplyButton() { @@ -606,11 +602,5 @@ namespace Ryujinx.Ava.UI.ViewModels SaveSettings(); CloseWindow?.Invoke(); } - - public void CancelButton() - { - RevertIfNotSaved(); - CloseWindow?.Invoke(); - } } } diff --git a/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml b/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml index 5428435dc2..ff4779a441 100644 --- a/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml +++ b/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml @@ -65,7 +65,6 @@ Name="PlayerIndexBox" HorizontalAlignment="Stretch" VerticalAlignment="Center" - SelectionChanged="PlayerIndexBox_OnSelectionChanged" ItemsSource="{Binding PlayerIndexes}" SelectedIndex="{Binding PlayerId}"> diff --git a/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml.cs b/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml.cs index ff71da9c74..e9b5cab736 100644 --- a/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml.cs +++ b/src/Ryujinx/UI/Views/Settings/SettingsInputView.axaml.cs @@ -1,7 +1,4 @@ using Avalonia.Controls; -using Ryujinx.Ava.Common.Locale; -using Ryujinx.Ava.UI.Helpers; -using Ryujinx.Ava.UI.Models; using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels.Input; @@ -9,15 +6,10 @@ namespace Ryujinx.Ava.UI.Views.Settings { public partial class SettingsInputView : UserControl { - public SettingsViewModel SettingsViewModel; - - private bool _dialogOpen; private InputViewModel ViewModel { get; set; } public SettingsInputView(SettingsViewModel viewModel) { - SettingsViewModel = viewModel; - DataContext = ViewModel = new InputViewModel(this, viewModel); InitializeComponent(); @@ -28,36 +20,6 @@ namespace Ryujinx.Ava.UI.Views.Settings ViewModel.Save(); } - private async void PlayerIndexBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (SettingsViewModel.IsModified && !_dialogOpen) - { - _dialogOpen = true; - - var result = await ContentDialogHelper.CreateConfirmationDialog( - LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage], - LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage], - LocaleManager.Instance[LocaleKeys.InputDialogYes], - LocaleManager.Instance[LocaleKeys.InputDialogNo], - LocaleManager.Instance[LocaleKeys.RyujinxConfirm]); - - if (result == UserResult.Yes) - { - ViewModel.Save(); - } - - _dialogOpen = false; - - SettingsViewModel.IsModified = false; - - if (e.AddedItems.Count > 0) - { - var player = (PlayerModel)e.AddedItems[0]; - ViewModel.PlayerId = player.Id; - } - } - } - public void Dispose() { ViewModel.Dispose(); diff --git a/src/Ryujinx/UI/Windows/SettingsWindow.axaml b/src/Ryujinx/UI/Windows/SettingsWindow.axaml index b5f0242959..263f06ec71 100644 --- a/src/Ryujinx/UI/Windows/SettingsWindow.axaml +++ b/src/Ryujinx/UI/Windows/SettingsWindow.axaml @@ -110,7 +110,7 @@