Compare commits

...

4 commits

Author SHA1 Message Date
Justin
e472259c3a
Merge 4a40835f71 into 280b6efa94 2024-11-13 19:39:47 -05:00
Fleeym
280b6efa94
fix: fix mod downloads not checking version (#1148)
Some checks are pending
Build Binaries / Build Windows (push) Waiting to run
Build Binaries / Build macOS (push) Waiting to run
Build Binaries / Build Android (64-bit) (push) Waiting to run
Build Binaries / Build Android (32-bit) (push) Waiting to run
Build Binaries / Publish (push) Blocked by required conditions
2024-11-14 02:26:40 +02:00
Justin
4a40835f71
Change approach 2024-11-08 12:23:18 -05:00
Justin
74d0924bcb
Part 2: Geode SDK 2024-11-08 10:20:30 -05:00
6 changed files with 55 additions and 15 deletions

View file

@ -164,7 +164,27 @@ function(setup_geode_mod proname)
set(HAS_HEADERS Off) set(HAS_HEADERS Off)
endif() endif()
if (HAS_HEADERS AND WIN32) if (GEODE_BUNDLE_PDB AND WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
if (HAS_HEADERS)
add_custom_target(${proname}_PACKAGE ALL
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
COMMAND ${GEODE_CLI} package new ${CMAKE_CURRENT_SOURCE_DIR}
--binary $<TARGET_FILE:${proname}> $<TARGET_LINKER_FILE:${proname}> $<TARGET_PDB_FILE:${proname}>
--output ${CMAKE_CURRENT_BINARY_DIR}/${MOD_ID}.geode
${INSTALL_ARG} ${PDB_ARG}
VERBATIM USES_TERMINAL
)
else()
add_custom_target(${proname}_PACKAGE ALL
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
COMMAND ${GEODE_CLI} package new ${CMAKE_CURRENT_SOURCE_DIR}
--binary $<TARGET_FILE:${proname}> $<TARGET_PDB_FILE:${proname}>
--output ${CMAKE_CURRENT_BINARY_DIR}/${MOD_ID}.geode
${INSTALL_ARG} ${PDB_ARG}
VERBATIM USES_TERMINAL
)
endif()
elseif (HAS_HEADERS AND WIN32)
# this adds the .lib file on windows, which is needed for linking with the headers # this adds the .lib file on windows, which is needed for linking with the headers
add_custom_target(${proname}_PACKAGE ALL add_custom_target(${proname}_PACKAGE ALL
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json

View file

@ -8,6 +8,7 @@
#include <fmt/chrono.h> #include <fmt/chrono.h>
#include <loader/LoaderImpl.hpp> #include <loader/LoaderImpl.hpp>
#include "../internal/about.hpp" #include "../internal/about.hpp"
#include "Geode/loader/Loader.hpp"
using namespace server; using namespace server;
@ -647,7 +648,7 @@ ServerRequest<ServerModVersion> server::getModVersion(std::string const& id, Mod
}, },
}, version); }, 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<ServerModVersion, ServerError> { [](web::WebResponse* response) -> Result<ServerModVersion, ServerError> {
if (response->ok()) { if (response->ok()) {
// Parse payload // Parse payload

View file

@ -8,6 +8,7 @@
#include <Geode/utils/ColorProvider.hpp> #include <Geode/utils/ColorProvider.hpp>
#include <Geode/binding/ButtonSprite.hpp> #include <Geode/binding/ButtonSprite.hpp>
#include <Geode/loader/Loader.hpp> #include <Geode/loader/Loader.hpp>
#include "server/DownloadManager.hpp"
#include "ui/mods/GeodeStyle.hpp" #include "ui/mods/GeodeStyle.hpp"
#include "ui/mods/popups/ModPopup.hpp" #include "ui/mods/popups/ModPopup.hpp"
#include "ui/mods/popups/DevPopup.hpp" #include "ui/mods/popups/DevPopup.hpp"
@ -631,18 +632,7 @@ void ModItem::onEnable(CCObject*) {
UpdateModListStateEvent(UpdateModState(m_source.getID())).post(); UpdateModListStateEvent(UpdateModState(m_source.getID())).post();
} }
void ModItem::onInstall(CCObject*) { void ModItem::onInstall(CCObject*) {
if (auto updates = m_source.hasUpdates()) { m_source.startInstall();
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);
} }
void ModItem::onDevelopers(CCObject*) { void ModItem::onDevelopers(CCObject*) {
DevListPopup::create(m_source)->show(); DevListPopup::create(m_source)->show();

View file

@ -7,11 +7,13 @@
#include <Geode/loader/ModSettingsManager.hpp> #include <Geode/loader/ModSettingsManager.hpp>
#include <Geode/ui/GeodeUI.hpp> #include <Geode/ui/GeodeUI.hpp>
#include <Geode/utils/ColorProvider.hpp> #include <Geode/utils/ColorProvider.hpp>
#include <optional>
#include "ConfirmUninstallPopup.hpp" #include "ConfirmUninstallPopup.hpp"
#include "../settings/ModSettingsPopup.hpp" #include "../settings/ModSettingsPopup.hpp"
#include "../../../internal/about.hpp" #include "../../../internal/about.hpp"
#include "../../GeodeUIEvent.hpp" #include "../../GeodeUIEvent.hpp"
#include "../popups/ModtoberPopup.hpp" #include "../popups/ModtoberPopup.hpp"
#include "server/DownloadManager.hpp"
class FetchTextArea : public CCNode { class FetchTextArea : public CCNode {
public: public:
@ -1047,7 +1049,9 @@ void ModPopup::onInstall(CCObject*) {
return; return;
} }
} }
server::ModDownloadManager::get()->startDownload(m_source.getID(), std::nullopt);
m_source.startInstall();
this->onClose(nullptr); this->onClose(nullptr);
} }

View file

@ -240,3 +240,27 @@ server::ServerRequest<std::optional<server::ServerModUpdate>> ModSource::checkUp
}, },
}, m_value); }, 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
);
}
}

View file

@ -49,4 +49,5 @@ public:
server::ServerRequest<std::optional<std::string>> fetchChangelog() const; server::ServerRequest<std::optional<std::string>> fetchChangelog() const;
server::ServerRequest<std::unordered_set<std::string>> fetchValidTags() const; server::ServerRequest<std::unordered_set<std::string>> fetchValidTags() const;
server::ServerRequest<std::optional<server::ServerModUpdate>> checkUpdates(); server::ServerRequest<std::optional<server::ServerModUpdate>> checkUpdates();
void startInstall();
}; };