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.
*/
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 setSSL(QNetworkRequest& request);

View file

@ -170,7 +170,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
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();
socket->close();
@ -189,7 +189,13 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
void LauncherCore::launchExecutable(const ProfileSettings& profile, const QStringList args) {
auto process = new QProcess(this);
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) {
@ -197,35 +203,40 @@ void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess
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;
auto env = process->processEnvironment();
#if defined(Q_OS_LINUX)
if(profile.useGamescope) {
arguments.push_back("gamescope");
if (isGame) {
if (profile.useGamescope) {
arguments.push_back("gamescope");
if(profile.gamescope.fullscreen)
arguments.push_back("-f");
if (profile.gamescope.fullscreen)
arguments.push_back("-f");
if(profile.gamescope.borderless)
arguments.push_back("-b");
if (profile.gamescope.borderless)
arguments.push_back("-b");
if(profile.gamescope.width > 0)
arguments.push_back("-w " + QString::number(profile.gamescope.width));
if (profile.gamescope.width > 0)
arguments.push_back("-w " +
QString::number(profile.gamescope.width));
if(profile.gamescope.height > 0)
arguments.push_back("-h " + QString::number(profile.gamescope.height));
if (profile.gamescope.height > 0)
arguments.push_back("-h " +
QString::number(profile.gamescope.height));
if(profile.gamescope.refreshRate > 0)
arguments.push_back("-r " + QString::number(profile.gamescope.refreshRate));
if (profile.gamescope.refreshRate > 0)
arguments.push_back(
"-r " + QString::number(profile.gamescope.refreshRate));
}
if (profile.useGamemode)
arguments.push_back("gamemoderun");
}
if(profile.useGamemode)
arguments.push_back("gamemoderun");
#endif
#if defined(Q_OS_LINUX)
@ -247,7 +258,9 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr
auto executable = arguments[0];
arguments.removeFirst();
process->setWorkingDirectory(profile.gamePath + "/game/");
if (isGame)
process->setWorkingDirectory(profile.gamePath + "/game/");
process->setProcessEnvironment(env);
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->setIcon(QIcon::fromTheme("settings"));
connect(wineCfg, &QAction::triggered, [=] {
this->core.launchExecutable(currentProfile(), {"winecfg.exe"});
this->core.launchExternalTool(currentProfile(), {"winecfg.exe"});
});
#endif