FIRE-8140: Resync netmap instances, clean up leftovers in llnetmap

Cinders 2013-03-22 00:06:00 -06:00
parent 823dcca28e
commit 21c966ffdc
4 changed files with 319 additions and 65 deletions

View File

@ -45,7 +45,16 @@
#include "llfloaterworldmap.h"
#include "llagent.h"
#include "llworld.h" // <FS:CR> Aurora Sim />
// Firestorm includes
#include "rlvhandler.h"
#include "llavataractions.h"
#include "llavatarnamecache.h"
#include "llfloatersidepanelcontainer.h"
#include "llviewerobject.h"
#include "llviewerparceloverlay.h"
#include "llviewerparcelmgr.h"
#include "llviewermenu.h"
#include "llworld.h" // <FS:CR> Aurora Sim
//
// Constants
@ -72,6 +81,7 @@ LLFloaterMap::LLFloaterMap(const LLSD& key)
mTextBoxNorthEast(NULL),
mTextBoxNorthWest(NULL),
mTextBoxSouthWest(NULL),
mPopupMenu(NULL), // <FS:CR>
mMap(NULL)
{
}
@ -83,14 +93,16 @@ LLFloaterMap::~LLFloaterMap()
BOOL LLFloaterMap::postBuild()
{
mMap = getChild<LLNetMap>("Net Map");
if (gSavedSettings.getBOOL("DoubleClickTeleport"))
{
mMap->setToolTipMsg(getString("AltToolTipMsg"));
}
else if (gSavedSettings.getBOOL("DoubleClickShowWorldMap"))
{
mMap->setToolTipMsg(getString("ToolTipMsg"));
}
// <FS:Ansariel> Synchronize tooltips throughout instances
//if (gSavedSettings.getBOOL("DoubleClickTeleport"))
//{
// mMap->setToolTipMsg(getString("AltToolTipMsg"));
//}
//else if (gSavedSettings.getBOOL("DoubleClickShowWorldMap"))
//{
// mMap->setToolTipMsg(getString("ToolTipMsg"));
//}
// </FS:Ansariel> Synchronize tooltips throughout instances
sendChildToBack(mMap);
mTextBoxNorth = getChild<LLTextBox> ("floater_map_north");
@ -102,11 +114,50 @@ BOOL LLFloaterMap::postBuild()
mTextBoxSouthWest = getChild<LLTextBox> ("floater_map_southwest");
mTextBoxNorthWest = getChild<LLTextBox> ("floater_map_northwest");
// <Firestorm Minimap changes>
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<LLMenuGL>("menu_mini_map.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
if (mPopupMenu && !LLTracker::isTracking(0))
{
mPopupMenu->setItemEnabled ("Stop Tracking", false);
}
// </Firestorm minimap changes>
stretchMiniMap(getRect().getWidth() - MAP_PADDING_LEFT - MAP_PADDING_RIGHT,
getRect().getHeight() - MAP_PADDING_TOP - MAP_PADDING_BOTTOM);
updateMinorDirections();
// Get the drag handle all the way in back
sendChildToBack(getDragHandle());
setIsChrome(TRUE);
getDragHandle()->setTitleVisible(TRUE);
// keep onscreen
gFloaterView->adjustToFitScreen(this, FALSE);
@ -124,24 +175,82 @@ BOOL LLFloaterMap::handleDoubleClick(S32 x, S32 y, MASK mask)
LLVector3d pos_global = mMap->viewPosToGlobal(x, y);
// If we're not tracking a beacon already, double-click will set one
if (!LLTracker::isTracking(NULL))
// <FS:Ansariel> Synchronize double click handling throughout instances
//LLTracker::stopTracking(NULL);
//LLFloaterWorldMap* world_map = LLFloaterWorldMap::getInstance();
//if (world_map)
//{
// world_map->trackLocation(pos_global);
//}
//
//if (gSavedSettings.getBOOL("DoubleClickTeleport"))
//{
// // If DoubleClickTeleport is on, double clicking the minimap will teleport there
// gAgent.teleportViaLocationLookAt(pos_global);
//}
//else if (gSavedSettings.getBOOL("DoubleClickShowWorldMap"))
//{
// LLFloaterReg::showInstance("world_map");
//}
mMap->performDoubleClickAction(pos_global);
// </FS:Ansariel> Synchronize double click handling throughout instances
return TRUE;
}
BOOL LLFloaterMap::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
if (mPopupMenu)
{
LLFloaterWorldMap* world_map = LLFloaterWorldMap::getInstance();
if (world_map)
// [SL:KB] - Patch: World-MiniMap | Checked: 2012-07-08 (Catznip-3.3.0)
mMap->mPosGlobalRightClick = mMap->viewPosToGlobal(x, y);
mPopupMenu->setItemVisible("View Profile", mMap->mClosestAgentsToCursor.size() == 1);
LLMenuItemBranchGL* pProfilesMenu = mPopupMenu->getChild<LLMenuItemBranchGL>("View Profiles");
if (pProfilesMenu)
{
world_map->trackLocation(pos_global);
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<LLMenuItemCallGL>(p);
if (pMenuItem)
pProfilesMenu->getBranch()->addChild(pMenuItem);
}
}
}
if (gSavedSettings.getBOOL("DoubleClickTeleport"))
{
// If DoubleClickTeleport is on, double clicking the minimap will teleport there
gAgent.teleportViaLocationLookAt(pos_global);
}
else if (gSavedSettings.getBOOL("DoubleClickShowWorldMap"))
{
LLFloaterReg::showInstance("world_map");
F32 range = dist_vec(mMap->getClosestAgentPosition(), gAgent.getPositionGlobal());
mPopupMenu->setItemVisible("Cam", (range < gSavedSettings.getF32("RenderFarClip")
|| gObjectList.findObject(mMap->getClosestAgentRightClick()) != NULL));
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;
}
@ -215,6 +324,12 @@ void LLFloaterMap::draw()
setMouseOpaque(TRUE);
getDragHandle()->setMouseOpaque(TRUE);
}
if (LLTracker::isTracking(0))
{
mPopupMenu->setItemEnabled("Stop Tracking", true);
}
// <FS:CR> Aurora Sim
//LLFloater::draw();
if(LLWorld::getInstance()->getAllowMinimap())
@ -224,35 +339,164 @@ void LLFloaterMap::draw()
// <FS:CR> Aurora Sim
}
void LLFloaterMap::stretchMiniMap(S32 width,S32 height)
{
//fix for ext-7112
//by default ctrl can't overlap caption area
if(mMap)
{
LLRect map_rect;
map_rect.setLeftTopAndSize( MAP_PADDING_LEFT, getRect().getHeight() - MAP_PADDING_TOP, width, height);
mMap->reshape( width, height, 1);
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);
// }
//}
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<LLFloaterMap>("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));
}
}
// <FS:Ansariel> Avatar tracking feature
void LLFloaterMap::handleStartTracking()
{
mMap->startTracking();
}
// </FS:Ansariel> Avatar tracking feature
// <FS:CR> FIXME: Cut and paste duplicate code from llnetmap.cpp
void LLFloaterMap::setAvatarProfileLabel(const LLAvatarName& avName, const std::string& item_name)
{
LLMenuItemGL* pItem = mPopupMenu->findChild<LLMenuItemGL>(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->getClosestAgentRightClick());
}
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];
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;
}

View File

@ -28,7 +28,9 @@
#define LL_LLFLOATERMAP_H
#include "llfloater.h"
#include "llavatarname.h" // <FS:CR>
class LLMenuGL;
class LLNetMap;
class LLTextBox;
@ -39,17 +41,36 @@ class LLFloaterMap : public LLFloater
{
public:
LLFloaterMap(const LLSD& key);
static LLFloaterMap* getInstance();
virtual ~LLFloaterMap();
/*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();
private:
// void handleZoom(const LLSD& userdata);
void handleZoom(const LLSD& userdata);
void handleStopTracking (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); // <FS:CR>
void setMinimized( BOOL );
void stretchMiniMap(S32 width,S32 height);
LLMenuGL* mPopupMenu;
LLTextBox* mTextBoxEast;
LLTextBox* mTextBoxNorth;

View File

@ -1677,14 +1677,6 @@ void LLNetMap::handleCam()
camAvatar();
}
void LLNetMap::showProfile()
{
if (mClosestAgentRightClick.notNull())
{
LLAvatarActions::showProfile(mClosestAgentRightClick);
}
}
// <FS:Ansariel> Avatar tracking feature
void LLNetMap::handleStartTracking()
{

View File

@ -95,6 +95,8 @@ public:
void renderScaledPointGlobal( const LLVector3d& pos, const LLColor4U &color, F32 radius );
LLVector3d viewPosToGlobal(S32 x,S32 y);
LLUUID getClosestAgentRightClick() const { return mClosestAgentRightClick; }
LLUUID getClosestAgentToCursor() const { return mClosestAgentToCursor; }
LLVector3d getClosestAgentPosition() const { return mClosestAgentPosition; }
// <FS:Ansariel> Synchronize double click handling throughout instances
void performDoubleClickAction(LLVector3d pos_global);
@ -124,7 +126,6 @@ private:
static bool outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y, S32 slop);
private:
// bool mUpdateNow;
// [SL:KB] - Patch: World-MinimapOverlay | Checked: 2012-06-20 (Catznip-3.3.0)
bool mUpdateObjectImage;
@ -158,13 +159,9 @@ private:
LLUUID mClosestAgentToCursor;
// [SL:KB] - Patch: World-MiniMap | Checked: 2012-07-08 (Catznip-3.3.0)
uuid_vec_t mClosestAgentsToCursor;
LLVector3d mClosestAgentPosition;
LLUUID mClosestAgentRightClick;
LLVector3d mPosGlobalRightClick;
// [/SL:KB]
// LLUUID mClosestAgentAtLastRightClick;
// <FS:Ansariel> Synchronize tooltips throughout instances
//std::string mToolTipMsg;
static std::string sToolTipMsg;
@ -177,10 +174,10 @@ public:
void setAvatarMark(const LLSD& userdata);
void clearAvatarMarks();
void camAvatar();
void showProfile();
// <FS:CR> Minimap improvements
void handleShowProfile(const LLSD& sdParam) const;
void saveClosestAgentRightClick();
uuid_vec_t mClosestAgentsToCursor;
LLVector3d mPosGlobalRightClick;
// </FS:CR>
void startTracking();