From d12514af8193888f9eb66bb92a9c2ac3d4e0e56e Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 9 Feb 2021 01:59:15 +0200 Subject: SL-14797 Normalize right-click menus on Landmarks & Picks Part#3 --- indra/llinventory/llparcel.h | 6 ---- indra/llinventory/llparcelflags.h | 2 +- indra/newview/lllandmarkactions.cpp | 22 ------------- indra/newview/lllandmarkactions.h | 6 ---- indra/newview/llpanelteleporthistory.cpp | 38 ++++++++++++---------- indra/newview/llpanelteleporthistory.h | 4 +-- indra/newview/llteleporthistorystorage.cpp | 22 +++++++++++++ indra/newview/llteleporthistorystorage.h | 7 ++++ .../default/xui/en/menu_teleport_history_item.xml | 19 ++++++++--- 9 files changed, 67 insertions(+), 59 deletions(-) diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 3b39aeb56b..5d08c1f4c6 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -295,7 +295,6 @@ public: void setAllowTerraform(BOOL b){setParcelFlag(PF_ALLOW_TERRAFORM, b); } void setAllowDamage(BOOL b) { setParcelFlag(PF_ALLOW_DAMAGE, b); } void setAllowFly(BOOL b) { setParcelFlag(PF_ALLOW_FLY, b); } - void setAllowLandmark(BOOL b){ setParcelFlag(PF_ALLOW_LANDMARK, b); } void setAllowGroupScripts(BOOL b) { setParcelFlag(PF_ALLOW_GROUP_SCRIPTS, b); } void setAllowOtherScripts(BOOL b) { setParcelFlag(PF_ALLOW_OTHER_SCRIPTS, b); } void setAllowDeedToGroup(BOOL b) { setParcelFlag(PF_ALLOW_DEED_TO_GROUP, b); } @@ -476,11 +475,6 @@ public: BOOL getAllowFly() const { return (mParcelFlags & PF_ALLOW_FLY) ? TRUE : FALSE; } - // Remove permission restrictions for creating landmarks. - // We should eventually remove this flag completely. - BOOL getAllowLandmark() const - { return TRUE; } - BOOL getAllowGroupScripts() const { return (mParcelFlags & PF_ALLOW_GROUP_SCRIPTS) ? TRUE : FALSE; } diff --git a/indra/llinventory/llparcelflags.h b/indra/llinventory/llparcelflags.h index 25b27a281a..4cffa83cc1 100644 --- a/indra/llinventory/llparcelflags.h +++ b/indra/llinventory/llparcelflags.h @@ -33,7 +33,7 @@ const U32 PF_ALLOW_FLY = 1 << 0;// Can start flying const U32 PF_ALLOW_OTHER_SCRIPTS= 1 << 1;// Scripts by others can run. const U32 PF_FOR_SALE = 1 << 2;// Can buy this land const U32 PF_FOR_SALE_OBJECTS = 1 << 7;// Can buy all objects on this land -const U32 PF_ALLOW_LANDMARK = 1 << 3; +const U32 PF_ALLOW_LANDMARK = 1 << 3;// Always true/deprecated const U32 PF_ALLOW_TERRAFORM = 1 << 4; const U32 PF_ALLOW_DAMAGE = 1 << 5; const U32 PF_CREATE_OBJECTS = 1 << 6; diff --git a/indra/newview/lllandmarkactions.cpp b/indra/newview/lllandmarkactions.cpp index c243f8b4f0..a17dc674ac 100644 --- a/indra/newview/lllandmarkactions.cpp +++ b/indra/newview/lllandmarkactions.cpp @@ -228,23 +228,6 @@ LLViewerInventoryItem* LLLandmarkActions::findLandmarkForAgentPos() return findLandmarkForGlobalPos(gAgent.getPositionGlobal()); } -bool LLLandmarkActions::canCreateLandmarkHere() -{ - LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if(!agent_parcel) - { - LL_WARNS() << "No agent region" << LL_ENDL; - return false; - } - if (agent_parcel->getAllowLandmark() - || LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK)) - { - return true; - } - - return false; -} - void LLLandmarkActions::createLandmarkHere( const std::string& name, const std::string& desc, @@ -261,11 +244,6 @@ void LLLandmarkActions::createLandmarkHere( LL_WARNS() << "No agent parcel" << LL_ENDL; return; } - if (!canCreateLandmarkHere()) - { - LLNotificationsUtil::add("CannotCreateLandmarkNotOwner"); - return; - } create_inventory_item(gAgent.getID(), gAgent.getSessionID(), folder_id, LLTransactionID::tnull, diff --git a/indra/newview/lllandmarkactions.h b/indra/newview/lllandmarkactions.h index 870d92811e..ae7b072fcb 100644 --- a/indra/newview/lllandmarkactions.h +++ b/indra/newview/lllandmarkactions.h @@ -72,12 +72,6 @@ public: */ static LLViewerInventoryItem* findLandmarkForAgentPos(); - - /** - * @brief Checks whether agent has rights to create landmark for current parcel. - */ - static bool canCreateLandmarkHere(); - /** * @brief Creates landmark for current parcel. */ diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index fe0608d544..3f5664f431 100644 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -396,9 +396,7 @@ LLContextMenu* LLTeleportHistoryPanel::ContextMenu::createMenu() // (N.B. callbacks don't take const refs as mID is local scope) LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; - registrar.add("TeleportHistory.Teleport", boost::bind(&LLTeleportHistoryPanel::ContextMenu::onTeleport, this)); - registrar.add("TeleportHistory.MoreInformation",boost::bind(&LLTeleportHistoryPanel::ContextMenu::onInfo, this)); - registrar.add("TeleportHistory.CopyToClipboard",boost::bind(&LLTeleportHistoryPanel::ContextMenu::onCopyToClipboard, this)); + registrar.add("TeleportHistory.Action", boost::bind(&LLTeleportHistoryPanel::ContextMenu::onUserAction, this, _2)); // create the context menu from the XUI llassert(LLMenuGL::sMenuContainer != NULL); @@ -406,14 +404,27 @@ LLContextMenu* LLTeleportHistoryPanel::ContextMenu::createMenu() "menu_teleport_history_item.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); } -void LLTeleportHistoryPanel::ContextMenu::onTeleport() +void LLTeleportHistoryPanel::ContextMenu::onUserAction(const LLSD& userdata) { - confirmTeleport(mIndex); -} - -void LLTeleportHistoryPanel::ContextMenu::onInfo() -{ - LLTeleportHistoryFlatItem::showPlaceInfoPanel(mIndex); + std::string command_name = userdata.asString(); + if ("teleport" == command_name) + { + confirmTeleport(mIndex); + } + else if ("view" == command_name) + { + LLTeleportHistoryFlatItem::showPlaceInfoPanel(mIndex); + } + else if ("show_on_map" == command_name) + { + LLTeleportHistoryStorage::getInstance()->showItemOnMap(mIndex); + } + else if ("copy_slurl" == command_name) + { + LLVector3d globalPos = LLTeleportHistoryStorage::getInstance()->getItems()[mIndex].mGlobalPos; + LLLandmarkActions::getSLURLfromPosGlobal(globalPos, + boost::bind(&LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback, _1)); + } } //static @@ -427,13 +438,6 @@ void LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback(const std::string& sl LLNotificationsUtil::add("CopySLURL", args); } -void LLTeleportHistoryPanel::ContextMenu::onCopyToClipboard() -{ - LLVector3d globalPos = LLTeleportHistoryStorage::getInstance()->getItems()[mIndex].mGlobalPos; - LLLandmarkActions::getSLURLfromPosGlobal(globalPos, - boost::bind(&LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback, _1)); -} - // Not yet implemented; need to remove buildPanel() from constructor when we switch //static LLRegisterPanelClassWrapper t_teleport_history("panel_teleport_history"); diff --git a/indra/newview/llpanelteleporthistory.h b/indra/newview/llpanelteleporthistory.h index b88861c5c6..e0abbc47db 100644 --- a/indra/newview/llpanelteleporthistory.h +++ b/indra/newview/llpanelteleporthistory.h @@ -52,9 +52,7 @@ public: private: LLContextMenu* createMenu(); - void onTeleport(); - void onInfo(); - void onCopyToClipboard(); + void onUserAction(const LLSD& userdata); static void gotSLURLCallback(const std::string& slurl); diff --git a/indra/newview/llteleporthistorystorage.cpp b/indra/newview/llteleporthistorystorage.cpp index 8a5704939a..93fa457bd0 100644 --- a/indra/newview/llteleporthistorystorage.cpp +++ b/indra/newview/llteleporthistorystorage.cpp @@ -33,6 +33,8 @@ #include "lldir.h" #include "llteleporthistory.h" #include "llagent.h" +#include "llfloaterreg.h" +#include "llfloaterworldmap.h" // Max offset for two global positions to consider them as equal const F64 MAX_GLOBAL_POS_OFFSET = 5.0f; @@ -253,3 +255,23 @@ void LLTeleportHistoryStorage::goToItem(S32 idx) gAgent.teleportViaLocation(mItems[idx].mGlobalPos); } +void LLTeleportHistoryStorage::showItemOnMap(S32 idx) +{ + // Validate specified index. + if (idx < 0 || idx >= (S32)mItems.size()) + { + LL_WARNS() << "Invalid teleport history index (" << idx << ") specified" << LL_ENDL; + dump(); + return; + } + + LLVector3d landmark_global_pos = mItems[idx].mGlobalPos; + + LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance(); + if (!landmark_global_pos.isExactlyZero() && worldmap_instance) + { + worldmap_instance->trackLocation(landmark_global_pos); + LLFloaterReg::showInstance("world_map", "center"); + } +} + diff --git a/indra/newview/llteleporthistorystorage.h b/indra/newview/llteleporthistorystorage.h index 946ac0af1a..3578923fd7 100644 --- a/indra/newview/llteleporthistorystorage.h +++ b/indra/newview/llteleporthistorystorage.h @@ -107,6 +107,13 @@ public: */ void goToItem(S32 idx); + /** + * Show specific item on map. + * + * The item is specified by its index (starting from 0). + */ + void showItemOnMap(S32 idx); + private: void load(); diff --git a/indra/newview/skins/default/xui/en/menu_teleport_history_item.xml b/indra/newview/skins/default/xui/en/menu_teleport_history_item.xml index f939c3996d..52da591e35 100644 --- a/indra/newview/skins/default/xui/en/menu_teleport_history_item.xml +++ b/indra/newview/skins/default/xui/en/menu_teleport_history_item.xml @@ -7,20 +7,31 @@ layout="topleft" name="Teleport"> + function="TeleportHistory.Action" + parameter="teleport" /> + function="TeleportHistory.Action" + parameter="view" /> + + + + function="TeleportHistory.Action" + parameter="copy_slurl" /> -- cgit v1.2.3