From 01881e5490ae1e92493f1a9946491c95cda1ef54 Mon Sep 17 00:00:00 2001 From: redstrate Date: Wed, 3 Nov 2021 06:31:02 -0400 Subject: [PATCH] Add option to change to a custom WINE prefix --- src/settingswindow.cpp | 33 ++++++++++++++++++++++++++++----- src/settingswindow.h | 2 ++ src/xivlauncher.cpp | 21 ++++++++++++++++++--- src/xivlauncher.h | 2 +- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 2807914..ba24423 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -78,6 +78,25 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window winePathLabel->setText(this->window.winePath); }); + auto winePrefixDirectory = new QLabel(window.winePrefixPath); + winePrefixDirectory->setWordWrap(true); + wineBoxLayout->addRow("Wine Prefix", winePrefixDirectory); + + auto selectPrefixButton = new QPushButton("Select Wine Prefix"); + connect(selectPrefixButton, &QPushButton::pressed, [this, winePrefixDirectory] { + this->window.winePrefixPath = QFileDialog::getExistingDirectory(this, "Open Wine Prefix"); + winePrefixDirectory->setText(this->window.winePrefixPath); + + this->window.readInitialInformation(); + }); + wineBoxLayout->addWidget(selectPrefixButton); + + auto openPrefixButton = new QPushButton("Open Wine Prefix"); + connect(openPrefixButton, &QPushButton::pressed, [this] { + openPath(this->window.winePrefixPath); + }); + wineBoxLayout->addWidget(openPrefixButton); + auto enableDXVKhud = new QCheckBox("Enable DXVK HUD"); enableDXVKhud->setChecked(window.enableDXVKhud); wineBoxLayout->addWidget(enableDXVKhud); @@ -147,14 +166,18 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window auto gameDirectoryButton = new QPushButton("Open Game Directory"); connect(gameDirectoryButton, &QPushButton::pressed, [this] { + openPath(this->window.gamePath); + }); + layout->addWidget(gameDirectoryButton); +} + +void SettingsWindow::openPath(const QString path) { #if defined(Q_OS_WIN) - // for some reason, windows requires special treatment (what else is new?) - const QFileInfo fileInfo(this->window.gamePath); + // for some reason, windows requires special treatment (what else is new?) + const QFileInfo fileInfo(path); QProcess::startDetached("explorer.exe", QStringList(QDir::toNativeSeparators(fileInfo.canonicalFilePath()))); #else - QDesktopServices::openUrl("file://" + this->window.gamePath); + QDesktopServices::openUrl("file://" + path); #endif - }); - layout->addWidget(gameDirectoryButton); } \ No newline at end of file diff --git a/src/settingswindow.h b/src/settingswindow.h index 75a41c4..b60a09b 100644 --- a/src/settingswindow.h +++ b/src/settingswindow.h @@ -9,5 +9,7 @@ public: SettingsWindow(LauncherWindow& window, QWidget* parent = nullptr); private: + void openPath(const QString path); + LauncherWindow& window; }; \ No newline at end of file diff --git a/src/xivlauncher.cpp b/src/xivlauncher.cpp index a52def2..f343750 100755 --- a/src/xivlauncher.cpp +++ b/src/xivlauncher.cpp @@ -89,13 +89,15 @@ void LauncherWindow::launchExecutable(const QStringList args) { } #endif -#if defined(Q_OS_MACOS) || defined(Q_OS_LINUX) - arguments.push_back(winePath); -#endif +#if defined(Q_OS_MAC) || defined(Q_OS_LINUX) + env << "WINEPREFIX=" + winePrefixPath; if(enableDXVKhud) env << "DXVK_HUD=full"; + arguments.push_back(winePath); +#endif + arguments.append(args); auto executable = arguments[0]; @@ -156,6 +158,18 @@ void LauncherWindow::readInitialInformation() { #endif } + if(settings.contains("winePrefix") && settings.value("winePrefix").canConvert() && !settings.value("winePrefix").toString().isEmpty()) { + winePrefixPath = settings.value("winePrefix").toString(); + } else { +#if defined(Q_OS_MACOS) + winePrefixPath = QDir::homePath() + "/Library/Application Support/FINAL FANTASY XIV ONLINE/Bottles/published_Final_Fantasy"; +#endif + +#if defined(Q_OS_LINUX) + winePrefixPath = QDir::homePath() + "/.wine"; +#endif + } + bootVersion = readVersion(gamePath + "/boot/ffxivboot.ver"); gameVersion = readVersion(gamePath + "/game/ffxivgame.ver"); @@ -298,6 +312,7 @@ LauncherWindow::LauncherWindow(QWidget* parent) : auto info = LoginInformation{usernameEdit->text(), passwordEdit->text(), otpEdit->text()}; settings.setValue("gamePath", gamePath); + settings.setValue("winePrefix", winePrefixPath); settings.setValue("rememberUsername", rememberUsernameBox->checkState() == Qt::CheckState::Checked); if(rememberUsernameBox->checkState() == Qt::CheckState::Checked) { diff --git a/src/xivlauncher.h b/src/xivlauncher.h index 890d8a2..e56fe49 100755 --- a/src/xivlauncher.h +++ b/src/xivlauncher.h @@ -32,7 +32,7 @@ public: QNetworkAccessManager* mgr; int language = 1; // 1 is english, thats all i know - QString gamePath, winePath; + QString gamePath, winePath, winePrefixPath; QString bootVersion, gameVersion; bool useEsync, useGamescope, useGamemode;