From 25639b267db13f86f8446c10d61c814839920bc3 Mon Sep 17 00:00:00 2001
From: James Cook <james@lindenlab.com>
Date: Tue, 20 Oct 2009 17:52:56 +0000
Subject: EXT-462 Avatar context menu only shows Freeze/Eject/Debug when in god
 mode. Changed enable and visible named callbacks to "IsGodCustomerService" so
 we have one global function that can be used in menus everywhere. Reviewed
 with Leyla.

---
 indra/newview/llinspectavatar.cpp                  |  7 ------
 indra/newview/llviewermenu.cpp                     | 20 +++++------------
 indra/newview/llviewermenu.h                       |  1 -
 .../default/xui/en/menu_inspect_avatar_gear.xml    |  9 +++-----
 indra/newview/skins/default/xui/en/menu_viewer.xml | 26 +++++++++++-----------
 5 files changed, 22 insertions(+), 41 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp
index 4eb6061bea..99580d0918 100644
--- a/indra/newview/llinspectavatar.cpp
+++ b/indra/newview/llinspectavatar.cpp
@@ -110,7 +110,6 @@ private:
 	void onClickZoomIn();  
 	void onClickFindOnMap();
 	bool onVisibleFindOnMap();
-	bool onVisibleGodMode();
 	void onClickMuteVolume();
 	void onVolumeChange(const LLSD& data);
 	
@@ -195,7 +194,6 @@ LLInspectAvatar::LLInspectAvatar(const LLSD& sd)
 	mCommitCallbackRegistrar.add("InspectAvatar.FindOnMap",	boost::bind(&LLInspectAvatar::onClickFindOnMap, this));	
 	mCommitCallbackRegistrar.add("InspectAvatar.ZoomIn", boost::bind(&LLInspectAvatar::onClickZoomIn, this));
 	mVisibleCallbackRegistrar.add("InspectAvatar.VisibleFindOnMap",	boost::bind(&LLInspectAvatar::onVisibleFindOnMap, this));	
-	mVisibleCallbackRegistrar.add("InspectAvatar.VisibleGodMode",	boost::bind(&LLInspectAvatar::onVisibleGodMode, this));	
 
 
 	// can't make the properties request until the widgets are constructed
@@ -453,11 +451,6 @@ bool LLInspectAvatar::onVisibleFindOnMap()
 	return gAgent.isGodlike() || is_agent_mappable(mAvatarID);
 }
 
-bool LLInspectAvatar::onVisibleGodMode()
-{
-	return gAgent.isGodlike();
-}
-
 void LLInspectAvatar::onClickIM()
 { 
 	LLAvatarActions::startIM(mAvatarID);
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 806085dc24..a9ba9ead1a 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1634,16 +1634,6 @@ class LLAdvancedToggleCharacterGeometry : public view_listener_t
 }
 };
 
-class LLEnableGodCustomerService : public view_listener_t
-{
-	bool handleEvent(const LLSD& userdata)
-{
-		bool new_value = enable_god_customer_service(NULL);
-		return new_value;
-	}
-};
-
-
 
 	/////////////////////////////
 // TEST MALE / TEST FEMALE //
@@ -4029,7 +4019,7 @@ void handle_god_request_avatar_geometry(void *)
 {
 	if (gAgent.isGodlike())
 	{
-		LLSelectMgr::getInstance()->sendGodlikeRequest("avatar toggle", NULL);
+		LLSelectMgr::getInstance()->sendGodlikeRequest("avatar toggle", "");
 	}
 }
 
@@ -6802,7 +6792,7 @@ BOOL enable_god_liaison(void*)
 	return gAgent.getGodLevel() >= GOD_LIAISON;
 }
 
-BOOL enable_god_customer_service(void*)
+bool is_god_customer_service()
 {
 	return gAgent.getGodLevel() >= GOD_CUSTOMER_SERVICE;
 }
@@ -7746,8 +7736,10 @@ void initialize_menus()
 	LLUICtrl::CommitCallbackRegistry::Registrar& commit = LLUICtrl::CommitCallbackRegistry::currentRegistrar();
 	LLUICtrl::VisibleCallbackRegistry::Registrar& visible = LLUICtrl::VisibleCallbackRegistry::currentRegistrar();
 	
-	// Enable God Mode
-	view_listener_t::addMenu(new LLEnableGodCustomerService(), "EnableGodCustomerService");
+	// Generic enable and visible
+	// Don't prepend MenuName.Foo because these can be used in any menu.
+	enable.add("IsGodCustomerService", boost::bind(&is_god_customer_service));
+	visible.add("IsGodCustomerService", boost::bind(&is_god_customer_service));
 
 	// Agent
 	commit.add("Agent.toggleFlying", boost::bind(&LLAgent::toggleFlying));
diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h
index d28d54c933..6d32df2bc5 100644
--- a/indra/newview/llviewermenu.h
+++ b/indra/newview/llviewermenu.h
@@ -84,7 +84,6 @@ void detach_label(std::string& label, const LLSD&);
 void handle_detach(void*);
 BOOL enable_god_full(void* user_data);
 BOOL enable_god_liaison(void* user_data);
-BOOL enable_god_customer_service(void* user_data);
 BOOL enable_god_basic(void* user_data);
 void set_underclothes_menu_options();
 
diff --git a/indra/newview/skins/default/xui/en/menu_inspect_avatar_gear.xml b/indra/newview/skins/default/xui/en/menu_inspect_avatar_gear.xml
index 5279f9d141..edff1a093a 100644
--- a/indra/newview/skins/default/xui/en/menu_inspect_avatar_gear.xml
+++ b/indra/newview/skins/default/xui/en/menu_inspect_avatar_gear.xml
@@ -64,30 +64,27 @@
   </menu_item_call>  
   <menu_item_call
    label="Freeze"
-   layout="topleft"
    name="freeze">
     <menu_item_call.on_click
      function="InspectAvatar.Freeze"/>
     <menu_item_call.on_visible
-     function="InspectAvatar.VisibleGodMode"/>
+     function="IsGodCustomerService"/>
   </menu_item_call>
   <menu_item_call
    label="Eject"
-   layout="topleft"
    name="eject">
     <menu_item_call.on_click
      function="InspectAvatar.Eject"/>
     <menu_item_call.on_visible
-     function="InspectAvatar.VisibleGodMode"/>
+     function="IsGodCustomerService"/>
   </menu_item_call>
   <menu_item_call
    label="Debug"
-   layout="topleft"
    name="debug">
     <menu_item_call.on_click
      function="InspectAvatar.Debug"/>
     <menu_item_call.on_visible
-     function="InspectAvatar.VisibleGodMode"/>
+     function="IsGodCustomerService"/>
   </menu_item_call>
   <menu_item_call
    label="Find On Map"
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 116d8ae12a..e9cdf2b7c4 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2998,7 +2998,7 @@
                     <menu_item_call.on_click
                      function="Advanced.ToggleCharacterGeometry" />
                     <menu_item_call.on_enable
-                     function="EnableGodCustomerService" />
+                     function="IsGodCustomerService" />
                 </menu_item_call>
                 <menu_item_call
                  label="Test Male"
@@ -3251,7 +3251,7 @@
                 <menu_item_call.on_click
                  function="Admin.ForceTakeCopy" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
             <menu_item_call
              label="Force Owner To Me"
@@ -3260,7 +3260,7 @@
                 <menu_item_call.on_click
                  function="Admin.HandleObjectOwnerSelf" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
             <menu_item_call
              label="Force Owner Permissive"
@@ -3269,7 +3269,7 @@
                 <menu_item_call.on_click
                  function="Admin.HandleObjectOwnerPermissive" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
             <menu_item_call
              label="Delete"
@@ -3279,7 +3279,7 @@
                 <menu_item_call.on_click
                  function="Admin.HandleForceDelete" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
             <menu_item_call
              label="Lock"
@@ -3289,7 +3289,7 @@
                 <menu_item_call.on_click
                  function="Admin.HandleObjectLock" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
             <menu_item_call
              label="Get Assets IDs"
@@ -3299,7 +3299,7 @@
                 <menu_item_call.on_click
                  function="Admin.HandleObjectAssetIDs" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
         </menu>
         <menu
@@ -3315,7 +3315,7 @@
                 <menu_item_call.on_click
                  function="Admin.HandleForceParcelOwnerToMe" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
             <menu_item_call
              label="Set to Linden Content"
@@ -3325,7 +3325,7 @@
                 <menu_item_call.on_click
                  function="Admin.HandleForceParcelToContent" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
             <menu_item_call
              label="Claim Public Land"
@@ -3334,7 +3334,7 @@
                 <menu_item_call.on_click
                  function="Admin.HandleClaimPublicLand" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
         </menu>
         <menu
@@ -3350,7 +3350,7 @@
                 <menu_item_call.on_click
                  function="Admin.HandleRegionDumpTempAssetData" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
             <menu_item_call
              label="Save Region State"
@@ -3359,7 +3359,7 @@
                 <menu_item_call.on_click
                  function="Admin.OnSaveState" />
                 <menu_item_call.on_enable
-                 function="EnableGodCustomerService" />
+                 function="IsGodCustomerService" />
             </menu_item_call>
         </menu>
         <menu_item_call
@@ -3370,7 +3370,7 @@
              function="Floater.Show"
              parameter="god_tools" />
             <menu_item_call.on_enable
-             function="EnableGodCustomerService" />
+             function="IsGodCustomerService" />
         </menu_item_call>
     </menu>
     <menu
-- 
cgit v1.2.3