diff options
Diffstat (limited to 'indra/newview/lltexturectrl.cpp')
-rw-r--r-- | indra/newview/lltexturectrl.cpp | 353 |
1 files changed, 322 insertions, 31 deletions
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 25c481cdf5..801d0f0893 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -32,6 +32,7 @@ #include "llrender.h" #include "llagent.h" #include "llviewertexturelist.h" +#include "llselectmgr.h" #include "llcheckboxctrl.h" #include "llcombobox.h" #include "llbutton.h" @@ -70,6 +71,8 @@ #include "lllocalbitmaps.h" #include "llerror.h" +#include "llavatarappearancedefines.h" + static const S32 LOCAL_TRACKING_ID_COLUMN = 1; //static const char CURRENT_IMAGE_NAME[] = "Current Texture"; @@ -114,7 +117,8 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mOnFloaterCommitCallback(NULL), mOnFloaterCloseCallback(NULL), mSetImageAssetIDCallback(NULL), - mOnUpdateImageStatsCallback(NULL) + mOnUpdateImageStatsCallback(NULL), + mBakeTextureEnabled(FALSE) { buildFromFile("floater_texture_ctrl.xml"); mCanApplyImmediately = can_apply_immediately; @@ -132,26 +136,47 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id, bool set_selecti mNoCopyTextureSelected = FALSE; mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? mImageAssetID = image_id; - LLUUID item_id = findItemID(mImageAssetID, FALSE); - if (item_id.isNull()) + + if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(mImageAssetID)) { - mInventoryPanel->getRootFolder()->clearSelection(); + if ( mBakeTextureEnabled && mModeSelector->getSelectedIndex() != 2) + { + mModeSelector->setSelectedIndex(2, 0); + onModeSelect(0,this); + } } else { - LLInventoryItem* itemp = gInventory.getItem(image_id); - if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID())) + if (mModeSelector->getSelectedIndex() == 2) { - // no copy texture - getChild<LLUICtrl>("apply_immediate_check")->setValue(FALSE); - mNoCopyTextureSelected = TRUE; + mModeSelector->setSelectedIndex(0, 0); + onModeSelect(0,this); + } + + LLUUID item_id = findItemID(mImageAssetID, FALSE); + if (item_id.isNull()) + { + mInventoryPanel->getRootFolder()->clearSelection(); + } + else + { + LLInventoryItem* itemp = gInventory.getItem(image_id); + if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID())) + { + // no copy texture + getChild<LLUICtrl>("apply_immediate_check")->setValue(FALSE); + mNoCopyTextureSelected = TRUE; + } } - } - if (set_selection) - { - mInventoryPanel->setSelection(item_id, TAKE_FOCUS_NO); + if (set_selection) + { + mInventoryPanel->setSelection(item_id, TAKE_FOCUS_NO); + } } + + + } } @@ -337,6 +362,10 @@ BOOL LLFloaterTexturePicker::postBuild() mInventoryPanel = getChild<LLInventoryPanel>("inventory panel"); + mModeSelector = getChild<LLRadioGroup>("mode_selection"); + mModeSelector->setCommitCallback(onModeSelect, this); + mModeSelector->setSelectedIndex(0, 0); + if(mInventoryPanel) { U32 filter_types = 0x0; @@ -368,10 +397,6 @@ BOOL LLFloaterTexturePicker::postBuild() } } - mModeSelector = getChild<LLRadioGroup>("mode_selection"); - mModeSelector->setCommitCallback(onModeSelect, this); - mModeSelector->setSelectedIndex(0, 0); - childSetAction("l_add_btn", LLFloaterTexturePicker::onBtnAdd, this); childSetAction("l_rem_btn", LLFloaterTexturePicker::onBtnRemove, this); childSetAction("l_upl_btn", LLFloaterTexturePicker::onBtnUpload, this); @@ -400,14 +425,72 @@ BOOL LLFloaterTexturePicker::postBuild() LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterTexturePicker::onTextureSelect, this, _1)); + getChild<LLComboBox>("l_bake_use_texture_combo_box")->setCommitCallback(onBakeTextureSelect, this); + getChild<LLCheckBoxCtrl>("hide_base_mesh_region")->setCommitCallback(onHideBaseMeshRegionCheck, this); + + setBakeTextureEnabled(FALSE); return TRUE; } // virtual void LLFloaterTexturePicker::draw() { - static LLCachedControl<F32> max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); - drawConeToOwner(mContextConeOpacity, max_opacity, mOwner); + if (mOwner) + { + static LLCachedControl<F32> max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, mOwner); + + // draw cone of context pointing back to texture swatch + LLRect owner_rect; + mOwner->localRectToOtherView(mOwner->getLocalRect(), &owner_rect, this); + LLRect local_rect = getLocalRect(); + if (gFocusMgr.childHasKeyboardFocus(this) && mOwner->isInVisibleChain() && mContextConeOpacity > 0.001f) + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + LLGLEnable(GL_CULL_FACE); + gGL.begin(LLRender::QUADS); + { + gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); + gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); + gGL.vertex2i(owner_rect.mRight, owner_rect.mTop); + gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); + gGL.vertex2i(local_rect.mRight, local_rect.mTop); + gGL.vertex2i(local_rect.mLeft, local_rect.mTop); + + gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); + gGL.vertex2i(local_rect.mLeft, local_rect.mTop); + gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); + gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); + gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom); + gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop); + + gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); + gGL.vertex2i(local_rect.mRight, local_rect.mBottom); + gGL.vertex2i(local_rect.mRight, local_rect.mTop); + gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); + gGL.vertex2i(owner_rect.mRight, owner_rect.mTop); + gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom); + + + gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity); + gGL.vertex2i(local_rect.mLeft, local_rect.mBottom); + gGL.vertex2i(local_rect.mRight, local_rect.mBottom); + gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity); + gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom); + gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom); + } + gGL.end(); + } + } + + if (gFocusMgr.childHasMouseCapture(getDragHandle())) + { + mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME)); + } + else + { + mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME)); + } updateImageStats(); @@ -423,7 +506,24 @@ void LLFloaterTexturePicker::draw() mTexturep = NULL; if(mImageAssetID.notNull()) { - mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID); + LLPointer<LLViewerFetchedTexture> texture = NULL; + + if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(mImageAssetID)) + { + LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + if (obj) + { + LLViewerTexture* viewerTexture = obj->getBakedTextureForMagicId(mImageAssetID); + texture = viewerTexture ? dynamic_cast<LLViewerFetchedTexture*>(viewerTexture) : NULL; + } + } + + if (texture.isNull()) + { + texture = LLViewerTextureManager::getFetchedTexture(mImageAssetID); + } + + mTexturep = texture; mTexturep->setBoostLevel(LLGLTexture::BOOST_PREVIEW); } @@ -717,10 +817,69 @@ void LLFloaterTexturePicker::onModeSelect(LLUICtrl* ctrl, void *userdata) /*self->getChild<LLCheckBox>("show_folders_check")->setVisible(mode); no idea under which conditions the above is even shown, needs testing. */ - self->getChild<LLButton>("l_add_btn")->setVisible(!mode); - self->getChild<LLButton>("l_rem_btn")->setVisible(!mode); - self->getChild<LLButton>("l_upl_btn")->setVisible(!mode); - self->getChild<LLScrollListCtrl>("l_name_list")->setVisible(!mode); + self->getChild<LLButton>("l_add_btn")->setVisible(mode == 1); + self->getChild<LLButton>("l_rem_btn")->setVisible(mode == 1); + self->getChild<LLButton>("l_upl_btn")->setVisible(mode == 1); + self->getChild<LLScrollListCtrl>("l_name_list")->setVisible(mode == 1); + + self->getChild<LLComboBox>("l_bake_use_texture_combo_box")->setVisible(mode == 2); + self->getChild<LLCheckBoxCtrl>("hide_base_mesh_region")->setVisible(false);// mode == 2); + + if (mode == 2) + { + self->stopUsingPipette(); + + S8 val = -1; + + LLUUID imageID = self->mImageAssetID; + if (imageID == IMG_USE_BAKED_HEAD) + { + val = 0; + } + else if (imageID == IMG_USE_BAKED_UPPER) + { + val = 1; + } + else if (imageID == IMG_USE_BAKED_LOWER) + { + val = 2; + } + else if (imageID == IMG_USE_BAKED_EYES) + { + val = 3; + } + else if (imageID == IMG_USE_BAKED_SKIRT) + { + val = 4; + } + else if (imageID == IMG_USE_BAKED_HAIR) + { + val = 5; + } + else if (imageID == IMG_USE_BAKED_LEFTARM) + { + val = 6; + } + else if (imageID == IMG_USE_BAKED_LEFTLEG) + { + val = 7; + } + else if (imageID == IMG_USE_BAKED_AUX1) + { + val = 8; + } + else if (imageID == IMG_USE_BAKED_AUX2) + { + val = 9; + } + else if (imageID == IMG_USE_BAKED_AUX3) + { + val = 10; + } + + + self->getChild<LLComboBox>("l_bake_use_texture_combo_box")->setSelectedByValue(val, TRUE); + } } // static @@ -841,6 +1000,86 @@ void LLFloaterTexturePicker::onApplyImmediateCheck(LLUICtrl* ctrl, void *user_da picker->commitIfImmediateSet(); } +//static +void LLFloaterTexturePicker::onBakeTextureSelect(LLUICtrl* ctrl, void *user_data) +{ + LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)user_data; + LLComboBox* combo_box = (LLComboBox*)ctrl; + + S8 type = combo_box->getValue().asInteger(); + + LLUUID imageID = self->mDefaultImageAssetID; + if (type == 0) + { + imageID = IMG_USE_BAKED_HEAD; + } + else if (type == 1) + { + imageID = IMG_USE_BAKED_UPPER; + } + else if (type == 2) + { + imageID = IMG_USE_BAKED_LOWER; + } + else if (type == 3) + { + imageID = IMG_USE_BAKED_EYES; + } + else if (type == 4) + { + imageID = IMG_USE_BAKED_SKIRT; + } + else if (type == 5) + { + imageID = IMG_USE_BAKED_HAIR; + } + else if (type == 6) + { + imageID = IMG_USE_BAKED_LEFTARM; + } + else if (type == 7) + { + imageID = IMG_USE_BAKED_LEFTLEG; + } + else if (type == 8) + { + imageID = IMG_USE_BAKED_AUX1; + } + else if (type == 9) + { + imageID = IMG_USE_BAKED_AUX2; + } + else if (type == 10) + { + imageID = IMG_USE_BAKED_AUX3; + } + + self->setImageID(imageID); + self->mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? + + if (!self->mPreviewSettingChanged) + { + self->mCanPreview = gSavedSettings.getBOOL("TextureLivePreview"); + } + else + { + self->mPreviewSettingChanged = false; + } + + if (self->mCanPreview) + { + // only commit intentional selections, not implicit ones + self->commitIfImmediateSet(); + } +} + +//static +void LLFloaterTexturePicker::onHideBaseMeshRegionCheck(LLUICtrl* ctrl, void *user_data) +{ + //LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data; + //LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl; +} + void LLFloaterTexturePicker::updateFilterPermMask() { //mInventoryPanel->setFilterPermMask( getFilterPermMask() ); Commented out due to no-copy texture loss. @@ -896,6 +1135,28 @@ void LLFloaterTexturePicker::setLocalTextureEnabled(BOOL enabled) mModeSelector->setIndexEnabled(1,enabled); } +void LLFloaterTexturePicker::setBakeTextureEnabled(BOOL enabled) +{ + BOOL changed = (enabled != mBakeTextureEnabled); + + mBakeTextureEnabled = enabled; + mModeSelector->setIndexEnabled(2, enabled); + + if (!mBakeTextureEnabled && (mModeSelector->getSelectedIndex() == 2)) + { + mModeSelector->setSelectedIndex(0, 0); + } + + if (changed && mBakeTextureEnabled && LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(mImageAssetID)) + { + if (mModeSelector->getSelectedIndex() != 2) + { + mModeSelector->setSelectedIndex(2, 0); + } + } + onModeSelect(0, this); +} + void LLFloaterTexturePicker::onTextureSelect( const LLTextureEntry& te ) { LLUUID inventory_item_id = findItemID(te.getID(), TRUE); @@ -945,7 +1206,8 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) mImageAssetID(p.image_id), mDefaultImageAssetID(p.default_image_id), mDefaultImageName(p.default_image_name), - mFallbackImage(p.fallback_image) + mFallbackImage(p.fallback_image), + mBakeTextureEnabled(FALSE) { // Default of defaults is white image for diff tex @@ -1041,6 +1303,10 @@ void LLTextureCtrl::setVisible( BOOL visible ) void LLTextureCtrl::setEnabled( BOOL enabled ) { LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); + if( floaterp ) + { + floaterp->setActive(enabled); + } if( enabled ) { std::string tooltip; @@ -1055,11 +1321,6 @@ void LLTextureCtrl::setEnabled( BOOL enabled ) closeDependentFloater(); } - if( floaterp ) - { - floaterp->setActive(enabled); - } - mCaption->setEnabled( enabled ); LLView::setEnabled( enabled ); @@ -1137,6 +1398,10 @@ void LLTextureCtrl::showPicker(BOOL take_focus) { texture_floaterp->setSetImageAssetIDCallback(boost::bind(&LLTextureCtrl::setImageAssetID, this, _1)); } + if (texture_floaterp) + { + texture_floaterp->setBakeTextureEnabled(mBakeTextureEnabled); + } LLFloater* root_floater = gFloaterView->getParentFloater(this); if (root_floater) @@ -1312,6 +1577,16 @@ void LLTextureCtrl::setImageAssetID( const LLUUID& asset_id ) } } +void LLTextureCtrl::setBakeTextureEnabled(BOOL enabled) +{ + mBakeTextureEnabled = enabled; + LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); + if (floaterp) + { + floaterp->setBakeTextureEnabled(enabled); + } +} + BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, @@ -1366,7 +1641,23 @@ void LLTextureCtrl::draw() } else if (!mImageAssetID.isNull()) { - LLPointer<LLViewerFetchedTexture> texture = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES,LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + LLPointer<LLViewerFetchedTexture> texture = NULL; + + if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(mImageAssetID)) + { + LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + if (obj) + { + LLViewerTexture* viewerTexture = obj->getBakedTextureForMagicId(mImageAssetID); + texture = viewerTexture ? dynamic_cast<LLViewerFetchedTexture*>(viewerTexture) : NULL; + } + + } + + if (texture.isNull()) + { + texture = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + } texture->setBoostLevel(LLGLTexture::BOOST_PREVIEW); texture->forceToSaveRawImage(0) ; |