From 5a7ad2249b50470a84fc45eac95de2297ecc2da9 Mon Sep 17 00:00:00 2001 From: Rémy Raes Date: Thu, 14 Dec 2023 22:19:21 +0100 Subject: Mod download UI integration (#595) UI integration for the mod downloading feature. Feature activation locked behind a convar. --- NorthstarDLL/mods/autodownload/moddownloader.h | 38 ++++++++++++++++---------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'NorthstarDLL/mods/autodownload/moddownloader.h') diff --git a/NorthstarDLL/mods/autodownload/moddownloader.h b/NorthstarDLL/mods/autodownload/moddownloader.h index ae4f603a..747b3c01 100644 --- a/NorthstarDLL/mods/autodownload/moddownloader.h +++ b/NorthstarDLL/mods/autodownload/moddownloader.h @@ -18,6 +18,16 @@ class ModDownloader }; std::unordered_map verifiedMods = {}; + /** + * Mod archive download callback. + * + * This function is called by curl as it's downloading the mod archive; this + * will retrieve the current `ModDownloader` instance and update its `modState` + * member accordingly. + */ + static int ModFetchingProgressCallback( + void* ptr, curl_off_t totalDownloadSize, curl_off_t finishedDownloadSize, curl_off_t totalToUpload, curl_off_t nowUploaded); + /** * Downloads a mod archive from distant store. * @@ -35,20 +45,6 @@ class ModDownloader */ std::optional FetchModFromDistantStore(std::string_view modName, std::string_view modVersion); - /** - * Checks whether a mod is verified. - * - * A mod is deemed verified/authorized through a manual validation process that is - * described here: https://github.com/R2Northstar/VerifiedMods; in practice, a mod - * is considered authorized if their name AND exact version appear in the - * `verifiedMods` variable. - * - * @param modName name of the mod to be checked - * @param modVersion version of the mod to be checked, must follow semantic versioning - * @returns whether the mod is authorized and can be auto-downloaded - */ - bool IsModAuthorized(std::string_view modName, std::string_view modVersion); - /** * Tells if a mod archive has not been corrupted. * @@ -93,6 +89,20 @@ class ModDownloader */ void FetchModsListFromAPI(); + /** + * Checks whether a mod is verified. + * + * A mod is deemed verified/authorized through a manual validation process that is + * described here: https://github.com/R2Northstar/VerifiedMods; in practice, a mod + * is considered authorized if their name AND exact version appear in the + * `verifiedMods` variable. + * + * @param modName name of the mod to be checked + * @param modVersion version of the mod to be checked, must follow semantic versioning + * @returns whether the mod is authorized and can be auto-downloaded + */ + bool IsModAuthorized(std::string_view modName, std::string_view modVersion); + /** * Downloads a given mod from Thunderstore API to local game profile. * -- cgit v1.2.3