From deec7b6c071caa7bcd3c8bb56903e1da21c35bf5 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com>
Date: Wed, 11 Feb 2026 06:14:36 +0200
Subject: #5404 Allow adding to favorites directly from the avatar
---
indra/newview/llinventoryfunctions.cpp | 2 +-
indra/newview/llviewermenu.cpp | 71 ++++++++++++++++++++++
.../skins/default/xui/en/menu_attachment_self.xml | 22 +++++++
3 files changed, 94 insertions(+), 1 deletion(-)
(limited to 'indra')
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 458ea24d33..7522ea4907 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -2555,7 +2555,7 @@ bool get_is_favorite(const LLUUID& obj_id)
return obj && obj->getIsFavorite();
}
- return object->getIsFavorite();
+ return object && object->getIsFavorite();
}
void set_favorite(const LLUUID& obj_id, bool favorite)
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 5799e23ca5..597292fac5 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -3017,6 +3017,40 @@ void handle_object_show_original()
show_item_original(object->getAttachmentItemID());
}
+void handle_object_set_favorite(const LLSD& userdata)
+{
+ LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
+ if (!object)
+ {
+ return;
+ }
+ LLViewerObject *parent = (LLViewerObject*)object->getParent();
+ while (parent)
+ {
+ if(parent->isAvatar())
+ {
+ break;
+ }
+ object = parent;
+ parent = (LLViewerObject*)parent->getParent();
+ }
+ if (!object || object->isAvatar())
+ {
+ return;
+ }
+
+ LLUUID item_id = gInventory.getLinkedItemID(object->getAttachmentItemID());
+
+ std::string action = userdata.asString();
+ if (action == "Add")
+ {
+ set_favorite(item_id, true);
+ }
+ if (action == "Remove")
+ {
+ set_favorite(item_id, false);
+ }
+}
static void init_default_item_label(LLUICtrl* ctrl)
{
@@ -3073,6 +3107,41 @@ bool enable_object_touch(LLUICtrl* ctrl)
return new_value;
};
+bool enable_object_favorite(const LLSD& userdata)
+{
+ LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
+ if (!object)
+ {
+ return false;
+ }
+ LLViewerObject* parent = (LLViewerObject*)object->getParent();
+ while (parent)
+ {
+ if (parent->isAvatar())
+ {
+ break;
+ }
+ object = parent;
+ parent = (LLViewerObject*)parent->getParent();
+ }
+ if (!object || object->isAvatar())
+ {
+ return false;
+ }
+
+ std::string action = userdata.asString();
+ LLUUID item_id = gInventory.getLinkedItemID(object->getAttachmentItemID());
+ if (action == "Add")
+ {
+ return !get_is_favorite(item_id);
+ }
+ if (action == "Remove")
+ {
+ return get_is_favorite(item_id);
+ }
+ return false;
+}
+
//void label_touch(std::string& label, void*)
//{
// LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
@@ -10170,6 +10239,7 @@ void initialize_menus()
view_listener_t::addMenu(new LLObjectBuild(), "Object.Build");
commit.add("Object.Touch", boost::bind(&handle_object_touch));
commit.add("Object.ShowOriginal", boost::bind(&handle_object_show_original));
+ commit.add("Object.SetFavorite", boost::bind(&handle_object_set_favorite, _2));
commit.add("Object.SitOrStand", boost::bind(&handle_object_sit_or_stand));
commit.add("Object.Delete", boost::bind(&handle_object_delete));
view_listener_t::addMenu(new LLObjectAttachToAvatar(true), "Object.AttachToAvatar");
@@ -10198,6 +10268,7 @@ void initialize_menus()
enable.add("Object.EnableEditGLTFMaterial", boost::bind(&enable_object_edit_gltf_material));
enable.add("Object.EnableOpen", boost::bind(&enable_object_open));
enable.add("Object.EnableTouch", boost::bind(&enable_object_touch, _1));
+ enable.add("Object.EnableFavorites", boost::bind(&enable_object_favorite, _2));
enable.add("Object.EnableDelete", boost::bind(&enable_object_delete));
enable.add("Object.EnableWear", boost::bind(&object_is_wearable));
diff --git a/indra/newview/skins/default/xui/en/menu_attachment_self.xml b/indra/newview/skins/default/xui/en/menu_attachment_self.xml
index d978619355..c9adf46ad7 100644
--- a/indra/newview/skins/default/xui/en/menu_attachment_self.xml
+++ b/indra/newview/skins/default/xui/en/menu_attachment_self.xml
@@ -48,6 +48,28 @@
+
+
+
+
+
+
+
+
--
cgit v1.3