From c141b248a82d4c88af33d525806707213cf58f7e Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 18 Apr 2024 16:31:52 -0400 Subject: [PATCH] Change SettingsWindow title on dirty --- src/Ryujinx/Assets/Locales/en_US.json | 1 + src/Ryujinx/UI/ViewModels/SettingsViewModel.cs | 17 +++++++++++++++-- src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs | 18 ++++++++++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx/Assets/Locales/en_US.json b/src/Ryujinx/Assets/Locales/en_US.json index 8df0f96a14..30936a2a1b 100644 --- a/src/Ryujinx/Assets/Locales/en_US.json +++ b/src/Ryujinx/Assets/Locales/en_US.json @@ -91,6 +91,7 @@ "LinuxVmMaxMapCountWarningTextPrimary": "Max amount of memory mappings is lower than recommended.", "LinuxVmMaxMapCountWarningTextSecondary": "The current value of vm.max_map_count ({0}) is lower than {1}. Some games might try to create more memory mappings than currently allowed. Ryujinx will crash as soon as this limit gets exceeded.\n\nYou might want to either manually increase the limit or install pkexec, which allows Ryujinx to assist with that.", "Settings": "Settings", + "SettingsDirty": "Unsaved Changes", "SettingsTabGeneral": "User Interface", "SettingsTabGeneralGeneral": "General", "SettingsTabGeneralEnableDiscordRichPresence": "Enable Discord Rich Presence", diff --git a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs index 70e5fa5c74..3fda90a646 100644 --- a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs @@ -49,11 +49,24 @@ namespace Ryujinx.Ava.UI.ViewModels private int _graphicsBackendIndex; private int _scalingFilter; private int _scalingFilterLevel; + private int _networkInterfaceIndex; + private int _multiplayerModeIndex; + + private bool _isModified; + + public bool IsModified + { + get => _isModified; + set + { + DirtyEvent?.Invoke(value); + _isModified = value; + } + } public event Action CloseWindow; public event Action SaveSettingsEvent; - private int _networkInterfaceIndex; - private int _multiplayerModeIndex; + public event Action DirtyEvent; public int ResolutionScale { diff --git a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs index 314501c525..8d21636a86 100644 --- a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs @@ -10,17 +10,18 @@ namespace Ryujinx.Ava.UI.Windows { public partial class SettingsWindow : StyleableWindow { - internal SettingsViewModel ViewModel { get; set; } + private SettingsViewModel ViewModel { get; } public SettingsWindow(VirtualFileSystem virtualFileSystem, ContentManager contentManager) { - Title = $"Ryujinx {Program.Version} - {LocaleManager.Instance[LocaleKeys.Settings]}"; + Title = $"{LocaleManager.Instance[LocaleKeys.Settings]}"; ViewModel = new SettingsViewModel(virtualFileSystem, contentManager); DataContext = ViewModel; ViewModel.CloseWindow += Close; ViewModel.SaveSettingsEvent += SaveSettings; + ViewModel.DirtyEvent += UpdateDirtyTitle; InitializeComponent(); Load(); @@ -35,6 +36,19 @@ namespace Ryujinx.Ava.UI.Windows Load(); } + public void UpdateDirtyTitle(bool isDirty) + { + if (isDirty) + { + Title = $"{LocaleManager.Instance[LocaleKeys.Settings]} - {LocaleManager.Instance[LocaleKeys.SettingsDirty]}"; + } + else + { + Title = $"{LocaleManager.Instance[LocaleKeys.Settings]}"; + + } + } + public void SaveSettings() { InputPage.InputView?.SaveCurrentProfile();