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

Add option to change to a custom WINE prefix

This commit is contained in:
redstrate 2021-11-03 06:31:02 -04:00
parent f921e734ef
commit 01881e5490
4 changed files with 49 additions and 9 deletions

View file

@ -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] {
#if defined(Q_OS_WIN)
// for some reason, windows requires special treatment (what else is new?)
const QFileInfo fileInfo(this->window.gamePath);
QProcess::startDetached("explorer.exe", QStringList(QDir::toNativeSeparators(fileInfo.canonicalFilePath())));
#else
QDesktopServices::openUrl("file://" + this->window.gamePath);
#endif
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(path);
QProcess::startDetached("explorer.exe", QStringList(QDir::toNativeSeparators(fileInfo.canonicalFilePath())));
#else
QDesktopServices::openUrl("file://" + path);
#endif
}

View file

@ -9,5 +9,7 @@ public:
SettingsWindow(LauncherWindow& window, QWidget* parent = nullptr);
private:
void openPath(const QString path);
LauncherWindow& window;
};

View file

@ -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<QString>() && !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) {

View file

@ -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;