diff --git a/include/assetupdater.h b/include/assetupdater.h index 9a4f59c..1aaab6c 100644 --- a/include/assetupdater.h +++ b/include/assetupdater.h @@ -33,13 +33,14 @@ private: QString remoteDalamudVersion; QString remoteRuntimeVersion; + QString remoteNativeLauncherVersion; QTemporaryDir tempDir; - bool doneDownloadingDalamud = true; - bool doneDownloadingNativelauncher = true; - bool doneDownloadingRuntimeCore = true; - bool doneDownloadingRuntimeDesktop = true; + bool doneDownloadingDalamud = false; + bool doneDownloadingNativelauncher = false; + bool doneDownloadingRuntimeCore = false; + bool doneDownloadingRuntimeDesktop = false; bool needsRuntimeInstall = false; bool needsDalamudInstall = false; bool needsNativeInstall = false; diff --git a/include/launchercore.h b/include/launchercore.h index 5ba9b6a..bc6edc9 100755 --- a/include/launchercore.h +++ b/include/launchercore.h @@ -142,6 +142,7 @@ public: QString dalamudVersion; int dalamudAssetVersion = -1; QString runtimeVersion; + QString nativeLauncherVersion; int defaultProfileIndex = 0; signals: diff --git a/include/settingswindow.h b/include/settingswindow.h index ef381af..1a86212 100644 --- a/include/settingswindow.h +++ b/include/settingswindow.h @@ -55,6 +55,7 @@ private: QCheckBox* enableDalamudBox = nullptr; QLabel* dalamudVersionLabel = nullptr; QLabel* dalamudAssetVersionLabel = nullptr; + QLabel* nativeLauncherVersionLabel = nullptr; QCheckBox* dalamudOptOutBox = nullptr; bool currentlyReloadingControls = false; diff --git a/src/assetupdater.cpp b/src/assetupdater.cpp index 383c8e8..cd2d533 100644 --- a/src/assetupdater.cpp +++ b/src/assetupdater.cpp @@ -21,9 +21,10 @@ const QString baseDalamudAssetDistribution = baseGoatDomain + "/DalamudAssets"; const QString dalamudAssetManifestURL = baseDalamudAssetDistribution + "/asset.json"; const QString baseNativeLauncherDistribution = - "https://github.com/redstrate/nativelauncher/releases/download/"; + "https://xiv.zone/astra-distrib/nativelauncher"; const QString nativeLauncherLatestPackageURL = - baseNativeLauncherDistribution + "/latest/NativeLauncher.exe"; + baseNativeLauncherDistribution + "/NativeLauncher.exe"; +const QString nativeLauncherVersionManifestURL = baseNativeLauncherDistribution + "/version"; const QString dotnetRuntimePackageURL = "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 // they're all updated in unison, so there's no reason to have multiple checks { @@ -123,16 +142,31 @@ void AssetUpdater::beginInstall() { if(!success) { // TODO: handle failure here + qInfo() << "Failed to install Dalamud!"; } else { needsDalamudInstall = false; } } 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"); - 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) { @@ -145,7 +179,7 @@ void AssetUpdater::beginInstall() { .empty(); if(!success) { - // TODO: handle failure here + qInfo() << "Failed to install dotnet!"; } else { QFile file(dataDir + "/DalamudRuntime/runtime.ver"); file.open(QIODevice::WriteOnly | QIODevice::Text); @@ -201,7 +235,7 @@ void AssetUpdater::checkIfCheckingIsDone() { if(dialog->wasCanceled()) return; - if(remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1) { + if(remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1 || remoteNativeLauncherVersion.isEmpty()) { return; } @@ -212,8 +246,6 @@ void AssetUpdater::checkIfCheckingIsDone() { // dalamud injector / net runtime if(launcher.runtimeVersion != remoteRuntimeVersion) { - doneDownloadingRuntimeCore = false; - doneDownloadingRuntimeDesktop = false; needsRuntimeInstall = true; // core @@ -267,7 +299,7 @@ void AssetUpdater::checkIfCheckingIsDone() { if(remoteDalamudVersion != launcher.dalamudVersion) { qInfo() << "Downloading Dalamud..."; - doneDownloadingDalamud = false; + needsDalamudInstall = true; QNetworkRequest request(dalamudLatestPackageURL); @@ -346,14 +378,11 @@ void AssetUpdater::checkIfCheckingIsDone() { checkIfFinished(); } - // nativelauncher - const bool hasNative = QFile::exists(dataDir + "/NativeLauncher.exe"); - if (!hasNative) { - // download nativelauncher release (needed to launch the game with fixed - // ACLs) + if(remoteNativeLauncherVersion != launcher.nativeLauncherVersion) { + qInfo() << "Native launcher out of date."; + + dialog->setLabelText("Updating native launcher..."); - qInfo() << "Downloading NativeLauncher..."; - doneDownloadingNativelauncher = false; needsNativeInstall = true; QNetworkRequest request(nativeLauncherLatestPackageURL); @@ -362,8 +391,6 @@ void AssetUpdater::checkIfCheckingIsDone() { connect(reply, &QNetworkReply::finished, [this, reply] { qInfo() << "NativeLauncher finished downloading!"; - dialog->setLabelText("Updating Nativelauncher..."); - QFile file(tempDir.path() + "/NativeLauncher.exe"); file.open(QIODevice::WriteOnly); file.write(reply->readAll()); @@ -373,5 +400,11 @@ void AssetUpdater::checkIfCheckingIsDone() { checkIfFinished(); }); + } else { + qInfo() << "Native launcher up to date."; + + doneDownloadingNativelauncher = true; + + checkIfFinished(); } } diff --git a/src/launchercore.cpp b/src/launchercore.cpp index 8087131..3e55358 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -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(); // create the Default profile if it doesnt exist diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 4792676..6ed392b 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -373,6 +373,9 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC dalamudAssetVersionLabel = new QLabel(); dalamudBoxLayout->addRow("Dalamud Asset Version", dalamudAssetVersionLabel); + + nativeLauncherVersionLabel = new QLabel(); + dalamudBoxLayout->addRow("Native Launcher Version", nativeLauncherVersionLabel); } tabWidget->setCurrentIndex(defaultTab); @@ -493,6 +496,12 @@ void SettingsWindow::reloadControls() { 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); window.reloadControls();