From a2f73779bee986c76ae024b39aaa3bdf3bb6f85f Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 14 Apr 2022 17:48:06 -0400 Subject: [PATCH] Automatically set HideWineExports depending on game license Square Enix detects your platform as "macOS" when it detects Wine DLL exports (only on the 64-bit launcher apparently), so if you have a Windows license selected Astra will automatically add the relevant registry key for you now. If you still want to take advantage of your macOS license, you'll still be able to play by selecting "macOS" as your license in your settings. --- include/launchercore.h | 4 +++- src/launchercore.cpp | 29 ++++++++++++++++++++++++----- src/launcherwindow.cpp | 2 +- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/include/launchercore.h b/include/launchercore.h index 8555402..f986a2e 100755 --- a/include/launchercore.h +++ b/include/launchercore.h @@ -137,13 +137,15 @@ public: /* * This just wraps it in wine if needed. */ - void launchExecutable(const ProfileSettings& settings, QProcess* process, QStringList args, bool isGame); + void launchExecutable(const ProfileSettings& settings, QProcess* process, QStringList args, bool isGame, bool needsRegistrySetup); /* * Launches an external tool. Gamescope for example is intentionally excluded. */ void launchExternalTool(const ProfileSettings& settings, QStringList args); + void addRegistryKey(const ProfileSettings& settings, QString key, QString value, QString data); + void buildRequest(const ProfileSettings& settings, QNetworkRequest& request); void setSSL(QNetworkRequest& request); QString readVersion(QString path); diff --git a/src/launchercore.cpp b/src/launchercore.cpp index 1463a43..45f600b 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -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}, false); + launchExecutable(profile, dalamudProcess, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded}, false, true); connection->close(); socket->close(); @@ -189,13 +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, true); + launchExecutable(profile, process, args, true, true); } void LauncherCore::launchExternalTool(const ProfileSettings& profile, const QStringList args) { auto process = new QProcess(this); process->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); - launchExecutable(profile, process, args, false); + launchExecutable(profile, process, args, false, true); } void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args) { @@ -203,13 +203,25 @@ void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess arguments.append(args); - launchExecutable(profile, process, arguments, true); + launchExecutable(profile, process, arguments, true, true); } -void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args, bool isGame) { +void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args, bool isGame, bool needsRegistrySetup) { QList arguments; auto env = process->processEnvironment(); + if(needsRegistrySetup) { +#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) + if(profile.license == GameLicense::macOS) { + addRegistryKey(profile, "HKEY_CURRENT_USER\\Software\\Wine", "HideWineExports", "0"); + } else { + addRegistryKey(profile, "HKEY_CURRENT_USER\\Software\\Wine", "HideWineExports", "1"); + } +#endif + } + + process->setProcessChannelMode(QProcess::ForwardedChannels); + #if defined(Q_OS_LINUX) if (isGame) { if (profile.useGamescope) { @@ -674,3 +686,10 @@ QString LauncherCore::getDefaultGamePath() { return QDir::homePath() + "/.wine/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn"; #endif } + +void LauncherCore::addRegistryKey(const ProfileSettings& settings, + QString key, QString value, QString data) { + auto process = new QProcess(this); + process->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); + launchExecutable(settings, process, {"reg", "add", key, "/v", value, "/d", data, "/f" }, false, false); +} diff --git a/src/launcherwindow.cpp b/src/launcherwindow.cpp index 2aebd88..944f825 100644 --- a/src/launcherwindow.cpp +++ b/src/launcherwindow.cpp @@ -111,7 +111,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo wineCfg->setMenuRole(QAction::MenuRole::NoRole); wineCfg->setIcon(QIcon::fromTheme("configure")); connect(wineCfg, &QAction::triggered, [=] { - this->core.launchExternalTool(currentProfile(), {"winecfg.exe"}); + this->core.launchExternalTool(currentProfile(), {"regedit.exe"}); }); #endif