From ae24afec8fc9fc357b25e2ff36fd040a68f8f163 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 22 May 2020 14:37:14 +0300 Subject: SL-13190 Allow Edit Attached Object Position From Inventory --- indra/newview/llcofwearables.cpp | 16 ++++++++ indra/newview/llinventorybridge.cpp | 11 ++++++ indra/newview/llinventoryfunctions.cpp | 45 ++++++++++++++++++++++ indra/newview/llinventoryfunctions.h | 4 ++ indra/newview/llpanelwearing.cpp | 37 ++++++++++++++---- indra/newview/llviewermenu.cpp | 15 +++++++- indra/newview/llviewermenu.h | 1 + indra/newview/llwearableitemslist.cpp | 8 ++-- .../skins/default/xui/da/menu_cof_attachment.xml | 1 + .../skins/default/xui/da/menu_wearing_gear.xml | 3 +- .../skins/default/xui/da/menu_wearing_tab.xml | 3 +- .../skins/default/xui/de/menu_cof_attachment.xml | 1 + .../skins/default/xui/de/menu_wearing_gear.xml | 3 +- .../skins/default/xui/de/menu_wearing_tab.xml | 2 +- .../skins/default/xui/en/menu_cof_attachment.xml | 10 +++++ .../skins/default/xui/en/menu_inventory.xml | 16 ++++---- .../default/xui/en/menu_wearable_list_item.xml | 13 +++---- .../skins/default/xui/en/menu_wearing_gear.xml | 17 ++++++-- .../skins/default/xui/en/menu_wearing_tab.xml | 18 ++++----- .../skins/default/xui/es/menu_cof_attachment.xml | 1 + .../skins/default/xui/es/menu_wearing_gear.xml | 3 +- .../skins/default/xui/es/menu_wearing_tab.xml | 2 +- .../skins/default/xui/fr/menu_cof_attachment.xml | 1 + .../skins/default/xui/fr/menu_wearing_gear.xml | 3 +- .../skins/default/xui/fr/menu_wearing_tab.xml | 2 +- .../skins/default/xui/it/menu_cof_attachment.xml | 1 + .../skins/default/xui/it/menu_wearing_gear.xml | 3 +- .../skins/default/xui/it/menu_wearing_tab.xml | 2 +- .../skins/default/xui/ja/menu_cof_attachment.xml | 1 + .../skins/default/xui/ja/menu_wearing_gear.xml | 3 +- .../skins/default/xui/ja/menu_wearing_tab.xml | 2 +- .../skins/default/xui/pl/menu_cof_attachment.xml | 1 + .../skins/default/xui/pl/menu_wearing_gear.xml | 3 +- .../skins/default/xui/pl/menu_wearing_tab.xml | 3 +- .../skins/default/xui/pt/menu_cof_attachment.xml | 1 + .../skins/default/xui/pt/menu_wearing_gear.xml | 3 +- .../skins/default/xui/pt/menu_wearing_tab.xml | 2 +- .../skins/default/xui/ru/menu_cof_attachment.xml | 1 + .../skins/default/xui/ru/menu_wearing_gear.xml | 3 +- .../skins/default/xui/ru/menu_wearing_tab.xml | 2 +- .../skins/default/xui/tr/menu_cof_attachment.xml | 1 + .../skins/default/xui/tr/menu_wearing_gear.xml | 3 +- .../skins/default/xui/tr/menu_wearing_tab.xml | 2 +- .../skins/default/xui/zh/menu_cof_attachment.xml | 1 + .../skins/default/xui/zh/menu_wearing_gear.xml | 3 +- .../skins/default/xui/zh/menu_wearing_tab.xml | 2 +- 46 files changed, 218 insertions(+), 61 deletions(-) (limited to 'indra') diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp index 1caefd58ab..aede623f58 100644 --- a/indra/newview/llcofwearables.cpp +++ b/indra/newview/llcofwearables.cpp @@ -140,10 +140,26 @@ protected: { LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + registrar.add("Attachment.Edit", boost::bind(handleMultiple, handle_item_edit, mUUIDs)); registrar.add("Attachment.Detach", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + enable_registrar.add("Attachment.OnEnable", boost::bind(&CofAttachmentContextMenu::onEnable, this, _2)); + return createFromFile("menu_cof_attachment.xml"); } + + bool onEnable(const LLSD& userdata) + { + const std::string event_name = userdata.asString(); + + if ("edit" == event_name) + { + return (1 == mUUIDs.size()) && (get_is_item_editable(mUUIDs.front())); + } + + return true; + } }; ////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 657c65c68d..bb7f219ed9 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -6385,6 +6385,10 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action) { LLAppearanceMgr::instance().wearItemOnAvatar(mUUID, true, false); // Don't replace if adding. } + else if ("edit" == action) + { + handle_attachment_edit(mUUID); + } else if (isRemoveAction(action)) { LLAppearanceMgr::instance().removeItemFromAvatar(mUUID); @@ -6535,6 +6539,13 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) if( get_is_item_worn( mUUID ) ) { items.push_back(std::string("Wearable And Object Separator")); + + items.push_back(std::string("Wearable Edit")); + if ( ((flags & FIRST_SELECTED_ITEM) == 0) || !get_is_item_editable(mUUID) ) + { + disabled_items.push_back(std::string("Wearable Edit")); + } + items.push_back(std::string("Detach From Yourself")); } else if (!isItemInTrash() && !isLinkedObjectInTrash() && !isLinkedObjectMissing() && !isCOFFolder()) diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 646d92b9e1..d069aa3223 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -78,6 +78,7 @@ #include "lltooldraganddrop.h" #include "lltrans.h" #include "lluictrlfactory.h" +#include "llviewermenu.h" #include "llviewermessage.h" #include "llviewerfoldertype.h" #include "llviewerobjectlist.h" @@ -655,6 +656,50 @@ BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id) return TRUE; } +bool get_is_item_editable(const LLUUID& inv_item_id) +{ + if (const LLInventoryItem* inv_item = gInventory.getLinkedItem(inv_item_id)) + { + switch (inv_item->getType()) + { + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + return gAgentWearables.isWearableModifiable(inv_item_id); + case LLAssetType::AT_OBJECT: + return true; + default: + return false;; + } + } + return gAgentAvatarp->getWornAttachment(inv_item_id) != nullptr; +} + +void handle_item_edit(const LLUUID& inv_item_id) +{ + if (get_is_item_editable(inv_item_id)) + { + if (const LLInventoryItem* inv_item = gInventory.getLinkedItem(inv_item_id)) + { + switch (inv_item->getType()) + { + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + LLAgentWearables::editWearable(inv_item_id); + break; + case LLAssetType::AT_OBJECT: + handle_attachment_edit(inv_item_id); + break; + default: + break; + } + } + else + { + handle_attachment_edit(inv_item_id); + } + } +} + BOOL get_is_category_removable(const LLInventoryModel* model, const LLUUID& id) { // NOTE: This function doesn't check the folder's children. diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index fd106bc2d8..04eb962372 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -53,6 +53,10 @@ BOOL get_can_item_be_worn(const LLUUID& id); BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id); +// Performs the appropiate edit action (if one exists) for this item +bool get_is_item_editable(const LLUUID& inv_item_id); +void handle_item_edit(const LLUUID& inv_item_id); + BOOL get_is_category_removable(const LLInventoryModel* model, const LLUUID& id); BOOL get_is_category_renameable(const LLInventoryModel* model, const LLUUID& id); diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index 89cb495db9..6b187c7485 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -64,7 +64,8 @@ public: LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; - registrar.add("Gear.Edit", boost::bind(&edit_outfit)); + registrar.add("Gear.EditItem", boost::bind(&LLWearingGearMenu::handleMultiple, this, handle_item_edit)); + registrar.add("Gear.EditOutfit", boost::bind(&edit_outfit)); registrar.add("Gear.TakeOff", boost::bind(&LLPanelWearing::onRemoveItem, mPanelWearing)); registrar.add("Gear.Copy", boost::bind(&LLPanelWearing::copyToClipboard, mPanelWearing)); @@ -78,6 +79,16 @@ public: LLToggleableMenu* getMenu() { return mMenu; } private: + void handleMultiple(std::function functor) + { + uuid_vec_t selected_item_ids; + mPanelWearing->getSelectedItemsUUIDs(selected_item_ids); + + for (const LLUUID& item_id : selected_item_ids) + { + functor(item_id); + } + } LLToggleableMenu* mMenu; LLPanelWearing* mPanelWearing; @@ -92,7 +103,8 @@ protected: { LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; - registrar.add("Wearing.Edit", boost::bind(&edit_outfit)); + registrar.add("Wearing.EditItem", boost::bind(handleMultiple, handle_item_edit, mUUIDs)); + registrar.add("Wearing.EditOutfit", boost::bind(&edit_outfit)); registrar.add("Wearing.ShowOriginal", boost::bind(show_item_original, mUUIDs.front())); registrar.add("Wearing.TakeOff", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); @@ -138,14 +150,16 @@ protected: } // Enable/disable some menu items depending on the selection. + bool show_edit = bp_selected || clothes_selected || attachments_selected; bool allow_detach = !bp_selected && !clothes_selected && attachments_selected; bool allow_take_off = !bp_selected && clothes_selected && !attachments_selected; + menu->setItemVisible("edit_item", show_edit); + menu->setItemEnabled("edit_item", 1 == mUUIDs.size() && get_is_item_editable(mUUIDs.front())); menu->setItemVisible("take_off", allow_take_off); menu->setItemVisible("detach", allow_detach); - menu->setItemVisible("edit_outfit_separator", allow_take_off || allow_detach); + menu->setItemVisible("edit_outfit_separator", show_edit | allow_take_off || allow_detach); menu->setItemVisible("show_original", mUUIDs.size() == 1); - menu->setItemVisible("edit_item", FALSE); } }; @@ -173,12 +187,13 @@ protected: void updateMenuItemsVisibility(LLContextMenu* menu) { + menu->setItemVisible("edit_item", TRUE); + menu->setItemEnabled("edit_item", 1 == mUUIDs.size()); menu->setItemVisible("take_off", FALSE); menu->setItemVisible("detach", TRUE); - menu->setItemVisible("edit_outfit_separator", TRUE); + menu->setItemVisible("edit_outfit_separator", FALSE); menu->setItemVisible("show_original", FALSE); - menu->setItemVisible("edit_item", TRUE); - menu->setItemVisible("edit", FALSE); + menu->setItemVisible("edit_outfit", FALSE); } LLPanelWearing* mPanelWearing; @@ -350,6 +365,14 @@ bool LLPanelWearing::isActionEnabled(const LLSD& userdata) } } + uuid_vec_t selected_uuids; + getSelectedItemsUUIDs(selected_uuids); + + if (command_name == "edit_item") + { + return (1 == selected_uuids.size()) && (get_is_item_editable(selected_uuids.front())); + } + return false; } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index b6c7be2ed3..b388d6a1bd 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -2777,7 +2777,6 @@ class LLObjectBuild : public view_listener_t } }; - void handle_object_edit() { LLViewerParcelMgr::getInstance()->deselectLand(); @@ -2822,6 +2821,20 @@ void handle_object_edit() return; } +void handle_attachment_edit(const LLUUID& inv_item_id) +{ + if (isAgentAvatarValid()) + { + if (LLViewerObject* attached_obj = gAgentAvatarp->getWornAttachment(inv_item_id)) + { + LLSelectMgr::getInstance()->deselectAll(); + LLSelectMgr::getInstance()->selectObjectAndFamily(attached_obj); + + handle_object_edit(); + } + } +} + void handle_object_inspect() { LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h index 6882405407..ce84a4bbc3 100644 --- a/indra/newview/llviewermenu.h +++ b/indra/newview/llviewermenu.h @@ -109,6 +109,7 @@ void handle_zoom_to_object(LLUUID object_id); void handle_object_return(); void handle_object_delete(); void handle_object_edit(); +void handle_attachment_edit(const LLUUID& inv_item_id); void handle_buy_land(); diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index e7bbee5efd..93bb0a7eed 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -794,7 +794,7 @@ LLContextMenu* LLWearableItemsList::ContextMenu::createMenu() // Register handlers common for all wearable types. registrar.add("Wearable.Wear", boost::bind(wear_multiple, ids, true)); registrar.add("Wearable.Add", boost::bind(wear_multiple, ids, false)); - registrar.add("Wearable.Edit", boost::bind(handleMultiple, LLAgentWearables::editWearable, ids)); + registrar.add("Wearable.Edit", boost::bind(handle_item_edit, selected_id)); registrar.add("Wearable.CreateNew", boost::bind(createNewWearable, selected_id)); registrar.add("Wearable.ShowOriginal", boost::bind(show_item_original, selected_id)); registrar.add("Wearable.TakeOffDetach", @@ -858,7 +858,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu const LLWearableType::EType wearable_type = item->getWearableType(); const bool is_link = item->getIsLinkType(); const bool is_worn = get_is_item_worn(id); - const bool is_editable = gAgentWearables.isWearableModifiable(id); + const bool is_editable = get_is_item_editable(id); const bool is_already_worn = gAgentWearables.selfHasWearable(wearable_type); if (is_worn) { @@ -893,8 +893,8 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu setMenuItemEnabled(menu, "wear_add", LLAppearanceMgr::instance().canAddWearables(ids)); setMenuItemVisible(menu, "wear_replace", n_worn == 0 && n_already_worn != 0 && can_be_worn); //visible only when one item selected and this item is worn - setMenuItemVisible(menu, "edit", !standalone && mask & (MASK_CLOTHING|MASK_BODYPART) && n_worn == n_items && n_worn == 1); - setMenuItemEnabled(menu, "edit", n_editable == 1 && n_worn == 1 && n_items == 1); + setMenuItemVisible(menu, "edit", !standalone && mask & (MASK_CLOTHING|MASK_BODYPART|MASK_ATTACHMENT) && n_worn == n_items); + setMenuItemEnabled(menu, "edit", n_editable && n_worn == 1 && n_items == 1); setMenuItemVisible(menu, "create_new", mask & (MASK_CLOTHING|MASK_BODYPART) && n_items == 1); setMenuItemEnabled(menu, "create_new", LLAppearanceMgr::instance().canAddWearables(ids)); setMenuItemVisible(menu, "show_original", !standalone); diff --git a/indra/newview/skins/default/xui/da/menu_cof_attachment.xml b/indra/newview/skins/default/xui/da/menu_cof_attachment.xml index 9d7fc0f223..ede33b8efb 100644 --- a/indra/newview/skins/default/xui/da/menu_cof_attachment.xml +++ b/indra/newview/skins/default/xui/da/menu_cof_attachment.xml @@ -1,4 +1,5 @@ + diff --git a/indra/newview/skins/default/xui/da/menu_wearing_gear.xml b/indra/newview/skins/default/xui/da/menu_wearing_gear.xml index 515a15b287..da33c67a02 100644 --- a/indra/newview/skins/default/xui/da/menu_wearing_gear.xml +++ b/indra/newview/skins/default/xui/da/menu_wearing_gear.xml @@ -1,5 +1,6 @@ - + + diff --git a/indra/newview/skins/default/xui/da/menu_wearing_tab.xml b/indra/newview/skins/default/xui/da/menu_wearing_tab.xml index c0db7b6842..98b80c2c4d 100644 --- a/indra/newview/skins/default/xui/da/menu_wearing_tab.xml +++ b/indra/newview/skins/default/xui/da/menu_wearing_tab.xml @@ -1,6 +1,7 @@ + - + diff --git a/indra/newview/skins/default/xui/de/menu_cof_attachment.xml b/indra/newview/skins/default/xui/de/menu_cof_attachment.xml index 05d3dfca9d..cf0270b273 100644 --- a/indra/newview/skins/default/xui/de/menu_cof_attachment.xml +++ b/indra/newview/skins/default/xui/de/menu_cof_attachment.xml @@ -1,4 +1,5 @@ + diff --git a/indra/newview/skins/default/xui/de/menu_wearing_gear.xml b/indra/newview/skins/default/xui/de/menu_wearing_gear.xml index dacf898b6a..dfe2759bcb 100644 --- a/indra/newview/skins/default/xui/de/menu_wearing_gear.xml +++ b/indra/newview/skins/default/xui/de/menu_wearing_gear.xml @@ -1,6 +1,7 @@ - + + diff --git a/indra/newview/skins/default/xui/de/menu_wearing_tab.xml b/indra/newview/skins/default/xui/de/menu_wearing_tab.xml index 61002b3dad..fff325c930 100644 --- a/indra/newview/skins/default/xui/de/menu_wearing_tab.xml +++ b/indra/newview/skins/default/xui/de/menu_wearing_tab.xml @@ -2,7 +2,7 @@ - + diff --git a/indra/newview/skins/default/xui/en/menu_cof_attachment.xml b/indra/newview/skins/default/xui/en/menu_cof_attachment.xml index c402100fb1..42f81d2c94 100644 --- a/indra/newview/skins/default/xui/en/menu_cof_attachment.xml +++ b/indra/newview/skins/default/xui/en/menu_cof_attachment.xml @@ -2,6 +2,16 @@ + + + + - - -