From b4ee5d1a4dd01ca30493df4455e32ae3b29c414f Mon Sep 17 00:00:00 2001 From: redstrate Date: Tue, 9 Nov 2021 12:46:27 -0500 Subject: [PATCH] Make custom game directory function again --- src/settingswindow.cpp | 16 ++++++++++------ src/settingswindow.h | 2 ++ src/xivlauncher.cpp | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 75dd66e..913021f 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -59,22 +59,25 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window this->window.saveSettings(); }); - auto currentGameDirectory = new QLabel(window.currentProfile().gamePath); + currentGameDirectory = new QLabel(window.currentProfile().gamePath); currentGameDirectory->setWordWrap(true); gameBoxLayout->addRow("Game Directory", currentGameDirectory); auto selectDirectoryButton = new QPushButton("Select Game Directory"); - connect(selectDirectoryButton, &QPushButton::pressed, [this, currentGameDirectory] { - this->window.currentProfile().gamePath = QFileDialog::getExistingDirectory(this, "Open Game Directory"); - currentGameDirectory->setText(this->window.currentProfile().gamePath); + connect(selectDirectoryButton, &QPushButton::pressed, [this] { + getCurrentProfile().gamePath = QFileDialog::getExistingDirectory(this, "Open Game Directory"); - this->window.readInitialInformation(); + this->reloadControls(); + this->window.saveSettings(); + + // TODO: replace this call with a dedicated "read version information" call or something similar + //this->window.readInitialInformation(); }); gameBoxLayout->addWidget(selectDirectoryButton); auto gameDirectoryButton = new QPushButton("Open Game Directory"); connect(gameDirectoryButton, &QPushButton::pressed, [this] { - openPath(this->window.currentProfile().gamePath); + openPath(getCurrentProfile().gamePath); }); gameBoxLayout->addWidget(gameDirectoryButton); @@ -260,6 +263,7 @@ void SettingsWindow::reloadControls() { ProfileSettings& profile = window.getProfile(profileWidget->currentRow()); nameEdit->setText(profile.name); directXCombo->setCurrentIndex(profile.useDX9 ? 1 : 0); + currentGameDirectory->setText(profile.gamePath); serverType->setCurrentIndex(profile.isSapphire ? 1 : 0); rememberUsernameBox->setChecked(profile.rememberUsername); diff --git a/src/settingswindow.h b/src/settingswindow.h index ac52197..6db1c15 100644 --- a/src/settingswindow.h +++ b/src/settingswindow.h @@ -5,6 +5,7 @@ #include #include #include +#include class LauncherWindow; struct ProfileSettings; @@ -24,6 +25,7 @@ private: QLineEdit* nameEdit = nullptr; QComboBox* directXCombo = nullptr; + QLabel* currentGameDirectory = nullptr; QComboBox* serverType = nullptr; QCheckBox* rememberUsernameBox = nullptr, *rememberPasswordBox = nullptr; diff --git a/src/xivlauncher.cpp b/src/xivlauncher.cpp index ee6ec5d..e3bc861 100755 --- a/src/xivlauncher.cpp +++ b/src/xivlauncher.cpp @@ -385,6 +385,7 @@ void LauncherWindow::saveSettings() { settings.beginGroup(profile.name); settings.setValue("useDX9", profile.useDX9); + settings.setValue("gamePath", profile.gamePath); settings.setValue("isSapphire", profile.isSapphire); settings.setValue("rememberUsername", profile.rememberUsername);