From 34e3464411468b57736df664463bdff4821fe08e Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 25 Feb 2022 20:20:52 -0500 Subject: [PATCH] Launch Dalamud injector natively on Windows This also prevents tools like winecfg or system info unnecessarily running in gamescope, if enabled. --- src/launchercore.cpp | 25 +++++++++++++++++-------- src/launchercore.h | 11 +++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/launchercore.cpp b/src/launchercore.cpp index e19adb9..3eaca83 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -203,8 +203,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au auto list = dalamudProcess->processEnvironment().toStringList(); - // TODO: what if we aren't on wine? - dalamudProcess->start(profile.winePath, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", output, argsEncoded}); + launchExecutable(profile, dalamudProcess, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", output, argsEncoded}); }); } @@ -226,19 +225,19 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au gameClosed(); }); - launchExecutable(profile, gameProcess, arguments); + launchGameExecutable(profile, gameProcess, arguments); successfulLaunch(); } void LauncherCore::launchExecutable(const ProfileSettings& profile, const QStringList args) { auto process = new QProcess(this); + process->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); launchExecutable(profile, process, args); } -void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args) { +void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args) { QList arguments; - auto env = process->processEnvironment(); #if defined(Q_OS_LINUX) if(profile.useGamescope) { @@ -262,7 +261,18 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr if(profile.useGamemode) arguments.push_back("gamemoderun"); +#endif + arguments.append(args); + + launchExecutable(profile, process, args); +} + +void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args) { + QList arguments; + auto env = process->processEnvironment(); + +#if defined(Q_OS_LINUX) if(profile.useEsync) { env.insert("WINEESYNC", QString::number(1)); env.insert("WINEFSYNC", QString::number(1)); @@ -273,9 +283,6 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr #if defined(Q_OS_MAC) || defined(Q_OS_LINUX) env.insert("WINEPREFIX", profile.winePrefixPath); - if(profile.enableDXVKhud) - env.insert("DXVK_HUD", "full"); - arguments.push_back(profile.winePath); #endif @@ -287,6 +294,8 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr process->setWorkingDirectory(profile.gamePath + "/game/"); process->setProcessEnvironment(env); + qDebug() << "launching " << executable << " with args" << arguments; + process->start(executable, arguments); } diff --git a/src/launchercore.h b/src/launchercore.h index b3909b7..cc4020d 100755 --- a/src/launchercore.h +++ b/src/launchercore.h @@ -95,8 +95,19 @@ public: int deleteProfile(QString name); void launchGame(const ProfileSettings& settings, LoginAuth auth); + void launchExecutable(const ProfileSettings& settings, QStringList args); + + /* + * Used for processes that should be wrapped in gamescope, etc. + */ + void launchGameExecutable(const ProfileSettings& settings, QProcess* process, QStringList args); + + /* + * This just wraps it in wine if needed. + */ void launchExecutable(const ProfileSettings& settings, QProcess* process, QStringList args); + void buildRequest(QNetworkRequest& request); void setSSL(QNetworkRequest& request); QString readVersion(QString path);