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:
parent
c1f9b8f88d
commit
f8566a5669
2 changed files with 22 additions and 5 deletions
|
@ -3,6 +3,8 @@
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include "xivlauncher.h"
|
#include "xivlauncher.h"
|
||||||
|
|
||||||
|
@ -13,9 +15,19 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window
|
||||||
auto layout = new QFormLayout(this);
|
auto layout = new QFormLayout(this);
|
||||||
setLayout(layout);
|
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");
|
auto gameDirectoryButton = new QPushButton("Open Game Directory");
|
||||||
connect(gameDirectoryButton, &QPushButton::pressed, [this] {
|
connect(gameDirectoryButton, &QPushButton::pressed, [this] {
|
||||||
QDesktopServices::openUrl("file://" + this->window.gamePath);
|
QDesktopServices::openUrl("file://" + this->window.gamePath);
|
||||||
});
|
});
|
||||||
layout->addRow(gameDirectoryButton);
|
layout->addWidget(gameDirectoryButton);
|
||||||
}
|
}
|
|
@ -109,6 +109,9 @@ QString LauncherWindow::readVersion(QString path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::readInitialInformation() {
|
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)
|
#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
|
#endif
|
||||||
|
@ -118,9 +121,9 @@ void LauncherWindow::readInitialInformation() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#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
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bootVersion = readVersion(gamePath + "/boot/ffxivboot.ver");
|
bootVersion = readVersion(gamePath + "/boot/ffxivboot.ver");
|
||||||
gameVersion = readVersion(gamePath + "/game/ffxivgame.ver");
|
gameVersion = readVersion(gamePath + "/game/ffxivgame.ver");
|
||||||
|
@ -227,6 +230,8 @@ LauncherWindow::LauncherWindow(QWidget* parent) :
|
||||||
connect(loginButton, &QPushButton::released, [=] {
|
connect(loginButton, &QPushButton::released, [=] {
|
||||||
auto info = LoginInformation{usernameEdit->text(), passwordEdit->text(), otpEdit->text()};
|
auto info = LoginInformation{usernameEdit->text(), passwordEdit->text(), otpEdit->text()};
|
||||||
|
|
||||||
|
settings.setValue("gamePath", gamePath);
|
||||||
|
|
||||||
settings.setValue("rememberUsername", rememberUsernameBox->checkState() == Qt::CheckState::Checked);
|
settings.setValue("rememberUsername", rememberUsernameBox->checkState() == Qt::CheckState::Checked);
|
||||||
if(rememberUsernameBox->checkState() == Qt::CheckState::Checked) {
|
if(rememberUsernameBox->checkState() == Qt::CheckState::Checked) {
|
||||||
auto job = new QKeychain::WritePasswordJob("LauncherWindow");
|
auto job = new QKeychain::WritePasswordJob("LauncherWindow");
|
||||||
|
|
Loading…
Add table
Reference in a new issue