diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 2803f97..2807914 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -43,6 +43,41 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window infoLabel->setWordWrap(true); wineBoxLayout->addWidget(infoLabel); + auto winePathLabel = new QLabel(window.winePath); + winePathLabel->setWordWrap(true); + wineBoxLayout->addRow("Wine Executable", winePathLabel); + + auto wineVersionCombo = new QComboBox(); + +#if defined(Q_OS_MAC) + wineVersionCombo->insertItem(2, "FFXIV Built-In"); +#endif + + wineVersionCombo->insertItem(0, "System Wine"); + wineVersionCombo->insertItem(1, "Custom Path..."); + wineVersionCombo->setCurrentIndex(window.settings.value("wineVersion", 0).toInt()); + wineBoxLayout->addWidget(wineVersionCombo); + + auto selectWineButton = new QPushButton("Select Wine Executable"); + selectWineButton->setEnabled(window.settings.value("wineVersion", 0).toInt() == 2); + wineBoxLayout->addWidget(selectWineButton); + + connect(wineVersionCombo, &QComboBox::currentIndexChanged, [this, selectWineButton, winePathLabel](int index) { + this->window.settings.setValue("wineVersion", index); + selectWineButton->setEnabled(index == 1); + + this->window.readInitialInformation(); + winePathLabel->setText(this->window.winePath); + }); + + connect(selectWineButton, &QPushButton::pressed, [this, winePathLabel] { + this->window.winePath = QFileDialog::getOpenFileName(this, "Open Wine Executable"); + this->window.settings.setValue("winePath", this->window.winePath); + + this->window.readInitialInformation(); + winePathLabel->setText(this->window.winePath); + }); + auto enableDXVKhud = new QCheckBox("Enable DXVK HUD"); enableDXVKhud->setChecked(window.enableDXVKhud); wineBoxLayout->addWidget(enableDXVKhud); @@ -53,25 +88,6 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window }); #endif -#if defined(Q_OS_MAC) - auto useSystemWine = new QCheckBox("Use System Wine"); - useSystemWine->setChecked(window.useSystemWine); - wineBoxLayout->addWidget(useSystemWine); - - connect(useSystemWine, &QCheckBox::stateChanged, [this](int state) { - this->window.useSystemWine = state; - this->window.settings.setValue("useSystemWine", static_cast(state)); - }); - - auto systemWineLabel = new QLabel("Use the system wine instead of the one packaged with the macOS version of FFXIV.\n" - "You can easily install wine through homebrew, but please note that the game will not run out of the box\n" - "on DX11 without DXVK installed."); - systemWineLabel->setWordWrap(true); - wineBoxLayout->addWidget(systemWineLabel); - - layout->addRow(wineBox); -#endif - #if defined(Q_OS_LINUX) auto useEsync = new QCheckBox("Use Esync"); useEsync->setChecked(window.useEsync); diff --git a/src/xivlauncher.cpp b/src/xivlauncher.cpp index 87bbc3e..a52def2 100755 --- a/src/xivlauncher.cpp +++ b/src/xivlauncher.cpp @@ -70,27 +70,10 @@ void LauncherWindow::launchGame(const LoginAuth auth) { void LauncherWindow::launchExecutable(const QStringList args) { auto process = new QProcess(this); process->setProcessChannelMode(QProcess::ForwardedChannels); - process->setWorkingDirectory(gamePath + "/game/"); QList arguments; - - // for platforms using wine, set wine before ffxiv_dx11.exe - // TODO: make wine path configurable -#if defined(Q_OS_MACOS) - if(useSystemWine) { - arguments.push_back("/usr/local/bin/wine64"); - } else { - arguments.push_back("/Applications/FINAL FANTASY XIV ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine"); - } - QStringList env = QProcess::systemEnvironment(); - if(enableDXVKhud) - env << "DXVK_HUD=full"; - - process->setEnvironment(env); -#endif - #if defined(Q_OS_LINUX) if(useGamescope) { arguments.push_back("gamescope"); @@ -101,21 +84,25 @@ void LauncherWindow::launchExecutable(const QStringList args) { if(useGamemode) arguments.push_back("gamemoderun"); - arguments.push_back("wine"); - - QStringList env = QProcess::systemEnvironment(); - if(useEsync) { env << "WINEESYNC=1"; } - - process->setEnvironment(env); #endif +#if defined(Q_OS_MACOS) || defined(Q_OS_LINUX) + arguments.push_back(winePath); +#endif + + if(enableDXVKhud) + env << "DXVK_HUD=full"; + arguments.append(args); auto executable = arguments[0]; arguments.removeFirst(); + + process->setWorkingDirectory(gamePath + "/game/"); + process->setEnvironment(env); process->start(executable, arguments); } @@ -127,6 +114,32 @@ QString LauncherWindow::readVersion(QString path) { } void LauncherWindow::readInitialInformation() { + const int wineVersion = settings.value("wineVersion", 0).toInt(); +#if defined(Q_OS_MAC) + switch(wineVersion) { + case 0: // system wine + winePath = "/usr/local/bin/wine64"; + break; + case 1: // custom path + winePath = settings.value("winePath").toString(); + break; + case 2: // ffxiv built-in (for mac users) + winePath = "/Applications/FINAL FANTASY XIV ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine"; + break; + } +#endif + +#if defined(Q_OS_LINUX) + switch(wineVersion) { + case 0: // system wine (should be in $PATH) + winePath = "wine"; + break; + case 1: // custom pth + winePath = settings.value("winePath").toString(); + break; + } +#endif + if(settings.contains("gamePath") && settings.value("gamePath").canConvert() && !settings.value("gamePath").toString().isEmpty()) { gamePath = settings.value("gamePath").toString(); } else { @@ -149,7 +162,6 @@ void LauncherWindow::readInitialInformation() { useEsync = settings.value("useEsync", false).toBool(); useGamemode = settings.value("useGamemode", false).toBool(); useGamescope = settings.value("useGamescope", false).toBool(); - useSystemWine = settings.value("useSystemWine", false).toBool(); enableDXVKhud = settings.value("enableDXVKhud", false).toBool(); } @@ -282,8 +294,6 @@ LauncherWindow::LauncherWindow(QWidget* parent) : readInitialInformation(); - launchExecutable({gamePath + "/game/ffxiv_dx11.exe", "DEV.TestSID=xxxx"}); - connect(loginButton, &QPushButton::released, [=] { auto info = LoginInformation{usernameEdit->text(), passwordEdit->text(), otpEdit->text()}; diff --git a/src/xivlauncher.h b/src/xivlauncher.h index e42a751..890d8a2 100755 --- a/src/xivlauncher.h +++ b/src/xivlauncher.h @@ -32,12 +32,11 @@ public: QNetworkAccessManager* mgr; int language = 1; // 1 is english, thats all i know - QString gamePath; + QString gamePath, winePath; QString bootVersion, gameVersion; bool useEsync, useGamescope, useGamemode; bool useDX9 = false; - bool useSystemWine = false; bool enableDXVKhud = false; void launchGame(const LoginAuth auth);