aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.UI.Common/Helper/CommandLineState.cs
blob: 6de963a74a784c826e128add5569ca0cc4a87b64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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 bool? OverrideDockedMode { get; private set; }
        public static bool? OverrideHardwareAcceleration { get; private set; }
        public static string OverrideGraphicsBackend { get; private set; }
        public static string OverrideHideCursor { 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;
                    case "--docked-mode":
                        OverrideDockedMode = true;
                        break;
                    case "--handheld-mode":
                        OverrideDockedMode = false;
                        break;
                    case "--hide-cursor":
                        if (i + 1 >= args.Length)
                        {
                            Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'");

                            continue;
                        }

                        OverrideHideCursor = args[++i];
                        break;
                    case "--software-gui":
                        OverrideHardwareAcceleration = false;
                        break;
                    case "--hardware-gui":
                        OverrideHardwareAcceleration = true;
                        break;
                    default:
                        LaunchPathArg = arg;
                        break;
                }
            }

            Arguments = arguments.ToArray();
        }
    }
}