From 36f37ebf8a97cf1d5dacf6c8df41bf08375ac002 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 28 Feb 2023 12:08:25 -0600
Subject: [PATCH] SL-19263 Tidy up the reflection probe warning modal and add a
 cancel button.

---
 indra/newview/llpanelvolume.cpp               | 58 +++++++++++++------
 indra/newview/llpanelvolume.h                 |  7 +++
 .../skins/default/xui/en/notifications.xml    | 10 ++--
 3 files changed, 52 insertions(+), 23 deletions(-)

diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp
index 3c34d6ee65e..ed244f773c6 100644
--- a/indra/newview/llpanelvolume.cpp
+++ b/indra/newview/llpanelvolume.cpp
@@ -749,29 +749,49 @@ void LLPanelVolume::sendIsReflectionProbe()
     BOOL value = getChild<LLUICtrl>("Reflection Probe")->getValue();
     BOOL old_value = volobjp->isReflectionProbe();
 
-    volobjp->setIsReflectionProbe(value);
-    LL_INFOS() << "update reflection probe sent" << LL_ENDL;
+    if (value && value != old_value)
+    { // defer to notification util as to whether or not we *really* make this object a reflection probe
+        LLNotificationsUtil::add("ReflectionProbeApplied", LLSD(), LLSD(), boost::bind(&LLPanelVolume::doSendIsReflectionProbe, this, _1, _2));
+    }
+    else
+    {
+        volobjp->setIsReflectionProbe(value);
+    }
+}
 
-    if (value && !old_value)
-    { // has become a reflection probe, slam to a 10m sphere and pop up a message
-        // warning people about the pitfalls of reflection probes
-#if 0
-        auto* select_mgr = LLSelectMgr::getInstance();
+void LLPanelVolume::doSendIsReflectionProbe(const LLSD & notification, const LLSD & response)
+{
+    S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+    if (option == 0) // YES
+    {
+        LLViewerObject* objectp = mObject;
+        if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
+        {
+            return;
+        }
+        LLVOVolume* volobjp = (LLVOVolume*)objectp;
 
-        mObject->setScale(LLVector3(10.f, 10.f, 10.f));
-        select_mgr->sendMultipleUpdate(UPD_ROTATION | UPD_POSITION | UPD_SCALE);
+        volobjp->setIsReflectionProbe(true);
 
-        select_mgr->selectionUpdatePhantom(true);
-        select_mgr->selectionSetGLTFMaterial(LLUUID::null);
-        select_mgr->selectionSetAlphaOnly(0.f);
-        
-        LLVolumeParams params;
-        params.getPathParams().setCurveType(LL_PCODE_PATH_CIRCLE);
-        params.getProfileParams().setCurveType(LL_PCODE_PROFILE_CIRCLE_HALF);
-        mObject->updateVolume(params);
-#endif
+        { // has become a reflection probe, slam to a 10m sphere and pop up a message
+            // warning people about the pitfalls of reflection probes
+
+            auto* select_mgr = LLSelectMgr::getInstance();
 
-        LLNotificationsUtil::add("ReflectionProbeApplied");
+            select_mgr->selectionUpdatePhantom(true);
+            select_mgr->selectionSetGLTFMaterial(LLUUID::null);
+            select_mgr->selectionSetAlphaOnly(0.f);
+
+            LLVolumeParams params;
+            params.getPathParams().setCurveType(LL_PCODE_PATH_CIRCLE);
+            params.getProfileParams().setCurveType(LL_PCODE_PROFILE_CIRCLE_HALF);
+            mObject->updateVolume(params);
+        }
+    }
+    else
+    {
+        // cancelled, touch up UI state
+        getChild<LLUICtrl>("Reflection Probe")->setValue(false);
     }
 }
 
diff --git a/indra/newview/llpanelvolume.h b/indra/newview/llpanelvolume.h
index 62a6d01b21f..01b7ebb75c5 100644
--- a/indra/newview/llpanelvolume.h
+++ b/indra/newview/llpanelvolume.h
@@ -57,7 +57,14 @@ class LLPanelVolume : public LLPanel
 	void			refresh();
 
 	void			sendIsLight();
+    
+    // when an object is becoming a refleciton probe, present a dialog asking for confirmation
+    // otherwise, send the reflection probe update immediately
     void            sendIsReflectionProbe();
+
+    // callback for handling response of the ok/cancel/ignore dialog for making an object a reflection probe
+    void            doSendIsReflectionProbe(const LLSD& notification, const LLSD& response);
+
 	void			sendIsFlexible();
 
 	static bool		precommitValidate(const LLSD& data);
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 711be767645..bf67118eacb 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -12041,10 +12041,12 @@ Material successfully created.  Asset ID: [ASSET_ID]
     name="ReflectionProbeApplied"
     persist="true"
     type="alertmodal">
-    WARNING: You have made your object a Refelction Probe.  Continuing to manipulate the object while it is a probe will implicitly change the object to mimic its influence volume and will make irreversible changes to the object.  If you don't know what a reflection probe is, uncheck "Reflection Probe" immediately.  To learn more about Reflection Probes and how to use them, see https://wiki.secondlife.com/wiki/PBR_Materials#Understanding_and_Assisting_the_New_Reflections_System.
-    <usetemplate ignoretext="Reflection Probe tips"
-                 name="okignore"
-                 yestext="OK"/>
+    WARNING: You have made your object a Reflection Probe.  This will implicitly change the object to mimic its influence volume and will make irreversible changes to the object.  Do you want to continue?
+   <usetemplate
+       ignoretext="Reflection Probe tips"
+       name="okcancelignore"
+       notext="Cancel"
+       yestext="OK"/>
   </notification>
   
 </notifications>
-- 
GitLab