SL-10499, SL-10497 - use LLAgentBenefits info

meow-7.2.2
Brad Payne (Vir Linden) 2019-11-14 15:01:50 +00:00
parent b3b103efe5
commit 7df0a4ddd0
15 changed files with 105 additions and 133 deletions

View File

@ -26,7 +26,14 @@
#include "llviewerprecompiledheaders.h"
#include "llagentbenefits.h"
LLAgentBenefits::LLAgentBenefits()
LLAgentBenefits::LLAgentBenefits():
m_initalized(false),
m_animated_object_limit(-1),
m_animation_upload_cost(-1),
m_attachment_limit(-1),
m_group_membership_limit(-1),
m_sound_upload_cost(-1),
m_texture_upload_cost(-1)
{
}
@ -78,35 +85,43 @@ bool LLAgentBenefits::init(const LLSD& benefits_sd)
{
return false;
}
m_initalized = true;
return true;
}
S32 LLAgentBenefits::getAnimatedObjectLimit() const
{
//llassert(m_initalized);
return m_animated_object_limit;
}
S32 LLAgentBenefits::getAnimationUploadCost() const
{
//llassert(m_initalized);
return m_animation_upload_cost;
}
S32 LLAgentBenefits::getAttachmentLimit() const
{
//llassert(m_initalized);
return m_attachment_limit;
}
S32 LLAgentBenefits::getGroupMembershipLimit() const
{
//llassert(m_initalized);
return m_group_membership_limit;
}
S32 LLAgentBenefits::getSoundUploadCost() const
{
//llassert(m_initalized);
return m_sound_upload_cost;
}
S32 LLAgentBenefits::getTextureUploadCost() const
{
//llassert(m_initalized);
return m_texture_upload_cost;
}

View File

@ -52,6 +52,8 @@ private:
S32 m_group_membership_limit;
S32 m_sound_upload_cost;
S32 m_texture_upload_cost;
bool m_initalized;
};
#endif

View File

@ -38,6 +38,7 @@
#include "llstring.h"
#include "llagent.h"
#include "llagentbenefits.h"
#include "llanimationstates.h"
#include "llbbox.h"
#include "llbutton.h"
@ -1004,16 +1005,18 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata)
{
std::string name = floaterp->getChild<LLUICtrl>("name_form")->getValue().asString();
std::string desc = floaterp->getChild<LLUICtrl>("description_form")->getValue().asString();
S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload();
S32 expected_upload_cost = LLAgentBenefits::instance().getAnimationUploadCost();
LLResourceUploadInfo::ptr_t assetUpdloadInfo(new LLResourceUploadInfo(
LLResourceUploadInfo::ptr_t assetUploadInfo(new LLResourceUploadInfo(
floaterp->mTransactionID, LLAssetType::AT_ANIMATION,
name, desc, 0,
LLFolderType::FT_NONE, LLInventoryType::IT_ANIMATION,
LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"),
LLFloaterPerms::getNextOwnerPerms("Uploads"),
LLFloaterPerms::getGroupPerms("Uploads"),
LLFloaterPerms::getEveryonePerms("Uploads"),
expected_upload_cost));
upload_new_resource(assetUpdloadInfo);
upload_new_resource(assetUploadInfo);
}
else
{

View File

@ -161,6 +161,7 @@ void LLFloaterNameDesc::onBtnOK( )
{
getChildView("ok_btn")->setEnabled(FALSE); // don't allow inadvertent extra uploads
// FIXME PREMIUM - upload cost. Need to know which asset type this is, use agent benefits.
LLAssetStorage::LLStoreAssetCallback callback = NULL;
S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass).

View File

@ -102,7 +102,6 @@ public:
virtual LLSD prepareUpload();
virtual LLSD generatePostBody();
virtual S32 getEconomyUploadCost();
virtual LLUUID finishUpload(LLSD &result);
virtual bool showInventoryPanel() const { return false; }
@ -129,11 +128,6 @@ LLSD LLARScreenShotUploader::generatePostBody()
return mReport;
}
S32 LLARScreenShotUploader::getEconomyUploadCost()
{ // Abuse report screen shots do not cost anything to upload.
return 0;
}
LLUUID LLARScreenShotUploader::finishUpload(LLSD &result)
{
/* *TODO$: Report success or failure. Carried over from previous todo on responder*/

View File

@ -36,6 +36,7 @@
#include "llaccordionctrltab.h"
#include "llappearancemgr.h"
#include "llagentbenefits.h"
#include "lleconomy.h"
#include "llerror.h"
#include "llfilepicker.h"
@ -1205,7 +1206,7 @@ void LLOutfitGallery::uploadOutfitImage(const std::vector<std::string>& filename
return;
}
S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass).
S32 expected_upload_cost = LLAgentBenefits::instance().getTextureUploadCost();
void *nruserdata = NULL;
nruserdata = (void *)&outfit_id;

View File

@ -28,6 +28,7 @@
#include "llpanelmaininventory.h"
#include "llagent.h"
#include "llagentbenefits.h"
#include "llagentcamera.h"
#include "llavataractions.h"
#include "llcheckboxctrl.h"
@ -227,16 +228,21 @@ BOOL LLPanelMainInventory::postBuild()
initListCommandsHandlers();
// *TODO:Get the cost info from the server
const std::string upload_cost("10");
const std::string texture_upload_cost_str = std::to_string(LLAgentBenefits::instance().getTextureUploadCost());
const std::string sound_upload_cost_str = std::to_string(LLAgentBenefits::instance().getSoundUploadCost());
const std::string animation_upload_cost_str = std::to_string(LLAgentBenefits::instance().getAnimationUploadCost());
LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get();
if (menu)
{
menu->getChild<LLMenuItemGL>("Upload Image")->setLabelArg("[COST]", upload_cost);
menu->getChild<LLMenuItemGL>("Upload Sound")->setLabelArg("[COST]", upload_cost);
menu->getChild<LLMenuItemGL>("Upload Animation")->setLabelArg("[COST]", upload_cost);
menu->getChild<LLMenuItemGL>("Bulk Upload")->setLabelArg("[COST]", upload_cost);
menu->getChild<LLMenuItemGL>("Upload Image")->setLabelArg("[COST]", texture_upload_cost_str);
menu->getChild<LLMenuItemGL>("Upload Sound")->setLabelArg("[COST]", sound_upload_cost_str);
menu->getChild<LLMenuItemGL>("Upload Animation")->setLabelArg("[COST]", animation_upload_cost_str);
// FIXME PREMIUM - bulk upload of what? This doesn't work with
// mixed items if costs aren't all the same. For now treating
// as textures.
menu->getChild<LLMenuItemGL>("Bulk Upload")->setLabelArg("[COST]", texture_upload_cost_str);
}
// Trigger callback for focus received so we can deselect items in inbox/outbox
@ -1512,28 +1518,18 @@ void LLPanelMainInventory::setUploadCostIfNeeded()
LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get();
if(mNeedUploadCost && menu)
{
LLMenuItemBranchGL* upload_menu = menu->findChild<LLMenuItemBranchGL>("upload");
if(upload_menu)
{
S32 upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload();
std::string cost_str;
const std::string texture_upload_cost_str = std::to_string(LLAgentBenefits::instance().getTextureUploadCost());
const std::string sound_upload_cost_str = std::to_string(LLAgentBenefits::instance().getSoundUploadCost());
const std::string animation_upload_cost_str = std::to_string(LLAgentBenefits::instance().getAnimationUploadCost());
// getPriceUpload() returns -1 if no data available yet.
if(upload_cost >= 0)
{
mNeedUploadCost = false;
cost_str = llformat("%d", upload_cost);
}
else
{
cost_str = llformat("%d", gSavedSettings.getU32("DefaultUploadCost"));
}
menu->getChild<LLView>("Upload Image")->setLabelArg("[COST]", texture_upload_cost_str);
menu->getChild<LLView>("Upload Sound")->setLabelArg("[COST]", sound_upload_cost_str);
menu->getChild<LLView>("Upload Animation")->setLabelArg("[COST]", animation_upload_cost_str);
upload_menu->getChild<LLView>("Upload Image")->setLabelArg("[COST]", cost_str);
upload_menu->getChild<LLView>("Upload Sound")->setLabelArg("[COST]", cost_str);
upload_menu->getChild<LLView>("Upload Animation")->setLabelArg("[COST]", cost_str);
upload_menu->getChild<LLView>("Bulk Upload")->setLabelArg("[COST]", cost_str);
}
// FIXME PREMIUM - bulk upload of what? This doesn't work with
// mixed items if costs aren't all the same. For now treating
// as textures.
menu->getChild<LLView>("Bulk Upload")->setLabelArg("[COST]", texture_upload_cost_str);
}
}

View File

@ -612,6 +612,7 @@ void LLPanelPeople::removePicker()
BOOL LLPanelPeople::postBuild()
{
// FIXME PREMIUM - need to get premium vs. basic info via BaaS
S32 max_premium = PREMIUM_MAX_AGENT_GROUPS;
if (gAgent.getRegion())
{

View File

@ -35,12 +35,13 @@
#include "llfloaterflickr.h"
#include "llfloatertwitter.h"
#include "llagentbenefits.h"
/**
* Provides several ways to save a snapshot.
*/
class LLPanelSnapshotOptions
: public LLPanel
, public LLEconomyObserver
{
LOG_CLASS(LLPanelSnapshotOptions);
@ -49,7 +50,6 @@ public:
~LLPanelSnapshotOptions();
/*virtual*/ BOOL postBuild();
/*virtual*/ void onOpen(const LLSD& key);
/*virtual*/ void onEconomyDataChange() { updateUploadCost(); }
private:
void updateUploadCost();
@ -74,12 +74,10 @@ LLPanelSnapshotOptions::LLPanelSnapshotOptions()
mCommitCallbackRegistrar.add("Snapshot.SaveToComputer", boost::bind(&LLPanelSnapshotOptions::onSaveToComputer, this));
mCommitCallbackRegistrar.add("Snapshot.SendToTwitter", boost::bind(&LLPanelSnapshotOptions::onSendToTwitter, this));
mCommitCallbackRegistrar.add("Snapshot.SendToFlickr", boost::bind(&LLPanelSnapshotOptions::onSendToFlickr, this));
LLGlobalEconomy::getInstance()->addObserver(this);
}
LLPanelSnapshotOptions::~LLPanelSnapshotOptions()
{
LLGlobalEconomy::getInstance()->removeObserver(this);
}
// virtual
@ -97,7 +95,7 @@ void LLPanelSnapshotOptions::onOpen(const LLSD& key)
void LLPanelSnapshotOptions::updateUploadCost()
{
S32 upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload();
S32 upload_cost = LLAgentBenefits::instance().getTextureUploadCost();
getChild<LLUICtrl>("save_to_inventory_btn")->setLabelArg("[AMOUNT]", llformat("%d", upload_cost));
}

View File

@ -247,7 +247,6 @@ static std::string gAgentStartLocation = "safe";
static bool mLoginStatePastUI = false;
const S32 DEFAULT_MAX_AGENT_GROUPS = 42;
const S32 ALLOWED_MAX_AGENT_GROUPS = 500;
const F32 STATE_AGENT_WAIT_TIMEOUT = 240; //seconds
boost::scoped_ptr<LLEventPump> LLStartUp::sStateWatcher(new LLEventStream("StartupState"));
@ -3607,26 +3606,9 @@ bool process_login_success_response()
LLViewerMedia::getInstance()->openIDSetup(openid_url, openid_token);
}
gMaxAgentGroups = DEFAULT_MAX_AGENT_GROUPS;
if(response.has("max-agent-groups"))
{
S32 agent_groups = atoi(std::string(response["max-agent-groups"]).c_str());
if (agent_groups > 0 && agent_groups <= ALLOWED_MAX_AGENT_GROUPS)
{
gMaxAgentGroups = agent_groups;
LL_INFOS("LLStartup") << "gMaxAgentGroups read from login.cgi: "
<< gMaxAgentGroups << LL_ENDL;
}
else
{
LL_INFOS("LLStartup") << "Invalid value received, using defaults for gMaxAgentGroups: "
<< gMaxAgentGroups << LL_ENDL;
}
}
else {
LL_INFOS("LLStartup") << "Missing max-agent-groups, using default value for gMaxAgentGroups: "
<< gMaxAgentGroups << LL_ENDL;
}
gMaxAgentGroups = LLAgentBenefits::instance().getGroupMembershipLimit();
LL_INFOS("LLStartup") << "gMaxAgentGroups set from agent benefits: "
<< gMaxAgentGroups << LL_ENDL;
bool success = false;
// JC: gesture loading done below, when we have an asset system

View File

@ -171,22 +171,6 @@ void LLResourceUploadInfo::logPreparedUpload()
"Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL;
}
S32 LLResourceUploadInfo::getEconomyUploadCost()
{
// Update L$ and ownership credit information
// since it probably changed on the server
if (getAssetType() == LLAssetType::AT_TEXTURE ||
getAssetType() == LLAssetType::AT_SOUND ||
getAssetType() == LLAssetType::AT_ANIMATION ||
getAssetType() == LLAssetType::AT_MESH)
{
return LLGlobalEconomy::instance().getPriceUpload();
}
return 0;
}
LLUUID LLResourceUploadInfo::finishUpload(LLSD &result)
{
if (getFolderId().isNull())
@ -740,7 +724,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti
return;
}
S32 uploadPrice = result["upload_price"].asInteger();//uploadInfo->getEconomyUploadCost();
S32 uploadPrice = result["upload_price"].asInteger();
if (uploadPrice > 0)
{

View File

@ -62,7 +62,6 @@ public:
virtual LLSD prepareUpload();
virtual LLSD generatePostBody();
virtual void logPreparedUpload();
virtual S32 getEconomyUploadCost();
virtual LLUUID finishUpload(LLSD &result);
LLTransactionID getTransactionId() const { return mTransactionId; }

View File

@ -45,6 +45,7 @@
// newview includes
#include "llagent.h"
#include "llagentaccess.h"
#include "llagentbenefits.h"
#include "llagentcamera.h"
#include "llagentui.h"
#include "llagentwearables.h"
@ -134,6 +135,7 @@
#include "llstartup.h"
#include "boost/unordered_map.hpp"
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
#include "llcleanup.h"
using namespace LLAvatarAppearanceDefines;
@ -508,13 +510,15 @@ void init_menus()
gViewerWindow->setMenuBackgroundColor(false,
LLGridManager::getInstance()->isInProductionGrid());
// Assume L$10 for now, the server will tell us the real cost at login
// *TODO:Also fix cost in llfolderview.cpp for Inventory menus
const std::string upload_cost("10");
gMenuHolder->childSetLabelArg("Upload Image", "[COST]", upload_cost);
gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", upload_cost);
gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", upload_cost);
gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", upload_cost);
const std::string texture_upload_cost_str = std::to_string(LLAgentBenefits::instance().getTextureUploadCost());
const std::string sound_upload_cost_str = std::to_string(LLAgentBenefits::instance().getSoundUploadCost());
const std::string animation_upload_cost_str = std::to_string(LLAgentBenefits::instance().getAnimationUploadCost());
gMenuHolder->childSetLabelArg("Upload Image", "[COST]", texture_upload_cost_str);
gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", sound_upload_cost_str);
gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", animation_upload_cost_str);
// FIXME PREMIUM - do we need to handle non-texture bulk uploads?
gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", texture_upload_cost_str);
gAttachSubMenu = gMenuBarView->findChildMenuByName("Attach Object", TRUE);
gDetachSubMenu = gMenuBarView->findChildMenuByName("Detach Object", TRUE);
@ -8665,18 +8669,30 @@ class LLUploadCostCalculator : public view_listener_t
bool handleEvent(const LLSD& userdata)
{
std::string menu_name = userdata.asString();
std::vector<std::string> fields;
boost::split(fields, userdata.asString(), boost::is_any_of(","));
if (fields.size()<1)
{
return false;
}
std::string menu_name = fields[0];
std::string asset_type_str = "texture";
if (fields.size()>1)
{
asset_type_str = fields[1];
}
LL_DEBUGS("Benefits") << "userdata " << userdata << " menu_name " << menu_name << " asset_type_str " << asset_type_str << LL_ENDL;
calculateCost(asset_type_str);
gMenuHolder->childSetLabelArg(menu_name, "[COST]", mCostStr);
return true;
}
void calculateCost();
void calculateCost(const std::string& asset_type_str);
public:
LLUploadCostCalculator()
{
calculateCost();
}
};
@ -8702,19 +8718,24 @@ class LLToggleUIHints : public view_listener_t
}
};
void LLUploadCostCalculator::calculateCost()
void LLUploadCostCalculator::calculateCost(const std::string& asset_type_str)
{
S32 upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload();
// FIXME PREMIUM reasonable default?
S32 upload_cost = LLAgentBenefits::instance().getTextureUploadCost();
// getPriceUpload() returns -1 if no data available yet.
if(upload_cost >= 0)
if (asset_type_str == "texture")
{
mCostStr = llformat("%d", upload_cost);
upload_cost = LLAgentBenefits::instance().getTextureUploadCost();
}
else
else if (asset_type_str == "animation")
{
mCostStr = llformat("%d", gSavedSettings.getU32("DefaultUploadCost"));
upload_cost = LLAgentBenefits::instance().getAnimationUploadCost();
}
else if (asset_type_str == "sound")
{
upload_cost = LLAgentBenefits::instance().getSoundUploadCost();
}
mCostStr = std::to_string(upload_cost);
}
void show_navbar_context_menu(LLView* ctrl, S32 x, S32 y)
@ -8819,6 +8840,7 @@ void initialize_menus()
enable.add("displayViewerEventRecorderMenuItems",boost::bind(&LLViewerEventRecorder::displayViewerEventRecorderMenuItems,&LLViewerEventRecorder::instance()));
// FIXME PREMIUM these need to be distinguished by asset type - see menu_viewer.xml
view_listener_t::addEnable(new LLUploadCostCalculator(), "Upload.CalculateCosts");
enable.add("Conversation.IsConversationLoggingAllowed", boost::bind(&LLFloaterIMContainer::isConversationLoggingAllowed));

View File

@ -38,6 +38,7 @@
#include "raytrace.h"
#include "llagent.h" // Get state values from here
#include "llagentbenefits.h"
#include "llagentcamera.h"
#include "llagentwearables.h"
#include "llanimationstates.h"
@ -7060,20 +7061,7 @@ U32 LLVOAvatar::getNumAttachments() const
//-----------------------------------------------------------------------------
S32 LLVOAvatar::getMaxAttachments() const
{
const S32 MAX_AGENT_ATTACHMENTS = 38;
S32 max_attach = MAX_AGENT_ATTACHMENTS;
if (gAgent.getRegion())
{
LLSD features;
gAgent.getRegion()->getSimulatorFeatures(features);
if (features.has("MaxAgentAttachments"))
{
max_attach = features["MaxAgentAttachments"].asInteger();
}
}
return max_attach;
return LLAgentBenefits::instance().getAttachmentLimit();
}
//-----------------------------------------------------------------------------
@ -7107,24 +7095,7 @@ U32 LLVOAvatar::getNumAnimatedObjectAttachments() const
//-----------------------------------------------------------------------------
S32 LLVOAvatar::getMaxAnimatedObjectAttachments() const
{
S32 max_attach = 0;
if (gSavedSettings.getBOOL("AnimatedObjectsIgnoreLimits"))
{
max_attach = getMaxAttachments();
}
else
{
if (gAgent.getRegion())
{
LLSD features;
gAgent.getRegion()->getSimulatorFeatures(features);
if (features.has("AnimatedObjects"))
{
max_attach = features["AnimatedObjects"]["MaxAgentAnimatedObjectAttachments"].asInteger();
}
}
}
return max_attach;
return LLAgentBenefits::instance().getAnimatedObjectLimit();
}
//-----------------------------------------------------------------------------

View File

@ -1306,7 +1306,7 @@
function="File.EnableUpload" />
<menu_item_call.on_visible
function="Upload.CalculateCosts"
parameter="Upload Image" />
parameter="Upload Image,texture" />
</menu_item_call>
<menu_item_call
label="Sound (L$[COST])..."
@ -1319,7 +1319,7 @@
function="File.EnableUpload" />
<menu_item_call.on_visible
function="Upload.CalculateCosts"
parameter="Upload Sound" />
parameter="Upload Sound,sound" />
</menu_item_call>
<menu_item_call
label="Animation (L$[COST])..."
@ -1332,7 +1332,7 @@
function="File.EnableUpload" />
<menu_item_call.on_visible
function="Upload.CalculateCosts"
parameter="Upload Animation" />
parameter="Upload Animation,animation" />
</menu_item_call>
<menu_item_call
label="Model..."
@ -1350,6 +1350,9 @@
label="Bulk (L$[COST] per file)..."
layout="topleft"
name="Bulk Upload">
<menu_item_call.on_visible
function="Upload.CalculateCosts"
parameter="Bulk Upload,texture" />
<menu_item_call.on_click
function="File.UploadBulk"
parameter="" />