diff options
| author | Morph <39850852+Morph1984@users.noreply.github.com> | 2020-12-25 15:17:49 -0500 | 
|---|---|---|
| committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2020-12-25 15:41:00 -0500 | 
| commit | ff3aa5d3804db4deef3c4a1996a5bbc7d8bf202c (patch) | |
| tree | b38c8e07c64056927eda314929cf4d572db5d025 /src/yuzu | |
| parent | 0dc4ab42cc1efba566d428c84221a82ef5c76283 (diff) | |
yuzu/main: Add basic command line arguments
The following command line arguments are supported:
yuzu.exe "path_to_game" - Launches a game at "path_to_game"
yuzu.exe -f - Launches the next game in fullscreen
yuzu.exe -g "path_to_game" - Launches a game at "path_to_game"
yuzu.exe -f -g "path_to_game" - Launches a game at "path_to_game" in fullscreen
Diffstat (limited to 'src/yuzu')
| -rw-r--r-- | src/yuzu/main.cpp | 42 | 
1 files changed, 39 insertions, 3 deletions
| diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 7aa515226..ebaccd2ef 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -292,12 +292,48 @@ GMainWindow::GMainWindow()      connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);      connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); +    MigrateConfigFiles(); + +    ui.action_Fullscreen->setChecked(false); +      QStringList args = QApplication::arguments(); -    if (args.length() >= 2) { -        BootGame(args[1]); + +    if (args.size() < 2) { +        return;      } -    MigrateConfigFiles(); +    QString game_path; + +    for (int i = 1; i < args.size(); ++i) { +        // Preserves drag/drop functionality +        if (args.size() == 2 && !args[1].startsWith(QChar::fromLatin1('-'))) { +            game_path = args[1]; +            break; +        } + +        // Launch game in fullscreen mode +        if (args[i] == QStringLiteral("-f")) { +            ui.action_Fullscreen->setChecked(true); +            continue; +        } + +        // Launch game at path +        if (args[i] == QStringLiteral("-g")) { +            if (i >= args.size() - 1) { +                continue; +            } + +            if (args[i + 1].startsWith(QChar::fromLatin1('-'))) { +                continue; +            } + +            game_path = args[++i]; +        } +    } + +    if (!game_path.isEmpty()) { +        BootGame(game_path); +    }  }  GMainWindow::~GMainWindow() { | 
