1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Load expansion versions on launch, and show versions in settings

This commit is contained in:
redstrate 2021-12-02 15:02:59 -05:00
parent 9668c0c30e
commit 34eb4b4f3c
6 changed files with 62 additions and 11 deletions

View file

@ -342,6 +342,20 @@ void LauncherCore::readGameVersion() {
for(auto& profile : profileSettings) { for(auto& profile : profileSettings) {
profile.bootVersion = readVersion(profile.gamePath + "/boot/ffxivboot.ver"); profile.bootVersion = readVersion(profile.gamePath + "/boot/ffxivboot.ver");
profile.gameVersion = readVersion(profile.gamePath + "/game/ffxivgame.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);
} }
} }
@ -461,3 +475,10 @@ void LauncherCore::addUpdateButtons(const ProfileSettings& settings, QMessageBox
messageBox.addButton(QMessageBox::StandardButton::Ok); messageBox.addButton(QMessageBox::StandardButton::Ok);
} }
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))));
}

View file

@ -21,6 +21,8 @@ struct ProfileSettings {
int language = 1; // 1 is english, thats all i know int language = 1; // 1 is english, thats all i know
QString gamePath, winePath, winePrefixPath; QString gamePath, winePath, winePrefixPath;
QString bootVersion, gameVersion; QString bootVersion, gameVersion;
int installedMaxExpansion = -1;
QList<QString> expansionVersions;
// wine // wine
// 0 = system, 1 = custom, 2 = built-in (mac only) // 0 = system, 1 = custom, 2 = built-in (mac only)
@ -97,5 +99,7 @@ signals:
void settingsChanged(); void settingsChanged();
private: private:
void readExpansionVersions(ProfileSettings& info, int max);
QVector<ProfileSettings> profileSettings; QVector<ProfileSettings> profileSettings;
}; };

View file

@ -91,6 +91,9 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg
}); });
gameBoxLayout->addWidget(gameDirectoryButton); gameBoxLayout->addWidget(gameDirectoryButton);
expansionVersionLabel = new QLabel();
gameBoxLayout->addWidget(expansionVersionLabel);
auto loginBox = new QGroupBox("Login Options"); auto loginBox = new QGroupBox("Login Options");
auto loginBoxLayout = new QFormLayout(); auto loginBoxLayout = new QFormLayout();
loginBox->setLayout(loginBoxLayout); loginBox->setLayout(loginBoxLayout);
@ -294,6 +297,38 @@ void SettingsWindow::reloadControls() {
directXCombo->setCurrentIndex(profile.useDX9 ? 1 : 0); directXCombo->setCurrentIndex(profile.useDX9 ? 1 : 0);
currentGameDirectory->setText(profile.gamePath); 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 // wine
wineVersionCombo->setCurrentIndex(profile.wineVersion); wineVersionCombo->setCurrentIndex(profile.wineVersion);
selectWineButton->setEnabled(profile.wineVersion == 1); selectWineButton->setEnabled(profile.wineVersion == 1);

View file

@ -30,6 +30,7 @@ private:
QLineEdit* nameEdit = nullptr; QLineEdit* nameEdit = nullptr;
QComboBox* directXCombo = nullptr; QComboBox* directXCombo = nullptr;
QLabel* currentGameDirectory = nullptr; QLabel* currentGameDirectory = nullptr;
QLabel* expansionVersionLabel = nullptr;
// wine // wine
QComboBox* wineVersionCombo; QComboBox* wineVersionCombo;

View file

@ -92,8 +92,6 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) {
auth.region = parts[5].toInt(); auth.region = parts[5].toInt();
auth.maxExpansion = parts[13].toInt(); auth.maxExpansion = parts[13].toInt();
readExpansionVersions(info, auth.maxExpansion);
registerSession(info); registerSession(info);
} }
} else { } else {
@ -157,13 +155,6 @@ QString SquareLauncher::getBootHash(const LoginInformation& info) {
return result; 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() { void SquareLauncher::gateOpen() {
QUrlQuery query; QUrlQuery query;
query.addQueryItem("", QString::number(QDateTime::currentMSecsSinceEpoch())); query.addQueryItem("", QString::number(QDateTime::currentMSecsSinceEpoch()));

View file

@ -22,7 +22,6 @@ signals:
private: private:
QString getBootHash(const LoginInformation& info); QString getBootHash(const LoginInformation& info);
void readExpansionVersions(const LoginInformation& info, int max);
QString stored, SID; QString stored, SID;
LoginAuth auth; LoginAuth auth;