diff options
| author | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-02-11 06:14:36 +0200 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-02-11 17:20:39 +0200 |
| commit | deec7b6c071caa7bcd3c8bb56903e1da21c35bf5 (patch) | |
| tree | 5f8bfe920b2ee0d17f789a806991b8978372c797 /indra | |
| parent | e83f6a291c32d9f3b88660e7770216c83e4f85ff (diff) | |
#5404 Allow adding to favorites directly from the avatar
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llviewermenu.cpp | 71 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/menu_attachment_self.xml | 22 |
3 files changed, 94 insertions, 1 deletions
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 @@ <menu_item_call.on_click function="Object.ShowOriginal" /> </menu_item_call> + <menu_item_call + label="Add to favorites" + layout="topleft" + name="Add to favorites"> + <menu_item_call.on_click + function="Object.SetFavorite" + parameter="Add" /> + <menu_item_call.on_visible + function="Object.EnableFavorites" + parameter="Add"/> + </menu_item_call> + <menu_item_call + label="Remove from favorites" + layout="topleft" + name="Remove from favorites"> + <menu_item_call.on_click + function="Object.SetFavorite" + parameter="Remove" /> + <menu_item_call.on_visible + function="Object.EnableFavorites" + parameter="Remove" /> + </menu_item_call> <menu_item_separator layout="topleft" /> |
