mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-26 02:23:05 +00:00
Move confimration dialogue to SettingsWindow
This commit is contained in:
parent
1ad9b27ed6
commit
286aebf70f
6 changed files with 32 additions and 52 deletions
|
@ -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!",
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
Name="PlayerIndexBox"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
SelectionChanged="PlayerIndexBox_OnSelectionChanged"
|
||||
ItemsSource="{Binding PlayerIndexes}"
|
||||
SelectedIndex="{Binding PlayerId}">
|
||||
<ComboBox.ItemTemplate>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
<Button
|
||||
IsCancel="True"
|
||||
Content="{locale:Locale SettingsButtonCancel}"
|
||||
Command="{Binding CancelButton}" />
|
||||
Click="Cancel_OnClick" />
|
||||
<Button
|
||||
Name="Apply"
|
||||
Content="{locale:Locale SettingsButtonApply}"
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using FluentAvalonia.Core;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.ViewModels;
|
||||
using Ryujinx.Ava.UI.Views.Settings;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
|
@ -137,6 +139,33 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
}
|
||||
}
|
||||
|
||||
private static void RevertIfNotSaved()
|
||||
{
|
||||
Program.ReloadConfig();
|
||||
}
|
||||
|
||||
private async void Cancel_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ViewModel.IsModified)
|
||||
{
|
||||
var result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogSettingsUnsavedChangesMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogSettingsUnsavedChangesSubMessage],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm],
|
||||
parent: this);
|
||||
|
||||
if (result != UserResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RevertIfNotSaved();
|
||||
Close();
|
||||
}
|
||||
|
||||
protected override void OnClosing(WindowClosingEventArgs e)
|
||||
{
|
||||
HotkeysPage.Dispose();
|
||||
|
|
Loading…
Reference in a new issue