From 377f7e5818e4b0f8e1587ed370d707448fedb92c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 16 Jul 2013 14:10:35 +0200 Subject: [PATCH] Properly handle offer TP check in people panel in case of multi-selections --- indra/newview/fsfloaterradar.cpp | 2 +- indra/newview/fsradarmenu.cpp | 12 ++--- indra/newview/llavataractions.cpp | 52 ++++++++++++++++--- indra/newview/llavataractions.h | 2 +- indra/newview/llpanelpeoplemenus.cpp | 12 ++--- .../skins/default/xui/en/menu_fs_radar.xml | 3 ++ .../xui/en/menu_fs_radar_multiselect.xml | 3 ++ .../xui/en/menu_people_nearby_multiselect.xml | 3 ++ 8 files changed, 63 insertions(+), 26 deletions(-) diff --git a/indra/newview/fsfloaterradar.cpp b/indra/newview/fsfloaterradar.cpp index e8e757a3b8..903ad2cf6d 100644 --- a/indra/newview/fsfloaterradar.cpp +++ b/indra/newview/fsfloaterradar.cpp @@ -206,7 +206,7 @@ void FSFloaterRadar::onTeleportButtonClicked() { uuid_vec_t selected_uuids; mRadarPanel->getCurrentItemIDs(selected_uuids); - LLAvatarActions::offerTeleport(LLAvatarActions::canOfferTeleport(selected_uuids)); + LLAvatarActions::offerTeleport(selected_uuids); } void FSFloaterRadar::onShareButtonClicked() diff --git a/indra/newview/fsradarmenu.cpp b/indra/newview/fsradarmenu.cpp index 172f33eadf..02e014761a 100644 --- a/indra/newview/fsradarmenu.cpp +++ b/indra/newview/fsradarmenu.cpp @@ -201,14 +201,10 @@ bool FSRadarMenu::enableContextMenuItem(const LLSD& userdata) return (LLAvatarTracker::instance().isBuddyOnline(id) && is_agent_mappable(id)) || gAgent.isGodlike(); } - // Prevent teleport button from being disabled when someone on your - // friends list logs out but is still in the region and you have - // multiple people selected. - //else if(item == std::string("can_offer_teleport")) - //{ - // return LLAvatarActions::canOfferTeleport(mUUIDs); - //} - // + else if(item == std::string("can_offer_teleport")) + { + return LLAvatarActions::canOfferTeleport(mUUIDs); + } else if (item == std::string("can_open_inventory")) { return (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWINV)); diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 13b401dab0..a2b060a33f 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -192,7 +192,23 @@ void LLAvatarActions::offerTeleport(const uuid_vec_t& ids) if (ids.size() == 0) return; - handle_lure(ids); + // Fix edge case with multi-selection containing offlines + //handle_lure(ids); + uuid_vec_t result; + for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) + { + if (canOfferTeleport(*it)) + { + result.push_back(*it); + // Maximum 250 lures + if (result.size() == 250) + { + break; + } + } + } + handle_lure(result); + // } static void on_avatar_name_cache_start_im(const LLUUID& agent_id, @@ -1039,19 +1055,39 @@ bool LLAvatarActions::canOfferTeleport(const LLUUID& id) } // static -uuid_vec_t LLAvatarActions::canOfferTeleport(const uuid_vec_t& ids) +bool LLAvatarActions::canOfferTeleport(const uuid_vec_t& ids) { - uuid_vec_t result; + // We can't send more than 250 lures in a single message, so disable this + // button when there are too many id's selected. + // Fix edge case with multi-selection containing offlines + //if(ids.size() > 250) return false; + // + //bool result = true; + //for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) + //{ + // if(!canOfferTeleport(*it)) + // { + // result = false; + // break; + // } + //} + //return result; + + if (ids.size() == 1) + { + return canOfferTeleport(ids.front()); + } + + S32 valid_count = 0; for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) { - if(canOfferTeleport(*it)) + if (canOfferTeleport(*it)) { - result.push_back(*it); - // We can't send more than 250 lures in a single message, so stop when we are full - if(result.size() == 250) break; + valid_count++; } } - return result; + return (valid_count > 0 && valid_count <= 250); + // } void LLAvatarActions::inviteToGroup(const LLUUID& id) diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h index 61b87287e9..648a2119bd 100755 --- a/indra/newview/llavataractions.h +++ b/indra/newview/llavataractions.h @@ -203,7 +203,7 @@ public: /** * @return a list of avatars that can be teleported from the input list */ - static uuid_vec_t canOfferTeleport(const uuid_vec_t& ids); + static bool canOfferTeleport(const uuid_vec_t& ids); /** * Checks whether all items selected in the given inventory panel can be shared diff --git a/indra/newview/llpanelpeoplemenus.cpp b/indra/newview/llpanelpeoplemenus.cpp index 521cc7fda0..548ff619df 100755 --- a/indra/newview/llpanelpeoplemenus.cpp +++ b/indra/newview/llpanelpeoplemenus.cpp @@ -234,14 +234,10 @@ bool PeopleContextMenu::enableContextMenuItem(const LLSD& userdata) return (LLAvatarTracker::instance().isBuddyOnline(id) && is_agent_mappable(id)) || gAgent.isGodlike(); } - // Prevent teleport button from being disabled when someone on your - // friends list logs out but is still in the region and you have - // multiple people selected. - //else if(item == std::string("can_offer_teleport")) - //{ - // return LLAvatarActions::canOfferTeleport(mUUIDs); - //} - // + else if(item == std::string("can_offer_teleport")) + { + return LLAvatarActions::canOfferTeleport(mUUIDs); + } // FIRE-8804: Prevent opening inventory from using share in radar context menu else if (item == std::string("can_open_inventory")) { diff --git a/indra/newview/skins/default/xui/en/menu_fs_radar.xml b/indra/newview/skins/default/xui/en/menu_fs_radar.xml index 5241bb8795..09d8502690 100644 --- a/indra/newview/skins/default/xui/en/menu_fs_radar.xml +++ b/indra/newview/skins/default/xui/en/menu_fs_radar.xml @@ -85,6 +85,9 @@ name="teleport"> + + diff --git a/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml b/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml index f275fe7634..5f973088fd 100755 --- a/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml +++ b/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml @@ -62,5 +62,8 @@ name="offer_teleport"> +