diff options
Diffstat (limited to 'indra/newview/llviewermenufile.cpp')
| -rw-r--r-- | indra/newview/llviewermenufile.cpp | 156 | 
1 files changed, 125 insertions, 31 deletions
| diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index a9a91b158b..15181dcd9f 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -30,6 +30,7 @@  // project includes  #include "llagent.h" +#include "llagentbenefits.h"  #include "llagentcamera.h"  #include "llfilepicker.h"  #include "llfloaterreg.h" @@ -67,7 +68,6 @@  #include "llviewerassetupload.h"  // linden libraries -#include "lleconomy.h"  #include "llnotificationsutil.h"  #include "llsdserialize.h"  #include "llsdutil.h" @@ -85,8 +85,6 @@ class LLFileEnableUpload : public view_listener_t  	bool handleEvent(const LLSD& userdata)  	{          return true; -// 		bool new_value = gStatusBar && LLGlobalEconomy::getInstance() && (gStatusBar->getBalance() >= LLGlobalEconomy::getInstance()->getPriceUpload()); -// 		return new_value;  	}  }; @@ -393,7 +391,9 @@ const void upload_single_file(const std::vector<std::string>& filenames, LLFileP  		}  		if (type == LLFilePicker::FFLOAD_ANIM)  		{ -			if (filename.rfind(".anim") != std::string::npos) +			std::string filename_lc(filename); +			LLStringUtil::toLower(filename_lc); +			if (filename_lc.rfind(".anim") != std::string::npos)  			{  				LLFloaterReg::showInstance("upload_anim_anim", LLSD(filename));  			} @@ -406,22 +406,18 @@ const void upload_single_file(const std::vector<std::string>& filenames, LLFileP  	return;  } - -const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type) +void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification, const LLSD& response)  { -	// 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 +	S32 option = LLNotificationsUtil::getSelectedOption(notification, response); +	if (option != 0) +	{ +		// Cancel upload +		return; +	} -	S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload();  	for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter)  	{  		std::string filename = (*in_iter); -		if (!check_file_extension(filename, type)) continue;  		std::string name = gDirUtilp->getBaseFileName(filename, true);  		std::string asset_name = name; @@ -430,6 +426,13 @@ const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::  		LLStringUtil::stripNonprintable(asset_name);  		LLStringUtil::trim(asset_name); +		std::string ext = gDirUtilp->getExtension(filename); +		LLAssetType::EType asset_type; +		U32 codec; +		S32 expected_upload_cost; +		if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec) && +			LLAgentBenefitsMgr::current().findUploadCost(asset_type, expected_upload_cost)) +		{  		LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo(  			filename,  			asset_name, @@ -440,9 +443,96 @@ const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::  			LLFloaterPerms::getEveryonePerms("Uploads"),  			expected_upload_cost)); -		upload_new_resource(uploadInfo, NULL, NULL); +		upload_new_resource(uploadInfo);  	}  } +} + +bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S32& total_cost, S32& file_count, S32& bvh_count) +{ +	total_cost = 0; +	file_count = 0; +	bvh_count = 0; +	for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) +	{ +		std::string filename = (*in_iter); +		std::string ext = gDirUtilp->getExtension(filename); + +		if (ext == "bvh") +		{ +			bvh_count++; +		} + +		LLAssetType::EType asset_type; +		U32 codec; +		S32 cost; + +		if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec) && +			LLAgentBenefitsMgr::current().findUploadCost(asset_type, cost)) +		{ +			total_cost += cost; +			file_count++; +		} +	} +	 +    return file_count > 0; +} + +const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type) +{ +	// 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)) +	{ +		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)); + +		if (filtered_filenames.size() > expected_upload_count) +		{ +			if (bvh_count == filtered_filenames.size() - expected_upload_count) +			{ +				LLNotificationsUtil::add("DoNotSupportBulkAnimationUpload"); +			} +			else +			{ +				LLNotificationsUtil::add("BulkUploadIncompatibleFiles"); +			} +		} +	} +	else if (bvh_count == filtered_filenames.size()) +	{ +		LLNotificationsUtil::add("DoNotSupportBulkAnimationUpload"); +	} +	else +	{ +		LLNotificationsUtil::add("BulkUploadNoCompatibleFiles"); +	} + +}  class LLFileUploadImage : public view_listener_t  { @@ -464,7 +554,7 @@ class LLFileUploadModel : public view_listener_t  		LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) LLFloaterReg::getInstance("upload_model");  		if (fmp && !fmp->isModelLoading())  		{ -			fmp->loadModel(3); +			fmp->loadHighLodModel();  		}  		return TRUE; @@ -595,10 +685,17 @@ class LLFileTakeSnapshotToDisk : public view_listener_t  		S32 width = gViewerWindow->getWindowWidthRaw();  		S32 height = gViewerWindow->getWindowHeightRaw(); -		if (gSavedSettings.getBOOL("HighResSnapshot")) +		bool render_ui = gSavedSettings.getBOOL("RenderUIInSnapshot"); +		bool render_hud = gSavedSettings.getBOOL("RenderHUDInSnapshot"); + +		BOOL high_res = gSavedSettings.getBOOL("HighResSnapshot"); +		if (high_res)  		{  			width *= 2;  			height *= 2; +			// not compatible with UI/HUD +			render_ui = false; +			render_hud = false;  		}  		if (gViewerWindow->rawSnapshot(raw, @@ -606,8 +703,11 @@ class LLFileTakeSnapshotToDisk : public view_listener_t  									   height,  									   TRUE,  									   FALSE, -									   gSavedSettings.getBOOL("RenderUIInSnapshot"), -									   FALSE)) +									   render_ui, +									   render_hud, +									   FALSE, +									   LLSnapshotModel::SNAPSHOT_TYPE_COLOR, +									   high_res ? S32_MAX : MAX_SNAPSHOT_IMAGE_SIZE)) //per side  		{  			LLPointer<LLImageFormatted> formatted;              LLSnapshotModel::ESnapshotFormat fmt = (LLSnapshotModel::ESnapshotFormat) gSavedSettings.getS32("SnapshotFormat"); @@ -693,7 +793,7 @@ LLUUID upload_new_resource(  	bool show_inventory)  {	 -    LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( +    LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLNewFileResourceUploadInfo>(          src_filename,          name, desc, compression_info,          destination_folder_type, inv_type, @@ -730,10 +830,7 @@ void upload_done_callback(  				if(!(can_afford_transaction(expected_upload_cost)))  				{ -					LLStringUtil::format_map_t args; -					args["NAME"] = data->mAssetInfo.getName(); -					args["AMOUNT"] = llformat("%d", expected_upload_cost); -					LLBuyCurrencyHTML::openCurrencyFloater( LLTrans::getString("UploadingCosts", args), expected_upload_cost ); +					LLBuyCurrencyHTML::openCurrencyFloater( "", expected_upload_cost );  					is_balance_sufficient = FALSE;  				}  				else if(region) @@ -776,7 +873,7 @@ void upload_done_callback(  					create_inventory_item(gAgent.getID(), gAgent.getSessionID(),  							      folder_id, data->mAssetInfo.mTransactionID, data->mAssetInfo.getName(),  							      data->mAssetInfo.getDescription(), data->mAssetInfo.mType, -							      data->mInventoryType, NOT_WEARABLE, next_owner_perms, +                                  data->mInventoryType, NO_INV_SUBTYPE, next_owner_perms,  							      LLPointer<LLInventoryCallback>(NULL));  				}  				else @@ -812,7 +909,7 @@ void upload_done_callback(  		LLStringUtil::trim(asset_name);  		std::string display_name = LLStringUtil::null; -		LLAssetStorage::LLStoreAssetCallback callback = NULL; +		LLAssetStorage::LLStoreAssetCallback callback;  		void *userdata = NULL;  		upload_new_resource(  			next_file, @@ -867,10 +964,7 @@ void upload_new_resource(  			if (balance < uploadInfo->getExpectedUploadCost())  			{  				// insufficient funds, bail on this upload -				LLStringUtil::format_map_t args; -				args["NAME"] = uploadInfo->getName(); -                args["AMOUNT"] = llformat("%d", uploadInfo->getExpectedUploadCost()); -                LLBuyCurrencyHTML::openCurrencyFloater(LLTrans::getString("UploadingCosts", args), uploadInfo->getExpectedUploadCost()); +                LLBuyCurrencyHTML::openCurrencyFloater("", uploadInfo->getExpectedUploadCost());  				return;  			}  		} | 
