diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfavoritesbar.cpp | 78 | ||||
-rw-r--r-- | indra/newview/lllandmarkactions.cpp | 45 | ||||
-rw-r--r-- | indra/newview/lllandmarkactions.h | 13 | ||||
-rw-r--r-- | indra/newview/llworldmap.cpp | 7 | ||||
-rw-r--r-- | indra/newview/llworldmap.h | 1 |
5 files changed, 111 insertions, 33 deletions
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 007c6b2c4c..76ece9d165 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -66,29 +66,46 @@ const S32 DROP_DOWN_MENU_WIDTH = 250; * Helper for LLFavoriteLandmarkButton and LLFavoriteLandmarkMenuItem. * Performing requests for SLURL for given Landmark ID */ -class LLSLURLGetter +class LLLandmarkInfoGetter { public: - LLSLURLGetter() - : mLandmarkID(LLUUID::null) - , mSLURL("(Loading...)") - , mLoaded(false) {} + LLLandmarkInfoGetter() + : mLandmarkID(LLUUID::null), + mName("(Loading...)"), + mPosX(0), + mPosY(0), + mLoaded(false) + {} void setLandmarkID(const LLUUID& id) { mLandmarkID = id; } const LLUUID& getLandmarkId() const { return mLandmarkID; } - const std::string& getSLURL() + const std::string& getName() { if(!mLoaded) - requestSLURL(); + requestNameAndPos(); - return mSLURL; + return mName; + } + + S32 getPosX() + { + if (!mLoaded) + requestNameAndPos(); + return mPosX; + } + + S32 getPosY() + { + if (!mLoaded) + requestNameAndPos(); + return mPosY; } private: /** * Requests landmark data from server. */ - void requestSLURL() + void requestNameAndPos() { if (mLandmarkID.isNull()) return; @@ -96,19 +113,23 @@ private: LLVector3d g_pos; if(LLLandmarkActions::getLandmarkGlobalPos(mLandmarkID, g_pos)) { - LLLandmarkActions::getSLURLfromPosGlobal(g_pos, - boost::bind(&LLSLURLGetter::landmarkNameCallback, this, _1), false); + LLLandmarkActions::getRegionNameAndCoordsFromPosGlobal(g_pos, + boost::bind(&LLLandmarkInfoGetter::landmarkNameCallback, this, _1, _2, _3)); } } - void landmarkNameCallback(const std::string& name) + void landmarkNameCallback(const std::string& name, S32 x, S32 y) { - mSLURL = name; + mPosX = x; + mPosY = y; + mName = name; mLoaded = true; } LLUUID mLandmarkID; - std::string mSLURL; + std::string mName; + S32 mPosX; + S32 mPosY; bool mLoaded; }; @@ -125,7 +146,15 @@ public: BOOL handleToolTip(S32 x, S32 y, MASK mask) { - LLToolTipMgr::instance().show(mUrlGetter.getSLURL()); + std::string region_name = mLandmarkInfoGetter.getName(); + + if (!region_name.empty()) + { + LLToolTip::Params params; + params.message = llformat("%s\n%s (%d, %d)", getLabelSelected().c_str(), region_name.c_str(), mLandmarkInfoGetter.getPosX(), mLandmarkInfoGetter.getPosY()); + params.sticky_rect = calcScreenRect(); + LLToolTipMgr::instance().show(params); + } return TRUE; } @@ -141,8 +170,8 @@ public: return LLButton::handleHover(x, y, mask); } - void setLandmarkID(const LLUUID& id){ mUrlGetter.setLandmarkID(id); } - const LLUUID& getLandmarkId() const { return mUrlGetter.getLandmarkId(); } + void setLandmarkID(const LLUUID& id){ mLandmarkInfoGetter.setLandmarkID(id); } + const LLUUID& getLandmarkId() const { return mLandmarkInfoGetter.getLandmarkId(); } void onMouseEnter(S32 x, S32 y, MASK mask) { @@ -161,7 +190,7 @@ protected: friend class LLUICtrlFactory; private: - LLSLURLGetter mUrlGetter; + LLLandmarkInfoGetter mLandmarkInfoGetter; }; /** @@ -176,11 +205,18 @@ class LLFavoriteLandmarkMenuItem : public LLMenuItemCallGL public: BOOL handleToolTip(S32 x, S32 y, MASK mask) { - LLToolTipMgr::instance().show(mUrlGetter.getSLURL()); + std::string region_name = mLandmarkInfoGetter.getName(); + if (!region_name.empty()) + { + LLToolTip::Params params; + params.message = llformat("%s\n%s (%d, %d)", getLabel().c_str(), region_name.c_str(), mLandmarkInfoGetter.getPosX(), mLandmarkInfoGetter.getPosY()); + params.sticky_rect = calcScreenRect(); + LLToolTipMgr::instance().show(params); + } return TRUE; } - void setLandmarkID(const LLUUID& id){ mUrlGetter.setLandmarkID(id); } + void setLandmarkID(const LLUUID& id){ mLandmarkInfoGetter.setLandmarkID(id); } virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) { @@ -212,7 +248,7 @@ protected: friend class LLUICtrlFactory; private: - LLSLURLGetter mUrlGetter; + LLLandmarkInfoGetter mLandmarkInfoGetter; LLFavoritesBarCtrl* fb; }; diff --git a/indra/newview/lllandmarkactions.cpp b/indra/newview/lllandmarkactions.cpp index 2e6615dd91..b36b7cf50e 100644 --- a/indra/newview/lllandmarkactions.cpp +++ b/indra/newview/lllandmarkactions.cpp @@ -270,23 +270,42 @@ void LLLandmarkActions::getSLURLfromPosGlobal(const LLVector3d& global_pos, slur { U64 new_region_handle = to_region_handle(global_pos); - LLWorldMap::url_callback_t url_cb = boost::bind(&LLLandmarkActions::onRegionResponse, + LLWorldMap::url_callback_t url_cb = boost::bind(&LLLandmarkActions::onRegionResponseSLURL, cb, global_pos, escaped, - _1, _2, _3, _4); + _2); LLWorldMap::getInstance()->sendHandleRegionRequest(new_region_handle, url_cb, std::string("unused"), false); } } -void LLLandmarkActions::onRegionResponse(slurl_callback_t cb, +void LLLandmarkActions::getRegionNameAndCoordsFromPosGlobal(const LLVector3d& global_pos, region_name_and_coords_callback_t cb) +{ + std::string sim_name; + LLSimInfo* sim_infop = LLWorldMap::getInstance()->simInfoFromPosGlobal(global_pos); + if (sim_infop) + { + LLVector3 pos = sim_infop->getLocalPos(global_pos); + cb(sim_infop->mName, llround(pos.mV[VX]), llround(pos.mV[VY])); + } + else + { + U64 new_region_handle = to_region_handle(global_pos); + + LLWorldMap::url_callback_t url_cb = boost::bind(&LLLandmarkActions::onRegionResponseNameAndCoords, + cb, + global_pos, + _1); + + LLWorldMap::getInstance()->sendHandleRegionRequest(new_region_handle, url_cb, std::string("unused"), false); + } +} + +void LLLandmarkActions::onRegionResponseSLURL(slurl_callback_t cb, const LLVector3d& global_pos, bool escaped, - U64 region_handle, - const std::string& url, - const LLUUID& snapshot_id, - bool teleport) + const std::string& url) { std::string sim_name; std::string slurl; @@ -303,6 +322,18 @@ void LLLandmarkActions::onRegionResponse(slurl_callback_t cb, cb(slurl); } +void LLLandmarkActions::onRegionResponseNameAndCoords(region_name_and_coords_callback_t cb, + const LLVector3d& global_pos, + U64 region_handle) +{ + LLSimInfo* sim_infop = LLWorldMap::getInstance()->simInfoFromHandle(region_handle); + if (sim_infop) + { + LLVector3 local_pos = sim_infop->getLocalPos(global_pos); + cb(sim_infop->mName, llround(local_pos.mV[VX]), llround(local_pos.mV[VY])); + } +} + bool LLLandmarkActions::getLandmarkGlobalPos(const LLUUID& landmarkInventoryItemID, LLVector3d& posGlobal) { LLLandmark* landmark = LLLandmarkActions::getLandmark(landmarkInventoryItemID); diff --git a/indra/newview/lllandmarkactions.h b/indra/newview/lllandmarkactions.h index e882db0a92..d651259790 100644 --- a/indra/newview/lllandmarkactions.h +++ b/indra/newview/lllandmarkactions.h @@ -43,6 +43,7 @@ class LLLandmarkActions { public: typedef boost::function<void(std::string& slurl)> slurl_callback_t; + typedef boost::function<void(std::string& slurl, S32 x, S32 y)> region_name_and_coords_callback_t; /** * @brief Fetches landmark LLViewerInventoryItems for the given landmark name. @@ -92,6 +93,8 @@ public: */ static void getSLURLfromPosGlobal(const LLVector3d& global_pos, slurl_callback_t cb, bool escaped = true); + static void getRegionNameAndCoordsFromPosGlobal(const LLVector3d& global_pos, region_name_and_coords_callback_t cb); + /** * @brief Gets landmark global position specified by inventory LLUUID. * Found position is placed into "posGlobal" variable. @@ -120,13 +123,13 @@ private: LLLandmarkActions(); LLLandmarkActions(const LLLandmarkActions&); - static void onRegionResponse(slurl_callback_t cb, + static void onRegionResponseSLURL(slurl_callback_t cb, const LLVector3d& global_pos, bool escaped, - U64 region_handle, - const std::string& url, - const LLUUID& snapshot_id, - bool teleport); + const std::string& url); + static void onRegionResponseNameAndCoords(region_name_and_coords_callback_t cb, + const LLVector3d& global_pos, + U64 region_handle); }; #endif //LL_LLLANDMARKACTIONS_H diff --git a/indra/newview/llworldmap.cpp b/indra/newview/llworldmap.cpp index b8ecd9556f..829d631473 100644 --- a/indra/newview/llworldmap.cpp +++ b/indra/newview/llworldmap.cpp @@ -94,6 +94,13 @@ LLVector3d LLSimInfo::getGlobalPos(LLVector3 local_pos) const return pos; } +LLVector3 LLSimInfo::getLocalPos(LLVector3d global_pos) const +{ + LLVector3d sim_origin = from_region_handle(mHandle); + return LLVector3(global_pos - sim_origin); +} + + //--------------------------------------------------------------------------- // World Map diff --git a/indra/newview/llworldmap.h b/indra/newview/llworldmap.h index 9daee38752..366de8f071 100644 --- a/indra/newview/llworldmap.h +++ b/indra/newview/llworldmap.h @@ -78,6 +78,7 @@ public: LLSimInfo(); LLVector3d getGlobalPos(LLVector3 local_pos) const; + LLVector3 getLocalPos(LLVector3d global_pos) const; public: U64 mHandle; |