mirror of
https://github.com/redstrate/Astra.git
synced 2025-06-08 15:07:45 +00:00
Update Dalamud automatically
This commit is contained in:
parent
5afca07f1e
commit
02beef81ce
2 changed files with 46 additions and 3 deletions
|
@ -3,6 +3,8 @@
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include <quazip/JlCompress.h>
|
#include <quazip/JlCompress.h>
|
||||||
|
|
||||||
|
@ -10,6 +12,7 @@
|
||||||
|
|
||||||
const QString dalamudRemotePath = "https://goatcorp.github.io/dalamud-distrib/";
|
const QString dalamudRemotePath = "https://goatcorp.github.io/dalamud-distrib/";
|
||||||
const QString dalamudVersion = "latest";
|
const QString dalamudVersion = "latest";
|
||||||
|
const QString dalamudVersionPath = dalamudRemotePath + "/version";
|
||||||
|
|
||||||
const QString nativeLauncherRemotePath = "https://github.com/redstrate/nativelauncher/releases/download/";
|
const QString nativeLauncherRemotePath = "https://github.com/redstrate/nativelauncher/releases/download/";
|
||||||
const QString nativeLauncherVersion = "v1.0.0";
|
const QString nativeLauncherVersion = "v1.0.0";
|
||||||
|
@ -25,8 +28,38 @@ void AssetUpdater::update(const ProfileSettings& profile) {
|
||||||
|
|
||||||
const bool hasDalamud = QFile::exists(dataDir + "/NativeLauncher.exe") && QFile::exists(dataDir + "/Dalamud");
|
const bool hasDalamud = QFile::exists(dataDir + "/NativeLauncher.exe") && QFile::exists(dataDir + "/Dalamud");
|
||||||
|
|
||||||
|
bool isDalamudUpdated = false;
|
||||||
|
if(hasDalamud) {
|
||||||
|
if(remoteDalamudVersion.isEmpty()) {
|
||||||
|
QNetworkRequest request(dalamudVersionPath);
|
||||||
|
|
||||||
|
auto reply = launcher.mgr->get(request);
|
||||||
|
reply->setObjectName("DalamudVersionCheck");
|
||||||
|
currentSettings = &profile; // TODO: this is dirty, should change
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if(QFile::exists(dataDir + "/Dalamud/Dalamud.deps.json")) {
|
||||||
|
QFile depsJson(dataDir + "/Dalamud/Dalamud.deps.json");
|
||||||
|
depsJson.open(QFile::ReadOnly);
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(depsJson.readAll());
|
||||||
|
|
||||||
|
// TODO: UGLY
|
||||||
|
QString versionString = doc["targets"].toObject()[".NETCoreApp,Version=v5.0"].toObject().keys().filter("Dalamud")[0];
|
||||||
|
versionString = versionString.remove("Dalamud/");
|
||||||
|
|
||||||
|
if(versionString != remoteDalamudVersion) {
|
||||||
|
isDalamudUpdated = false;
|
||||||
|
} else {
|
||||||
|
isDalamudUpdated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// first we determine if we need dalamud
|
// first we determine if we need dalamud
|
||||||
const bool needsDalamud = profile.enableDalamud && !hasDalamud;
|
const bool needsDalamud = profile.enableDalamud && (!hasDalamud || !isDalamudUpdated);
|
||||||
if(needsDalamud) {
|
if(needsDalamud) {
|
||||||
// download nativelauncher release (needed to launch the game with fixed ACLs)
|
// download nativelauncher release (needed to launch the game with fixed ACLs)
|
||||||
{
|
{
|
||||||
|
@ -70,6 +103,12 @@ void AssetUpdater::finishDownload(QNetworkReply* reply) {
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
checkIfFinished();
|
checkIfFinished();
|
||||||
|
} else if(reply->objectName() == "DalamudVersionCheck") {
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
||||||
|
remoteDalamudVersion = doc["AssemblyVersion"].toString();
|
||||||
|
|
||||||
|
update(*currentSettings);
|
||||||
|
currentSettings = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,5 +22,9 @@ signals:
|
||||||
private:
|
private:
|
||||||
LauncherCore& launcher;
|
LauncherCore& launcher;
|
||||||
|
|
||||||
|
const ProfileSettings* currentSettings = nullptr;
|
||||||
|
|
||||||
|
QString remoteDalamudVersion;
|
||||||
|
|
||||||
QTemporaryDir tempDir;
|
QTemporaryDir tempDir;
|
||||||
};
|
};
|
Loading…
Add table
Reference in a new issue