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

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.
This commit is contained in:
Joshua Goins 2022-04-14 17:48:06 -04:00
parent e5ebac764a
commit a2f73779be
3 changed files with 28 additions and 7 deletions

View file

@ -137,13 +137,15 @@ 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, 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. * Launches an external tool. Gamescope for example is intentionally excluded.
*/ */
void launchExternalTool(const ProfileSettings& settings, QStringList args); 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 buildRequest(const ProfileSettings& settings, QNetworkRequest& request);
void setSSL(QNetworkRequest& request); void setSSL(QNetworkRequest& request);
QString readVersion(QString path); QString readVersion(QString path);

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}, false); launchExecutable(profile, dalamudProcess, {dataDir + "/Dalamud/" + "Dalamud.Injector.exe", QString::number(exitCode), argsEncoded}, false, true);
connection->close(); connection->close();
socket->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) { 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, true); launchExecutable(profile, process, args, true, true);
} }
void LauncherCore::launchExternalTool(const ProfileSettings& profile, const QStringList args) { void LauncherCore::launchExternalTool(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, false); launchExecutable(profile, process, args, false, true);
} }
void LauncherCore::launchGameExecutable(const ProfileSettings& profile, QProcess* process, const QStringList args) { 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); 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<QString> arguments; QList<QString> arguments;
auto env = process->processEnvironment(); 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 defined(Q_OS_LINUX)
if (isGame) { if (isGame) {
if (profile.useGamescope) { 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"; return QDir::homePath() + "/.wine/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn";
#endif #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);
}

View file

@ -111,7 +111,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
wineCfg->setMenuRole(QAction::MenuRole::NoRole); wineCfg->setMenuRole(QAction::MenuRole::NoRole);
wineCfg->setIcon(QIcon::fromTheme("configure")); wineCfg->setIcon(QIcon::fromTheme("configure"));
connect(wineCfg, &QAction::triggered, [=] { connect(wineCfg, &QAction::triggered, [=] {
this->core.launchExternalTool(currentProfile(), {"winecfg.exe"}); this->core.launchExternalTool(currentProfile(), {"regedit.exe"});
}); });
#endif #endif