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

Add selectable game directory

This commit is contained in:
redstrate 2021-11-01 13:35:27 -04:00
parent c1f9b8f88d
commit f8566a5669
2 changed files with 22 additions and 5 deletions

View file

@ -3,6 +3,8 @@
#include <QFormLayout>
#include <QPushButton>
#include <QDesktopServices>
#include <QLabel>
#include <QFileDialog>
#include "xivlauncher.h"
@ -13,9 +15,19 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window
auto layout = new QFormLayout(this);
setLayout(layout);
auto currentGameDirectory = new QLabel(window.gamePath);
layout->addRow("Game Directory", currentGameDirectory);
auto selectDirectoryButton = new QPushButton("Select Game Directory");
connect(selectDirectoryButton, &QPushButton::pressed, [this, currentGameDirectory] {
this->window.gamePath = QFileDialog::getExistingDirectory(this, "Open Game Directory");
currentGameDirectory->setText(this->window.gamePath);
});
layout->addWidget(selectDirectoryButton);
auto gameDirectoryButton = new QPushButton("Open Game Directory");
connect(gameDirectoryButton, &QPushButton::pressed, [this] {
QDesktopServices::openUrl("file://" + this->window.gamePath);
});
layout->addRow(gameDirectoryButton);
layout->addWidget(gameDirectoryButton);
}

View file

@ -109,18 +109,21 @@ QString LauncherWindow::readVersion(QString path) {
}
void LauncherWindow::readInitialInformation() {
if(settings.contains("gamePath") && settings.value("gamePath").canConvert<QString>() && !settings.value("gamePath").toString().isEmpty()) {
gamePath = settings.value("gamePath").toString();
} else {
#if defined(Q_OS_WIN)
gamePath = "C:\\Program Files (x86\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn";
gamePath = "C:\\Program Files (x86\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn";
#endif
#if defined(Q_OS_MACOS)
gamePath = 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";
gamePath = 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";
#endif
#if defined(Q_OS_LINUX)
// TODO: this is assuming it's in your default WINEPREFIX
gamePath = QDir::homePath() + "/.wine/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn";
gamePath = QDir::homePath() + "/.wine/drive_c/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn";
#endif
}
bootVersion = readVersion(gamePath + "/boot/ffxivboot.ver");
gameVersion = readVersion(gamePath + "/game/ffxivgame.ver");
@ -227,6 +230,8 @@ LauncherWindow::LauncherWindow(QWidget* parent) :
connect(loginButton, &QPushButton::released, [=] {
auto info = LoginInformation{usernameEdit->text(), passwordEdit->text(), otpEdit->text()};
settings.setValue("gamePath", gamePath);
settings.setValue("rememberUsername", rememberUsernameBox->checkState() == Qt::CheckState::Checked);
if(rememberUsernameBox->checkState() == Qt::CheckState::Checked) {
auto job = new QKeychain::WritePasswordJob("LauncherWindow");