From db8e4824e7f00516142461fa25616e3527007d66 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <none@none>
Date: Tue, 26 Nov 2013 19:43:15 -0500
Subject: [PATCH] STORM-1986 Added right click Show on Map context menu for
 Inventory floater landmarks Possible fix for BUG-4593

---
 doc/contributions.txt                         |  1 +
 indra/newview/llfloaterworldmap.cpp           |  6 ++--
 indra/newview/llinventorybridge.cpp           | 36 +++++++++++++++++++
 indra/newview/llinventorybridge.h             |  4 +++
 .../skins/default/xui/en/menu_inventory.xml   |  8 +++++
 5 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 2f9d0c2c86e..898efcfbcea 100755
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -674,6 +674,7 @@ Jonathan Yap
 	OPEN-161
 	STORM-1953
 	STORM-1957
+	STORM-1986
 Kadah Coba
 	STORM-1060
     STORM-1843
diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp
index 137b5446cfe..cb637c71624 100755
--- a/indra/newview/llfloaterworldmap.cpp
+++ b/indra/newview/llfloaterworldmap.cpp
@@ -627,8 +627,8 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global)
 	if (!sim_info)
 	{
 		// We haven't found a region for that point yet, leave the tracking to the world map
-		LLWorldMap::getInstance()->setTracking(pos_global);
 		LLTracker::stopTracking(NULL);
+		LLWorldMap::getInstance()->setTracking(pos_global);
 		S32 world_x = S32(pos_global.mdV[0] / 256);
 		S32 world_y = S32(pos_global.mdV[1] / 256);
 		LLWorldMapMessage::getInstance()->sendMapBlockRequest(world_x, world_y, world_x, world_y, true);
@@ -643,9 +643,9 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global)
 	{
 		// Down region. Show the blue circle of death!
 		// i.e. let the world map that this and tell it it's invalid
+		LLTracker::stopTracking(NULL);
 		LLWorldMap::getInstance()->setTracking(pos_global);
 		LLWorldMap::getInstance()->setTrackingInvalid();
-		LLTracker::stopTracking(NULL);
 		setDefaultBtn("");
 		
 		// clicked on a down region - turn off coord display
@@ -665,8 +665,8 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global)
 	
 	std::string tooltip("");
 	mTrackedStatus = LLTracker::TRACKING_LOCATION;
-	LLTracker::trackLocation(pos_global, full_name, tooltip);
 	LLWorldMap::getInstance()->cancelTracking();		// The floater is taking over the tracking
+	LLTracker::trackLocation(pos_global, full_name, tooltip);
 	
 	LLVector3d coord_pos = LLTracker::getTrackedPositionGlobal();
 	updateTeleportCoordsDisplay( coord_pos );
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 80ef506272c..f65e28a165b 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -74,6 +74,7 @@
 #include "llvoavatarself.h"
 #include "llwearablelist.h"
 #include "lllandmarkactions.h"
+#include "llpanellandmarks.h"
 
 void copy_slurl_to_clipboard_callback_inv(const std::string& slurl);
 
@@ -1449,6 +1450,40 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action)
 			}
 		}
 	}
+	else if ("show_on_map" == action)
+	{
+		doActionOnCurSelectedLandmark(boost::bind(&LLItemBridge::doShowOnMap, this, _1));
+	}
+}
+
+void LLItemBridge::doActionOnCurSelectedLandmark(LLLandmarkList::loaded_callback_t cb)
+{
+	LLViewerInventoryItem* cur_item = getItem();
+	if(cur_item && cur_item->getInventoryType() == LLInventoryType::IT_LANDMARK)
+	{ 
+		LLLandmark* landmark = LLLandmarkActions::getLandmark(cur_item->getUUID(), cb);
+		if (landmark)
+		{
+			cb(landmark);
+		}
+	}
+}
+
+void LLItemBridge::doShowOnMap(LLLandmark* landmark)
+{
+	LLVector3d landmark_global_pos;
+	// landmark has already been tested for NULL by calling routine
+	if (!landmark->getGlobalPos(landmark_global_pos))
+	{
+		return;
+	}
+
+	LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance();
+	if (!landmark_global_pos.isExactlyZero() && worldmap_instance)
+	{
+		worldmap_instance->trackLocation(landmark_global_pos);
+		LLFloaterReg::showInstance("world_map", "center");
+	}
 }
 
 void copy_slurl_to_clipboard_callback_inv(const std::string& slurl)
@@ -4580,6 +4615,7 @@ void LLLandmarkBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 		items.push_back(std::string("Landmark Separator"));
 		items.push_back(std::string("url_copy"));
 		items.push_back(std::string("About Landmark"));
+		items.push_back(std::string("show_on_map"));
 	}
 
 	// Disable "About Landmark" menu item for
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index 517153e1710..bc875e8f375 100755
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -36,6 +36,7 @@
 #include "llviewercontrol.h"
 #include "llviewerwearable.h"
 #include "lltooldraganddrop.h"
+#include "lllandmarklist.h"
 
 class LLInventoryFilter;
 class LLInventoryPanel;
@@ -239,7 +240,10 @@ class LLItemBridge : public LLInvFVBridge
 	BOOL confirmRemoveItem(const LLSD& notification, const LLSD& response);
 	virtual BOOL isItemPermissive() const;
 	virtual void buildDisplayName() const;
+	void doActionOnCurSelectedLandmark(LLLandmarkList::loaded_callback_t cb);
 
+private:
+	void doShowOnMap(LLLandmark* landmark);
 };
 
 class LLFolderBridge : public LLInvFVBridge
diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml
index 512205ba43c..6fa45d7d665 100755
--- a/indra/newview/skins/default/xui/en/menu_inventory.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory.xml
@@ -552,6 +552,14 @@
          function="Inventory.DoToSelected"
          parameter="about" />
     </menu_item_call>
+   <menu_item_call
+     label="Show on Map"
+     layout="topleft"
+     name="show_on_map">
+        <menu_item_call.on_click
+         function="Inventory.DoToSelected"
+         parameter="show_on_map" />
+    </menu_item_call>
     <menu_item_separator
      layout="topleft" 
      name="Animation Separator" />
-- 
GitLab