From f8566a56690a58540a137ce0ee59f210e4eae97e Mon Sep 17 00:00:00 2001 From: redstrate Date: Mon, 1 Nov 2021 13:35:27 -0400 Subject: [PATCH] Add selectable game directory --- src/settingswindow.cpp | 14 +++++++++++++- src/xivlauncher.cpp | 13 +++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 33ecec0..b54b508 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #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); } \ No newline at end of file diff --git a/src/xivlauncher.cpp b/src/xivlauncher.cpp index 41fa9bf..76ed0b7 100755 --- a/src/xivlauncher.cpp +++ b/src/xivlauncher.cpp @@ -109,18 +109,21 @@ QString LauncherWindow::readVersion(QString path) { } void LauncherWindow::readInitialInformation() { + if(settings.contains("gamePath") && settings.value("gamePath").canConvert() && !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");