aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ui.Common/Helper/CommandLineState.cs
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2022-11-13 00:36:36 +0100
committerGitHub <noreply@github.com>2022-11-12 20:36:36 -0300
commiteebc39228db4663e03fa73306e725424f7ce1273 (patch)
treea0e231a860f41839af09b3c358630a086180b606 /Ryujinx.Ui.Common/Helper/CommandLineState.cs
parent9daf029f356898336de1ad0c63b6c36e261e4f9b (diff)
UI: Allow overriding graphics backend + Move command line parser into a new class (#3707)1.1.343
* Ava: Keep command line args when restarting * UI: Move common UI functions to ProgramHelper Add command line option to override the configured graphics backend * Ava: Add CleanupUpdate task back * Remove unused usings * Revert combining common UI functions Rename ProgramHelper to CommandLineState Move command line parsing to CommandLineState * Rename CommandLineProfile to Profile * Fix assigning the wrong array to Arguments
Diffstat (limited to 'Ryujinx.Ui.Common/Helper/CommandLineState.cs')
-rw-r--r--Ryujinx.Ui.Common/Helper/CommandLineState.cs81
1 files changed, 81 insertions, 0 deletions
diff --git a/Ryujinx.Ui.Common/Helper/CommandLineState.cs b/Ryujinx.Ui.Common/Helper/CommandLineState.cs
new file mode 100644
index 00000000..cda4af4e
--- /dev/null
+++ b/Ryujinx.Ui.Common/Helper/CommandLineState.cs
@@ -0,0 +1,81 @@
+using Ryujinx.Common.Logging;
+using System.Collections.Generic;
+
+namespace Ryujinx.Ui.Common.Helper
+{
+ public static class CommandLineState
+ {
+ public static string[] Arguments { get; private set; }
+
+ public static string OverrideGraphicsBackend { get; private set; }
+ public static string BaseDirPathArg { get; private set; }
+ public static string Profile { get; private set; }
+ public static string LaunchPathArg { get; private set; }
+ public static bool StartFullscreenArg { get; private set; }
+
+ public static void ParseArguments(string[] args)
+ {
+ List<string> arguments = new();
+
+ // Parse Arguments.
+ for (int i = 0; i < args.Length; ++i)
+ {
+ string arg = args[i];
+
+ switch (arg)
+ {
+ case "-r":
+ case "--root-data-dir":
+ if (i + 1 >= args.Length)
+ {
+ Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'");
+
+ continue;
+ }
+
+ BaseDirPathArg = args[++i];
+
+ arguments.Add(arg);
+ arguments.Add(args[i]);
+ break;
+ case "-p":
+ case "--profile":
+ if (i + 1 >= args.Length)
+ {
+ Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'");
+
+ continue;
+ }
+
+ Profile = args[++i];
+
+ arguments.Add(arg);
+ arguments.Add(args[i]);
+ break;
+ case "-f":
+ case "--fullscreen":
+ StartFullscreenArg = true;
+
+ arguments.Add(arg);
+ break;
+ case "-g":
+ case "--graphics-backend":
+ if (i + 1 >= args.Length)
+ {
+ Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'");
+
+ continue;
+ }
+
+ OverrideGraphicsBackend = args[++i];
+ break;
+ default:
+ LaunchPathArg = arg;
+ break;
+ }
+ }
+
+ Arguments = arguments.ToArray();
+ }
+ }
+} \ No newline at end of file