mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-23 04:57:44 +00:00
Add native launcher update support
When updating to this new commit, you will download the 1.1.0 release automatically since we create a new version file. This commit also fixes a bug where in certain cases the asset updating process could end early. The native launcher version is also visible from the settings window!
This commit is contained in:
parent
dbbcb67134
commit
50ad93ee8f
6 changed files with 74 additions and 22 deletions
|
@ -33,13 +33,14 @@ private:
|
||||||
|
|
||||||
QString remoteDalamudVersion;
|
QString remoteDalamudVersion;
|
||||||
QString remoteRuntimeVersion;
|
QString remoteRuntimeVersion;
|
||||||
|
QString remoteNativeLauncherVersion;
|
||||||
|
|
||||||
QTemporaryDir tempDir;
|
QTemporaryDir tempDir;
|
||||||
|
|
||||||
bool doneDownloadingDalamud = true;
|
bool doneDownloadingDalamud = false;
|
||||||
bool doneDownloadingNativelauncher = true;
|
bool doneDownloadingNativelauncher = false;
|
||||||
bool doneDownloadingRuntimeCore = true;
|
bool doneDownloadingRuntimeCore = false;
|
||||||
bool doneDownloadingRuntimeDesktop = true;
|
bool doneDownloadingRuntimeDesktop = false;
|
||||||
bool needsRuntimeInstall = false;
|
bool needsRuntimeInstall = false;
|
||||||
bool needsDalamudInstall = false;
|
bool needsDalamudInstall = false;
|
||||||
bool needsNativeInstall = false;
|
bool needsNativeInstall = false;
|
||||||
|
|
|
@ -142,6 +142,7 @@ public:
|
||||||
QString dalamudVersion;
|
QString dalamudVersion;
|
||||||
int dalamudAssetVersion = -1;
|
int dalamudAssetVersion = -1;
|
||||||
QString runtimeVersion;
|
QString runtimeVersion;
|
||||||
|
QString nativeLauncherVersion;
|
||||||
|
|
||||||
int defaultProfileIndex = 0;
|
int defaultProfileIndex = 0;
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -55,6 +55,7 @@ private:
|
||||||
QCheckBox* enableDalamudBox = nullptr;
|
QCheckBox* enableDalamudBox = nullptr;
|
||||||
QLabel* dalamudVersionLabel = nullptr;
|
QLabel* dalamudVersionLabel = nullptr;
|
||||||
QLabel* dalamudAssetVersionLabel = nullptr;
|
QLabel* dalamudAssetVersionLabel = nullptr;
|
||||||
|
QLabel* nativeLauncherVersionLabel = nullptr;
|
||||||
QCheckBox* dalamudOptOutBox = nullptr;
|
QCheckBox* dalamudOptOutBox = nullptr;
|
||||||
|
|
||||||
bool currentlyReloadingControls = false;
|
bool currentlyReloadingControls = false;
|
||||||
|
|
|
@ -21,9 +21,10 @@ const QString baseDalamudAssetDistribution = baseGoatDomain + "/DalamudAssets";
|
||||||
const QString dalamudAssetManifestURL = baseDalamudAssetDistribution + "/asset.json";
|
const QString dalamudAssetManifestURL = baseDalamudAssetDistribution + "/asset.json";
|
||||||
|
|
||||||
const QString baseNativeLauncherDistribution =
|
const QString baseNativeLauncherDistribution =
|
||||||
"https://github.com/redstrate/nativelauncher/releases/download/";
|
"https://xiv.zone/astra-distrib/nativelauncher";
|
||||||
const QString nativeLauncherLatestPackageURL =
|
const QString nativeLauncherLatestPackageURL =
|
||||||
baseNativeLauncherDistribution + "/latest/NativeLauncher.exe";
|
baseNativeLauncherDistribution + "/NativeLauncher.exe";
|
||||||
|
const QString nativeLauncherVersionManifestURL = baseNativeLauncherDistribution + "/version";
|
||||||
|
|
||||||
const QString dotnetRuntimePackageURL =
|
const QString dotnetRuntimePackageURL =
|
||||||
"https://dotnetcli.azureedge.net/dotnet/Runtime/%1/dotnet-runtime-%1-win-x64.zip";
|
"https://dotnetcli.azureedge.net/dotnet/Runtime/%1/dotnet-runtime-%1-win-x64.zip";
|
||||||
|
@ -80,6 +81,24 @@ void AssetUpdater::update(const ProfileSettings& profile) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// native launcher
|
||||||
|
{
|
||||||
|
QNetworkRequest request(nativeLauncherVersionManifestURL);
|
||||||
|
|
||||||
|
remoteNativeLauncherVersion.clear();
|
||||||
|
|
||||||
|
auto reply = launcher.mgr->get(request);
|
||||||
|
connect(reply, &QNetworkReply::finished, [this, profile, reply] {
|
||||||
|
dialog->setLabelText("Checking for native launcher updates...");
|
||||||
|
|
||||||
|
remoteNativeLauncherVersion = reply->readAll().trimmed();
|
||||||
|
|
||||||
|
qInfo() << "Latest native launcher version reported: " << remoteNativeLauncherVersion;
|
||||||
|
|
||||||
|
checkIfCheckingIsDone();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// dalamud injector / net runtime / nativelauncher
|
// dalamud injector / net runtime / nativelauncher
|
||||||
// they're all updated in unison, so there's no reason to have multiple checks
|
// they're all updated in unison, so there's no reason to have multiple checks
|
||||||
{
|
{
|
||||||
|
@ -123,16 +142,31 @@ void AssetUpdater::beginInstall() {
|
||||||
|
|
||||||
if(!success) {
|
if(!success) {
|
||||||
// TODO: handle failure here
|
// TODO: handle failure here
|
||||||
|
qInfo() << "Failed to install Dalamud!";
|
||||||
} else {
|
} else {
|
||||||
needsDalamudInstall = false;
|
needsDalamudInstall = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(needsNativeInstall) {
|
if(needsNativeInstall) {
|
||||||
QFile::copy(tempDir.path() + "/NativeLauncher.exe",
|
qInfo() << "Installing native launcher...";
|
||||||
|
|
||||||
|
if(QFile::exists(dataDir + "/NativeLauncher.exe"))
|
||||||
|
QFile::remove(dataDir + "/NativeLauncher.exe");
|
||||||
|
|
||||||
|
bool success = QFile::copy(tempDir.path() + "/NativeLauncher.exe",
|
||||||
dataDir + "/NativeLauncher.exe");
|
dataDir + "/NativeLauncher.exe");
|
||||||
|
|
||||||
needsNativeInstall = false;
|
if(!success) {
|
||||||
|
qInfo() << "Failed to install native launcher!";
|
||||||
|
} else {
|
||||||
|
QFile file(dataDir + "/nativelauncher.ver");
|
||||||
|
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
|
file.write(remoteNativeLauncherVersion.toUtf8());
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
needsNativeInstall = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(needsRuntimeInstall) {
|
if(needsRuntimeInstall) {
|
||||||
|
@ -145,7 +179,7 @@ void AssetUpdater::beginInstall() {
|
||||||
.empty();
|
.empty();
|
||||||
|
|
||||||
if(!success) {
|
if(!success) {
|
||||||
// TODO: handle failure here
|
qInfo() << "Failed to install dotnet!";
|
||||||
} else {
|
} else {
|
||||||
QFile file(dataDir + "/DalamudRuntime/runtime.ver");
|
QFile file(dataDir + "/DalamudRuntime/runtime.ver");
|
||||||
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
|
@ -201,7 +235,7 @@ void AssetUpdater::checkIfCheckingIsDone() {
|
||||||
if(dialog->wasCanceled())
|
if(dialog->wasCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1) {
|
if(remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1 || remoteNativeLauncherVersion.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,8 +246,6 @@ void AssetUpdater::checkIfCheckingIsDone() {
|
||||||
|
|
||||||
// dalamud injector / net runtime
|
// dalamud injector / net runtime
|
||||||
if(launcher.runtimeVersion != remoteRuntimeVersion) {
|
if(launcher.runtimeVersion != remoteRuntimeVersion) {
|
||||||
doneDownloadingRuntimeCore = false;
|
|
||||||
doneDownloadingRuntimeDesktop = false;
|
|
||||||
needsRuntimeInstall = true;
|
needsRuntimeInstall = true;
|
||||||
|
|
||||||
// core
|
// core
|
||||||
|
@ -267,7 +299,7 @@ void AssetUpdater::checkIfCheckingIsDone() {
|
||||||
|
|
||||||
if(remoteDalamudVersion != launcher.dalamudVersion) {
|
if(remoteDalamudVersion != launcher.dalamudVersion) {
|
||||||
qInfo() << "Downloading Dalamud...";
|
qInfo() << "Downloading Dalamud...";
|
||||||
doneDownloadingDalamud = false;
|
|
||||||
needsDalamudInstall = true;
|
needsDalamudInstall = true;
|
||||||
|
|
||||||
QNetworkRequest request(dalamudLatestPackageURL);
|
QNetworkRequest request(dalamudLatestPackageURL);
|
||||||
|
@ -346,14 +378,11 @@ void AssetUpdater::checkIfCheckingIsDone() {
|
||||||
checkIfFinished();
|
checkIfFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
// nativelauncher
|
if(remoteNativeLauncherVersion != launcher.nativeLauncherVersion) {
|
||||||
const bool hasNative = QFile::exists(dataDir + "/NativeLauncher.exe");
|
qInfo() << "Native launcher out of date.";
|
||||||
if (!hasNative) {
|
|
||||||
// download nativelauncher release (needed to launch the game with fixed
|
dialog->setLabelText("Updating native launcher...");
|
||||||
// ACLs)
|
|
||||||
|
|
||||||
qInfo() << "Downloading NativeLauncher...";
|
|
||||||
doneDownloadingNativelauncher = false;
|
|
||||||
needsNativeInstall = true;
|
needsNativeInstall = true;
|
||||||
|
|
||||||
QNetworkRequest request(nativeLauncherLatestPackageURL);
|
QNetworkRequest request(nativeLauncherLatestPackageURL);
|
||||||
|
@ -362,8 +391,6 @@ void AssetUpdater::checkIfCheckingIsDone() {
|
||||||
connect(reply, &QNetworkReply::finished, [this, reply] {
|
connect(reply, &QNetworkReply::finished, [this, reply] {
|
||||||
qInfo() << "NativeLauncher finished downloading!";
|
qInfo() << "NativeLauncher finished downloading!";
|
||||||
|
|
||||||
dialog->setLabelText("Updating Nativelauncher...");
|
|
||||||
|
|
||||||
QFile file(tempDir.path() + "/NativeLauncher.exe");
|
QFile file(tempDir.path() + "/NativeLauncher.exe");
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
file.write(reply->readAll());
|
file.write(reply->readAll());
|
||||||
|
@ -373,5 +400,11 @@ void AssetUpdater::checkIfCheckingIsDone() {
|
||||||
|
|
||||||
checkIfFinished();
|
checkIfFinished();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
qInfo() << "Native launcher up to date.";
|
||||||
|
|
||||||
|
doneDownloadingNativelauncher = true;
|
||||||
|
|
||||||
|
checkIfFinished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,6 +305,13 @@ void LauncherCore::readInitialInformation() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(QFile::exists(dataDir + "/nativelauncher.ver")) {
|
||||||
|
QFile nativeVer(dataDir + "/nativelauncher.ver");
|
||||||
|
nativeVer.open(QFile::ReadOnly | QFile::Text);
|
||||||
|
|
||||||
|
nativeLauncherVersion = QString(nativeVer.readAll());
|
||||||
|
}
|
||||||
|
|
||||||
auto profiles = settings.childGroups();
|
auto profiles = settings.childGroups();
|
||||||
|
|
||||||
// create the Default profile if it doesnt exist
|
// create the Default profile if it doesnt exist
|
||||||
|
|
|
@ -373,6 +373,9 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC
|
||||||
|
|
||||||
dalamudAssetVersionLabel = new QLabel();
|
dalamudAssetVersionLabel = new QLabel();
|
||||||
dalamudBoxLayout->addRow("Dalamud Asset Version", dalamudAssetVersionLabel);
|
dalamudBoxLayout->addRow("Dalamud Asset Version", dalamudAssetVersionLabel);
|
||||||
|
|
||||||
|
nativeLauncherVersionLabel = new QLabel();
|
||||||
|
dalamudBoxLayout->addRow("Native Launcher Version", nativeLauncherVersionLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
tabWidget->setCurrentIndex(defaultTab);
|
tabWidget->setCurrentIndex(defaultTab);
|
||||||
|
@ -493,6 +496,12 @@ void SettingsWindow::reloadControls() {
|
||||||
dalamudAssetVersionLabel->setText(QString::number(core.dalamudAssetVersion));
|
dalamudAssetVersionLabel->setText(QString::number(core.dalamudAssetVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(core.nativeLauncherVersion.isEmpty()) {
|
||||||
|
nativeLauncherVersionLabel->setText("Native launcher is not installed.");
|
||||||
|
} else {
|
||||||
|
nativeLauncherVersionLabel->setText(core.nativeLauncherVersion);
|
||||||
|
}
|
||||||
|
|
||||||
dalamudOptOutBox->setChecked(profile.dalamud.optOutOfMbCollection);
|
dalamudOptOutBox->setChecked(profile.dalamud.optOutOfMbCollection);
|
||||||
|
|
||||||
window.reloadControls();
|
window.reloadControls();
|
||||||
|
|
Loading…
Add table
Reference in a new issue