diff --git a/src/launchercore.cpp b/src/launchercore.cpp index 8e58ef5..67f3cbf 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -342,6 +342,20 @@ void LauncherCore::readGameVersion() { for(auto& profile : profileSettings) { profile.bootVersion = readVersion(profile.gamePath + "/boot/ffxivboot.ver"); profile.gameVersion = readVersion(profile.gamePath + "/game/ffxivgame.ver"); + + for(auto dir : QDir(profile.gamePath + "/game/sqpack/").entryList(QDir::Filter::Dirs)) { + if(dir.contains("ex") && dir.length() == 3 && dir[2].isDigit()) { + const int expacVersion = dir[2].digitValue(); + + profile.installedMaxExpansion = std::max(profile.installedMaxExpansion, expacVersion); + } + + if(dir == "ffxiv") { + profile.installedMaxExpansion = std::max(profile.installedMaxExpansion, 0); + } + } + + readExpansionVersions(profile, profile.installedMaxExpansion); } } @@ -460,4 +474,11 @@ void LauncherCore::addUpdateButtons(const ProfileSettings& settings, QMessageBox }); messageBox.addButton(QMessageBox::StandardButton::Ok); -} \ No newline at end of file +} + +void LauncherCore::readExpansionVersions(ProfileSettings& info, int max) { + info.expansionVersions.clear(); + + for(int i = 0; i < max; i++) + info.expansionVersions.push_back(readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(info.gamePath, QString::number(i + 1)))); +} diff --git a/src/launchercore.h b/src/launchercore.h index e3b3b51..22aca79 100755 --- a/src/launchercore.h +++ b/src/launchercore.h @@ -21,6 +21,8 @@ struct ProfileSettings { int language = 1; // 1 is english, thats all i know QString gamePath, winePath, winePrefixPath; QString bootVersion, gameVersion; + int installedMaxExpansion = -1; + QList expansionVersions; // wine // 0 = system, 1 = custom, 2 = built-in (mac only) @@ -97,5 +99,7 @@ signals: void settingsChanged(); private: + void readExpansionVersions(ProfileSettings& info, int max); + QVector profileSettings; }; diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 8464b30..9c43f43 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -91,6 +91,9 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg }); gameBoxLayout->addWidget(gameDirectoryButton); + expansionVersionLabel = new QLabel(); + gameBoxLayout->addWidget(expansionVersionLabel); + auto loginBox = new QGroupBox("Login Options"); auto loginBoxLayout = new QFormLayout(); loginBox->setLayout(loginBoxLayout); @@ -294,6 +297,38 @@ void SettingsWindow::reloadControls() { directXCombo->setCurrentIndex(profile.useDX9 ? 1 : 0); currentGameDirectory->setText(profile.gamePath); + if(profile.installedMaxExpansion == -1) { + expansionVersionLabel->setText("No game installed."); + } else { + QString expacString; + if(profile.installedMaxExpansion >= 0) { + expacString += "A Realm Reborn"; + expacString += QString(" (%1)\n").arg(profile.gameVersion); + } + + if(profile.installedMaxExpansion >= 1) { + expacString += "Heavensward"; + expacString += QString(" (%1)\n").arg(profile.expansionVersions[0]); + } + + if(profile.installedMaxExpansion >= 2) { + expacString += "Stormblood"; + expacString += QString(" (%1)\n").arg(profile.expansionVersions[1]); + } + + if(profile.installedMaxExpansion >= 3) { + expacString += "Shadowbringers"; + expacString += QString(" (%1)\n").arg(profile.expansionVersions[2]); + } + + if(profile.installedMaxExpansion >= 4) { + expacString += "Endwalker"; + expacString += QString(" (%1)\n").arg(profile.expansionVersions[3]); + } + + expansionVersionLabel->setText(expacString); + } + // wine wineVersionCombo->setCurrentIndex(profile.wineVersion); selectWineButton->setEnabled(profile.wineVersion == 1); diff --git a/src/settingswindow.h b/src/settingswindow.h index 304eacc..2a0d29d 100644 --- a/src/settingswindow.h +++ b/src/settingswindow.h @@ -30,6 +30,7 @@ private: QLineEdit* nameEdit = nullptr; QComboBox* directXCombo = nullptr; QLabel* currentGameDirectory = nullptr; + QLabel* expansionVersionLabel = nullptr; // wine QComboBox* wineVersionCombo; diff --git a/src/squarelauncher.cpp b/src/squarelauncher.cpp index 4d9f031..f623ba5 100644 --- a/src/squarelauncher.cpp +++ b/src/squarelauncher.cpp @@ -92,8 +92,6 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) { auth.region = parts[5].toInt(); auth.maxExpansion = parts[13].toInt(); - readExpansionVersions(info, auth.maxExpansion); - registerSession(info); } } else { @@ -157,13 +155,6 @@ QString SquareLauncher::getBootHash(const LoginInformation& info) { return result; } -void SquareLauncher::readExpansionVersions(const LoginInformation& info, int max) { - expansionVersions.clear(); - - for(int i = 0; i < max; i++) - expansionVersions.push_back(window.readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(info.settings->gamePath, QString::number(i + 1)))); -} - void SquareLauncher::gateOpen() { QUrlQuery query; query.addQueryItem("", QString::number(QDateTime::currentMSecsSinceEpoch())); diff --git a/src/squarelauncher.h b/src/squarelauncher.h index 7d780ba..4c353e3 100644 --- a/src/squarelauncher.h +++ b/src/squarelauncher.h @@ -22,7 +22,6 @@ signals: private: QString getBootHash(const LoginInformation& info); - void readExpansionVersions(const LoginInformation& info, int max); QString stored, SID; LoginAuth auth;