1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-24 05:17:46 +00:00

Fix "Configure Wine" menu item not working if game is not installed

Now there is a dedicated way to launch an external tool, that does not
wrap in gamescope (if enabled) and not in the game's working directory.
This commit is contained in:
Joshua Goins 2022-04-09 17:53:43 -04:00
parent d7e3694835
commit a2bb741c72
3 changed files with 40 additions and 22 deletions

View file

@ -126,7 +126,12 @@ public:
/* /*
* This just wraps it in wine if needed. * This just wraps it in wine if needed.
*/ */
void launchExecutable(const ProfileSettings& settings, QProcess* process, QStringList args); void launchExecutable(const ProfileSettings& settings, QProcess* process, QStringList args, bool isGame);
/*
* Launches an external tool. Gamescope for example is intentionally excluded.
*/
void launchExternalTool(const ProfileSettings& settings, QStringList args);
void buildRequest(const ProfileSettings& settings, QNetworkRequest& request); void buildRequest(const ProfileSettings& settings, QNetworkRequest& request);
void setSSL(QNetworkRequest& request); void setSSL(QNetworkRequest& request);

View file

@ -170,7 +170,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
auto list = dalamudProcess->processEnvironment().toStringList(); auto list = dalamudProcess->processEnvironment().toStringList();
launchExecutable(profile, dalamudProcess, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded}); launchExecutable(profile, dalamudProcess, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded}, false);
connection->close(); connection->close();
socket->close(); socket->close();
@ -189,7 +189,13 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
void LauncherCore::launchExecutable(const ProfileSettings& profile, const QStringList args) { void LauncherCore::launchExecutable(const ProfileSettings& profile, const QStringList args) {
auto process = new QProcess(this); auto process = new QProcess(this);
process->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); process->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
launchExecutable(profile, process, args); launchExecutable(profile, process, args, true);
}
void LauncherCore::launchExternalTool(const ProfileSettings& profile, const QStringList args) {
auto process = new QProcess(this);
process->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
launchExecutable(profile, process, args, false);
} }
void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args) { void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args) {
@ -197,35 +203,40 @@ void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess
arguments.append(args); arguments.append(args);
launchExecutable(profile, process, arguments); launchExecutable(profile, process, arguments, true);
} }
void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args) { void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args, bool isGame) {
QList<QString> arguments; QList<QString> arguments;
auto env = process->processEnvironment(); auto env = process->processEnvironment();
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
if(profile.useGamescope) { if (isGame) {
if (profile.useGamescope) {
arguments.push_back("gamescope"); arguments.push_back("gamescope");
if(profile.gamescope.fullscreen) if (profile.gamescope.fullscreen)
arguments.push_back("-f"); arguments.push_back("-f");
if(profile.gamescope.borderless) if (profile.gamescope.borderless)
arguments.push_back("-b"); arguments.push_back("-b");
if(profile.gamescope.width > 0) if (profile.gamescope.width > 0)
arguments.push_back("-w " + QString::number(profile.gamescope.width)); arguments.push_back("-w " +
QString::number(profile.gamescope.width));
if(profile.gamescope.height > 0) if (profile.gamescope.height > 0)
arguments.push_back("-h " + QString::number(profile.gamescope.height)); arguments.push_back("-h " +
QString::number(profile.gamescope.height));
if(profile.gamescope.refreshRate > 0) if (profile.gamescope.refreshRate > 0)
arguments.push_back("-r " + QString::number(profile.gamescope.refreshRate)); arguments.push_back(
"-r " + QString::number(profile.gamescope.refreshRate));
} }
if(profile.useGamemode) if (profile.useGamemode)
arguments.push_back("gamemoderun"); arguments.push_back("gamemoderun");
}
#endif #endif
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
@ -247,7 +258,9 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr
auto executable = arguments[0]; auto executable = arguments[0];
arguments.removeFirst(); arguments.removeFirst();
if (isGame)
process->setWorkingDirectory(profile.gamePath + "/game/"); process->setWorkingDirectory(profile.gamePath + "/game/");
process->setProcessEnvironment(env); process->setProcessEnvironment(env);
qDebug() << "launching " << executable << " with args" << arguments; qDebug() << "launching " << executable << " with args" << arguments;

View file

@ -74,7 +74,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
wineCfg = fileMenu->addAction("Configure Wine..."); wineCfg = fileMenu->addAction("Configure Wine...");
wineCfg->setIcon(QIcon::fromTheme("settings")); wineCfg->setIcon(QIcon::fromTheme("settings"));
connect(wineCfg, &QAction::triggered, [=] { connect(wineCfg, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {"winecfg.exe"}); this->core.launchExternalTool(currentProfile(), {"winecfg.exe"});
}); });
#endif #endif