summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2013-11-18 19:05:34 -0500
committerOz Linden <oz@lindenlab.com>2013-11-18 19:05:34 -0500
commit6bd777214c535b91048533c792cb2dd499ec6ebf (patch)
tree24cd4bb15bac292cfd71c39dcdd58e597fffb8e3 /indra/newview
parentebc9bcbf69f7a519677a6522979a6bf6cbb04bb8 (diff)
add callbacks to LLAgent for Region and Parcel changes
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llagent.cpp48
-rwxr-xr-xindra/newview/llagent.h28
-rwxr-xr-xindra/newview/lllocationinputctrl.cpp4
-rwxr-xr-xindra/newview/llmoveview.cpp2
-rwxr-xr-xindra/newview/llpanelplaces.cpp2
-rwxr-xr-xindra/newview/llpaneltopinfobar.cpp2
-rwxr-xr-xindra/newview/llviewerparcelmgr.cpp9
-rwxr-xr-xindra/newview/llviewerparcelmgr.h10
8 files changed, 75 insertions, 30 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 325707bbf1..da29aaff50 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -259,9 +259,9 @@ bool handleSlowMotionAnimation(const LLSD& newvalue)
return true;
}
-// static
-void LLAgent::parcelChangedCallback()
+void LLAgent::setCanEditParcel() // called via mParcelChangedSignal
{
+ LL_DEBUGS("AgentLocation") << LL_ENDL;
bool can_edit = LLToolMgr::getInstance()->canEdit();
gAgent.mCanEditParcel = can_edit;
@@ -425,6 +425,8 @@ LLAgent::LLAgent() :
mListener.reset(new LLAgentListener(*this));
+ addParcelChangedCallback(&setCanEditParcel);
+
mMoveTimer.stop();
}
@@ -451,8 +453,6 @@ void LLAgent::init()
mLastKnownRequestMaturity = mLastKnownResponseMaturity;
mIsDoSendMaturityPreferenceToServer = true;
- LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(boost::bind(&LLAgent::parcelChangedCallback));
-
if (!mTeleportFinishedSlot.connected())
{
mTeleportFinishedSlot = LLViewerParcelMgr::getInstance()->setTeleportFinishedCallback(boost::bind(&LLAgent::handleTeleportFinished, this));
@@ -835,22 +835,34 @@ void LLAgent::handleServerBakeRegionTransition(const LLUUID& region_id)
}
}
+void LLAgent::changeParcels()
+{
+ LL_DEBUGS("AgentLocation") << LL_ENDL;
+ // Notify anything that wants to know about parcel changes
+ mParcelChangedSignal();
+}
+
+boost::signals2::connection LLAgent::addParcelChangedCallback(parcel_changed_callback_t cb)
+{
+ return mParcelChangedSignal.connect(cb);
+}
+
//-----------------------------------------------------------------------------
// setRegion()
//-----------------------------------------------------------------------------
void LLAgent::setRegion(LLViewerRegion *regionp)
{
bool teleport = true;
-
+ bool notifyRegionChange;
+
llassert(regionp);
if (mRegionp != regionp)
{
- // std::string host_name;
- // host_name = regionp->getHost().getHostName();
-
+ notifyRegionChange = true;
+
std::string ip = regionp->getHost().getString();
- llinfos << "Moving agent into region: " << regionp->getName()
- << " located at " << ip << llendl;
+ LL_INFOS("AgentLocation") << "Moving agent into region: " << regionp->getName()
+ << " located at " << ip << LL_ENDL;
if (mRegionp)
{
// We've changed regions, we're now going to change our agent coordinate frame.
@@ -902,6 +914,10 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
// Pass new region along to metrics components that care about this level of detail.
LLAppViewer::metricsUpdateRegion(regionp->getHandle());
}
+ else
+ {
+ notifyRegionChange = false;
+ }
mRegionp = regionp;
// Pass the region host to LLUrlEntryParcel to resolve parcel name
@@ -943,6 +959,12 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
// Need to handle via callback after caps arrive.
mRegionp->setCapabilitiesReceivedCallback(boost::bind(&LLAgent::handleServerBakeRegionTransition,this,_1));
}
+
+ if (notifyRegionChange)
+ {
+ LL_DEBUGS("AgentLocation") << "Calling RegionChanged callbacks" << LL_ENDL;
+ mRegionChangedSignal();
+ }
}
@@ -967,6 +989,12 @@ LLHost LLAgent::getRegionHost() const
}
}
+boost::signals2::connection LLAgent::addRegionChangedCallback(region_changed_callback_t cb)
+{
+ return mRegionChangedSignal.connect(cb);
+}
+
+
//-----------------------------------------------------------------------------
// inPrelude()
//-----------------------------------------------------------------------------
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 7fac17d098..fafa166efd 100755
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -231,15 +231,36 @@ private:
LLVector3 mHomePosRegion;
//--------------------------------------------------------------------
- // Region
+ // Parcel
//--------------------------------------------------------------------
public:
+ void changeParcels(); // called by LLViewerParcelMgr when we cross a parcel boundary
+
+ // Register a boost callback to be called when the agent changes parcels
+ typedef boost::function<void()> parcel_changed_callback_t;
+ boost::signals2::connection addParcelChangedCallback(parcel_changed_callback_t);
+
+private:
+ typedef boost::signals2::signal<void()> parcel_changed_signal_t;
+ parcel_changed_signal_t mParcelChangedSignal;
+
+ //--------------------------------------------------------------------
+ // Region
+ //--------------------------------------------------------------------
+ public:
void setRegion(LLViewerRegion *regionp);
LLViewerRegion *getRegion() const;
LLHost getRegionHost() const;
BOOL inPrelude();
-private:
+
+ // Register a boost callback to be called when the agent changes regions
+ typedef boost::function<void()> region_changed_callback_t;
+ boost::signals2::connection addRegionChangedCallback(region_changed_callback_t);
+
+ private:
LLViewerRegion *mRegionp;
+ typedef boost::signals2::signal<void()> region_changed_signal_t;
+ region_changed_signal_t mRegionChangedSignal;
//--------------------------------------------------------------------
// History
@@ -640,9 +661,10 @@ private:
public:
bool canEditParcel() const { return mCanEditParcel; }
private:
+ static void setCanEditParcel();
bool mCanEditParcel;
- static void parcelChangedCallback();
+
/********************************************************************************
** **
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp
index 5022dba934..dbdff11f11 100755
--- a/indra/newview/lllocationinputctrl.cpp
+++ b/indra/newview/lllocationinputctrl.cpp
@@ -407,14 +407,14 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)
// - Make the "Add landmark" button updated when either current parcel gets changed
// or a landmark gets created or removed from the inventory.
// - Update the location string on parcel change.
- mParcelMgrConnection = LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(
+ mParcelMgrConnection = gAgent.addParcelChangedCallback(
boost::bind(&LLLocationInputCtrl::onAgentParcelChange, this));
// LLLocationHistory instance is being created before the location input control, so we have to update initial state of button manually.
mButton->setEnabled(LLLocationHistory::instance().getItemCount() > 0);
mLocationHistoryConnection = LLLocationHistory::getInstance()->setChangedCallback(
boost::bind(&LLLocationInputCtrl::onLocationHistoryChanged, this,_1));
- mRegionCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLLocationInputCtrl::onRegionBoundaryCrossed, this));
+ mRegionCrossingSlot = gAgent.addRegionChangedCallback(boost::bind(&LLLocationInputCtrl::onRegionBoundaryCrossed, this));
createNavMeshStatusListenerForCurrentRegion();
mRemoveLandmarkObserver = new LLRemoveLandmarkObserver(this);
diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp
index eb6591eb39..32b168b8c5 100755
--- a/indra/newview/llmoveview.cpp
+++ b/indra/newview/llmoveview.cpp
@@ -140,7 +140,7 @@ BOOL LLFloaterMove::postBuild()
initMovementMode();
- LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(LLFloaterMove::sUpdateFlyingStatus);
+ gAgent.addParcelChangedCallback(LLFloaterMove::sUpdateFlyingStatus);
return TRUE;
}
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp
index 6c2a01fc82..8bb3ace2d9 100755
--- a/indra/newview/llpanelplaces.cpp
+++ b/indra/newview/llpanelplaces.cpp
@@ -251,7 +251,7 @@ LLPanelPlaces::LLPanelPlaces()
gInventory.addObserver(mInventoryObserver);
- mAgentParcelChangedConnection = LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(
+ mAgentParcelChangedConnection = gAgent.addParcelChangedCallback(
boost::bind(&LLPanelPlaces::updateVerbs, this));
//buildFromFile( "panel_places.xml"); // Called from LLRegisterPanelClass::defaultPanelClassBuilder()
diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp
index 9dd665198f..0d09f0bbfc 100755
--- a/indra/newview/llpaneltopinfobar.cpp
+++ b/indra/newview/llpaneltopinfobar.cpp
@@ -166,7 +166,7 @@ BOOL LLPanelTopInfoBar::postBuild()
mShowCoordsCtrlConnection = ctrl->getSignal()->connect(boost::bind(&LLPanelTopInfoBar::onNavBarShowParcelPropertiesCtrlChanged, this));
}
- mParcelMgrConnection = LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(
+ mParcelMgrConnection = gAgent.addParcelChangedCallback(
boost::bind(&LLPanelTopInfoBar::onAgentParcelChange, this));
setVisibleCallback(boost::bind(&LLPanelTopInfoBar::onVisibilityChange, this, _2));
diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp
index 4cdb568d17..e361fad9de 100755
--- a/indra/newview/llviewerparcelmgr.cpp
+++ b/indra/newview/llviewerparcelmgr.cpp
@@ -1580,7 +1580,8 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
// Let interesting parties know about agent parcel change.
LLViewerParcelMgr* instance = LLViewerParcelMgr::getInstance();
- instance->mAgentParcelChangedSignal();
+ // Notify anything that wants to know when the agent changes parcels
+ gAgent.changeParcels();
if (instance->mTeleportInProgress)
{
@@ -2458,10 +2459,6 @@ LLViewerTexture* LLViewerParcelMgr::getPassImage() const
return sPassImage;
}
-boost::signals2::connection LLViewerParcelMgr::addAgentParcelChangedCallback(parcel_changed_callback_t cb)
-{
- return mAgentParcelChangedSignal.connect(cb);
-}
/*
* Set finish teleport callback. You can use it to observe all teleport events.
* NOTE:
@@ -2475,7 +2472,7 @@ boost::signals2::connection LLViewerParcelMgr::setTeleportFinishedCallback(telep
return mTeleportFinishedSignal.connect(cb);
}
-boost::signals2::connection LLViewerParcelMgr::setTeleportFailedCallback(parcel_changed_callback_t cb)
+boost::signals2::connection LLViewerParcelMgr::setTeleportFailedCallback(teleport_failed_callback_t cb)
{
return mTeleportFailedSignal.connect(cb);
}
diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h
index 6183b7e90e..9da49bb3f3 100755
--- a/indra/newview/llviewerparcelmgr.h
+++ b/indra/newview/llviewerparcelmgr.h
@@ -80,8 +80,8 @@ class LLViewerParcelMgr : public LLSingleton<LLViewerParcelMgr>
public:
typedef boost::function<void (const LLVector3d&, const bool& local)> teleport_finished_callback_t;
typedef boost::signals2::signal<void (const LLVector3d&, const bool&)> teleport_finished_signal_t;
- typedef boost::function<void()> parcel_changed_callback_t;
- typedef boost::signals2::signal<void()> parcel_changed_signal_t;
+ typedef boost::function<void()> teleport_failed_callback_t;
+ typedef boost::signals2::signal<void()> teleport_failed_signal_t;
LLViewerParcelMgr();
~LLViewerParcelMgr();
@@ -283,9 +283,8 @@ public:
// the agent is banned or not in the allowed group
BOOL isCollisionBanned();
- boost::signals2::connection addAgentParcelChangedCallback(parcel_changed_callback_t cb);
boost::signals2::connection setTeleportFinishedCallback(teleport_finished_callback_t cb);
- boost::signals2::connection setTeleportFailedCallback(parcel_changed_callback_t cb);
+ boost::signals2::connection setTeleportFailedCallback(teleport_failed_callback_t cb);
void onTeleportFinished(bool local, const LLVector3d& new_pos);
void onTeleportFailed();
@@ -338,8 +337,7 @@ private:
BOOL mTeleportInProgress;
teleport_finished_signal_t mTeleportFinishedSignal;
- parcel_changed_signal_t mTeleportFailedSignal;
- parcel_changed_signal_t mAgentParcelChangedSignal;
+ teleport_failed_signal_t mTeleportFailedSignal;
// Array of pieces of parcel edges to potentially draw
// Has (parcels_per_edge + 1) * (parcels_per_edge + 1) elements so