diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llmaterialeditor.cpp | 54 | ||||
| -rw-r--r-- | indra/newview/llmaterialeditor.h | 4 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/floater_material_editor.xml | 3 | 
3 files changed, 59 insertions, 2 deletions
| diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 9fb9f723cd..67d963bb63 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -29,6 +29,7 @@  #include "llmaterialeditor.h"  #include "llagent.h" +#include "llagentbenefits.h"  #include "llappviewer.h"  #include "llcombobox.h"  #include "llinventorymodel.h" @@ -86,6 +87,12 @@ BOOL LLMaterialEditor::postBuild()      childSetAction("save_as", boost::bind(&LLMaterialEditor::onClickSaveAs, 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*)      {          setHasUnsavedChanges(true); @@ -142,7 +149,12 @@ void LLMaterialEditor::setAlbedoId(const LLUUID& id)  {      mAlbedoTextureCtrl->setValue(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())      {          // todo: this does not account for posibility of texture @@ -151,6 +163,7 @@ void LLMaterialEditor::setAlbedoId(const LLUUID& id)          // Only set if we will need to upload this texture          mAlbedoTextureUploadId = id;      } +    setHasUnsavedChanges(true);  }  LLColor4 LLMaterialEditor::getAlbedoColor() @@ -211,7 +224,10 @@ void LLMaterialEditor::setMetallicRoughnessId(const LLUUID& id)  {      mMetallicTextureCtrl->setValue(id);      mMetallicTextureCtrl->setDefaultImageAssetID(id); +} +void LLMaterialEditor::setMetallicRoughnessUploadId(const LLUUID& id) +{      if (id.notNull())      {          // todo: this does not account for posibility of texture @@ -219,6 +235,7 @@ void LLMaterialEditor::setMetallicRoughnessId(const LLUUID& id)          childSetValue("metallic_upload_fee", getString("upload_fee_string"));          mMetallicTextureUploadId = id;      } +    setHasUnsavedChanges(true);  }  F32 LLMaterialEditor::getMetalnessFactor() @@ -250,7 +267,10 @@ void LLMaterialEditor::setEmissiveId(const LLUUID& id)  {      mEmissiveTextureCtrl->setValue(id);      mEmissiveTextureCtrl->setDefaultImageAssetID(id); +} +void LLMaterialEditor::setEmissiveUploadId(const LLUUID& id) +{      if (id.notNull())      {          // todo: this does not account for posibility of texture @@ -258,6 +278,7 @@ void LLMaterialEditor::setEmissiveId(const LLUUID& id)          childSetValue("emissive_upload_fee", getString("upload_fee_string"));          mEmissiveTextureUploadId = id;      } +    setHasUnsavedChanges(true);  }  LLColor4 LLMaterialEditor::getEmissiveColor() @@ -279,7 +300,10 @@ void LLMaterialEditor::setNormalId(const LLUUID& id)  {      mNormalTextureCtrl->setValue(id);      mNormalTextureCtrl->setDefaultImageAssetID(id); +} +void LLMaterialEditor::setNormalUploadId(const LLUUID& id) +{      if (id.notNull())      {          // todo: this does not account for posibility of texture @@ -287,6 +311,7 @@ void LLMaterialEditor::setNormalId(const LLUUID& id)          childSetValue("normal_upload_fee", getString("upload_fee_string"));          mNormalTextureUploadId = id;      } +    setHasUnsavedChanges(true);  }  bool LLMaterialEditor::getDoubleSided() @@ -306,6 +331,27 @@ void LLMaterialEditor::setHasUnsavedChanges(bool value)          mHasUnsavedChanges = 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) @@ -866,6 +912,8 @@ static void pack_textures(tinygltf::Model& model, tinygltf::Material& material,      LLPointer<LLImageJ2C>& mr_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)      {          albedo_tex = LLViewerTextureManager::getFetchedTexture(albedo_img, FTType::FTT_LOCAL_FILE, true); @@ -1035,9 +1083,13 @@ void LLMaterialFilePicker::loadMaterial(const std::string& filename)      }      mME->setAlbedoId(albedo_id); +    mME->setAlbedoUploadId(albedo_id);      mME->setMetallicRoughnessId(mr_id); +    mME->setMetallicRoughnessUploadId(mr_id);      mME->setEmissiveId(emissive_id); +    mME->setEmissiveUploadId(emissive_id);      mME->setNormalId(normal_id); +    mME->setNormalUploadId(normal_id);      mME->setFromGltfModel(model_in); @@ -1383,7 +1435,7 @@ void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, con      std::string buffer;      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; diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 6ccb27cf27..b2a6e96eac 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -99,6 +99,7 @@ public:      LLUUID getAlbedoId();      void setAlbedoId(const LLUUID& id); +    void setAlbedoUploadId(const LLUUID& id);      LLColor4 getAlbedoColor(); @@ -118,6 +119,7 @@ public:      LLUUID getMetallicRoughnessId();      void setMetallicRoughnessId(const LLUUID& id); +    void setMetallicRoughnessUploadId(const LLUUID& id);      F32 getMetalnessFactor();      void setMetalnessFactor(F32 factor); @@ -127,12 +129,14 @@ public:      LLUUID getEmissiveId();      void setEmissiveId(const LLUUID& id); +    void setEmissiveUploadId(const LLUUID& id);      LLColor4 getEmissiveColor();      void setEmissiveColor(const LLColor4& color);      LLUUID getNormalId();      void setNormalId(const LLUUID& id); +    void setNormalUploadId(const LLUUID& id);      bool getDoubleSided();      void setDoubleSided(bool double_sided); diff --git a/indra/newview/skins/default/xui/en/floater_material_editor.xml b/indra/newview/skins/default/xui/en/floater_material_editor.xml index df06896fa5..7d532ecd7b 100644 --- a/indra/newview/skins/default/xui/en/floater_material_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_material_editor.xml @@ -10,7 +10,7 @@   title="[MATERIAL_NAME]"   width="256">    <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            follows="left|top"            label="Double Sided" @@ -473,6 +473,7 @@                 layout="topleft"                 left="10"                 top_pad="5" +               name="total_upload_fee"             >        Total upload fee: L$ [FEE]      </text> | 
