diff options
author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2022-11-13 00:36:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-12 20:36:36 -0300 |
commit | eebc39228db4663e03fa73306e725424f7ce1273 (patch) | |
tree | a0e231a860f41839af09b3c358630a086180b606 /Ryujinx.Ava/Program.cs | |
parent | 9daf029f356898336de1ad0c63b6c36e261e4f9b (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.Ava/Program.cs')
-rw-r--r-- | Ryujinx.Ava/Program.cs | 65 |
1 files changed, 20 insertions, 45 deletions
diff --git a/Ryujinx.Ava/Program.cs b/Ryujinx.Ava/Program.cs index 61b184c6..053bccab 100644 --- a/Ryujinx.Ava/Program.cs +++ b/Ryujinx.Ava/Program.cs @@ -13,6 +13,7 @@ using Ryujinx.Common.SystemInfo; using Ryujinx.Modules; using Ryujinx.Ui.Common; using Ryujinx.Ui.Common.Configuration; +using Ryujinx.Ui.Common.Helper; using System; using System.IO; using System.Runtime.InteropServices; @@ -26,7 +27,6 @@ namespace Ryujinx.Ava public static double ActualScaleFactor { get; set; } public static string Version { get; private set; } public static string ConfigurationPath { get; private set; } - public static string CommandLineProfile { get; set; } public static bool PreviewerDetached { get; private set; } public static RenderTimer RenderTimer { get; private set; } @@ -87,46 +87,8 @@ namespace Ryujinx.Ava private static void Initialize(string[] args) { - // Parse Arguments. - string launchPathArg = null; - string baseDirPathArg = null; - bool startFullscreenArg = false; - - for (int i = 0; i < args.Length; ++i) - { - string arg = args[i]; - - if (arg == "-r" || arg == "--root-data-dir") - { - if (i + 1 >= args.Length) - { - Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'"); - - continue; - } - - baseDirPathArg = args[++i]; - } - else if (arg == "-p" || arg == "--profile") - { - if (i + 1 >= args.Length) - { - Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'"); - - continue; - } - - CommandLineProfile = args[++i]; - } - else if (arg == "-f" || arg == "--fullscreen") - { - startFullscreenArg = true; - } - else - { - launchPathArg = arg; - } - } + // Parse arguments + CommandLineState.ParseArguments(args); // Delete backup files after updating. Task.Run(Updater.CleanupUpdate); @@ -135,10 +97,10 @@ namespace Ryujinx.Ava // Hook unhandled exception and process exit events. AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => ProcessUnhandledException(e.ExceptionObject as Exception, e.IsTerminating); - AppDomain.CurrentDomain.ProcessExit += (object sender, EventArgs e) => Exit(); + AppDomain.CurrentDomain.ProcessExit += (object sender, EventArgs e) => Exit(); // Setup base data directory. - AppDataManager.Initialize(baseDirPathArg); + AppDataManager.Initialize(CommandLineState.BaseDirPathArg); // Initialize the configuration. ConfigurationState.Initialize(); @@ -173,9 +135,9 @@ namespace Ryujinx.Ava } } - if (launchPathArg != null) + if (CommandLineState.LaunchPathArg != null) { - MainWindow.DeferLoadApplication(launchPathArg, startFullscreenArg); + MainWindow.DeferLoadApplication(CommandLineState.LaunchPathArg, CommandLineState.StartFullscreenArg); } } @@ -215,6 +177,19 @@ namespace Ryujinx.Ava Logger.Warning?.PrintMsg(LogClass.Application, $"Failed to load config! Loading the default config instead.\nFailed config location {ConfigurationPath}"); } } + + // Check if graphics backend was overridden + if (CommandLineState.OverrideGraphicsBackend != null) + { + if (CommandLineState.OverrideGraphicsBackend.ToLower() == "opengl") + { + ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl; + } + else if (CommandLineState.OverrideGraphicsBackend.ToLower() == "vulkan") + { + ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.Vulkan; + } + } } private static void PrintSystemInfo() |