mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-21 20:27:45 +00:00
Don't hardcode FFXIV expansion names
Astra will now dynamically load them from the game itself, making it much more future-proof for future expansion launches.
This commit is contained in:
parent
e4a2d6f59d
commit
8c2a79b5cf
4 changed files with 61 additions and 45 deletions
|
@ -41,13 +41,13 @@ struct ProfileSettings {
|
||||||
// game
|
// game
|
||||||
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, wineVersion;
|
QString bootVersion, wineVersion;
|
||||||
int installedMaxExpansion = -1;
|
int installedMaxExpansion = -1;
|
||||||
QList<QString> expansionVersions;
|
QVector<QString> gameVersions;
|
||||||
bool enableWatchdog = false;
|
bool enableWatchdog = false;
|
||||||
|
|
||||||
bool isGameInstalled() const {
|
bool isGameInstalled() const {
|
||||||
return !gameVersion.isEmpty();
|
return !gameVersions.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isWineInstalled() const {
|
bool isWineInstalled() const {
|
||||||
|
@ -175,14 +175,17 @@ public:
|
||||||
QString nativeLauncherVersion;
|
QString nativeLauncherVersion;
|
||||||
|
|
||||||
int defaultProfileIndex = 0;
|
int defaultProfileIndex = 0;
|
||||||
|
|
||||||
|
QVector<QString> expansionNames;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
void successfulLaunch();
|
void successfulLaunch();
|
||||||
void gameClosed();
|
void gameClosed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readExpansionVersions(ProfileSettings& info, int max);
|
|
||||||
bool checkIfInPath(QString program);
|
bool checkIfInPath(QString program);
|
||||||
|
void readGameData(ProfileSettings& profile);
|
||||||
|
|
||||||
QString getDefaultGamePath();
|
QString getDefaultGamePath();
|
||||||
QString getDefaultWinePrefixPath();
|
QString getDefaultWinePrefixPath();
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include "blowfish.h"
|
#include "blowfish.h"
|
||||||
#include "assetupdater.h"
|
#include "assetupdater.h"
|
||||||
#include "encryptedarg.h"
|
#include "encryptedarg.h"
|
||||||
|
#include "gamedata.h"
|
||||||
|
#include "exdparser.h"
|
||||||
|
|
||||||
#ifdef ENABLE_WATCHDOG
|
#ifdef ENABLE_WATCHDOG
|
||||||
#include "watchdog.h"
|
#include "watchdog.h"
|
||||||
|
@ -86,7 +88,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
|
||||||
gameArgs.push_back({"DEV.TestSID", auth.SID});
|
gameArgs.push_back({"DEV.TestSID", auth.SID});
|
||||||
gameArgs.push_back({"SYS.Region", QString::number(auth.region)});
|
gameArgs.push_back({"SYS.Region", QString::number(auth.region)});
|
||||||
gameArgs.push_back({"language", QString::number(profile.language)});
|
gameArgs.push_back({"language", QString::number(profile.language)});
|
||||||
gameArgs.push_back({"ver", profile.gameVersion});
|
gameArgs.push_back({"ver", profile.gameVersions[0]});
|
||||||
|
|
||||||
if(!auth.lobbyhost.isEmpty()) {
|
if(!auth.lobbyhost.isEmpty()) {
|
||||||
gameArgs.push_back({"DEV.GMServerHost", auth.frontierHost});
|
gameArgs.push_back({"DEV.GMServerHost", auth.frontierHost});
|
||||||
|
@ -151,7 +153,7 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au
|
||||||
startInfo["AssetDirectory"] = dataDir + "\\DalamudAssets";
|
startInfo["AssetDirectory"] = dataDir + "\\DalamudAssets";
|
||||||
startInfo["DefaultPluginDirectory"] = dataDir + "\\devPlugins";
|
startInfo["DefaultPluginDirectory"] = dataDir + "\\devPlugins";
|
||||||
startInfo["DelayInitializeMs"] = 0;
|
startInfo["DelayInitializeMs"] = 0;
|
||||||
startInfo["GameVersion"] = profile.gameVersion;
|
startInfo["GameVersion"] = profile.gameVersions[0];
|
||||||
startInfo["Language"] = profile.language;
|
startInfo["Language"] = profile.language;
|
||||||
startInfo["OptOutMbCollection"] = profile.dalamud.optOutOfMbCollection;
|
startInfo["OptOutMbCollection"] = profile.dalamud.optOutOfMbCollection;
|
||||||
|
|
||||||
|
@ -496,18 +498,38 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) {
|
||||||
void LauncherCore::readGameVersion() {
|
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.installedMaxExpansion = 0;
|
profile.installedMaxExpansion = 0;
|
||||||
|
|
||||||
for(auto dir : QDir(profile.gamePath + "/game/sqpack/").entryList(QDir::Filter::Dirs)) {
|
auto sqpackDirectories = QDir(profile.gamePath + "/game/sqpack/").entryList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot);
|
||||||
if(dir.contains("ex") && dir.length() == 3 && dir[2].isDigit()) {
|
profile.gameVersions.resize(sqpackDirectories.size());
|
||||||
const int expacVersion = dir[2].digitValue();
|
|
||||||
|
|
||||||
profile.installedMaxExpansion = std::max(profile.installedMaxExpansion, expacVersion);
|
for(auto dir : sqpackDirectories) {
|
||||||
|
if(dir.contains("ex") || dir == "ffxiv") {
|
||||||
|
int expansion = -1;
|
||||||
|
|
||||||
|
// we're going to treat ffxiv as ex0
|
||||||
|
if(dir == "ffxiv") {
|
||||||
|
expansion = 0;
|
||||||
|
|
||||||
|
profile.gameVersions[0] = readVersion(profile.gamePath + QString("/game/ffxivgame.ver"));
|
||||||
|
} else {
|
||||||
|
QString originalName = dir.remove("ex");
|
||||||
|
bool ok = false;
|
||||||
|
int convertedInt = originalName.toInt(&ok);
|
||||||
|
if(ok)
|
||||||
|
expansion = convertedInt;
|
||||||
|
|
||||||
|
profile.gameVersions[convertedInt] = readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(profile.gamePath, QString::number(expansion)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(expansion != -1) {
|
||||||
|
profile.installedMaxExpansion = std::max(profile.installedMaxExpansion, expansion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readExpansionVersions(profile, profile.installedMaxExpansion);
|
if(profile.installedMaxExpansion >= 0)
|
||||||
|
readGameData(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,13 +680,6 @@ 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))));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LauncherCore::checkIfInPath(const QString program) {
|
bool LauncherCore::checkIfInPath(const QString program) {
|
||||||
// TODO: also check /usr/local/bin, /bin32 etc (basically read $PATH)
|
// TODO: also check /usr/local/bin, /bin32 etc (basically read $PATH)
|
||||||
const QString directory = "/usr/bin";
|
const QString directory = "/usr/bin";
|
||||||
|
@ -706,3 +721,16 @@ void LauncherCore::addRegistryKey(const ProfileSettings& settings,
|
||||||
process->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
process->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
||||||
launchExecutable(settings, process, {"reg", "add", key, "/v", value, "/d", data, "/f" }, false, false);
|
launchExecutable(settings, process, {"reg", "add", key, "/v", value, "/d", data, "/f" }, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LauncherCore::readGameData(ProfileSettings& profile) {
|
||||||
|
GameData data(profile.gamePath.toStdString() + "/game/sqpack");
|
||||||
|
|
||||||
|
if(auto exh = data.readExcelSheet("ExVersion")) {
|
||||||
|
auto path = getEXDFilename(*exh, "exversion", "en", exh->pages[0]);
|
||||||
|
auto exd = readEXD(*exh, *data.extractFile("exd/" + path), exh->pages[0]);
|
||||||
|
|
||||||
|
for(auto row : exd.rows) {
|
||||||
|
expansionNames.push_back(row.data[0].data.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -485,29 +485,14 @@ void SettingsWindow::reloadControls() {
|
||||||
expacString += "Boot";
|
expacString += "Boot";
|
||||||
expacString += QString(" (%1)\n").arg(profile.bootVersion);
|
expacString += QString(" (%1)\n").arg(profile.bootVersion);
|
||||||
|
|
||||||
if(profile.installedMaxExpansion >= 0) {
|
for(int i = 0; i < profile.gameVersions.size(); i++) {
|
||||||
expacString += "A Realm Reborn";
|
QString expansionName = "Unknown Expansion";
|
||||||
expacString += QString(" (%1)\n").arg(profile.gameVersion);
|
if(i < core.expansionNames.size()) {
|
||||||
|
expansionName = core.expansionNames[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(profile.installedMaxExpansion >= 1) {
|
expacString += expansionName;
|
||||||
expacString += "Heavensward";
|
expacString += QString(" (%1)\n").arg(profile.gameVersions[i]);
|
||||||
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);
|
expansionVersionLabel->setText(expacString);
|
||||||
|
|
|
@ -161,7 +161,7 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme("https");
|
url.setScheme("https");
|
||||||
url.setHost("patch-gamever.ffxiv.com");
|
url.setHost("patch-gamever.ffxiv.com");
|
||||||
url.setPath(QString("/http/win32/ffxivneo_release_game/%1/%2").arg(info.settings->gameVersion, SID));
|
url.setPath(QString("/http/win32/ffxivneo_release_game/%1/%2").arg(info.settings->gameVersions[0], SID));
|
||||||
|
|
||||||
auto request = QNetworkRequest(url);
|
auto request = QNetworkRequest(url);
|
||||||
window.setSSL(request);
|
window.setSSL(request);
|
||||||
|
@ -171,8 +171,8 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
|
||||||
|
|
||||||
QString report = info.settings->bootVersion + "=" + getBootHash(info);
|
QString report = info.settings->bootVersion + "=" + getBootHash(info);
|
||||||
|
|
||||||
for(int i = 0; i < info.settings->installedMaxExpansion; i++)
|
for(int i = 1; i < info.settings->installedMaxExpansion; i++)
|
||||||
report += QString("\nex%1\t%2").arg(QString::number(i + 1), info.settings->expansionVersions[i]);
|
report += QString("\nex%1\t%2").arg(QString::number(i), info.settings->gameVersions[i]);
|
||||||
|
|
||||||
auto reply = window.mgr->post(request, report.toUtf8());
|
auto reply = window.mgr->post(request, report.toUtf8());
|
||||||
connect(reply, &QNetworkReply::finished, [=] {
|
connect(reply, &QNetworkReply::finished, [=] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue