From 8d95a5b87d7a22d251e835c8a8f5f04b097ec823 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 22 Dec 2024 16:55:29 -0800 Subject: [PATCH] UI: Option to automatically Hide UI when game launches Quality of life feature. Removes the need to manually hide UI every time the game launches --- .../Configuration/ConfigurationFileFormat.cs | 7 +++++- .../ConfigurationState.Migration.cs | 10 ++++++++ .../Configuration/ConfigurationState.Model.cs | 6 +++++ .../Configuration/ConfigurationState.cs | 2 ++ src/Ryujinx/AppHost.cs | 2 +- src/Ryujinx/Assets/locales.json | 24 +++++++++++++++++++ .../UI/ViewModels/MainWindowViewModel.cs | 18 ++++++++++++++ .../UI/Views/Main/MainMenuBarView.axaml | 23 ++++++++++++++++++ 8 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationFileFormat.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationFileFormat.cs index 027e1052b0..5f19f137f7 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationFileFormat.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationFileFormat.cs @@ -17,7 +17,7 @@ public class ConfigurationFileFormat /// /// The current version of the file format /// - public const int CurrentVersion = 57; + public const int CurrentVersion = 58; /// /// Version of the configuration file format @@ -351,6 +351,11 @@ public class ConfigurationFileFormat /// public bool StartFullscreen { get; set; } + /// + /// Start games with UI hidden + /// + public bool StartNoUI { get; set; } + /// /// Show console window /// diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.Migration.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.Migration.cs index a41ea2cd73..f153714832 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.Migration.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.Migration.cs @@ -638,6 +638,15 @@ public void Load(ConfigurationFileFormat configurationFileFormat, string configu configurationFileUpdated = true; } + if (configurationFileFormat.Version < 58) + { + Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 58."); + + configurationFileFormat.StartNoUI = false; + + configurationFileUpdated = true; + } + Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog; Graphics.ResScale.Value = configurationFileFormat.ResScale; Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom; @@ -719,6 +728,7 @@ public void Load(ConfigurationFileFormat configurationFileFormat, string configu UI.GridSize.Value = configurationFileFormat.GridSize; UI.ApplicationSort.Value = configurationFileFormat.ApplicationSort; UI.StartFullscreen.Value = configurationFileFormat.StartFullscreen; + UI.StartNoUI.Value = configurationFileFormat.StartNoUI; UI.ShowConsole.Value = configurationFileFormat.ShowConsole; UI.WindowStartup.WindowSizeWidth.Value = configurationFileFormat.WindowStartup.WindowSizeWidth; UI.WindowStartup.WindowSizeHeight.Value = configurationFileFormat.WindowStartup.WindowSizeHeight; diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.Model.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.Model.cs index f28ce0348c..9da0e8968a 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.Model.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.Model.cs @@ -149,6 +149,11 @@ public WindowStartupSettings() /// public ReactiveObject StartFullscreen { get; private set; } + /// + /// Start games with UI hidden + /// + public ReactiveObject StartNoUI { get; private set; } + /// /// Hide / Show Console Window /// @@ -189,6 +194,7 @@ public UISection() WindowStartup = new WindowStartupSettings(); BaseStyle = new ReactiveObject(); StartFullscreen = new ReactiveObject(); + StartNoUI = new ReactiveObject(); GameListViewMode = new ReactiveObject(); ShowNames = new ReactiveObject(); GridSize = new ReactiveObject(); diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs index 90bdc34091..5eb6528681 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs @@ -124,6 +124,7 @@ public ConfigurationFileFormat ToFileFormat() ApplicationSort = UI.ApplicationSort, IsAscendingOrder = UI.IsAscendingOrder, StartFullscreen = UI.StartFullscreen, + StartNoUI = UI.StartNoUI, ShowConsole = UI.ShowConsole, EnableKeyboard = Hid.EnableKeyboard, EnableMouse = Hid.EnableMouse, @@ -230,6 +231,7 @@ public void LoadDefault() UI.ApplicationSort.Value = 0; UI.IsAscendingOrder.Value = true; UI.StartFullscreen.Value = false; + UI.StartNoUI.Value = false; UI.ShowConsole.Value = true; UI.WindowStartup.WindowSizeWidth.Value = 1280; UI.WindowStartup.WindowSizeHeight.Value = 760; diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index 909eb05d50..fc76a57bb9 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -1043,7 +1043,7 @@ private void RenderLoop() _viewModel.WindowState = WindowState.FullScreen; } - if (_viewModel.WindowState is WindowState.FullScreen) + if (_viewModel.WindowState is WindowState.FullScreen || _viewModel.StartGamesWithoutUI) { _viewModel.ShowMenuAndStatusBar = false; } diff --git a/src/Ryujinx/Assets/locales.json b/src/Ryujinx/Assets/locales.json index 907a7d7bd9..73370d8643 100644 --- a/src/Ryujinx/Assets/locales.json +++ b/src/Ryujinx/Assets/locales.json @@ -572,6 +572,30 @@ "zh_TW": "使用全螢幕模式啟動遊戲" } }, + { + "ID": "MenuBarOptionsStartGamesWithoutUI", + "Translations": { + "ar_SA": "", + "de_DE": "", + "el_GR": "", + "en_US": "Start Games with UI Hidden", + "es_ES": "", + "fr_FR": "", + "he_IL": "", + "it_IT": "", + "ja_JP": "", + "ko_KR": "", + "no_NO": "", + "pl_PL": "", + "pt_BR": "", + "ru_RU": "", + "th_TH": "", + "tr_TR": "", + "uk_UA": "", + "zh_CN": "", + "zh_TW": "" + } + }, { "ID": "MenuBarOptionsStopEmulation", "Translations": { diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index 2f1800290b..34ad51c9eb 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -876,6 +876,19 @@ public bool StartGamesInFullscreen } } + public bool StartGamesWithoutUI + { + get => ConfigurationState.Instance.UI.StartNoUI; + set + { + ConfigurationState.Instance.UI.StartNoUI.Value = value; + + ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath); + + OnPropertyChanged(); + } + } + public bool ShowConsole { get => ConfigurationState.Instance.UI.ShowConsole; @@ -1613,6 +1626,11 @@ public void ToggleStartGamesInFullscreen() StartGamesInFullscreen = !StartGamesInFullscreen; } + public void ToggleStartGamesWithoutUI() + { + StartGamesWithoutUI = !StartGamesWithoutUI; + } + public void ToggleShowConsole() { ShowConsole = !ShowConsole; diff --git a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml index 2c07bd8ef9..b665c57626 100644 --- a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml +++ b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml @@ -119,6 +119,29 @@ + + + + + + + + +