1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Launch Dalamud injector natively on Windows

This also prevents tools like winecfg or system info unnecessarily
running in gamescope, if enabled.
This commit is contained in:
Joshua Goins 2022-02-25 20:20:52 -05:00
parent b01f96005f
commit 34e3464411
2 changed files with 28 additions and 8 deletions

View file

@ -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<QString> 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<QString> 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);
}

View file

@ -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);