diff --git a/include/assetupdater.h b/include/assetupdater.h index 1aaab6c..d11ac2f 100644 --- a/include/assetupdater.h +++ b/include/assetupdater.h @@ -5,6 +5,8 @@ #include #include +#include "launchercore.h" + class LauncherCore; class QNetworkReply; struct ProfileSettings; @@ -29,7 +31,7 @@ private: QProgressDialog* dialog; - const ProfileSettings* currentSettings = nullptr; + DalamudChannel chosenChannel; QString remoteDalamudVersion; QString remoteRuntimeVersion; diff --git a/include/launchercore.h b/include/launchercore.h index 6b6782b..58ec0b0 100755 --- a/include/launchercore.h +++ b/include/launchercore.h @@ -27,6 +27,12 @@ enum class WineType { Builtin // macos only }; +enum class DalamudChannel { + Stable, + Staging, + Net5 +}; + struct ProfileSettings { QUuid uuid; QString name; @@ -68,6 +74,7 @@ struct ProfileSettings { struct DalamudOptions { bool enabled = false; bool optOutOfMbCollection = false; + DalamudChannel channel = DalamudChannel::Stable; } dalamud; // login diff --git a/include/settingswindow.h b/include/settingswindow.h index 22b1a70..d99aeef 100644 --- a/include/settingswindow.h +++ b/include/settingswindow.h @@ -62,6 +62,7 @@ private: QLabel* dalamudAssetVersionLabel = nullptr; QLabel* nativeLauncherVersionLabel = nullptr; QCheckBox* dalamudOptOutBox = nullptr; + QComboBox* dalamudChannel = nullptr; bool currentlyReloadingControls = false; diff --git a/src/assetupdater.cpp b/src/assetupdater.cpp index cd2d533..9592ec6 100644 --- a/src/assetupdater.cpp +++ b/src/assetupdater.cpp @@ -13,9 +13,9 @@ const QString baseGoatDomain = "https://goatcorp.github.io"; -const QString baseDalamudDistribution = baseGoatDomain + "/dalamud-distrib"; -const QString dalamudLatestPackageURL = baseDalamudDistribution + "/latest.zip"; -const QString dalamudVersionManifestURL = baseDalamudDistribution + "/version"; +const QString baseDalamudDistribution = baseGoatDomain + "/dalamud-distrib/"; +const QString dalamudLatestPackageURL = baseDalamudDistribution + "%1latest.zip"; +const QString dalamudVersionManifestURL = baseDalamudDistribution + "%1version"; const QString baseDalamudAssetDistribution = baseGoatDomain + "/DalamudAssets"; const QString dalamudAssetManifestURL = baseDalamudAssetDistribution + "/asset.json"; @@ -31,6 +31,12 @@ const QString dotnetRuntimePackageURL = const QString dotnetDesktopPackageURL = "https://dotnetcli.azureedge.net/dotnet/WindowsDesktop/%1/windowsdesktop-runtime-%1-win-x64.zip"; +QMap channelToDistribPrefix = { + {DalamudChannel::Stable, "/"}, + {DalamudChannel::Staging, "stg/"}, + {DalamudChannel::Net5, "net5/"} +}; + AssetUpdater::AssetUpdater(LauncherCore& launcher) : launcher(launcher) { launcher.mgr->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy); @@ -102,7 +108,9 @@ void AssetUpdater::update(const ProfileSettings& profile) { // dalamud injector / net runtime / nativelauncher // they're all updated in unison, so there's no reason to have multiple checks { - QNetworkRequest request(dalamudVersionManifestURL); + QNetworkRequest request(dalamudVersionManifestURL.arg(channelToDistribPrefix[profile.dalamud.channel])); + + chosenChannel = profile.dalamud.channel; remoteDalamudVersion.clear(); remoteRuntimeVersion.clear(); @@ -302,7 +310,7 @@ void AssetUpdater::checkIfCheckingIsDone() { needsDalamudInstall = true; - QNetworkRequest request(dalamudLatestPackageURL); + QNetworkRequest request(dalamudLatestPackageURL.arg(channelToDistribPrefix[chosenChannel])); auto reply = launcher.mgr->get(request); connect(reply, &QNetworkReply::finished, [this, reply] { diff --git a/src/launchercore.cpp b/src/launchercore.cpp index eac5712..d9b9059 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -296,13 +296,23 @@ void LauncherCore::readInitialInformation() { 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]; + QString versionString; + if(doc["targets"].toObject().contains(".NETCoreApp,Version=v5.0")) { + versionString = + doc["targets"] + .toObject()[".NETCoreApp,Version=v5.0"] + .toObject() + .keys() + .filter("Dalamud")[0]; + } else { + versionString = + doc["targets"] + .toObject()[".NETCoreApp,Version=v6.0"] + .toObject() + .keys() + .filter("Dalamud")[0]; + } + dalamudVersion = versionString.remove("Dalamud/"); } @@ -398,6 +408,7 @@ void LauncherCore::readInitialInformation() { profile.dalamud.enabled = settings.value("enableDalamud", defaultSettings.dalamud.enabled).toBool(); profile.dalamud.optOutOfMbCollection = settings.value("dalamudOptOut", defaultSettings.dalamud.optOutOfMbCollection).toBool(); + profile.dalamud.channel = (DalamudChannel)settings.value("dalamudChannel", (int)defaultSettings.dalamud.channel).toInt(); profileSettings[settings.value("index").toInt()] = profile; @@ -595,6 +606,7 @@ void LauncherCore::saveSettings() { settings.setValue("enableDalamud", profile.dalamud.enabled); settings.setValue("dalamudOptOut", profile.dalamud.optOutOfMbCollection); + settings.setValue("dalamudChannel", (int)profile.dalamud.channel); settings.setValue("enableWatchdog", profile.enableWatchdog); settings.endGroup(); diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index fc464e7..f5785ef 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -403,6 +403,22 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC }); dalamudBoxLayout->addRow("Opt Out of Automatic Marketboard Collection", dalamudOptOutBox); + dalamudChannel = new QComboBox(); + dalamudChannel->insertItem(0, "Stable"); + dalamudChannel->insertItem(1, "Staging"); + dalamudChannel->insertItem(2, ".NET 5"); + + connect(dalamudChannel, + static_cast( + &QComboBox::currentIndexChanged), + [=](int index) { + getCurrentProfile().dalamud.channel = (DalamudChannel)index; + + this->core.saveSettings(); + }); + + dalamudBoxLayout->addRow("Dalamud Update Channel", dalamudChannel); + dalamudVersionLabel = new QLabel(); dalamudVersionLabel->setTextInteractionFlags(Qt::TextInteractionFlag::TextSelectableByMouse); dalamudBoxLayout->addRow("Dalamud Version", dalamudVersionLabel); @@ -550,6 +566,7 @@ void SettingsWindow::reloadControls() { } dalamudOptOutBox->setChecked(profile.dalamud.optOutOfMbCollection); + dalamudChannel->setCurrentIndex((int)profile.dalamud.channel); window.reloadControls();