[sldev] PATCH: Copy UUID pie menu item

John Hurliman jhurliman at wsu.edu
Sat Jan 13 01:56:11 PST 2007


I got a request in IRC to add a "Copy UUID" option to the pie menu for 
objects and avatars, much like the right-click menu item in your 
inventory. Countless times I've been working on something in 
libsecondlife where I'm trying to debug an object or avatar and need to 
get the UUID for it, and we've devised all sorts of strange contraptions 
including rolling a ball in to it that emits the UUID of things it hits, 
to sensors and whatever else. Hopefully someone will find a use for this 
while working on opensl code too.

John Hurliman


Index: llviewermenu.cpp
===================================================================
--- llviewermenu.cpp    (revision 23)
+++ llviewermenu.cpp    (working copy)
@@ -2050,6 +2050,36 @@
     }
 };
 
+class LLObjectEnableCopyUUID : public view_listener_t
+{
+    bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
+    {
+        LLViewerObject* object = gViewerWindow->lastObjectHit();
+        bool new_value = (object != NULL);
+        
gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
+        return true;
+    }
+};
+
+class LLObjectCopyUUID : public view_listener_t
+{
+    bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
+    {
+        LLViewerObject* object = gViewerWindow->lastObjectHit();
+        if (!object) return true;
+
+        LLUUID id = object->getID();
+
+        char buffer[UUID_STR_LENGTH];
+        id.toString(buffer);
+
+        
gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(buffer));
+
+        gSelectMgr->deselectAll();
+        return true;
+    }
+};
+
 bool handle_go_to()
 {
     // JAMESDEBUG try simulator autopilot
@@ -8774,6 +8804,7 @@
     (new LLObjectMute())->registerListener(gMenuHolder, "Object.Mute");
     (new LLObjectBuy())->registerListener(gMenuHolder, "Object.Buy");
     (new LLObjectEdit())->registerListener(gMenuHolder, "Object.Edit");
+    (new LLObjectCopyUUID())->registerListener(gMenuHolder, 
"Object.CopyUUID");
 
     (new LLObjectEnableOpen())->registerListener(gMenuHolder, 
"Object.EnableOpen");
     (new LLObjectEnableTouch())->registerListener(gMenuHolder, 
"Object.EnableTouch");
@@ -8786,6 +8817,7 @@
     (new LLObjectEnableRateCreator())->registerListener(gMenuHolder, 
"Object.EnableRateCreator");
     (new LLObjectEnableMute())->registerListener(gMenuHolder, 
"Object.EnableMute");
     (new LLObjectEnableBuy())->registerListener(gMenuHolder, 
"Object.EnableBuy");
+    (new LLObjectEnableCopyUUID())->registerListener(gMenuHolder, 
"Object.EnableCopyUUID");
 
     /*(new LLObjectVisibleTouch())->registerListener(gMenuHolder, 
"Object.VisibleTouch");
     (new LLObjectVisibleCustomTouch())->registerListener(gMenuHolder, 
"Object.VisibleCustomTouch");
Index: skins/xui/en-us/menu_pie_avatar.xml
===================================================================
--- skins/xui/en-us/menu_pie_avatar.xml    (revision 23)
+++ skins/xui/en-us/menu_pie_avatar.xml    (working copy)
@@ -47,6 +47,11 @@
             <on_visible function="Avatar.VisibleDebug" />
             <on_enable function="Avatar.EnableDebug" />
         </menu_item_call>
+        <menu_item_call enabled="false" hidden="false" label="Copy 
UUID" mouse_opaque="true"
+             name="Copy UUID">
+            <on_click function="Object.CopyUUID" />
+            <on_enable function="Object.EnableCopyUUID" />
+        </menu_item_call>
     </pie_menu>
     <menu_item_call enabled="false" hidden="false" label="Send IM..." 
mouse_opaque="true"
          name="Send IM...">
Index: skins/xui/en-us/menu_pie_object.xml
===================================================================
--- skins/xui/en-us/menu_pie_object.xml    (revision 23)
+++ skins/xui/en-us/menu_pie_object.xml    (working copy)
@@ -72,7 +72,11 @@
                 <on_click function="Object.Mute" />
                 <on_enable function="Object.EnableMute" />
             </menu_item_call>
-            <menu_item_separator />
+            <menu_item_call enabled="false" hidden="false" label="Copy 
UUID" mouse_opaque="true"
+                 name="Copy UUID">
+                <on_click function="Object.CopyUUID" />
+                <on_enable function="Object.EnableCopyUUID" />
+            </menu_item_call>
         </pie_menu>
         <menu_item_call enabled="false" hidden="false" label="Buy..." 
mouse_opaque="true" name="Buy...">
             <on_click function="Object.Buy" />



More information about the SLDev mailing list