diff options
Diffstat (limited to 'indra/newview/llviewermenufile.cpp')
-rw-r--r-- | indra/newview/llviewermenufile.cpp | 131 |
1 files changed, 86 insertions, 45 deletions
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index e3da52fc78..83f8e96f9a 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -523,15 +523,8 @@ const void upload_single_file(const std::vector<std::string>& filenames, LLFileP return; } -void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification, const LLSD& response) +void do_bulk_upload(std::vector<std::string> filenames, bool allow_2k) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option != 0) - { - // Cancel upload - return; - } - for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) { std::string filename = (*in_iter); @@ -551,12 +544,14 @@ void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec)) { bool resource_upload = false; - if (asset_type == LLAssetType::AT_TEXTURE) + if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer<LLImageFormatted> image_frmted = LLImageFormatted::createFromType(codec); - if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) + if (gDirUtilp->fileExists(filename) && image_frmted && image_frmted->load(filename)) { - expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted); + S32 biased_width = LLImageRaw::biasedDimToPowerOfTwo(image_frmted->getWidth(), LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + S32 biased_height = LLImageRaw::biasedDimToPowerOfTwo(image_frmted->getHeight(), LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(biased_width, biased_height); resource_upload = true; } } @@ -567,7 +562,7 @@ void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification if (resource_upload) { - LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( + LLNewFileResourceUploadInfo* info_p = new LLNewFileResourceUploadInfo( filename, asset_name, asset_name, 0, @@ -575,7 +570,13 @@ void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost)); + expected_upload_cost); + + if (!allow_2k) + { + info_p->setMaxImageSize(1024); + } + LLResourceUploadInfo::ptr_t uploadInfo(info_p); upload_new_resource(uploadInfo); } @@ -601,11 +602,30 @@ void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification } } -bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S32& total_cost, S32& file_count, S32& bvh_count) +void do_bulk_upload(std::vector<std::string> filenames, bool allow_2k, const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) + { + // Cancel upload + return; + } + + do_bulk_upload(filenames, allow_2k); +} + +bool get_bulk_upload_expected_cost( + const std::vector<std::string>& filenames, + bool allow_2k, + S32& total_cost, + S32& file_count, + S32& bvh_count, + S32& textures_2k_count) { total_cost = 0; file_count = 0; bvh_count = 0; + textures_2k_count = 0; for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) { std::string filename = (*in_iter); @@ -622,12 +642,19 @@ bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S3 if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec)) { - if (asset_type == LLAssetType::AT_TEXTURE) + if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer<LLImageFormatted> image_frmted = LLImageFormatted::createFromType(codec); - if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) + if (gDirUtilp->fileExists(filename) && image_frmted && image_frmted->load(filename)) { - total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted); + S32 biased_width = LLImageRaw::biasedDimToPowerOfTwo(image_frmted->getWidth(), LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + S32 biased_height = LLImageRaw::biasedDimToPowerOfTwo(image_frmted->getHeight(), LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(biased_width, biased_height); + S32 area = biased_width * biased_height; + if (area >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) + { + textures_2k_count++; + } file_count++; } } @@ -682,38 +709,27 @@ bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S3 return file_count > 0; } -const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type) +const void upload_bulk(const std::vector<std::string>& filtered_filenames, bool allow_2k) { - // TODO: - // Check user balance for entire cost - // Charge user entire cost - // Loop, uploading - // If an upload fails, refund the user for that one - // - // Also fix single upload to charge first, then refund - - // FIXME PREMIUM what about known types that can't be bulk uploaded - // (bvh)? These will fail in the item by item upload but won't be - // mentioned in the notification. - std::vector<std::string> filtered_filenames; - for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) - { - const std::string& filename = *in_iter; - if (check_file_extension(filename, type)) - { - filtered_filenames.push_back(filename); - } - } - S32 expected_upload_cost; S32 expected_upload_count; S32 bvh_count; - if (get_bulk_upload_expected_cost(filtered_filenames, expected_upload_cost, expected_upload_count, bvh_count)) + S32 textures_2k_count; + if (get_bulk_upload_expected_cost(filtered_filenames, allow_2k, expected_upload_cost, expected_upload_count, bvh_count, textures_2k_count)) { - LLSD args; - args["COST"] = expected_upload_cost; - args["COUNT"] = expected_upload_count; - LLNotificationsUtil::add("BulkUploadCostConfirmation", args, LLSD(), boost::bind(do_bulk_upload, filtered_filenames, _1, _2)); + LLSD key; + key["upload_cost"] = expected_upload_cost; + key["upload_count"] = expected_upload_count; + key["has_2k_textures"] = (textures_2k_count > 0); + + LLSD array; + for (const std::string& str : filtered_filenames) + { + array.append(str); + } + key["files"] = array; + + LLFloaterReg::showInstance("bulk_upload", key); if (filtered_filenames.size() > expected_upload_count) { @@ -738,6 +754,31 @@ const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker:: } +const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type, bool allow_2k) +{ + // TODO: + // Check user balance for entire cost + // Charge user entire cost + // Loop, uploading + // If an upload fails, refund the user for that one + // + // Also fix single upload to charge first, then refund + + // FIXME PREMIUM what about known types that can't be bulk uploaded + // (bvh)? These will fail in the item by item upload but won't be + // mentioned in the notification. + std::vector<std::string> filtered_filenames; + for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) + { + const std::string& filename = *in_iter; + if (check_file_extension(filename, type)) + { + filtered_filenames.push_back(filename); + } + } + upload_bulk(filtered_filenames, allow_2k); +} + class LLFileUploadImage : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -803,7 +844,7 @@ class LLFileUploadBulk : public view_listener_t { gAgentCamera.changeCameraToDefault(); } - LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2), LLFilePicker::FFLOAD_ALL, true); + LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2, true), LLFilePicker::FFLOAD_ALL, true); return true; } }; |