summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermenufile.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2024-07-02 20:39:39 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-07-02 21:53:43 +0300
commit1adb94a89c106176e01d950170b9c4d623dd2250 (patch)
treea53224485a5d9fa36ebfe2827562a12c2872b907 /indra/newview/llviewermenufile.cpp
parentb276936ef336a17e4c124da40c1c63b2829fc680 (diff)
viewer#1666 Allow switching 2k textures off in bulk uploads
Diffstat (limited to 'indra/newview/llviewermenufile.cpp')
-rw-r--r--indra/newview/llviewermenufile.cpp122
1 files changed, 81 insertions, 41 deletions
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index e3da52fc78..c4fecf8dff 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,7 +544,7 @@ 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))
@@ -567,7 +560,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 +568,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 +600,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 +640,20 @@ 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))
{
total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted);
+ if (image_frmted)
+ {
+ S32 area = image_frmted->getHeight() * image_frmted->getWidth();
+ if (area >= LLAgentBenefits::MIN_2K_TEXTURE_AREA)
+ {
+ textures_2k_count++;
+ }
+ }
file_count++;
}
}
@@ -682,38 +708,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 +753,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 +843,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;
}
};