diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index 8ee4b7d075ba7179df38c68b0421374f511bb2a9..a59642b2d810e64b07f9b48d7da52172ea479662 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -37,6 +37,8 @@ tooltip_ref="Command_Build_Tooltip" execute_function="Floater.ToolbarToggle" execute_parameters="build" + is_enabled_function="Agent.IsActionAllowed" + is_enabled_parameters="build" is_running_function="Floater.IsOpen" is_running_parameters="build" /> @@ -207,6 +209,8 @@ tooltip_ref="Command_Speak_Tooltip" execute_function="Floater.ToolbarToggle" execute_parameters="speak" + is_enabled_function="Agent.IsActionAllowed" + is_enabled_parameters="speak" is_running_function="Floater.IsOpen" is_running_parameters="speak" /> diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index ba4212698563b34dfd5e46247bf010687dab698f..ed29ac796092f83c504cbb4c9312b8f4eadebc94 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -71,6 +71,7 @@ #include "lltoolpie.h" #include "lltoolmgr.h" #include "lltrans.h" +#include "lluictrl.h" #include "llurlentry.h" #include "llviewercontrol.h" #include "llviewerdisplay.h" @@ -152,6 +153,34 @@ bool handleSlowMotionAnimation(const LLSD& newvalue) return true; } +// static +void LLAgent::parcelChangedCallback() +{ + bool can_edit = LLToolMgr::getInstance()->canEdit(); + + gAgent.mCanEditParcel = can_edit; +} + +// static +bool LLAgent::isActionAllowed(const LLSD& sdname) +{ + bool retval = false; + + const std::string& param = sdname.asString(); + + if (param == "build") + { + retval = gAgent.canEditParcel(); + } + else if (param == "speak") + { + retval = true; + } + + return retval; +} + + // ************************************************************ // Enabled this definition to compile a 'hacked' viewer that // locally believes the end user has godlike powers. @@ -183,6 +212,7 @@ LLAgent::LLAgent() : mbTeleportKeepsLookAt(false), mAgentAccess(new LLAgentAccess(gSavedSettings)), + mCanEditParcel(false), mTeleportSourceSLURL(new LLSLURL), mTeleportState( TELEPORT_NONE ), mRegionp(NULL), @@ -246,6 +276,10 @@ LLAgent::LLAgent() : mListener.reset(new LLAgentListener(*this)); mMoveTimer.stop(); + + LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(boost::bind(&LLAgent::parcelChangedCallback)); + + LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Agent.IsActionAllowed", boost::bind(&LLAgent::isActionAllowed, _2)); } // Requires gSavedSettings to be initialized. @@ -3361,7 +3395,14 @@ bool LLAgent::teleportCore(bool is_local) LLFloaterReg::hideInstance("region_info"); // minimize the Search floater (STORM-1474) - LLFloaterReg::getInstance("search")->setMinimized(TRUE); + { + LLFloater* instance = LLFloaterReg::getInstance("search"); + + if (instance && instance->getVisible()) + { + instance->setMinimized(TRUE); + } + } LLViewerParcelMgr::getInstance()->deselectLand(); LLViewerMediaFocus::getInstance()->clearFocus(); diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 5e23ced4243c1b065617869dfa9509715583707a..1775a0235cc351fa38be5f7da659fd758fef3c57 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -575,6 +575,15 @@ class LLAgent : public LLOldEvents::LLObservable ** ** *******************************************************************************/ + // Build +public: + bool canEditParcel() const { return mCanEditParcel; } +private: + bool mCanEditParcel; + + static bool isActionAllowed(const LLSD& sdname); + static void parcelChangedCallback(); + /******************************************************************************** ** ** ** ACCESS