Skip to content
Snippets Groups Projects
Commit 68dfa1f5 authored by Andrey Kleshchev's avatar Andrey Kleshchev
Browse files

SL-17640 Use LLAgentBenefitsMgr for upload cost

parent 2880cd01
No related branches found
No related tags found
2 merge requests!3Update to main branch,!2Rebase onto current main branch
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "llmaterialeditor.h" #include "llmaterialeditor.h"
#include "llagent.h" #include "llagent.h"
#include "llagentbenefits.h"
#include "llappviewer.h" #include "llappviewer.h"
#include "llcombobox.h" #include "llcombobox.h"
#include "llinventorymodel.h" #include "llinventorymodel.h"
...@@ -86,6 +87,12 @@ BOOL LLMaterialEditor::postBuild() ...@@ -86,6 +87,12 @@ BOOL LLMaterialEditor::postBuild()
childSetAction("save_as", boost::bind(&LLMaterialEditor::onClickSaveAs, this)); childSetAction("save_as", boost::bind(&LLMaterialEditor::onClickSaveAs, this));
childSetAction("cancel", boost::bind(&LLMaterialEditor::onClickCancel, this)); childSetAction("cancel", boost::bind(&LLMaterialEditor::onClickCancel, this));
S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost();
getChild<LLUICtrl>("albedo_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost));
getChild<LLUICtrl>("metallic_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost));
getChild<LLUICtrl>("emissive_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost));
getChild<LLUICtrl>("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost));
boost::function<void(LLUICtrl*, void*)> changes_callback = [this](LLUICtrl * ctrl, void*) boost::function<void(LLUICtrl*, void*)> changes_callback = [this](LLUICtrl * ctrl, void*)
{ {
setHasUnsavedChanges(true); setHasUnsavedChanges(true);
...@@ -142,7 +149,12 @@ void LLMaterialEditor::setAlbedoId(const LLUUID& id) ...@@ -142,7 +149,12 @@ void LLMaterialEditor::setAlbedoId(const LLUUID& id)
{ {
mAlbedoTextureCtrl->setValue(id); mAlbedoTextureCtrl->setValue(id);
mAlbedoTextureCtrl->setDefaultImageAssetID(id); mAlbedoTextureCtrl->setDefaultImageAssetID(id);
}
void LLMaterialEditor::setAlbedoUploadId(const LLUUID& id)
{
// Might be better to use local textures and
// assign a fee in case of a local texture
if (id.notNull()) if (id.notNull())
{ {
// todo: this does not account for posibility of texture // todo: this does not account for posibility of texture
...@@ -151,6 +163,7 @@ void LLMaterialEditor::setAlbedoId(const LLUUID& id) ...@@ -151,6 +163,7 @@ void LLMaterialEditor::setAlbedoId(const LLUUID& id)
// Only set if we will need to upload this texture // Only set if we will need to upload this texture
mAlbedoTextureUploadId = id; mAlbedoTextureUploadId = id;
} }
setHasUnsavedChanges(true);
} }
LLColor4 LLMaterialEditor::getAlbedoColor() LLColor4 LLMaterialEditor::getAlbedoColor()
...@@ -211,7 +224,10 @@ void LLMaterialEditor::setMetallicRoughnessId(const LLUUID& id) ...@@ -211,7 +224,10 @@ void LLMaterialEditor::setMetallicRoughnessId(const LLUUID& id)
{ {
mMetallicTextureCtrl->setValue(id); mMetallicTextureCtrl->setValue(id);
mMetallicTextureCtrl->setDefaultImageAssetID(id); mMetallicTextureCtrl->setDefaultImageAssetID(id);
}
void LLMaterialEditor::setMetallicRoughnessUploadId(const LLUUID& id)
{
if (id.notNull()) if (id.notNull())
{ {
// todo: this does not account for posibility of texture // todo: this does not account for posibility of texture
...@@ -219,6 +235,7 @@ void LLMaterialEditor::setMetallicRoughnessId(const LLUUID& id) ...@@ -219,6 +235,7 @@ void LLMaterialEditor::setMetallicRoughnessId(const LLUUID& id)
childSetValue("metallic_upload_fee", getString("upload_fee_string")); childSetValue("metallic_upload_fee", getString("upload_fee_string"));
mMetallicTextureUploadId = id; mMetallicTextureUploadId = id;
} }
setHasUnsavedChanges(true);
} }
F32 LLMaterialEditor::getMetalnessFactor() F32 LLMaterialEditor::getMetalnessFactor()
...@@ -250,7 +267,10 @@ void LLMaterialEditor::setEmissiveId(const LLUUID& id) ...@@ -250,7 +267,10 @@ void LLMaterialEditor::setEmissiveId(const LLUUID& id)
{ {
mEmissiveTextureCtrl->setValue(id); mEmissiveTextureCtrl->setValue(id);
mEmissiveTextureCtrl->setDefaultImageAssetID(id); mEmissiveTextureCtrl->setDefaultImageAssetID(id);
}
void LLMaterialEditor::setEmissiveUploadId(const LLUUID& id)
{
if (id.notNull()) if (id.notNull())
{ {
// todo: this does not account for posibility of texture // todo: this does not account for posibility of texture
...@@ -258,6 +278,7 @@ void LLMaterialEditor::setEmissiveId(const LLUUID& id) ...@@ -258,6 +278,7 @@ void LLMaterialEditor::setEmissiveId(const LLUUID& id)
childSetValue("emissive_upload_fee", getString("upload_fee_string")); childSetValue("emissive_upload_fee", getString("upload_fee_string"));
mEmissiveTextureUploadId = id; mEmissiveTextureUploadId = id;
} }
setHasUnsavedChanges(true);
} }
LLColor4 LLMaterialEditor::getEmissiveColor() LLColor4 LLMaterialEditor::getEmissiveColor()
...@@ -279,7 +300,10 @@ void LLMaterialEditor::setNormalId(const LLUUID& id) ...@@ -279,7 +300,10 @@ void LLMaterialEditor::setNormalId(const LLUUID& id)
{ {
mNormalTextureCtrl->setValue(id); mNormalTextureCtrl->setValue(id);
mNormalTextureCtrl->setDefaultImageAssetID(id); mNormalTextureCtrl->setDefaultImageAssetID(id);
}
void LLMaterialEditor::setNormalUploadId(const LLUUID& id)
{
if (id.notNull()) if (id.notNull())
{ {
// todo: this does not account for posibility of texture // todo: this does not account for posibility of texture
...@@ -287,6 +311,7 @@ void LLMaterialEditor::setNormalId(const LLUUID& id) ...@@ -287,6 +311,7 @@ void LLMaterialEditor::setNormalId(const LLUUID& id)
childSetValue("normal_upload_fee", getString("upload_fee_string")); childSetValue("normal_upload_fee", getString("upload_fee_string"));
mNormalTextureUploadId = id; mNormalTextureUploadId = id;
} }
setHasUnsavedChanges(true);
} }
bool LLMaterialEditor::getDoubleSided() bool LLMaterialEditor::getDoubleSided()
...@@ -306,6 +331,27 @@ void LLMaterialEditor::setHasUnsavedChanges(bool value) ...@@ -306,6 +331,27 @@ void LLMaterialEditor::setHasUnsavedChanges(bool value)
mHasUnsavedChanges = value; mHasUnsavedChanges = value;
childSetVisible("unsaved_changes", value); childSetVisible("unsaved_changes", value);
} }
S32 upload_texture_count = 0;
if (mAlbedoTextureUploadId.notNull() && mAlbedoTextureUploadId == getAlbedoId())
{
upload_texture_count++;
}
if (mMetallicTextureUploadId.notNull() && mMetallicTextureUploadId == getMetallicRoughnessId())
{
upload_texture_count++;
}
if (mEmissiveTextureUploadId.notNull() && mEmissiveTextureUploadId == getEmissiveId())
{
upload_texture_count++;
}
if (mNormalTextureUploadId.notNull() && mNormalTextureUploadId == getNormalId())
{
upload_texture_count++;
}
S32 upload_cost = upload_texture_count * LLAgentBenefitsMgr::current().getTextureUploadCost();
getChild<LLUICtrl>("total_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost));
} }
void LLMaterialEditor::onCommitAlbedoTexture(LLUICtrl * ctrl, const LLSD & data) void LLMaterialEditor::onCommitAlbedoTexture(LLUICtrl * ctrl, const LLSD & data)
...@@ -866,6 +912,8 @@ static void pack_textures(tinygltf::Model& model, tinygltf::Material& material, ...@@ -866,6 +912,8 @@ static void pack_textures(tinygltf::Model& model, tinygltf::Material& material,
LLPointer<LLImageJ2C>& mr_j2c, LLPointer<LLImageJ2C>& mr_j2c,
LLPointer<LLImageJ2C>& emissive_j2c) LLPointer<LLImageJ2C>& emissive_j2c)
{ {
// todo: consider using LLLocalBitmapMgr or storing textures' pointers somewhere in floater
// otherwise images won't exist for long if texture ctrl temporaly switches to something else
if (albedo_img) if (albedo_img)
{ {
albedo_tex = LLViewerTextureManager::getFetchedTexture(albedo_img, FTType::FTT_LOCAL_FILE, true); albedo_tex = LLViewerTextureManager::getFetchedTexture(albedo_img, FTType::FTT_LOCAL_FILE, true);
...@@ -1035,9 +1083,13 @@ void LLMaterialFilePicker::loadMaterial(const std::string& filename) ...@@ -1035,9 +1083,13 @@ void LLMaterialFilePicker::loadMaterial(const std::string& filename)
} }
mME->setAlbedoId(albedo_id); mME->setAlbedoId(albedo_id);
mME->setAlbedoUploadId(albedo_id);
mME->setMetallicRoughnessId(mr_id); mME->setMetallicRoughnessId(mr_id);
mME->setMetallicRoughnessUploadId(mr_id);
mME->setEmissiveId(emissive_id); mME->setEmissiveId(emissive_id);
mME->setEmissiveUploadId(emissive_id);
mME->setNormalId(normal_id); mME->setNormalId(normal_id);
mME->setNormalUploadId(normal_id);
mME->setFromGltfModel(model_in); mME->setFromGltfModel(model_in);
...@@ -1383,7 +1435,7 @@ void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, con ...@@ -1383,7 +1435,7 @@ void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, con
std::string buffer; std::string buffer;
buffer.assign((const char*) img->getData(), img->getDataSize()); buffer.assign((const char*) img->getData(), img->getDataSize());
U32 expected_upload_cost = 10; // TODO: where do we get L$10 for textures from? U32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost();
LLAssetStorage::LLStoreAssetCallback callback; LLAssetStorage::LLStoreAssetCallback callback;
......
...@@ -99,6 +99,7 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener ...@@ -99,6 +99,7 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener
LLUUID getAlbedoId(); LLUUID getAlbedoId();
void setAlbedoId(const LLUUID& id); void setAlbedoId(const LLUUID& id);
void setAlbedoUploadId(const LLUUID& id);
LLColor4 getAlbedoColor(); LLColor4 getAlbedoColor();
...@@ -118,6 +119,7 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener ...@@ -118,6 +119,7 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener
LLUUID getMetallicRoughnessId(); LLUUID getMetallicRoughnessId();
void setMetallicRoughnessId(const LLUUID& id); void setMetallicRoughnessId(const LLUUID& id);
void setMetallicRoughnessUploadId(const LLUUID& id);
F32 getMetalnessFactor(); F32 getMetalnessFactor();
void setMetalnessFactor(F32 factor); void setMetalnessFactor(F32 factor);
...@@ -127,12 +129,14 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener ...@@ -127,12 +129,14 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener
LLUUID getEmissiveId(); LLUUID getEmissiveId();
void setEmissiveId(const LLUUID& id); void setEmissiveId(const LLUUID& id);
void setEmissiveUploadId(const LLUUID& id);
LLColor4 getEmissiveColor(); LLColor4 getEmissiveColor();
void setEmissiveColor(const LLColor4& color); void setEmissiveColor(const LLColor4& color);
LLUUID getNormalId(); LLUUID getNormalId();
void setNormalId(const LLUUID& id); void setNormalId(const LLUUID& id);
void setNormalUploadId(const LLUUID& id);
bool getDoubleSided(); bool getDoubleSided();
void setDoubleSided(bool double_sided); void setDoubleSided(bool double_sided);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
title="[MATERIAL_NAME]" title="[MATERIAL_NAME]"
width="256"> width="256">
<string name="no_upload_fee_string">no upload fee</string> <string name="no_upload_fee_string">no upload fee</string>
<string name="upload_fee_string">L$10 upload fee</string> <string name="upload_fee_string">L$[FEE] upload fee</string>
<check_box <check_box
follows="left|top" follows="left|top"
label="Double Sided" label="Double Sided"
...@@ -473,6 +473,7 @@ ...@@ -473,6 +473,7 @@
layout="topleft" layout="topleft"
left="10" left="10"
top_pad="5" top_pad="5"
name="total_upload_fee"
> >
Total upload fee: L$ [FEE] Total upload fee: L$ [FEE]
</text> </text>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment