From 95abfb472d6b5e7112fea3299d64f4055143f452 Mon Sep 17 00:00:00 2001 From: redstrate Date: Mon, 1 Nov 2021 14:35:32 -0400 Subject: [PATCH] Add a bunch of Wine performance options to settings --- src/settingswindow.cpp | 53 +++++++++++++++++++++++++++++++++++ src/xivlauncher.cpp | 63 +++++++++++++++++++----------------------- src/xivlauncher.h | 6 ++-- 3 files changed, 86 insertions(+), 36 deletions(-) diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index b54b508..96eabb0 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include "xivlauncher.h" @@ -15,6 +17,57 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window auto layout = new QFormLayout(this); setLayout(layout); +#if defined(Q_OS_LINUX) + auto wineBox = new QGroupBox("Wine Options"); + auto wineBoxLayout = new QFormLayout(); + wineBox->setLayout(wineBoxLayout); + + auto infoLabel = new QLabel("This is a list of possible enhancements you can make to your Wine gaming experience.\n" + "This is all stuff you can do outside of the launcher, but we can take care of it for you."); + wineBoxLayout->addWidget(infoLabel); + + auto useEsync = new QCheckBox("Use Esync"); + useEsync->setChecked(window.settings.value("useEsync", false).toBool()); + wineBoxLayout->addWidget(useEsync); + + auto esyncLabel = new QLabel("Improves general game performance, but requires a Wine built with the Esync patches.\n" + "If you use the latest Wine staging, it should work."); + wineBoxLayout->addWidget(esyncLabel); + + connect(useEsync, &QCheckBox::stateChanged, [this](int state) { + this->window.useEsync = state; + this->window.settings.setValue("useEsync", static_cast(state)); + }); + + auto useGamescope = new QCheckBox("Use Gamescope"); + useGamescope->setChecked(window.settings.value("useGamescope", false).toBool()); + wineBoxLayout->addWidget( useGamescope); + + auto gamescopeLabel = new QLabel("Use the SteamOS compositor that uses Wayland.\n" + "If you are experiencing input issues on XWayland, try this option if you have it installed."); + wineBoxLayout->addWidget(gamescopeLabel); + + connect(useGamescope, &QCheckBox::stateChanged, [this](int state) { + this->window.useGamescope = state; + this->window.settings.setValue("useGamescope", static_cast(state)); + }); + + auto useGamemode = new QCheckBox("Use Gamemode"); + useGamemode->setChecked(window.settings.value("useGamemode", false).toBool()); + wineBoxLayout->addWidget(useGamemode); + + auto gamemodeLabel = new QLabel("Use Feral Interactive's GameMode, which applies a couple of performance enhancements.\n" + "May give a slight performance boost, but requires GameMode to be installed.\n"); + wineBoxLayout->addWidget(gamemodeLabel); + + connect(useGamemode, &QCheckBox::stateChanged, [this](int state) { + this->window.useGamemode = state; + this->window.settings.setValue("useGamemode", static_cast(state)); + }); + + layout->addRow(wineBox); +#endif + auto currentGameDirectory = new QLabel(window.gamePath); layout->addRow("Game Directory", currentGameDirectory); diff --git a/src/xivlauncher.cpp b/src/xivlauncher.cpp index 76ed0b7..037db9a 100755 --- a/src/xivlauncher.cpp +++ b/src/xivlauncher.cpp @@ -42,42 +42,42 @@ void LauncherWindow::buildRequest(QNetworkRequest& request) { void LauncherWindow::launch(const LoginAuth auth) { auto process = new QProcess(this); process->setProcessChannelMode(QProcess::ForwardedChannels); + process->setWorkingDirectory(gamePath + "/game/"); - bool isWine = false; - QString winePath; - QString ffxivPath; - -#if defined(Q_OS_WIN) - ffxivPath = gamePath + "\\game\\ffxiv_dx11.exe"; -#endif + QList arguments; + // for platforms using wine, set wine before ffxiv_dx11.exe + // TODO: make wine path configurable #if defined(Q_OS_MACOS) - isWine = true; - // TODO: this is assuming FFXIV is installed in /Applications - winePath = "/Applications/FINAL FANTASY XIV ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine"; - ffxivPath = QDir::homePath() + "/Library/Application Support/FINAL FANTASY XIV ONLINE/Bottles/published_Final_Fantasy/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn/game/ffxiv_dx11.exe"; + arguments.push_back("/Applications/FINAL FANTASY XIV ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine"); #endif #if defined(Q_OS_LINUX) - isWine = true; - // TODO: this is assuming you want to use the wine in your PATH, which isn't always the case - winePath = "wine"; - - // TODO: this is assuming it's in your default WINEPREFIX - ffxivPath = gamePath + "/game/ffxiv_dx11.exe"; - process->setWorkingDirectory(gamePath + "/game/"); -#endif - - QList arguments; - if (isWine) { - arguments.push_back(ffxivPath); + if(useGamescope) { + arguments.push_back("gamescope"); + arguments.push_back("-f"); + arguments.push_back("-b"); } - // i wonder what these mean... + if(useGamemode) + arguments.push_back("gamemoderun"); + + arguments.push_back("wine"); + + QStringList env = QProcess::systemEnvironment(); + env << "DXVK_HUD=full"; + + if(useEsync) { + env << "WINEESYNC=1"; + } + + process->setEnvironment(env); +#endif + + // now for the actual game... + arguments.push_back(gamePath + "\\game\\ffxiv_dx11.exe"); arguments.push_back("DEV.DataPathType=1"); arguments.push_back("DEV.UseSqPack=1"); - // by the way, it looks like setting graphics options is possible via these too, i wonder what - // else is hiding :-))) arguments.push_back(QString("DEV.MaxEntitledExpansionID=%1").arg(auth.maxExpansion)); arguments.push_back(QString("DEV.TestSID=%1").arg(auth.SID)); @@ -91,14 +91,9 @@ void LauncherWindow::launch(const LoginAuth auth) { arguments.push_back(QString("DEV.LobbyHost0%1=%2 DEV.LobbyPort0%1=54994").arg(QString::number(i), auth.lobbyhost)); } - if (isWine) { - QStringList env = QProcess::systemEnvironment(); - //env << "DXVK_FILTER_DEVICE_NAME=AMD"; - process->setEnvironment(env); - process->start(winePath, arguments); - } else { - process->start(ffxivPath, arguments); - } + auto executable = arguments[0]; + arguments.removeFirst(); + process->start(executable, arguments); } QString LauncherWindow::readVersion(QString path) { diff --git a/src/xivlauncher.h b/src/xivlauncher.h index 2047f91..d4fae46 100755 --- a/src/xivlauncher.h +++ b/src/xivlauncher.h @@ -35,17 +35,19 @@ public: QString gamePath; QString bootVersion, gameVersion; + bool useEsync, useGamescope, useGamemode; + void launch(const LoginAuth auth); void buildRequest(QNetworkRequest& request); void setSSL(QNetworkRequest& request); QString readVersion(QString path); + QSettings settings; + private: void readInitialInformation(); SapphireLauncher* sapphireLauncher; SquareBoot* squareBoot; SquareLauncher* squareLauncher; - - QSettings settings; };