summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-07-19 19:56:16 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-07-19 19:56:16 +0300
commit40a1154ec9e5b98bdeec408aa8cce7a10919d602 (patch)
treeb23c509220fd5e5427657079f73eedee2dc61b90
parent35a97efcb713db780399bb6ce1fbb38e517bd570 (diff)
SL-17640 Check account balance before uploading
-rw-r--r--indra/newview/llmaterialeditor.cpp22
-rw-r--r--indra/newview/llmaterialeditor.h1
2 files changed, 21 insertions, 2 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 4f8558277d..fe50689c1e 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -40,6 +40,7 @@
#include "llviewertexture.h"
#include "llsdutil.h"
#include "llselectmgr.h"
+#include "llstatusbar.h" // can_afford_transaction()
#include "llviewerinventory.h"
#include "llviewerregion.h"
#include "llvovolume.h"
@@ -79,6 +80,7 @@ private:
LLMaterialEditor::LLMaterialEditor(const LLSD& key)
: LLPreview(key)
, mHasUnsavedChanges(false)
+ , mExpectedUploadCost(0)
{
const LLInventoryItem* item = getItem();
if (item)
@@ -366,8 +368,8 @@ void LLMaterialEditor::setHasUnsavedChanges(bool value)
upload_texture_count++;
}
- S32 upload_cost = upload_texture_count * LLAgentBenefitsMgr::current().getTextureUploadCost();
- getChild<LLUICtrl>("total_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost));
+ mExpectedUploadCost = upload_texture_count * LLAgentBenefitsMgr::current().getTextureUploadCost();
+ getChild<LLUICtrl>("total_upload_fee")->setTextArg("[FEE]", llformat("%d", mExpectedUploadCost));
}
void LLMaterialEditor::setCanSaveAs(BOOL value)
@@ -474,6 +476,14 @@ static U32 write_texture(const LLUUID& id, tinygltf::Model& model)
void LLMaterialEditor::onClickSave()
{
+ if (!can_afford_transaction(mExpectedUploadCost))
+ {
+ LLSD args;
+ args["COST"] = llformat("%d", mExpectedUploadCost);
+ LLNotificationsUtil::add("ErrorCannotAffordUpload", args);
+ return;
+ }
+
applyToSelection();
saveIfNeeded();
}
@@ -839,6 +849,14 @@ void LLMaterialEditor::refreshFromInventory(const LLUUID& new_item_id)
void LLMaterialEditor::onClickSaveAs()
{
+ if (!can_afford_transaction(mExpectedUploadCost))
+ {
+ LLSD args;
+ args["COST"] = llformat("%d", mExpectedUploadCost);
+ LLNotificationsUtil::add("ErrorCannotAffordUpload", args);
+ return;
+ }
+
LLSD args;
args["DESC"] = mMaterialName;
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 6196e3d310..be376c9d2b 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -191,6 +191,7 @@ private:
LLPointer<LLImageJ2C> mEmissiveJ2C;
bool mHasUnsavedChanges;
+ S32 mExpectedUploadCost;
std::string mMaterialName;
};