From 1e5b37c94f870dc3faa94fb2d095cfa39fecb2a3 Mon Sep 17 00:00:00 2001 From: Bruno Macabeus Date: Thu, 14 Jan 2021 22:30:52 +0000 Subject: [PATCH] settings: add Show Confirm Exist toggle (#1856) --- .../Configuration/ConfigurationFileFormat.cs | 7 ++++++- .../Configuration/ConfigurationState.cs | 18 ++++++++++++++++++ Ryujinx/Config.json | 3 ++- Ryujinx/Ui/GLRenderer.cs | 2 +- Ryujinx/Ui/MainWindow.cs | 4 ++-- Ryujinx/Ui/Windows/SettingsWindow.cs | 7 +++++++ Ryujinx/Ui/Windows/SettingsWindow.glade | 16 ++++++++++++++++ Ryujinx/_schema.json | 11 +++++++++++ 8 files changed, 63 insertions(+), 5 deletions(-) diff --git a/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs b/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs index cb7c3b7e0..72cc579c7 100644 --- a/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs +++ b/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Configuration /// /// The current version of the file format /// - public const int CurrentVersion = 18; + public const int CurrentVersion = 20; public int Version { get; set; } @@ -128,6 +128,11 @@ namespace Ryujinx.Configuration /// public bool CheckUpdatesOnStart { get; set; } + /// + /// Show "Confirm Exit" Dialog + /// + public bool ShowConfirmExit { get; set; } + /// /// Enables or disables Vertical Sync /// diff --git a/Ryujinx.Common/Configuration/ConfigurationState.cs b/Ryujinx.Common/Configuration/ConfigurationState.cs index 4457eb36f..a0fef1b22 100644 --- a/Ryujinx.Common/Configuration/ConfigurationState.cs +++ b/Ryujinx.Common/Configuration/ConfigurationState.cs @@ -360,6 +360,11 @@ namespace Ryujinx.Configuration /// public ReactiveObject CheckUpdatesOnStart { get; private set; } + /// + /// Show "Confirm Exit" Dialog + /// + public ReactiveObject ShowConfirmExit { get; private set; } + private ConfigurationState() { Ui = new UiSection(); @@ -369,6 +374,7 @@ namespace Ryujinx.Configuration Hid = new HidSection(); EnableDiscordIntegration = new ReactiveObject(); CheckUpdatesOnStart = new ReactiveObject(); + ShowConfirmExit = new ReactiveObject(); } public ConfigurationFileFormat ToFileFormat() @@ -413,6 +419,7 @@ namespace Ryujinx.Configuration DockedMode = System.EnableDockedMode, EnableDiscordIntegration = EnableDiscordIntegration, CheckUpdatesOnStart = CheckUpdatesOnStart, + ShowConfirmExit = ShowConfirmExit, EnableVsync = Graphics.EnableVsync, EnableShaderCache = Graphics.EnableShaderCache, EnablePtc = System.EnablePtc, @@ -475,6 +482,7 @@ namespace Ryujinx.Configuration System.EnableDockedMode.Value = false; EnableDiscordIntegration.Value = true; CheckUpdatesOnStart.Value = true; + ShowConfirmExit.Value = true; Graphics.EnableVsync.Value = true; Graphics.EnableShaderCache.Value = true; System.EnablePtc.Value = true; @@ -770,6 +778,15 @@ namespace Ryujinx.Configuration configurationFileUpdated = true; } + if (configurationFileFormat.Version < 20) + { + Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 20."); + + configurationFileFormat.ShowConfirmExit = true; + + configurationFileUpdated = true; + } + List inputConfig = new List(); inputConfig.AddRange(configurationFileFormat.ControllerConfig); inputConfig.AddRange(configurationFileFormat.KeyboardConfig); @@ -796,6 +813,7 @@ namespace Ryujinx.Configuration System.EnableDockedMode.Value = configurationFileFormat.DockedMode; EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration; CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart; + ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit; Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync; Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache; System.EnablePtc.Value = configurationFileFormat.EnablePtc; diff --git a/Ryujinx/Config.json b/Ryujinx/Config.json index f7a119e3a..dac28ef3c 100644 --- a/Ryujinx/Config.json +++ b/Ryujinx/Config.json @@ -1,5 +1,5 @@ { - "version": 18, + "version": 20, "res_scale": 1, "res_scale_custom": 1, "max_anisotropy": -1, @@ -21,6 +21,7 @@ "docked_mode": false, "enable_discord_integration": true, "check_updates_on_start": true, + "show_confirm_exit": true, "enable_vsync": true, "enable_shader_cache": true, "enable_ptc": true, diff --git a/Ryujinx/Ui/GLRenderer.cs b/Ryujinx/Ui/GLRenderer.cs index 6115c22bb..35c00a332 100644 --- a/Ryujinx/Ui/GLRenderer.cs +++ b/Ryujinx/Ui/GLRenderer.cs @@ -154,7 +154,7 @@ namespace Ryujinx.Ui { if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape)) { - if (GtkDialog.CreateExitDialog()) + if (!ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog()) { Exit(); } diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index c197ad127..2e3437292 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -907,7 +907,7 @@ namespace Ryujinx.Ui private void Exit_Pressed(object sender, EventArgs args) { - if (!_gameLoaded || GtkDialog.CreateExitDialog()) + if (!_gameLoaded || !ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog()) { End(); } @@ -915,7 +915,7 @@ namespace Ryujinx.Ui private void Window_Close(object sender, DeleteEventArgs args) { - if (!_gameLoaded || GtkDialog.CreateExitDialog()) + if (!_gameLoaded || !ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog()) { End(); } diff --git a/Ryujinx/Ui/Windows/SettingsWindow.cs b/Ryujinx/Ui/Windows/SettingsWindow.cs index a44abfcc3..4497dedf1 100644 --- a/Ryujinx/Ui/Windows/SettingsWindow.cs +++ b/Ryujinx/Ui/Windows/SettingsWindow.cs @@ -41,6 +41,7 @@ namespace Ryujinx.Ui.Windows [GUI] CheckButton _dockedModeToggle; [GUI] CheckButton _discordToggle; [GUI] CheckButton _checkUpdatesToggle; + [GUI] CheckButton _showConfirmExitToggle; [GUI] CheckButton _vSyncToggle; [GUI] CheckButton _shaderCacheToggle; [GUI] CheckButton _ptcToggle; @@ -176,6 +177,11 @@ namespace Ryujinx.Ui.Windows _checkUpdatesToggle.Click(); } + if (ConfigurationState.Instance.ShowConfirmExit) + { + _showConfirmExitToggle.Click(); + } + if (ConfigurationState.Instance.Graphics.EnableVsync) { _vSyncToggle.Click(); @@ -393,6 +399,7 @@ namespace Ryujinx.Ui.Windows ConfigurationState.Instance.System.EnableDockedMode.Value = _dockedModeToggle.Active; ConfigurationState.Instance.EnableDiscordIntegration.Value = _discordToggle.Active; ConfigurationState.Instance.CheckUpdatesOnStart.Value = _checkUpdatesToggle.Active; + ConfigurationState.Instance.ShowConfirmExit.Value = _showConfirmExitToggle.Active; ConfigurationState.Instance.Graphics.EnableVsync.Value = _vSyncToggle.Active; ConfigurationState.Instance.Graphics.EnableShaderCache.Value = _shaderCacheToggle.Active; ConfigurationState.Instance.System.EnablePtc.Value = _ptcToggle.Active; diff --git a/Ryujinx/Ui/Windows/SettingsWindow.glade b/Ryujinx/Ui/Windows/SettingsWindow.glade index 936aa5209..97a88b229 100644 --- a/Ryujinx/Ui/Windows/SettingsWindow.glade +++ b/Ryujinx/Ui/Windows/SettingsWindow.glade @@ -137,6 +137,22 @@ 1 + + + Show "Confirm Exit" Dialog + True + True + False + start + True + + + False + True + 5 + 1 + + True diff --git a/Ryujinx/_schema.json b/Ryujinx/_schema.json index d8402feea..549611af8 100644 --- a/Ryujinx/_schema.json +++ b/Ryujinx/_schema.json @@ -1199,6 +1199,17 @@ false ] }, + "show_confirm_exit": { + "$id": "#/properties/show_confirm_exit", + "type": "boolean", + "title": "Show \"Confirm Exit\" Dialog", + "description": "Check to shows the \"Confirm Exit\" dialog when closing Ryujinx.", + "default": true, + "examples": [ + true, + false + ] + }, "enable_vsync": { "$id": "#/properties/enable_vsync", "type": "boolean",