summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelface.cpp
diff options
context:
space:
mode:
authorCosmic Linden <cosmic@lindenlab.com>2023-11-02 09:55:44 -0700
committerCosmic Linden <cosmic@lindenlab.com>2023-11-09 13:54:41 -0800
commit711354c2f526421b7cd2918f584731624a9995e5 (patch)
tree831a6bc08e80a87a593d03bc48036d5e045adfe9 /indra/newview/llpanelface.cpp
parentb3384a057d9556b2429a9c5847e8e1240103585a (diff)
SL-20553: Save material button in build floater now depends on agent inventory rather than object inventory
Diffstat (limited to 'indra/newview/llpanelface.cpp')
-rw-r--r--indra/newview/llpanelface.cpp65
1 files changed, 58 insertions, 7 deletions
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 9150b89de3..02c00e7f87 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -1880,15 +1880,55 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
}
}
+// One-off listener that updates the build floater UI when the agent inventory adds or removes an item
+class PBRPickerAgentListener : public LLInventoryObserver
+{
+protected:
+ bool mChangePending = true;
+public:
+ PBRPickerAgentListener() : LLInventoryObserver()
+ {
+ gInventory.addObserver(this);
+ }
+
+ const bool isListening()
+ {
+ return mChangePending;
+ }
+
+ void changed(U32 mask) override
+ {
+ if (!(mask & (ADD | REMOVE)))
+ {
+ return;
+ }
+
+ if (gFloaterTools)
+ {
+ gFloaterTools->dirty();
+ }
+ gInventory.removeObserver(this);
+ mChangePending = false;
+ }
+
+ ~PBRPickerAgentListener() override
+ {
+ gInventory.removeObserver(this);
+ mChangePending = false;
+
+ LLInventoryObserver::~LLInventoryObserver();
+ }
+};
+
// One-off listener that updates the build floater UI when the prim inventory updates
-class PBRPickerItemListener : public LLVOInventoryListener
+class PBRPickerObjectListener : public LLVOInventoryListener
{
protected:
LLViewerObject* mObjectp;
bool mChangePending = true;
public:
- PBRPickerItemListener(LLViewerObject* object)
+ PBRPickerObjectListener(LLViewerObject* object)
: mObjectp(object)
{
registerVOInventoryListener(mObjectp, nullptr);
@@ -1912,7 +1952,7 @@ public:
mChangePending = false;
}
- ~PBRPickerItemListener()
+ ~PBRPickerObjectListener()
{
removeVOInventoryListener();
mChangePending = false;
@@ -1931,9 +1971,9 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
// pbr material
LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control");
+ LLUUID pbr_id;
if (pbr_ctrl)
{
- LLUUID pbr_id;
LLSelectedTE::getPbrMaterialId(pbr_id, identical_pbr, has_pbr_material, has_faces_without_pbr);
pbr_ctrl->setTentative(identical_pbr ? FALSE : TRUE);
@@ -1956,14 +1996,25 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
if (objectp->isInventoryPending())
{
// Reuse the same listener when possible
- if (!mInventoryListener || !mInventoryListener->isListeningFor(objectp))
+ if (!mVOInventoryListener || !mVOInventoryListener->isListeningFor(objectp))
{
- mInventoryListener = std::make_unique<PBRPickerItemListener>(objectp);
+ mVOInventoryListener = std::make_unique<PBRPickerObjectListener>(objectp);
}
}
else
{
- mInventoryListener = nullptr;
+ mVOInventoryListener = nullptr;
+ }
+ if (!identical_pbr || pbr_id.isNull() || pbr_id == LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID)
+ {
+ mAgentInventoryListener = nullptr;
+ }
+ else
+ {
+ if (!mAgentInventoryListener || !mAgentInventoryListener->isListening())
+ {
+ mAgentInventoryListener = std::make_unique<PBRPickerAgentListener>();
+ }
}
const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled();