summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-09-26 23:23:52 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-09-26 23:23:52 +0300
commit30b6d29b042f6f9a5054d80cad26960b83d8472b (patch)
tree387e758a0871d2b8dbba97e12e50e8aa8857b51e /indra/newview
parent20f44fb522099e8e14e42ea0d5dedf76b24b9d6c (diff)
SL-17640 Material editor permissions support
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llmaterialeditor.cpp43
-rw-r--r--indra/newview/llmaterialeditor.h5
2 files changed, 42 insertions, 6 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 12d21cf284..a0ab771c7b 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -149,6 +149,8 @@ BOOL LLMaterialEditor::postBuild()
childSetVisible("unsaved_changes", mHasUnsavedChanges);
+ getChild<LLUICtrl>("total_upload_fee")->setTextArg("[FEE]", llformat("%d", 0));
+
// Todo:
// Disable/enable setCanApplyImmediately() based on
// working from inventory, upload or editing inworld
@@ -391,16 +393,43 @@ void LLMaterialEditor::setHasUnsavedChanges(bool value)
getChild<LLUICtrl>("total_upload_fee")->setTextArg("[FEE]", llformat("%d", mExpectedUploadCost));
}
-void LLMaterialEditor::setCanSaveAs(BOOL value)
+void LLMaterialEditor::setCanSaveAs(bool value)
{
childSetEnabled("save_as", value);
}
-void LLMaterialEditor::setCanSave(BOOL value)
+void LLMaterialEditor::setCanSave(bool value)
{
childSetEnabled("save", value);
}
+void LLMaterialEditor::setEnableEditing(bool can_modify)
+{
+ childSetEnabled("double sided", can_modify);
+
+ // BaseColor
+ childSetEnabled("base color", can_modify);
+ childSetEnabled("transparency", can_modify);
+ childSetEnabled("alpha mode", can_modify);
+ childSetEnabled("alpha cutoff", can_modify);
+
+ // Metallic-Roughness
+ childSetEnabled("metalness factor", can_modify);
+ childSetEnabled("roughness factor", can_modify);
+
+ // Metallic-Roughness
+ childSetEnabled("metalness factor", can_modify);
+ childSetEnabled("roughness factor", can_modify);
+
+ // Emissive
+ childSetEnabled("emissive color", can_modify);
+
+ mBaseColorTextureCtrl->setEnabled(can_modify);
+ mMetallicTextureCtrl->setEnabled(can_modify);
+ mEmissiveTextureCtrl->setEnabled(can_modify);
+ mNormalTextureCtrl->setEnabled(can_modify);
+}
+
void LLMaterialEditor::onCommitBaseColorTexture(LLUICtrl * ctrl, const LLSD & data)
{
// might be better to use arrays, to have a single callback
@@ -1624,6 +1653,7 @@ void LLMaterialEditor::loadAsset()
mAssetStatus = PREVIEW_ASSET_LOADED;
loadDefaults();
setHasUnsavedChanges(false);
+ setEnableEditing(allow_modify && !source_library);
}
else
{
@@ -1644,6 +1674,7 @@ void LLMaterialEditor::loadAsset()
mAssetID.setNull();
mAssetStatus = PREVIEW_ASSET_LOADED;
setHasUnsavedChanges(false);
+ setEnableEditing(allow_modify && !source_library);
return;
}
user_data->with("taskid", mObjectUUID).with("itemid", mItemUUID);
@@ -1653,6 +1684,8 @@ void LLMaterialEditor::loadAsset()
user_data = new LLSD(mItemUUID);
}
+ setEnableEditing(false); // wait for it to load
+
gAssetStorage->getInvItemAsset(source_sim,
gAgent.getID(),
gAgent.getSessionID(),
@@ -1724,8 +1757,9 @@ void LLMaterialEditor::onLoadComplete(const LLUUID& asset_uuid,
editor->decodeAsset(buffer);
- BOOL modifiable = editor->canModify(editor->mObjectID, editor->getItem());
- editor->setEnabled(modifiable);
+ BOOL allow_modify = editor->canModify(editor->mObjectID, editor->getItem());
+ BOOL source_library = editor->mObjectID.isNull() && gInventory.isObjectDescendentOf(editor->mItemUUID, gInventory.getLibraryRootFolderID());
+ editor->setEnableEditing(allow_modify && !source_library);
editor->setHasUnsavedChanges(false);
editor->mAssetStatus = PREVIEW_ASSET_LOADED;
}
@@ -1744,6 +1778,7 @@ void LLMaterialEditor::onLoadComplete(const LLUUID& asset_uuid,
{
LLNotificationsUtil::add("UnableToLoadMaterial");
}
+ editor->setEnableEditing(false);
LL_WARNS() << "Problem loading material: " << status << LL_ENDL;
editor->mAssetStatus = PREVIEW_ASSET_ERROR;
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 0d741614b8..8a67c3c348 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -153,8 +153,9 @@ public:
void setDoubleSided(bool double_sided);
void setHasUnsavedChanges(bool value);
- void setCanSaveAs(BOOL value);
- void setCanSave(BOOL value);
+ void setCanSaveAs(bool value);
+ void setCanSave(bool value);
+ void setEnableEditing(bool can_modify);
void onCommitBaseColorTexture(LLUICtrl* ctrl, const LLSD& data);
void onCommitMetallicTexture(LLUICtrl* ctrl, const LLSD& data);