From b3ca9b43acfbc6e3cacfcd4f92aa39443c55ef1c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 6 Feb 2014 14:28:34 +0100 Subject: [PATCH] Clean up LLFLoaterMap and remove unnecessary duplicate code --- indra/newview/llfloatermap.cpp | 346 +++++++-------------------------- indra/newview/llfloatermap.h | 22 +-- 2 files changed, 72 insertions(+), 296 deletions(-) diff --git a/indra/newview/llfloatermap.cpp b/indra/newview/llfloatermap.cpp index 8cc7499621..fb19a9ef21 100755 --- a/indra/newview/llfloatermap.cpp +++ b/indra/newview/llfloatermap.cpp @@ -45,18 +45,6 @@ #include "llfloaterworldmap.h" #include "llagent.h" -// Firestorm includes -#include "rlvhandler.h" -#include "llavataractions.h" -#include "llavatarnamecache.h" -#include "llfloatersidepanelcontainer.h" -#include "lltrans.h" -#include "llviewerobject.h" -#include "llviewerparceloverlay.h" -#include "llviewerparcelmgr.h" -#include "llviewermenu.h" -#include "llworld.h" // Aurora Sim - // // Constants // @@ -82,7 +70,6 @@ LLFloaterMap::LLFloaterMap(const LLSD& key) mTextBoxNorthEast(NULL), mTextBoxNorthWest(NULL), mTextBoxSouthWest(NULL), - mPopupMenu(NULL), // mMap(NULL) { } @@ -115,39 +102,7 @@ BOOL LLFloaterMap::postBuild() mTextBoxSouthWest = getChild ("floater_map_southwest"); mTextBoxNorthWest = getChild ("floater_map_northwest"); - // - LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; - - registrar.add("Minimap.Zoom", boost::bind(&LLFloaterMap::handleZoom, this, _2)); - registrar.add("Minimap.Tracker", boost::bind(&LLFloaterMap::handleStopTracking, this, _2)); - - registrar.add("Minimap.Mark", boost::bind(&LLFloaterMap::handleMark, this, _2)); - registrar.add("Minimap.ClearMarks", boost::bind(&LLFloaterMap::handleClearMarks, this)); - - registrar.add("Minimap.Cam", boost::bind(&LLFloaterMap::handleCam, this)); - registrar.add("Minimap.StartTracking", boost::bind(&LLFloaterMap::handleStartTracking, this)); - - // [SL:KB] - Patch: World-MiniMap | Checked: 2012-07-08 (Catznip-3.3.0) - registrar.add("Minimap.ShowProfile", boost::bind(&LLFloaterMap::handleShowProfile, this, _2)); - registrar.add("Minimap.TextureType", boost::bind(&LLFloaterMap::handleTextureType, this, _2)); - registrar.add("Minimap.ToggleOverlay", boost::bind(&LLFloaterMap::handleOverlayToggle, this, _2)); - - LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; - enable_registrar.add("Minimap.CheckTextureType", boost::bind(&LLFloaterMap::checkTextureType, this, _2)); - // [/SL:KB] - - // [SL:KB] - Patch: World-MinimapOverlay | Checked: 2012-06-20 (Catznip-3.3.0) - LLViewerParcelMgr::instance().setCollisionUpdateCallback(boost::bind(&LLFloaterMap::refreshParcelOverlay, this)); - LLViewerParcelOverlay::setUpdateCallback(boost::bind(&LLFloaterMap::refreshParcelOverlay, this)); - // [/SL:KB] - - mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile("menu_mini_map.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); - if (mPopupMenu && !LLTracker::isTracking(0)) - { - mPopupMenu->setItemEnabled ("Stop Tracking", false); - } - // - + // Remove titlebar stretchMiniMap(getRect().getWidth() - MAP_PADDING_LEFT - MAP_PADDING_RIGHT, getRect().getHeight() - MAP_PADDING_TOP - MAP_PADDING_BOTTOM); @@ -156,8 +111,10 @@ BOOL LLFloaterMap::postBuild() // Get the drag handle all the way in back sendChildToBack(getDragHandle()); + // Remove titlebar setIsChrome(TRUE); getDragHandle()->setTitleVisible(TRUE); + // // keep onscreen gFloaterView->adjustToFitScreen(this, FALSE); @@ -198,63 +155,6 @@ BOOL LLFloaterMap::handleDoubleClick(S32 x, S32 y, MASK mask) return TRUE; } -BOOL LLFloaterMap::handleRightMouseDown(S32 x, S32 y, MASK mask) -{ - if (mPopupMenu) - { - // [SL:KB] - Patch: World-MiniMap | Checked: 2012-07-08 (Catznip-3.3.0) - mMap->mClosestAgentRightClick = mMap->getClosestAgentToCursor(); - mMap->mPosGlobalRightClick = mMap->viewPosToGlobal(x, y); - - mPopupMenu->setItemVisible("View Profile", mMap->mClosestAgentsToCursor.size() == 1); - - LLMenuItemBranchGL* pProfilesMenu = mPopupMenu->getChild("View Profiles"); - if (pProfilesMenu) - { - pProfilesMenu->setVisible(mMap->mClosestAgentsToCursor.size() > 1); - - pProfilesMenu->getBranch()->empty(); - for (uuid_vec_t::const_iterator itAgent = mMap->mClosestAgentsToCursor.begin(); itAgent != mMap->mClosestAgentsToCursor.end(); ++itAgent) - { - LLMenuItemCallGL::Params p; - p.name = llformat("Profile Item %d", itAgent - mMap->mClosestAgentsToCursor.begin()); - - LLAvatarName avName; const LLUUID& idAgent = *itAgent; - if (LLAvatarNameCache::get(idAgent, &avName)) - { - p.label = avName.getCompleteName(); - } - else - { - p.label = LLTrans::getString("LoadingData"); - LLAvatarNameCache::get(idAgent, boost::bind(&LLFloaterMap::setAvatarProfileLabel, this, _2, p.name.getValue())); - } - p.on_click.function = boost::bind(&LLAvatarActions::showProfile, _2); - p.on_click.parameter = idAgent; - - LLMenuItemCallGL* pMenuItem = LLUICtrlFactory::create(p); - if (pMenuItem) - pProfilesMenu->getBranch()->addChild(pMenuItem); - } - } - mPopupMenu->setItemVisible("Cam", mMap->isZoomable()); - mPopupMenu->setItemVisible("MarkAvatar", mMap->getClosestAgentToCursor().notNull()); - mPopupMenu->setItemVisible("Start Tracking", mMap->getClosestAgentToCursor().notNull()); - mPopupMenu->setItemVisible("Profile Separator", (mMap->mClosestAgentsToCursor.size() >= 1 - || mMap->getClosestAgentToCursor().notNull())); - // [/SL:KB] - mPopupMenu->buildDrawLabels(); - mPopupMenu->updateParent(LLMenuGL::sMenuContainer); - // [SL:KB] - Patch: World-MiniMap | Checked: 2012-07-08 (Catznip-3.3.0) - mPopupMenu->setItemVisible("Stop Tracking", LLTracker::isTracking(0)); - mPopupMenu->setItemVisible("Stop Tracking Separator", LLTracker::isTracking(0)); - // [/SL:KB] - // mPopupMenu->setItemEnabled("Stop Tracking", LLTracker::isTracking(0)); - LLMenuGL::showPopup(this, mPopupMenu, x, y); - } - return TRUE; -} - void LLFloaterMap::setDirectionPos( LLTextBox* text_box, F32 rotation ) { // Rotation is in radians. @@ -324,19 +224,73 @@ void LLFloaterMap::draw() setMouseOpaque(TRUE); getDragHandle()->setMouseOpaque(TRUE); } - - if (LLTracker::isTracking(0)) - { - mPopupMenu->setItemEnabled("Stop Tracking", true); - } -// Aurora Sim - //LLFloater::draw(); - if(LLWorld::getInstance()->getAllowMinimap()) + LLFloater::draw(); +} + +void LLFloaterMap::reshape(S32 width, S32 height, BOOL called_from_parent) +{ + LLFloater::reshape(width, height, called_from_parent); + + // Remove titlebar + stretchMiniMap(width - MAP_PADDING_LEFT - MAP_PADDING_RIGHT, height - MAP_PADDING_TOP - MAP_PADDING_BOTTOM); + + updateMinorDirections(); +} + +// Unused as of 06-02-2014; Handled in LLNetMap +//void LLFloaterMap::handleZoom(const LLSD& userdata) +//{ +// std::string level = userdata.asString(); +// +// F32 scale = 0.0f; +// if (level == std::string("default")) +// { +// LLControlVariable *pvar = gSavedSettings.getControl("MiniMapScale"); +// if(pvar) +// { +// pvar->resetToDefault(); +// scale = gSavedSettings.getF32("MiniMapScale"); +// } +// } +// else if (level == std::string("close")) +// scale = LLNetMap::MAP_SCALE_MAX; +// else if (level == std::string("medium")) +// scale = LLNetMap::MAP_SCALE_MID; +// else if (level == std::string("far")) +// scale = LLNetMap::MAP_SCALE_MIN; +// if (scale != 0.0f) +// { +// mMap->setScale(scale); +// } +//} +// + +LLFloaterMap* LLFloaterMap::getInstance() +{ + return LLFloaterReg::getTypedInstance("mini_map"); +} + +// FIRE-1825: Minimap floater background transparency +// virtual +F32 LLFloaterMap::getCurrentTransparency() +{ + static LLCachedControl fsMiniMapOpacity(gSavedSettings, "FSMiniMapOpacity"); + return fsMiniMapOpacity(); +} + +// Remove titlebar +void LLFloaterMap::setMinimized(BOOL b) +{ + LLFloater::setMinimized(b); + if (b) { - LLFloater::draw(); + setTitle(getString("mini_map_caption")); + } + else + { + setTitle(""); } -// Aurora Sim } void LLFloaterMap::stretchMiniMap(S32 width,S32 height) @@ -351,168 +305,4 @@ void LLFloaterMap::stretchMiniMap(S32 width,S32 height) mMap->setRect(map_rect); } } - -void LLFloaterMap::reshape(S32 width, S32 height, BOOL called_from_parent) -{ - LLFloater::reshape(width, height, called_from_parent); - - stretchMiniMap(width - MAP_PADDING_LEFT - MAP_PADDING_RIGHT, - height - MAP_PADDING_TOP - MAP_PADDING_BOTTOM); - - updateMinorDirections(); -} - -void LLFloaterMap::handleZoom(const LLSD& userdata) -{ - std::string level = userdata.asString(); - - F32 scale = 0.0f; - - if (level == std::string("default")) - { - LLControlVariable *pvar = gSavedSettings.getControl("MiniMapScale"); - if(pvar) - { - pvar->resetToDefault(); - scale = gSavedSettings.getF32("MiniMapScale"); - } - } - else if (level == std::string("close")) - scale = LLNetMap::MAP_SCALE_MAX; - else if (level == std::string("medium")) - scale = LLNetMap::MAP_SCALE_MID; - else if (level == std::string("far")) - scale = LLNetMap::MAP_SCALE_MIN; - if (scale != 0.0f) - { - mMap->setScale(scale); - } -} - -LLFloaterMap* LLFloaterMap::getInstance() -{ - return LLFloaterReg::getTypedInstance("mini_map"); -} - -void LLFloaterMap::setMinimized(BOOL b) -{ - LLFloater::setMinimized(b); - if(b) - { - setTitle(getString("mini_map_caption")); - } - else - { - setTitle(""); - } -} - -void LLFloaterMap::handleMark(const LLSD& userdata) -{ - mMap->setAvatarMark(userdata); -} - -void LLFloaterMap::handleClearMarks() -{ - mMap->clearAvatarMarks(); -} - -void LLFloaterMap::handleCam() -{ - mMap->camAvatar(); -} - -void LLFloaterMap::handleStopTracking (const LLSD& userdata) -{ - if (mPopupMenu) - { - mPopupMenu->setItemEnabled ("Stop Tracking", false); - LLTracker::stopTracking ((void*)(ptrdiff_t)LLTracker::isTracking(NULL)); - } -} - -// Avatar tracking feature -void LLFloaterMap::handleStartTracking() -{ - mMap->startTracking(); -} -// Avatar tracking feature - -// FIXME: Cut and paste duplicate code from llnetmap.cpp -void LLFloaterMap::setAvatarProfileLabel(const LLAvatarName& avName, const std::string& item_name) -{ - LLMenuItemGL* pItem = mPopupMenu->findChild(item_name, TRUE /*recurse*/); - if (pItem) - { - pItem->setLabel(avName.getCompleteName()); - pItem->getMenu()->arrange(); - } -} - -void LLFloaterMap::handleOverlayToggle(const LLSD& sdParam) -{ - // Toggle the setting - const std::string strControl = sdParam.asString(); - BOOL fCurValue = gSavedSettings.getBOOL(strControl); - gSavedSettings.setBOOL(strControl, !fCurValue); - - // Force an overlay update - refreshParcelOverlay(); -} - -void LLFloaterMap::handleShowProfile(const LLSD& sdParam) const -{ - const std::string strParam = sdParam.asString(); - if ("closest" == strParam) - { - LLAvatarActions::showProfile(mMap->mClosestAgentRightClick); - } - else if ("place" == strParam) - { - LLSD sdParams; - sdParams["type"] = "remote_place"; - sdParams["x"] = mMap->mPosGlobalRightClick.mdV[VX]; - sdParams["y"] = mMap->mPosGlobalRightClick.mdV[VY]; - sdParams["z"] = mMap->mPosGlobalRightClick.mdV[VZ]; - - if (gSavedSettings.getBOOL("FSUseStandalonePlaceDetailsFloater")) - { - LLFloaterReg::showInstance("fs_placedetails", sdParams); - } - else - { - LLFloaterSidePanelContainer::showPanel("places", sdParams); - } - } -} - -bool LLFloaterMap::checkTextureType(const LLSD& sdParam) const -{ - const std::string strParam = sdParam.asString(); - - bool fWorldMapTextures = gSavedSettings.getBOOL("MiniMapWorldMapTextures"); - if ("maptile" == strParam) - return fWorldMapTextures; - else if ("terrain" == strParam) - return !fWorldMapTextures; - return false; -} - -void LLFloaterMap::handleTextureType(const LLSD& sdParam) const -{ - gSavedSettings.setBOOL("MiniMapWorldMapTextures", ("maptile" == sdParam.asString())); -} - -void LLFloaterMap::refreshParcelOverlay() -{ - mMap->mUpdateParcelImage = true; -} - -// FIRE-1825: Minimap floater background transparency -// virtual -F32 LLFloaterMap::getCurrentTransparency() -{ - static LLCachedControl fsMiniMapOpacity(gSavedSettings, "FSMiniMapOpacity"); - return fsMiniMapOpacity(); -} - +// diff --git a/indra/newview/llfloatermap.h b/indra/newview/llfloatermap.h index 6876d74976..1564b7483c 100755 --- a/indra/newview/llfloatermap.h +++ b/indra/newview/llfloatermap.h @@ -28,9 +28,7 @@ #define LL_LLFLOATERMAP_H #include "llfloater.h" -#include "llavatarname.h" // -class LLMenuGL; class LLNetMap; class LLTextBox; @@ -46,7 +44,6 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ BOOL handleDoubleClick( S32 x, S32 y, MASK mask ); - /*virtual*/ BOOL handleRightMouseDown( S32 x, S32 y, MASK mask ); /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); /*virtual*/ void draw(); @@ -54,26 +51,15 @@ public: /*virtual*/ F32 getCurrentTransparency(); private: - void handleZoom(const LLSD& userdata); - void handleStopTracking (const LLSD& userdata); + // Unused as of 06-02-2014; Handled in LLNetMap + //void handleZoom(const LLSD& userdata); void setDirectionPos( LLTextBox* text_box, F32 rotation ); void updateMinorDirections(); - void handleMark(const LLSD& userdata); - void handleClearMarks(); - void handleCam(); - void handleStartTracking(); - void handleShowProfile(const LLSD& sdParam) const; - void handleOverlayToggle(const LLSD& sdParam); - void refreshParcelOverlay(); - bool checkTextureType(const LLSD& sdParam) const; - void handleTextureType(const LLSD& sdParam) const; - void setAvatarProfileLabel(const LLAvatarName& avName, const std::string& item_name); // + // Remove titlebar void setMinimized( BOOL ); - void stretchMiniMap(S32 width,S32 height); - - LLMenuGL* mPopupMenu; + // LLTextBox* mTextBoxEast; LLTextBox* mTextBoxNorth;