summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/lllandmarkactions.cpp37
-rw-r--r--indra/newview/lllandmarkactions.h7
-rw-r--r--indra/newview/lllocationinputctrl.cpp14
-rw-r--r--indra/newview/lllocationinputctrl.h1
4 files changed, 54 insertions, 5 deletions
diff --git a/indra/newview/lllandmarkactions.cpp b/indra/newview/lllandmarkactions.cpp
index 091346d3b4..0b07dd4f21 100644
--- a/indra/newview/lllandmarkactions.cpp
+++ b/indra/newview/lllandmarkactions.cpp
@@ -133,6 +133,33 @@ public:
}
};
+// Returns true if the given inventory item is a landmark pointing to the current parcel.
+// Used to find out if there is at least one landmark from current parcel.
+class LLFistAgentParcelLandmark : public LLInventoryCollectFunctor
+{
+private:
+ bool mFounded;// to avoid unnecessary check
+
+public:
+ LLFistAgentParcelLandmark(): mFounded(false){}
+
+ /*virtual*/ bool operator()(LLInventoryCategory* cat, LLInventoryItem* item)
+ {
+ if (mFounded || !item || item->getType() != LLAssetType::AT_LANDMARK)
+ return false;
+
+ LLLandmark* landmark = gLandmarkList.getAsset(item->getAssetUUID());
+ if (!landmark) // the landmark not been loaded yet
+ return false;
+
+ LLVector3d landmark_global_pos;
+ if (!landmark->getGlobalPos(landmark_global_pos))
+ return false;
+ mFounded = LLViewerParcelMgr::getInstance()->inAgentParcel(landmark_global_pos);
+ return mFounded;
+ }
+};
+
static void fetch_landmarks(LLInventoryModel::cat_array_t& cats,
LLInventoryModel::item_array_t& items,
LLInventoryCollectFunctor& add)
@@ -172,6 +199,16 @@ bool LLLandmarkActions::landmarkAlreadyExists()
return findLandmarkForAgentPos() != NULL;
}
+//static
+bool LLLandmarkActions::hasParcelLandmark()
+{
+ LLFistAgentParcelLandmark get_first_agent_landmark;
+ LLInventoryModel::cat_array_t cats;
+ LLInventoryModel::item_array_t items;
+ fetch_landmarks(cats, items, get_first_agent_landmark);
+ return !items.empty();
+
+}
// *TODO: This could be made more efficient by only fetching the FIRST
// landmark that meets the criteria
diff --git a/indra/newview/lllandmarkactions.h b/indra/newview/lllandmarkactions.h
index 32f05e702b..312426cab0 100644
--- a/indra/newview/lllandmarkactions.h
+++ b/indra/newview/lllandmarkactions.h
@@ -50,9 +50,14 @@ public:
*/
static LLInventoryModel::item_array_t fetchLandmarksByName(std::string& name, BOOL if_use_substring);
/**
- * @brief Checks whether landmark exists for current parcel.
+ * @brief Checks whether landmark exists for current agent position.
*/
static bool landmarkAlreadyExists();
+
+ /**
+ * @brief Checks whether landmark exists for current parcel.
+ */
+ static bool hasParcelLandmark();
/**
* @brief Searches landmark for global position.
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp
index 00f12ae2eb..8fe317a292 100644
--- a/indra/newview/lllocationinputctrl.cpp
+++ b/indra/newview/lllocationinputctrl.cpp
@@ -294,6 +294,11 @@ void LLLocationInputCtrl::hideList()
BOOL LLLocationInputCtrl::handleToolTip(S32 x, S32 y, MASK mask)
{
+
+ if(mAddLandmarkBtn->parentPointInView(x,y))
+ {
+ updateAddLandmarkTooltip();
+ }
// Let the buttons show their tooltips.
if (LLUICtrl::handleToolTip(x, y, mask))
{
@@ -602,11 +607,12 @@ void LLLocationInputCtrl::enableAddLandmarkButton(bool val)
// depending on whether current parcel has been landmarked.
void LLLocationInputCtrl::updateAddLandmarkButton()
{
- bool landmark_exists = LLLandmarkActions::landmarkAlreadyExists();
- enableAddLandmarkButton(!landmark_exists);
-
+ enableAddLandmarkButton(LLLandmarkActions::hasParcelLandmark());
+}
+void LLLocationInputCtrl::updateAddLandmarkTooltip()
+{
std::string tooltip;
- if(landmark_exists)
+ if(LLLandmarkActions::landmarkAlreadyExists())
{
tooltip = mEditLandmarkTooltip;
}
diff --git a/indra/newview/lllocationinputctrl.h b/indra/newview/lllocationinputctrl.h
index c74a294ca3..44dc0cb251 100644
--- a/indra/newview/lllocationinputctrl.h
+++ b/indra/newview/lllocationinputctrl.h
@@ -107,6 +107,7 @@ private:
bool findTeleportItemsByTitle(const LLTeleportHistoryItem& item, const std::string& filter);
void setText(const LLStringExplicit& text);
void updateAddLandmarkButton();
+ void updateAddLandmarkTooltip();
void updateContextMenu();
void updateWidgetlayout();
void changeLocationPresentation();