From a4fc76a0f749e07d703ddb7ed923d7c4ea94ab7e Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Wed, 19 May 2010 08:25:09 +0300
Subject: EXT-7219 FIXED Hooked up the avatar gender radio buttons

- Added callback for radio buttons

Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/392/

--HG--
branch : product-engine
---
 indra/newview/llpaneleditwearable.cpp              | 45 ++++++++++++++++++++++
 indra/newview/llpaneleditwearable.h                |  1 +
 .../skins/default/xui/en/panel_edit_wearable.xml   |  3 ++
 3 files changed, 49 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 557fb399be..5ad68ea4db 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -50,6 +50,7 @@
 #include "llaccordionctrltab.h"
 #include "llagentwearables.h"
 #include "llscrollingpanelparam.h"
+#include "llradiogroup.h"
 
 #include "llcolorswatch.h"
 #include "lltexturectrl.h"
@@ -615,6 +616,8 @@ BOOL LLPanelEditWearable::postBuild()
 	mPanelTitle = getChild<LLTextBox>("edit_wearable_title");
 	mDescTitle = getChild<LLTextBox>("description_text");
 
+	getChild<LLRadioGroup>("sex_radio")->setCommitCallback(boost::bind(&LLPanelEditWearable::onCommitSexChange, this));
+
 	// The following panels will be shown/hidden based on what wearable we're editing
 	// body parts
 	mPanelShape = getChild<LLPanel>("edit_shape_panel");
@@ -687,6 +690,40 @@ void LLPanelEditWearable::onRevertButtonClicked(void* userdata)
 	panel->revertChanges();
 }
 
+
+void LLPanelEditWearable::onCommitSexChange()
+{
+	if (!isAgentAvatarValid()) return;
+
+	LLWearableType::EType type = mWearablePtr->getType();
+	U32 index = gAgentWearables.getWearableIndex(mWearablePtr);
+
+	if( !gAgentWearables.isWearableModifiable(type, index))
+	{
+		return;
+	}
+
+	LLViewerVisualParam* param = static_cast<LLViewerVisualParam*>(gAgentAvatarp->getVisualParam( "male" ));
+	if( !param )
+	{
+		return;
+	}
+
+	bool is_new_sex_male = (gSavedSettings.getU32("AvatarSex") ? SEX_MALE : SEX_FEMALE) == SEX_MALE;
+	LLWearable*	wearable = gAgentWearables.getWearable(type, index);
+	if (wearable)
+	{
+		wearable->setVisualParamWeight(param->getID(), is_new_sex_male, FALSE);
+	}
+	param->setWeight( is_new_sex_male, FALSE );
+
+	gAgentAvatarp->updateSexDependentLayerSets( FALSE );
+
+	gAgentAvatarp->updateVisualParams();
+
+	updateScrollingPanelUI();
+}
+
 void LLPanelEditWearable::onTexturePickerCommit(const LLUICtrl* ctrl)
 {
 	const LLTextureCtrl* texture_ctrl = dynamic_cast<const LLTextureCtrl*>(ctrl);
@@ -1118,6 +1155,14 @@ void LLPanelEditWearable::updateVerbs()
 
 	mBtnRevert->setEnabled(is_dirty);
 	childSetEnabled("save_as_button", is_dirty && can_copy);
+
+	if(isAgentAvatarValid())
+	{
+		// Update viewer's radio buttons (of RadioGroup with control_name="AvatarSex") of Avatar's gender
+		// with value from "AvatarSex" setting
+		gSavedSettings.setU32("AvatarSex", (gAgentAvatarp->getSex() == SEX_MALE) );
+	}
+
 }
 
 // EOF
diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h
index a5a332019d..04839ca451 100644
--- a/indra/newview/llpaneleditwearable.h
+++ b/indra/newview/llpaneleditwearable.h
@@ -64,6 +64,7 @@ public:
 	void				revertChanges();
 
 	static void			onRevertButtonClicked(void* userdata);
+	void				onCommitSexChange();
 
 private:
 	typedef std::map<F32, LLViewerVisualParam*> value_map_t;
diff --git a/indra/newview/skins/default/xui/en/panel_edit_wearable.xml b/indra/newview/skins/default/xui/en/panel_edit_wearable.xml
index afcd4550ca..40fcc1d76c 100644
--- a/indra/newview/skins/default/xui/en/panel_edit_wearable.xml
+++ b/indra/newview/skins/default/xui/en/panel_edit_wearable.xml
@@ -175,6 +175,7 @@ left="0"
 		 value="Shape:"
 		 width="150" />
 		 <radio_group
+			 control_name="AvatarSex"
 			 follows="left|top|right"
 			 left="210"
 			 height="20"
@@ -190,6 +191,7 @@ left="0"
 				 left="0"
 				 name="sex_male"
 				 tool_tip="Male"
+				 value="1"
 				 width="40" />
 			 <radio_item
 				 follows="all"
@@ -199,6 +201,7 @@ left="0"
 				 left_pad="10"
 				 name="sex_female"
 				 tool_tip="Female"
+				 value="0"
 				 width="40" />
 		 </radio_group>
 		 <!--  graphical labels for the radio buttons above -->
-- 
cgit v1.2.3