SL-18677 Disable materials UI when materials caps are not available

master
Andrey Kleshchev 2022-11-18 21:06:48 +02:00
parent 32663643c7
commit ade79bc6f6
8 changed files with 42 additions and 16 deletions

View File

@ -229,7 +229,7 @@ public:
U32 getUnsavedChangesFlags() { return mUnsavedChanges; }
U32 getRevertedChangesFlags() { return mRevertedChanges; }
bool capabilitiesAvalaible();
static bool capabilitiesAvalaible();
private:
static bool updateInventoryItem(const std::string &buffer, const LLUUID &item_id, const LLUUID &task_id);

View File

@ -1774,6 +1774,7 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
has_pbr_material = false;
BOOL editable = objectp->permModify() && !objectp->isPermanentEnforced();
bool has_pbr_capabilities = LLMaterialEditor::capabilitiesAvalaible();
// pbr material
LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control");
@ -1784,13 +1785,14 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
LLSelectedTE::getPbrMaterialId(pbr_id, identical_pbr);
pbr_ctrl->setTentative(identical_pbr ? FALSE : TRUE);
pbr_ctrl->setEnabled(editable);
pbr_ctrl->setEnabled(editable && has_pbr_capabilities);
pbr_ctrl->setImageAssetID(pbr_id);
has_pbr_material = pbr_id.notNull();
}
getChildView("pbr_from_inventory")->setEnabled(editable);
getChildView("edit_selected_pbr")->setEnabled(editable && has_pbr_material);
getChildView("save_selected_pbr")->setEnabled(objectp->permCopy() && has_pbr_material);
getChildView("pbr_from_inventory")->setEnabled(editable && has_pbr_capabilities);
getChildView("edit_selected_pbr")->setEnabled(editable && has_pbr_material && has_pbr_capabilities);
getChildView("save_selected_pbr")->setEnabled(objectp->permCopy() && has_pbr_material && has_pbr_capabilities);
const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled();
if (show_pbr)
@ -1806,11 +1808,11 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
LLUICtrl* gltfCtrlTextureOffsetU = getChild<LLUICtrl>("gltfTextureOffsetU");
LLUICtrl* gltfCtrlTextureOffsetV = getChild<LLUICtrl>("gltfTextureOffsetV");
gltfCtrlTextureScaleU->setEnabled(show_texture_info);
gltfCtrlTextureScaleV->setEnabled(show_texture_info);
gltfCtrlTextureRotation->setEnabled(show_texture_info);
gltfCtrlTextureOffsetU->setEnabled(show_texture_info);
gltfCtrlTextureOffsetV->setEnabled(show_texture_info);
gltfCtrlTextureScaleU->setEnabled(show_texture_info && has_pbr_capabilities);
gltfCtrlTextureScaleV->setEnabled(show_texture_info && has_pbr_capabilities);
gltfCtrlTextureRotation->setEnabled(show_texture_info && has_pbr_capabilities);
gltfCtrlTextureOffsetU->setEnabled(show_texture_info && has_pbr_capabilities);
gltfCtrlTextureOffsetV->setEnabled(show_texture_info && has_pbr_capabilities);
if (show_texture_info)
{
@ -1823,23 +1825,23 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
{
return mat->mTextureTransform[texture_info].mScale[VX];
return mat ? mat->mTextureTransform[texture_info].mScale[VX] : 0.f;
}, transform.mScale[VX], scale_u_same, true, 1e-3f);
readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
{
return mat->mTextureTransform[texture_info].mScale[VY];
return mat ? mat->mTextureTransform[texture_info].mScale[VY] : 0.f;
}, transform.mScale[VY], scale_v_same, true, 1e-3f);
readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
{
return mat->mTextureTransform[texture_info].mRotation;
return mat ? mat->mTextureTransform[texture_info].mRotation : 0.f;
}, transform.mRotation, rotation_same, true, 1e-3f);
readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
{
return mat->mTextureTransform[texture_info].mOffset[VX];
return mat ? mat->mTextureTransform[texture_info].mOffset[VX] : 0.f;
}, transform.mOffset[VX], offset_u_same, true, 1e-3f);
readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
{
return mat->mTextureTransform[texture_info].mOffset[VY];
return mat ? mat->mTextureTransform[texture_info].mOffset[VY] : 0.f;
}, transform.mOffset[VY], offset_v_same, true, 1e-3f);
gltfCtrlTextureScaleU->setValue(transform.mScale[VX]);

View File

@ -127,6 +127,7 @@ LLPanelMainInventory::LLPanelMainInventory(const LLPanel::Params& p)
mCommitCallbackRegistrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars, this));
mEnableCallbackRegistrar.add("Inventory.EnvironmentEnabled", [](LLUICtrl *, const LLSD &) { return LLPanelMainInventory::hasSettingsInventory(); });
mEnableCallbackRegistrar.add("Inventory.MaterialsEnabled", [](LLUICtrl *, const LLSD &) { return LLPanelMainInventory::hasMaterialsInventory(); });
mSavedFolderState = new LLSaveFolderState();
@ -1595,5 +1596,13 @@ bool LLPanelMainInventory::hasSettingsInventory()
return LLEnvironment::instance().isInventoryEnabled();
}
bool LLPanelMainInventory::hasMaterialsInventory()
{
std::string agent_url = gAgent.getRegionCapability("UpdateMaterialAgentInventory");
std::string task_url = gAgent.getRegionCapability("UpdateMaterialTaskInventory");
return (!agent_url.empty() && !task_url.empty());
}
// List Commands //
////////////////////////////////////////////////////////////////////////////////

View File

@ -165,6 +165,7 @@ protected:
void onCustomAction(const LLSD& command_name);
bool handleDragAndDropToTrash(BOOL drop, EDragAndDropType cargo_type, EAcceptance* accept);
static bool hasSettingsInventory();
static bool hasMaterialsInventory();
/**
* Set upload cost in "Upload" sub menu.
*/

View File

@ -2807,6 +2807,11 @@ struct LLSelectedTEGetmatIdAndPermissions : public LLSelectedTEFunctor
bool enable_object_edit_gltf_material()
{
if (!LLMaterialEditor::capabilitiesAvalaible())
{
return false;
}
LLSelectedTEGetmatIdAndPermissions func;
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func);
return func.mCanModify && func.mMaterialId.notNull();
@ -2814,6 +2819,11 @@ bool enable_object_edit_gltf_material()
bool enable_object_save_gltf_material()
{
if (!LLMaterialEditor::capabilitiesAvalaible())
{
return false;
}
LLSelectedTEGetmatIdAndPermissions func;
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func);
return func.mCanCopy && func.mMaterialId.notNull();

View File

@ -2652,7 +2652,7 @@ void LLViewerRegion::cacheFullUpdateExtras(LLSD const & extras, std::string cons
}
else
{
LL_WARNS() << "got material override for unknown object_id, cannot cache it" << LL_ENDL;
LL_WARNS("GLTF") << "got material override for unknown object_id, cannot cache it" << LL_ENDL;
}
}

View File

@ -474,6 +474,8 @@
<menu_item_call.on_click
function="Inventory.DoCreate"
parameter="material" />
<menu_item_call.on_enable
function="Inventory.MaterialsEnabled" />
</menu_item_call>
<menu
label="New Clothes"

View File

@ -104,6 +104,8 @@
<menu_item_call.on_click
function="Inventory.DoCreate"
parameter="material" />
<menu_item_call.on_enable
function="Inventory.MaterialsEnabled" />
</menu_item_call>
<menu
height="175"