new option in mods.json for the new param of total files sizes

This commit is contained in:
otavepto 2024-07-01 11:53:10 +03:00
parent f5ae22a1e6
commit a307cc13e5
4 changed files with 12 additions and 2 deletions

View File

@ -54,6 +54,9 @@ struct Mod_entry {
int32 primaryFileSize{};
std::string previewFileName{};
int32 previewFileSize{};
uint64 total_files_sizes{}; // added in sdk 1.60, "Total size of all files (non-legacy), excluding the preview file"
std::string workshopItemURL{};
// voting information

View File

@ -1015,6 +1015,8 @@ static void try_parse_mods_file(class Settings *settings_client, Settings *setti
}
newMod.previewFileSize = mod.value().value("preview_filesize", preview_filesize);
newMod.total_files_sizes = mod.value().value("total_files_sizes", primary_filesize);
newMod.workshopItemURL = mod.value().value("workshop_item_url", "https://steamcommunity.com/sharedfiles/filedetails/?id=" + std::string(mod.key()));
newMod.votesUp = mod.value().value("upvotes", (uint32)500);
newMod.votesDown = mod.value().value("downvotes", (uint32)12);
@ -1043,6 +1045,7 @@ static void try_parse_mods_file(class Settings *settings_client, Settings *setti
PRINT_DEBUG(" preview_filename: '%s'", newMod.previewFileName.c_str());
PRINT_DEBUG(" preview_filesize: %i bytes", newMod.previewFileSize);
PRINT_DEBUG(" preview file handle: %llu", settings_client->getMod(newMod.id).handlePreviewFile);
PRINT_DEBUG(" total_files_sizes: %llu", settings_client->getMod(newMod.id).total_files_sizes);
PRINT_DEBUG(" workshop_item_url: '%s'", newMod.workshopItemURL.c_str());
PRINT_DEBUG(" preview_url: '%s'", newMod.previewURL.c_str());
} catch (std::exception& e) {
@ -1085,6 +1088,8 @@ static void try_detect_mods_folder(class Settings *settings_client, Settings *se
newMod.previewFileName = mod_preview_files.size() ? mod_preview_files[0] : "";
newMod.previewFileSize = (int32)get_file_size_safe(newMod.previewFileName, mod_images_fullpath);
newMod.total_files_sizes = newMod.primaryFileSize;
newMod.workshopItemURL = "https://steamcommunity.com/sharedfiles/filedetails/?id=" + mod_folder;
newMod.votesUp = (uint32)500;
newMod.votesDown = (uint32)12;
@ -1105,6 +1110,7 @@ static void try_detect_mods_folder(class Settings *settings_client, Settings *se
PRINT_DEBUG(" preview_filename: '%s'", newMod.previewFileName.c_str());
PRINT_DEBUG(" preview_filesize: %i bytes", newMod.previewFileSize);
PRINT_DEBUG(" preview file handle: %llu", settings_client->getMod(newMod.id).handlePreviewFile);
PRINT_DEBUG(" total_files_sizes: '%s'", newMod.total_files_sizes);
PRINT_DEBUG(" workshop_item_url: '%s'", newMod.workshopItemURL.c_str());
PRINT_DEBUG(" preview_url: '%s'", newMod.previewURL.c_str());
} catch (...) {}

View File

@ -106,8 +106,8 @@ void Steam_UGC::set_details(PublishedFileId_t id, SteamUGCDetails_t *pDetails)
// TODO should we enable this?
// pDetails->m_unNumChildren = mod.numChildren;
// TODO make the filesize is good (have a custom json shit I guess)
pDetails->m_ulTotalFilesSize = mod.primaryFileSize + mod.previewFileSize;
// TODO make the filesize is good
pDetails->m_ulTotalFilesSize = mod.total_files_sizes;
} else {
PRINT_DEBUG(" mod isn't installed, returning failure");
pDetails->m_eResult = k_EResultFail;

View File

@ -18,6 +18,7 @@
"primary_filesize": 1000000,
"preview_filename": "test.png",
"preview_filesize": 1000000,
"total_files_sizes": 9977664411,
"workshop_item_url": "https://steamcommunity.com/sharedfiles/filedetails/?id=111111111",
"upvotes": 10,
"downvotes": 1,