diff --git a/loader/src/server/Server.cpp b/loader/src/server/Server.cpp index 55be73e8..193221de 100644 --- a/loader/src/server/Server.cpp +++ b/loader/src/server/Server.cpp @@ -8,6 +8,7 @@ #include #include #include "../internal/about.hpp" +#include "Geode/loader/Loader.hpp" using namespace server; @@ -647,7 +648,7 @@ ServerRequest server::getModVersion(std::string const& id, Mod }, }, version); - return req.get(formatServerURL("/mods/{}/versions/{}", id, versionURL)).map( + return req.get(formatServerURL("/mods/{}/versions/{}?gd={}", id, versionURL, Loader::get()->getGameVersion())).map( [](web::WebResponse* response) -> Result { if (response->ok()) { // Parse payload diff --git a/loader/src/ui/mods/list/ModItem.cpp b/loader/src/ui/mods/list/ModItem.cpp index d12f64e0..662a7b40 100644 --- a/loader/src/ui/mods/list/ModItem.cpp +++ b/loader/src/ui/mods/list/ModItem.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "server/DownloadManager.hpp" #include "ui/mods/GeodeStyle.hpp" #include "ui/mods/popups/ModPopup.hpp" #include "ui/mods/popups/DevPopup.hpp" @@ -631,18 +632,7 @@ void ModItem::onEnable(CCObject*) { UpdateModListStateEvent(UpdateModState(m_source.getID())).post(); } void ModItem::onInstall(CCObject*) { - if (auto updates = m_source.hasUpdates()) { - if (updates->replacement.has_value()) { - server::ModDownloadManager::get()->startDownload( - updates->replacement->id, - updates->replacement->version, - std::nullopt, - m_source.getID() - ); - return; - } - } - server::ModDownloadManager::get()->startDownload(m_source.getID(), std::nullopt); + m_source.startInstall(); } void ModItem::onDevelopers(CCObject*) { DevListPopup::create(m_source)->show(); diff --git a/loader/src/ui/mods/popups/ModPopup.cpp b/loader/src/ui/mods/popups/ModPopup.cpp index fb9c54f8..a22578e8 100644 --- a/loader/src/ui/mods/popups/ModPopup.cpp +++ b/loader/src/ui/mods/popups/ModPopup.cpp @@ -7,11 +7,13 @@ #include #include #include +#include #include "ConfirmUninstallPopup.hpp" #include "../settings/ModSettingsPopup.hpp" #include "../../../internal/about.hpp" #include "../../GeodeUIEvent.hpp" #include "../popups/ModtoberPopup.hpp" +#include "server/DownloadManager.hpp" class FetchTextArea : public CCNode { public: @@ -1047,7 +1049,9 @@ void ModPopup::onInstall(CCObject*) { return; } } - server::ModDownloadManager::get()->startDownload(m_source.getID(), std::nullopt); + + m_source.startInstall(); + this->onClose(nullptr); } diff --git a/loader/src/ui/mods/sources/ModSource.cpp b/loader/src/ui/mods/sources/ModSource.cpp index 2234888f..a6aff3bb 100644 --- a/loader/src/ui/mods/sources/ModSource.cpp +++ b/loader/src/ui/mods/sources/ModSource.cpp @@ -240,3 +240,27 @@ server::ServerRequest> ModSource::checkUp }, }, m_value); } +void ModSource::startInstall() { + if (auto updates = this->hasUpdates()) { + if (updates->replacement.has_value()) { + server::ModDownloadManager::get()->startDownload( + updates->replacement->id, + updates->replacement->version, + std::nullopt, + this->getID() + ); + } else { + server::ModDownloadManager::get()->startDownload( + this->getID(), + updates->version + ); + } + } else { + server::ModDownloadManager::get()->startDownload( + this->getID(), + this->asServer() + ? std::optional{this->asServer()->latestVersion().getVersion()} + : std::nullopt + ); + } +} diff --git a/loader/src/ui/mods/sources/ModSource.hpp b/loader/src/ui/mods/sources/ModSource.hpp index aa13f3bb..0f6776ee 100644 --- a/loader/src/ui/mods/sources/ModSource.hpp +++ b/loader/src/ui/mods/sources/ModSource.hpp @@ -49,4 +49,5 @@ public: server::ServerRequest> fetchChangelog() const; server::ServerRequest> fetchValidTags() const; server::ServerRequest> checkUpdates(); + void startInstall(); };