From 7511ec1d31e9cee1b6727966686ae79aa32d6b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Mestre?= Date: Tue, 22 Oct 2024 10:00:55 -0300 Subject: [PATCH 1/2] Added a command line option (-c, --config) to load a configuration file through the command line parameters --- .../Helper/CommandLineState.cs | 25 +++++++++++++++++++ src/Ryujinx/Program.cs | 5 ++++ 2 files changed, 30 insertions(+) diff --git a/src/Ryujinx.UI.Common/Helper/CommandLineState.cs b/src/Ryujinx.UI.Common/Helper/CommandLineState.cs index ae0e4d904..7f8854c36 100644 --- a/src/Ryujinx.UI.Common/Helper/CommandLineState.cs +++ b/src/Ryujinx.UI.Common/Helper/CommandLineState.cs @@ -1,5 +1,6 @@ using Ryujinx.Common.Logging; using System.Collections.Generic; +using System.IO; namespace Ryujinx.UI.Common.Helper { @@ -16,6 +17,7 @@ namespace Ryujinx.UI.Common.Helper public static string LaunchPathArg { get; private set; } public static string LaunchApplicationId { get; private set; } public static bool StartFullscreenArg { get; private set; } + public static string OverrideConfigFile { get; private set; } public static void ParseArguments(string[] args) { @@ -96,6 +98,29 @@ namespace Ryujinx.UI.Common.Helper case "--software-gui": OverrideHardwareAcceleration = false; break; + case "-c": + case "--config": + if (i + 1 >= args.Length) + { + Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'"); + + continue; + } + + string configFile = args[++i]; + + if (Path.GetExtension(configFile).ToLower() != ".json") + { + Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'"); + + continue; + } + + OverrideConfigFile = configFile; + + arguments.Add(arg); + arguments.Add(args[i]); + break; default: LaunchPathArg = arg; break; diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index b77e05c12..3617cfed1 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -164,6 +164,11 @@ namespace Ryujinx.Ava ConfigurationPath = appDataConfigurationPath; } + if(!string.IsNullOrEmpty(CommandLineState.OverrideConfigFile) && File.Exists(CommandLineState.OverrideConfigFile)) + { + ConfigurationPath = CommandLineState.OverrideConfigFile; + } + if (ConfigurationPath == null) { // No configuration, we load the default values and save it to disk -- 2.47.1 From 95977fdc71434d2e43b7c5fd5412fe3d0186c37b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Mestre?= Date: Tue, 22 Oct 2024 11:04:13 -0300 Subject: [PATCH 2/2] Fix whitespace formatting --- src/Ryujinx/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index 3617cfed1..3c6e5130b 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -164,7 +164,7 @@ namespace Ryujinx.Ava ConfigurationPath = appDataConfigurationPath; } - if(!string.IsNullOrEmpty(CommandLineState.OverrideConfigFile) && File.Exists(CommandLineState.OverrideConfigFile)) + if (!string.IsNullOrEmpty(CommandLineState.OverrideConfigFile) && File.Exists(CommandLineState.OverrideConfigFile)) { ConfigurationPath = CommandLineState.OverrideConfigFile; } -- 2.47.1