From 566bbe7e09bf9cd9939cfae40773d86993803d1b Mon Sep 17 00:00:00 2001
From: Jonathan Yap <none@none>
Date: Sun, 19 Feb 2012 14:06:32 -0500
Subject: [PATCH] STORM-1808 Recode so build button is not clickable when
 grayed out

---
 indra/newview/app_settings/commands.xml |  4 ++--
 indra/newview/llagent.cpp               |  6 +-----
 indra/newview/lltoolmgr.cpp             | 11 +++++++++--
 indra/newview/lltoolmgr.h               |  2 +-
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml
index 16a7e0b3149..12ce45717b5 100644
--- a/indra/newview/app_settings/commands.xml
+++ b/indra/newview/app_settings/commands.xml
@@ -37,10 +37,10 @@
            tooltip_ref="Command_Build_Tooltip"
            execute_function="Build.Toggle"
            execute_parameters="build"
-           is_enabled_function="Agent.IsActionAllowed"
+           is_enabled_function="Build.Enabled"
            is_enabled_parameters="build"
            is_running_function="Floater.IsOpen"
-           is_running_parameters="build"
+           is_running_parameters="toolbox floater"
            />
   <command name="chat"
            available_in_toybox="true"
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index f0add8ddc44..3870a3be2ec 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -169,11 +169,7 @@ bool LLAgent::isActionAllowed(const LLSD& sdname)
 
 	const std::string& param = sdname.asString();
 
-	if (param == "build")
-	{
-		retval = LLViewerParcelMgr::getInstance()->allowAgentBuild();
-	}
-	else if (param == "speak")
+	if (param == "speak")
 	{
 		if ( gAgent.isVoiceConnected() && 
 			LLViewerParcelMgr::getInstance()->allowAgentVoice() &&
diff --git a/indra/newview/lltoolmgr.cpp b/indra/newview/lltoolmgr.cpp
index 6bc7c6de11b..ac01316462c 100644
--- a/indra/newview/lltoolmgr.cpp
+++ b/indra/newview/lltoolmgr.cpp
@@ -81,7 +81,7 @@ LLToolMgr::LLToolMgr()
 	// Not a panel, register these callbacks globally.
 	LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Active", boost::bind(&LLToolMgr::inEdit, this));
 	LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Enabled", boost::bind(&LLToolMgr::canEdit, this));
-	LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Build.Toggle", boost::bind(&LLToolMgr::toggleBuildMode, this));
+	LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Build.Toggle", boost::bind(&LLToolMgr::toggleBuildMode, this, _2));
 	
 	gToolNull = new LLTool(LLStringUtil::null);  // Does nothing
 	setCurrentTool(gToolNull);
@@ -245,8 +245,15 @@ bool LLToolMgr::canEdit()
 	return LLViewerParcelMgr::getInstance()->allowAgentBuild();
 }
 
-void LLToolMgr::toggleBuildMode()
+void LLToolMgr::toggleBuildMode(const LLSD& sdname)
 {
+	const std::string& param = sdname.asString();
+
+	if (param == "build" && !canEdit())
+	{
+		return;
+	}
+
 	LLFloaterReg::toggleInstanceOrBringToFront("build");
 
 	bool build_visible = LLFloaterReg::instanceVisible("build");
diff --git a/indra/newview/lltoolmgr.h b/indra/newview/lltoolmgr.h
index d489c4c829f..12649cfba2d 100644
--- a/indra/newview/lltoolmgr.h
+++ b/indra/newview/lltoolmgr.h
@@ -54,7 +54,7 @@ class LLToolMgr : public LLSingleton<LLToolMgr>
 
 	bool			inEdit();
 	bool			canEdit();
-	void			toggleBuildMode();
+	void			toggleBuildMode(const LLSD& sdname);
 	
 	/* Determines if we are in Build mode or not. */
 	bool			inBuildMode();
-- 
GitLab