summaryrefslogtreecommitdiff
path: root/indra/newview/llpaneleditwearable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpaneleditwearable.cpp')
-rw-r--r--indra/newview/llpaneleditwearable.cpp340
1 files changed, 294 insertions, 46 deletions
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 3c112b8b5e..36f2d05fab 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -50,12 +50,15 @@
#include "llaccordionctrltab.h"
#include "llagentwearables.h"
#include "llscrollingpanelparam.h"
+#include "llradiogroup.h"
#include "llcolorswatch.h"
#include "lltexturectrl.h"
#include "lltextureentry.h"
#include "llviewercontrol.h" // gSavedSettings
#include "llviewertexturelist.h"
+#include "llagentcamera.h"
+#include "llmorphview.h"
// register panel with appropriate XML
static LLRegisterPanelClassWrapper<LLPanelEditWearable> t_edit_wearable("panel_edit_wearable");
@@ -115,7 +118,7 @@ public:
public:
struct WearableEntry : public LLDictionaryEntry
{
- WearableEntry(EWearableType type,
+ WearableEntry(LLWearableType::EType type,
const std::string &title,
const std::string &desc_title,
U8 num_color_swatches, // number of 'color_swatches'
@@ -123,7 +126,7 @@ public:
U8 num_subparts, ... ); // number of subparts followed by a list of ETextureIndex and ESubparts
- const EWearableType mWearableType;
+ const LLWearableType::EType mWearableType;
const std::string mTitle;
const std::string mDescTitle;
subpart_vec_t mSubparts;
@@ -131,12 +134,12 @@ public:
texture_vec_t mTextureCtrls;
};
- struct Wearables : public LLDictionary<EWearableType, WearableEntry>
+ struct Wearables : public LLDictionary<LLWearableType::EType, WearableEntry>
{
Wearables();
} mWearables;
- const WearableEntry* getWearable(EWearableType type) const { return mWearables.lookup(type); }
+ const WearableEntry* getWearable(LLWearableType::EType type) const { return mWearables.lookup(type); }
//--------------------------------------------------------------------
// Subparts
@@ -212,24 +215,27 @@ LLEditWearableDictionary::~LLEditWearableDictionary()
LLEditWearableDictionary::Wearables::Wearables()
{
- addEntry(WT_SHAPE, new WearableEntry(WT_SHAPE,"edit_shape_title","shape_desc_text",0,0,9, SUBPART_SHAPE_HEAD, SUBPART_SHAPE_EYES, SUBPART_SHAPE_EARS, SUBPART_SHAPE_NOSE, SUBPART_SHAPE_MOUTH, SUBPART_SHAPE_CHIN, SUBPART_SHAPE_TORSO, SUBPART_SHAPE_LEGS, SUBPART_SHAPE_WHOLE));
- addEntry(WT_SKIN, new WearableEntry(WT_SKIN,"edit_skin_title","skin_desc_text",0,3,4, TEX_HEAD_BODYPAINT, TEX_UPPER_BODYPAINT, TEX_LOWER_BODYPAINT, SUBPART_SKIN_COLOR, SUBPART_SKIN_FACEDETAIL, SUBPART_SKIN_MAKEUP, SUBPART_SKIN_BODYDETAIL));
- addEntry(WT_HAIR, new WearableEntry(WT_HAIR,"edit_hair_title","hair_desc_text",0,1,4, TEX_HAIR, SUBPART_HAIR_COLOR, SUBPART_HAIR_STYLE, SUBPART_HAIR_EYEBROWS, SUBPART_HAIR_FACIAL));
- addEntry(WT_EYES, new WearableEntry(WT_EYES,"edit_eyes_title","eyes_desc_text",0,1,1, TEX_EYES_IRIS, SUBPART_EYES));
- addEntry(WT_SHIRT, new WearableEntry(WT_SHIRT,"edit_shirt_title","shirt_desc_text",1,1,1, TEX_UPPER_SHIRT, TEX_UPPER_SHIRT, SUBPART_SHIRT));
- addEntry(WT_PANTS, new WearableEntry(WT_PANTS,"edit_pants_title","pants_desc_text",1,1,1, TEX_LOWER_PANTS, TEX_LOWER_PANTS, SUBPART_PANTS));
- addEntry(WT_SHOES, new WearableEntry(WT_SHOES,"edit_shoes_title","shoes_desc_text",1,1,1, TEX_LOWER_SHOES, TEX_LOWER_SHOES, SUBPART_SHOES));
- addEntry(WT_SOCKS, new WearableEntry(WT_SOCKS,"edit_socks_title","socks_desc_text",1,1,1, TEX_LOWER_SOCKS, TEX_LOWER_SOCKS, SUBPART_SOCKS));
- addEntry(WT_JACKET, new WearableEntry(WT_JACKET,"edit_jacket_title","jacket_desc_text",1,2,1, TEX_UPPER_JACKET, TEX_UPPER_JACKET, TEX_LOWER_JACKET, SUBPART_JACKET));
- addEntry(WT_GLOVES, new WearableEntry(WT_GLOVES,"edit_gloves_title","gloves_desc_text",1,1,1, TEX_UPPER_GLOVES, TEX_UPPER_GLOVES, SUBPART_GLOVES));
- addEntry(WT_UNDERSHIRT, new WearableEntry(WT_UNDERSHIRT,"edit_undershirt_title","undershirt_desc_text",1,1,1, TEX_UPPER_UNDERSHIRT, TEX_UPPER_UNDERSHIRT, SUBPART_UNDERSHIRT));
- addEntry(WT_UNDERPANTS, new WearableEntry(WT_UNDERPANTS,"edit_underpants_title","underpants_desc_text",1,1,1, TEX_LOWER_UNDERPANTS, TEX_LOWER_UNDERPANTS, SUBPART_UNDERPANTS));
- addEntry(WT_SKIRT, new WearableEntry(WT_SKIRT,"edit_skirt_title","skirt_desc_text",1,1,1, TEX_SKIRT, TEX_SKIRT, SUBPART_SKIRT));
- addEntry(WT_ALPHA, new WearableEntry(WT_ALPHA,"edit_alpha_title","alpha_desc_text",0,5,1, TEX_LOWER_ALPHA, TEX_UPPER_ALPHA, TEX_HEAD_ALPHA, TEX_EYES_ALPHA, TEX_HAIR_ALPHA, SUBPART_ALPHA));
- addEntry(WT_TATTOO, new WearableEntry(WT_TATTOO,"edit_tattoo_title","tattoo_desc_text",0,3,1, TEX_LOWER_TATTOO, TEX_UPPER_TATTOO, TEX_HEAD_TATTOO, SUBPART_TATTOO));
+ // note the subpart that is listed first is treated as "default", regardless of what order is in enum.
+ // Please match the order presented in XUI. -Nyx
+ // this will affect what camera angle is shown when first editing a wearable
+ addEntry(LLWearableType::WT_SHAPE, new WearableEntry(LLWearableType::WT_SHAPE,"edit_shape_title","shape_desc_text",0,0,9, SUBPART_SHAPE_WHOLE, SUBPART_SHAPE_HEAD, SUBPART_SHAPE_EYES, SUBPART_SHAPE_EARS, SUBPART_SHAPE_NOSE, SUBPART_SHAPE_MOUTH, SUBPART_SHAPE_CHIN, SUBPART_SHAPE_TORSO, SUBPART_SHAPE_LEGS ));
+ addEntry(LLWearableType::WT_SKIN, new WearableEntry(LLWearableType::WT_SKIN,"edit_skin_title","skin_desc_text",0,3,4, TEX_HEAD_BODYPAINT, TEX_UPPER_BODYPAINT, TEX_LOWER_BODYPAINT, SUBPART_SKIN_COLOR, SUBPART_SKIN_FACEDETAIL, SUBPART_SKIN_MAKEUP, SUBPART_SKIN_BODYDETAIL));
+ addEntry(LLWearableType::WT_HAIR, new WearableEntry(LLWearableType::WT_HAIR,"edit_hair_title","hair_desc_text",0,1,4, TEX_HAIR, SUBPART_HAIR_COLOR, SUBPART_HAIR_STYLE, SUBPART_HAIR_EYEBROWS, SUBPART_HAIR_FACIAL));
+ addEntry(LLWearableType::WT_EYES, new WearableEntry(LLWearableType::WT_EYES,"edit_eyes_title","eyes_desc_text",0,1,1, TEX_EYES_IRIS, SUBPART_EYES));
+ addEntry(LLWearableType::WT_SHIRT, new WearableEntry(LLWearableType::WT_SHIRT,"edit_shirt_title","shirt_desc_text",1,1,1, TEX_UPPER_SHIRT, TEX_UPPER_SHIRT, SUBPART_SHIRT));
+ addEntry(LLWearableType::WT_PANTS, new WearableEntry(LLWearableType::WT_PANTS,"edit_pants_title","pants_desc_text",1,1,1, TEX_LOWER_PANTS, TEX_LOWER_PANTS, SUBPART_PANTS));
+ addEntry(LLWearableType::WT_SHOES, new WearableEntry(LLWearableType::WT_SHOES,"edit_shoes_title","shoes_desc_text",1,1,1, TEX_LOWER_SHOES, TEX_LOWER_SHOES, SUBPART_SHOES));
+ addEntry(LLWearableType::WT_SOCKS, new WearableEntry(LLWearableType::WT_SOCKS,"edit_socks_title","socks_desc_text",1,1,1, TEX_LOWER_SOCKS, TEX_LOWER_SOCKS, SUBPART_SOCKS));
+ addEntry(LLWearableType::WT_JACKET, new WearableEntry(LLWearableType::WT_JACKET,"edit_jacket_title","jacket_desc_text",1,2,1, TEX_UPPER_JACKET, TEX_UPPER_JACKET, TEX_LOWER_JACKET, SUBPART_JACKET));
+ addEntry(LLWearableType::WT_GLOVES, new WearableEntry(LLWearableType::WT_GLOVES,"edit_gloves_title","gloves_desc_text",1,1,1, TEX_UPPER_GLOVES, TEX_UPPER_GLOVES, SUBPART_GLOVES));
+ addEntry(LLWearableType::WT_UNDERSHIRT, new WearableEntry(LLWearableType::WT_UNDERSHIRT,"edit_undershirt_title","undershirt_desc_text",1,1,1, TEX_UPPER_UNDERSHIRT, TEX_UPPER_UNDERSHIRT, SUBPART_UNDERSHIRT));
+ addEntry(LLWearableType::WT_UNDERPANTS, new WearableEntry(LLWearableType::WT_UNDERPANTS,"edit_underpants_title","underpants_desc_text",1,1,1, TEX_LOWER_UNDERPANTS, TEX_LOWER_UNDERPANTS, SUBPART_UNDERPANTS));
+ addEntry(LLWearableType::WT_SKIRT, new WearableEntry(LLWearableType::WT_SKIRT,"edit_skirt_title","skirt_desc_text",1,1,1, TEX_SKIRT, TEX_SKIRT, SUBPART_SKIRT));
+ addEntry(LLWearableType::WT_ALPHA, new WearableEntry(LLWearableType::WT_ALPHA,"edit_alpha_title","alpha_desc_text",0,5,1, TEX_LOWER_ALPHA, TEX_UPPER_ALPHA, TEX_HEAD_ALPHA, TEX_EYES_ALPHA, TEX_HAIR_ALPHA, SUBPART_ALPHA));
+ addEntry(LLWearableType::WT_TATTOO, new WearableEntry(LLWearableType::WT_TATTOO,"edit_tattoo_title","tattoo_desc_text",1,3,1, TEX_HEAD_TATTOO, TEX_LOWER_TATTOO, TEX_UPPER_TATTOO, TEX_HEAD_TATTOO, SUBPART_TATTOO));
}
-LLEditWearableDictionary::WearableEntry::WearableEntry(EWearableType type,
+LLEditWearableDictionary::WearableEntry::WearableEntry(LLWearableType::EType type,
const std::string &title,
const std::string &desc_title,
U8 num_color_swatches,
@@ -330,6 +336,7 @@ LLEditWearableDictionary::ColorSwatchCtrls::ColorSwatchCtrls()
addEntry ( TEX_UPPER_GLOVES, new PickerControlEntry (TEX_UPPER_GLOVES, "Color/Tint" ));
addEntry ( TEX_UPPER_UNDERSHIRT, new PickerControlEntry (TEX_UPPER_UNDERSHIRT, "Color/Tint" ));
addEntry ( TEX_LOWER_UNDERPANTS, new PickerControlEntry (TEX_LOWER_UNDERPANTS, "Color/Tint" ));
+ addEntry ( TEX_HEAD_TATTOO, new PickerControlEntry(TEX_HEAD_TATTOO, "Color/Tint" ));
}
LLEditWearableDictionary::TextureCtrls::TextureCtrls()
@@ -442,7 +449,7 @@ get_picker_entry<LLTextureCtrl> (const ETextureIndex index)
template <typename CtrlType, class Predicate>
const LLEditWearableDictionary::PickerControlEntry*
-find_picker_ctrl_entry_if(EWearableType type, const Predicate pred)
+find_picker_ctrl_entry_if(LLWearableType::EType type, const Predicate pred)
{
const LLEditWearableDictionary::WearableEntry *wearable_entry
= LLEditWearableDictionary::getInstance()->getWearable(type);
@@ -475,7 +482,7 @@ find_picker_ctrl_entry_if(EWearableType type, const Predicate pred)
template <typename CtrlType>
void
-for_each_picker_ctrl_entry(LLPanel* panel, EWearableType type, function_t fun)
+for_each_picker_ctrl_entry(LLPanel* panel, LLWearableType::EType type, function_t fun)
{
if (!panel)
{
@@ -615,6 +622,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");
@@ -635,8 +644,16 @@ BOOL LLPanelEditWearable::postBuild()
mPanelAlpha = getChild<LLPanel>("edit_alpha_panel");
mPanelTattoo = getChild<LLPanel>("edit_tattoo_panel");
+ mTxtAvatarHeight = mPanelShape->getChild<LLTextBox>("avatar_height");
+
mWearablePtr = NULL;
+ configureAlphaCheckbox(LLVOAvatarDefines::TEX_LOWER_ALPHA, "lower alpha texture invisible");
+ configureAlphaCheckbox(LLVOAvatarDefines::TEX_UPPER_ALPHA, "upper alpha texture invisible");
+ configureAlphaCheckbox(LLVOAvatarDefines::TEX_HEAD_ALPHA, "head alpha texture invisible");
+ configureAlphaCheckbox(LLVOAvatarDefines::TEX_EYES_ALPHA, "eye alpha texture invisible");
+ configureAlphaCheckbox(LLVOAvatarDefines::TEX_HAIR_ALPHA, "hair alpha texture invisible");
+
return TRUE;
}
@@ -659,9 +676,10 @@ BOOL LLPanelEditWearable::isDirty() const
void LLPanelEditWearable::draw()
{
updateVerbs();
- if (getWearable())
+ if (getWearable() && getWearable()->getType() == LLWearableType::WT_SHAPE)
{
- updatePanelPickerControls(getWearable()->getType());
+ //updating avatar height
+ updateTypeSpecificControls(LLWearableType::WT_SHAPE);
}
LLPanel::draw();
@@ -683,6 +701,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);
@@ -694,7 +746,7 @@ void LLPanelEditWearable::onTexturePickerCommit(const LLUICtrl* ctrl)
if (getWearable())
{
- EWearableType type = getWearable()->getType();
+ LLWearableType::EType type = getWearable()->getType();
const PickerControlEntryNamePredicate name_pred(texture_ctrl->getName());
const LLEditWearableDictionary::PickerControlEntry* entry
= find_picker_ctrl_entry_if<LLTextureCtrl, PickerControlEntryNamePredicate>(type, name_pred);
@@ -725,7 +777,7 @@ void LLPanelEditWearable::onColorSwatchCommit(const LLUICtrl* ctrl)
{
if (getWearable())
{
- EWearableType type = getWearable()->getType();
+ LLWearableType::EType type = getWearable()->getType();
const PickerControlEntryNamePredicate name_pred(ctrl->getName());
const LLEditWearableDictionary::PickerControlEntry* entry
= find_picker_ctrl_entry_if<LLColorSwatchCtrl, PickerControlEntryNamePredicate>(type, name_pred);
@@ -747,7 +799,7 @@ void LLPanelEditWearable::onColorSwatchCommit(const LLUICtrl* ctrl)
}
}
-void LLPanelEditWearable::updatePanelPickerControls(EWearableType type)
+void LLPanelEditWearable::updatePanelPickerControls(LLWearableType::EType type)
{
LLPanel* panel = getPanel(type);
if (!panel)
@@ -823,7 +875,7 @@ void LLPanelEditWearable::showWearable(LLWearable* wearable, BOOL show)
mWearableItem = gInventory.getItem(mWearablePtr->getItemID());
llassert(mWearableItem);
- EWearableType type = wearable->getType();
+ LLWearableType::EType type = wearable->getType();
LLPanel *targetPanel = NULL;
std::string title;
std::string description_title;
@@ -849,6 +901,70 @@ void LLPanelEditWearable::showWearable(LLWearable* wearable, BOOL show)
// Update picker controls state
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (targetPanel, type, boost::bind(set_enabled_color_swatch_ctrl, show, _1, _2));
for_each_picker_ctrl_entry <LLTextureCtrl> (targetPanel, type, boost::bind(set_enabled_texture_ctrl, show, _1, _2));
+
+ showDefaultSubpart();
+}
+
+void LLPanelEditWearable::showDefaultSubpart()
+{
+ changeCamera(0);
+}
+
+void LLPanelEditWearable::onTabExpandedCollapsed(const LLSD& param, U8 index)
+{
+ bool expanded = param.asBoolean();
+
+ if (!mWearablePtr || !gAgentCamera.cameraCustomizeAvatar())
+ {
+ // we don't have a valid wearable we're editing, or we've left the wearable editor
+ return;
+ }
+
+ if (expanded)
+ {
+ changeCamera(index);
+ }
+
+}
+
+void LLPanelEditWearable::changeCamera(U8 subpart)
+{
+ const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(mWearablePtr->getType());
+ if (!wearable_entry)
+ {
+ llinfos << "could not get wearable dictionary entry for wearable type: " << mWearablePtr->getType() << llendl;
+ return;
+ }
+
+ if (subpart >= wearable_entry->mSubparts.size())
+ {
+ llinfos << "accordion tab expanded for invalid subpart. Wearable type: " << mWearablePtr->getType() << " subpart num: " << subpart << llendl;
+ return;
+ }
+
+ ESubpart subpart_e = wearable_entry->mSubparts[subpart];
+ const LLEditWearableDictionary::SubpartEntry *subpart_entry = LLEditWearableDictionary::getInstance()->getSubpart(subpart_e);
+
+ if (!subpart_entry)
+ {
+ llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
+ return;
+ }
+
+ // Update the camera
+ gMorphView->setCameraDistToDefault();
+ gMorphView->setCameraTargetJoint( gAgentAvatarp->getJoint( subpart_entry->mTargetJoint ) );
+ gMorphView->setCameraTargetOffset( subpart_entry->mTargetOffset );
+ gMorphView->setCameraOffset( subpart_entry->mCameraOffset );
+ if (gSavedSettings.getBOOL("AppearanceCameraMovement"))
+ {
+ gMorphView->updateCamera();
+ }
+}
+
+void LLPanelEditWearable::updateScrollingPanelList()
+{
+ updateScrollingPanelUI();
}
void LLPanelEditWearable::initializePanel()
@@ -859,11 +975,14 @@ void LLPanelEditWearable::initializePanel()
return;
}
- EWearableType type = mWearablePtr->getType();
+ LLWearableType::EType type = mWearablePtr->getType();
// set name
mTextEditor->setText(mWearablePtr->getName());
+ // toggle wearable type-specific controls
+ toggleTypeSpecificControls(type);
+
// clear and rebuild visual param list
const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
if (!wearable_entry)
@@ -906,6 +1025,9 @@ void LLPanelEditWearable::initializePanel()
// what edit group do we want to extract params for?
const std::string edit_group = subpart_entry->mEditGroup;
+ // initialize callback to ensure camera view changes appropriately.
+ tab->setDropDownStateChangedCallback(boost::bind(&LLPanelEditWearable::onTabExpandedCollapsed,this,_2,index));
+
// storage for ordered list of visual params
value_map_t sorted_params;
getSortedParams(sorted_params, edit_group);
@@ -919,7 +1041,44 @@ void LLPanelEditWearable::initializePanel()
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (getPanel(type), type, boost::bind(init_color_swatch_ctrl, this, _1, _2));
for_each_picker_ctrl_entry <LLTextureCtrl> (getPanel(type), type, boost::bind(init_texture_ctrl, this, _1, _2));
+ showDefaultSubpart();
updateVerbs();
+
+ if (getWearable())
+ {
+ LLWearableType::EType type = getWearable()->getType();
+ updatePanelPickerControls(type);
+ updateTypeSpecificControls(type);
+ }
+}
+
+void LLPanelEditWearable::toggleTypeSpecificControls(LLWearableType::EType type)
+{
+ // Toggle controls specific to shape editing panel.
+ {
+ bool is_shape = (type == LLWearableType::WT_SHAPE);
+ childSetVisible("sex_radio", is_shape);
+ childSetVisible("female_icon", is_shape);
+ childSetVisible("male_icon", is_shape);
+ }
+}
+
+void LLPanelEditWearable::updateTypeSpecificControls(LLWearableType::EType type)
+{
+ // Update controls specific to shape editing panel.
+ if (type == LLWearableType::WT_SHAPE)
+ {
+ // Update avatar height
+ std::string avatar_height_str = llformat("%.2f", gAgentAvatarp->mBodySize.mV[VZ]);
+ mTxtAvatarHeight->setTextArg("[HEIGHT]", avatar_height_str);
+ }
+
+ if (LLWearableType::WT_ALPHA == type)
+ {
+ updateAlphaCheckboxes();
+
+ initPreviousAlphaTextures();
+ }
}
void LLPanelEditWearable::updateScrollingPanelUI()
@@ -930,12 +1089,14 @@ void LLPanelEditWearable::updateScrollingPanelUI()
return;
}
- EWearableType type = mWearablePtr->getType();
+ LLWearableType::EType type = mWearablePtr->getType();
LLPanel *panel = getPanel(type);
if(panel && (mWearablePtr->getItemID().notNull()))
{
const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
+ llassert(wearable_entry);
+ if (!wearable_entry) return;
U8 num_subparts = wearable_entry->mSubparts.size();
LLScrollingPanelParam::sUpdateDelayFrames = 0;
@@ -960,67 +1121,67 @@ void LLPanelEditWearable::updateScrollingPanelUI()
}
}
-LLPanel* LLPanelEditWearable::getPanel(EWearableType type)
+LLPanel* LLPanelEditWearable::getPanel(LLWearableType::EType type)
{
switch (type)
{
- case WT_SHAPE:
+ case LLWearableType::WT_SHAPE:
return mPanelShape;
break;
- case WT_SKIN:
+ case LLWearableType::WT_SKIN:
return mPanelSkin;
break;
- case WT_HAIR:
+ case LLWearableType::WT_HAIR:
return mPanelHair;
break;
- case WT_EYES:
+ case LLWearableType::WT_EYES:
return mPanelEyes;
break;
- case WT_SHIRT:
+ case LLWearableType::WT_SHIRT:
return mPanelShirt;
break;
- case WT_PANTS:
+ case LLWearableType::WT_PANTS:
return mPanelPants;
break;
- case WT_SHOES:
+ case LLWearableType::WT_SHOES:
return mPanelShoes;
break;
- case WT_SOCKS:
+ case LLWearableType::WT_SOCKS:
return mPanelSocks;
break;
- case WT_JACKET:
+ case LLWearableType::WT_JACKET:
return mPanelJacket;
break;
- case WT_GLOVES:
+ case LLWearableType::WT_GLOVES:
return mPanelGloves;
break;
- case WT_UNDERSHIRT:
+ case LLWearableType::WT_UNDERSHIRT:
return mPanelUndershirt;
break;
- case WT_UNDERPANTS:
+ case LLWearableType::WT_UNDERPANTS:
return mPanelUnderpants;
break;
- case WT_SKIRT:
+ case LLWearableType::WT_SKIRT:
return mPanelSkirt;
break;
- case WT_ALPHA:
+ case LLWearableType::WT_ALPHA:
return mPanelAlpha;
break;
- case WT_TATTOO:
+ case LLWearableType::WT_TATTOO:
return mPanelTattoo;
break;
default:
@@ -1089,6 +1250,93 @@ 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) );
+ }
+
+}
+
+void LLPanelEditWearable::configureAlphaCheckbox(LLVOAvatarDefines::ETextureIndex te, const std::string& name)
+{
+ LLCheckBoxCtrl* checkbox = mPanelAlpha->getChild<LLCheckBoxCtrl>(name);
+ checkbox->setCommitCallback(boost::bind(&LLPanelEditWearable::onInvisibilityCommit, this, checkbox, te));
+
+ mAlphaCheckbox2Index[name] = te;
+}
+
+void LLPanelEditWearable::onInvisibilityCommit(LLCheckBoxCtrl* checkbox_ctrl, LLVOAvatarDefines::ETextureIndex te)
+{
+ if (!checkbox_ctrl) return;
+ if (!getWearable()) return;
+
+ llinfos << "onInvisibilityCommit, self " << this << " checkbox_ctrl " << checkbox_ctrl << llendl;
+
+ bool new_invis_state = checkbox_ctrl->get();
+ if (new_invis_state)
+ {
+ LLLocalTextureObject *lto = getWearable()->getLocalTextureObject(te);
+ mPreviousAlphaTexture[te] = lto->getID();
+
+ LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTexture( IMG_INVISIBLE );
+ U32 index = gAgentWearables.getWearableIndex(getWearable());
+ gAgentAvatarp->setLocalTexture(te, image, FALSE, index);
+ gAgentAvatarp->wearableUpdated(getWearable()->getType(), FALSE);
+ }
+ else
+ {
+ // Try to restore previous texture, if any.
+ LLUUID prev_id = mPreviousAlphaTexture[te];
+ if (prev_id.isNull() || (prev_id == IMG_INVISIBLE))
+ {
+ prev_id = LLUUID( gSavedSettings.getString( "UIImgDefaultAlphaUUID" ) );
+ }
+ if (prev_id.isNull()) return;
+
+ LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTexture(prev_id);
+ if (!image) return;
+
+ U32 index = gAgentWearables.getWearableIndex(getWearable());
+ gAgentAvatarp->setLocalTexture(te, image, FALSE, index);
+ gAgentAvatarp->wearableUpdated(getWearable()->getType(), FALSE);
+ }
+
+ updatePanelPickerControls(getWearable()->getType());
+}
+
+void LLPanelEditWearable::updateAlphaCheckboxes()
+{
+ for(string_texture_index_map_t::iterator iter = mAlphaCheckbox2Index.begin();
+ iter != mAlphaCheckbox2Index.end(); ++iter )
+ {
+ LLVOAvatarDefines::ETextureIndex te = (LLVOAvatarDefines::ETextureIndex)iter->second;
+ LLCheckBoxCtrl* ctrl = mPanelAlpha->getChild<LLCheckBoxCtrl>(iter->first);
+ if (ctrl)
+ {
+ ctrl->set(!gAgentAvatarp->isTextureVisible(te, mWearablePtr));
+ }
+ }
+}
+
+void LLPanelEditWearable::initPreviousAlphaTextures()
+{
+ initPreviousAlphaTextureEntry(TEX_LOWER_ALPHA);
+ initPreviousAlphaTextureEntry(TEX_UPPER_ALPHA);
+ initPreviousAlphaTextureEntry(TEX_HEAD_ALPHA);
+ initPreviousAlphaTextureEntry(TEX_EYES_ALPHA);
+ initPreviousAlphaTextureEntry(TEX_LOWER_ALPHA);
+}
+
+void LLPanelEditWearable::initPreviousAlphaTextureEntry(LLVOAvatarDefines::ETextureIndex te)
+{
+ LLLocalTextureObject *lto = getWearable()->getLocalTextureObject(te);
+ if (lto)
+ {
+ mPreviousAlphaTexture[te] = lto->getID();
+ }
}
// EOF