diff options
Diffstat (limited to 'indra/newview/lloutfitgallery.cpp')
-rw-r--r-- | indra/newview/lloutfitgallery.cpp | 186 |
1 files changed, 152 insertions, 34 deletions
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index de6a36ce2f..c38d3ab140 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -34,6 +34,7 @@ #include "llcommonutils.h" #include "llvfile.h" +#include "llaccordionctrltab.h" #include "llappearancemgr.h" #include "lleconomy.h" #include "llerror.h" @@ -46,6 +47,8 @@ #include "llinventorymodel.h" #include "lllocalbitmaps.h" #include "llnotificationsutil.h" +#include "llpaneloutfitsinventory.h" +#include "lltabcontainer.h" #include "lltexturectrl.h" #include "lltrans.h" #include "llviewercontrol.h" @@ -69,6 +72,7 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p) mItemsAddedCount(0), mOutfitLinkPending(NULL), mOutfitRenamePending(NULL), + mSnapshotFolderID(NULL), mRowPanelHeight(p.row_panel_height), mVerticalGap(p.vertical_gap), mHorizontalGap(p.horizontal_gap), @@ -106,7 +110,8 @@ BOOL LLOutfitGallery::postBuild() { BOOL rv = LLOutfitListBase::postBuild(); mScrollPanel = getChild<LLScrollContainer>("gallery_scroll_panel"); - mGalleryPanel = getChild<LLPanel>("gallery_panel"); + LLPanel::Params params = LLPanel::getDefaultParams(); // Don't parse XML when creating dummy LLPanel + mGalleryPanel = LLUICtrlFactory::create<LLPanel>(params); mMessageTextBox = getChild<LLTextBox>("no_outfits_txt"); mOutfitGalleryMenu = new LLOutfitGalleryContextMenu(this); return rv; @@ -234,6 +239,7 @@ void LLOutfitGallery::removeLastRow() { mRowCount--; mGalleryPanel->removeChild(mLastRowPanel); + mUnusedRowPanels.push_back(mLastRowPanel); mRowPanels.pop_back(); mLastRowPanel = mRowPanels.back(); } @@ -335,10 +341,11 @@ void LLOutfitGallery::removeFromLastRow(LLOutfitGalleryItem* item) { mItemPanels.back()->removeChild(item); mLastRowPanel->removeChild(mItemPanels.back()); + mUnusedItemPanels.push_back(mItemPanels.back()); mItemPanels.pop_back(); } -LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name) +LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name, LLUUID outfit_id) { LLOutfitGalleryItem::Params giparams; LLOutfitGalleryItem* gitem = LLUICtrlFactory::create<LLOutfitGalleryItem>(giparams); @@ -347,6 +354,7 @@ LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name) gitem->setFollowsLeft(); gitem->setFollowsTop(); gitem->setOutfitName(name); + gitem->setUUID(outfit_id); return gitem; } @@ -374,7 +382,16 @@ LLPanel* LLOutfitGallery::buildItemPanel(int left) { LLPanel::Params lpparams; int top = 0; - LLPanel* lpanel = LLUICtrlFactory::create<LLPanel>(lpparams); + LLPanel* lpanel = NULL; + if(mUnusedItemPanels.empty()) + { + lpanel = LLUICtrlFactory::create<LLPanel>(lpparams); + } + else + { + lpanel = mUnusedItemPanels.back(); + mUnusedItemPanels.pop_back(); + } LLRect rect = LLRect(left, top + mItemHeight, left + mItemWidth + mItemHorizontalGap, top); lpanel->setRect(rect); lpanel->reshape(mItemWidth + mItemHorizontalGap, mItemHeight); @@ -387,7 +404,16 @@ LLPanel* LLOutfitGallery::buildItemPanel(int left) LLPanel* LLOutfitGallery::buildRowPanel(int left, int bottom) { LLPanel::Params sparams; - LLPanel* stack = LLUICtrlFactory::create<LLPanel>(sparams); + LLPanel* stack = NULL; + if(mUnusedRowPanels.empty()) + { + stack = LLUICtrlFactory::create<LLPanel>(sparams); + } + else + { + stack = mUnusedRowPanels.back(); + mUnusedRowPanels.pop_back(); + } moveRowPanel(stack, left, bottom); return stack; } @@ -417,6 +443,19 @@ LLOutfitGallery::~LLOutfitGallery() gInventory.removeObserver(mOutfitsObserver); } delete mOutfitsObserver; + + while (!mUnusedRowPanels.empty()) + { + LLPanel* panelp = mUnusedRowPanels.back(); + mUnusedRowPanels.pop_back(); + panelp->die(); + } + while (!mUnusedItemPanels.empty()) + { + LLPanel* panelp = mUnusedItemPanels.back(); + mUnusedItemPanels.pop_back(); + panelp->die(); + } } void LLOutfitGallery::setFilterSubString(const std::string& string) @@ -474,7 +513,7 @@ void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) if (!cat) return; std::string name = cat->getName(); - LLOutfitGalleryItem* item = buildGalleryItem(name); + LLOutfitGalleryItem* item = buildGalleryItem(name, cat_id); mOutfitMap.insert(LLOutfitGallery::outfit_map_value_t(cat_id, item)); item->setRightMouseDownCallback(boost::bind(&LLOutfitListBase::outfitRightClickCallBack, this, _1, _2, _3, cat_id)); @@ -497,7 +536,7 @@ void LLOutfitGallery::updateAddedCategory(LLUUID cat_id) // Start observing changes in "My Outfits" category. mOutfitsObserver->addCategory(cat_id, - boost::bind(&LLOutfitGallery::refreshOutfit, this, cat_id)); + boost::bind(&LLOutfitGallery::refreshOutfit, this, cat_id), true); outfit_category->fetch(); refreshOutfit(cat_id); @@ -624,7 +663,8 @@ LLOutfitGalleryItem::LLOutfitGalleryItem(const Params& p) mSelected(false), mWorn(false), mDefaultImage(true), - mOutfitName("") + mOutfitName(""), + mUUID(LLUUID()) { buildFromFile("panel_outfit_gallery_item.xml"); } @@ -640,7 +680,6 @@ BOOL LLOutfitGalleryItem::postBuild() mOutfitNameText = getChild<LLTextBox>("outfit_name"); mOutfitWornText = getChild<LLTextBox>("outfit_worn_text"); - mFotoBgPanel = getChild<LLPanel>("foto_bg_panel"); mTextBgPanel = getChild<LLPanel>("text_bg_panel"); setOutfitWorn(false); mHidden = false; @@ -661,13 +700,24 @@ void LLOutfitGalleryItem::draw() const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); if (mTexturep) { - LLRect interior = border; - interior.stretch(-1); + if (mImageUpdatePending && mTexturep->getDiscardLevel() >= 0) + { + mImageUpdatePending = false; + if (mTexturep->getOriginalWidth() > MAX_OUTFIT_PHOTO_WIDTH || mTexturep->getOriginalHeight() > MAX_OUTFIT_PHOTO_HEIGHT) + { + setDefaultImage(); + } + } + else + { + LLRect interior = border; + interior.stretch(-1); - gl_draw_scaled_image(interior.mLeft - 1, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha); + gl_draw_scaled_image(interior.mLeft - 1, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha); - // Pump the priority - mTexturep->addTextureStats((F32)(interior.getWidth() * interior.getHeight())); + // Pump the priority + mTexturep->addTextureStats((F32)(interior.getWidth() * interior.getHeight())); + } } } @@ -709,12 +759,43 @@ BOOL LLOutfitGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) return LLUICtrl::handleRightMouseDown(x, y, mask); } -void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) +BOOL LLOutfitGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask) { - mImageAssetId = image_asset_id; - mTexturep = LLViewerTextureManager::getFetchedTexture(image_asset_id, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); - getChildView("preview_outfit")->setVisible(FALSE); - mDefaultImage = false; + LLTabContainer* appearence_tabs = LLPanelOutfitsInventory::findInstance()->getChild<LLTabContainer>("appearance_tabs"); + if (appearence_tabs && (mUUID != LLUUID())) + { + appearence_tabs->selectTabByName("outfitslist_tab"); + LLPanel* panel = appearence_tabs->getCurrentPanel(); + if (panel) + { + LLAccordionCtrl* accordion = panel->getChild<LLAccordionCtrl>("outfits_accordion"); + LLOutfitsList* outfit_list = dynamic_cast<LLOutfitsList*>(panel); + if (accordion != NULL && outfit_list != NULL) + { + outfit_list->setSelectedOutfitByUUID(mUUID); + LLAccordionCtrlTab* tab = accordion->getSelectedTab(); + tab->showAndFocusHeader(); + return TRUE; + } + } + } + + return LLPanel::handleDoubleClick(x, y, mask); +} + +bool LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) +{ + LLPointer<LLViewerFetchedTexture> texture = LLViewerTextureManager::getFetchedTexture(image_asset_id, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + if (texture && texture->getOriginalWidth() <= MAX_OUTFIT_PHOTO_WIDTH && texture->getOriginalHeight() <= MAX_OUTFIT_PHOTO_HEIGHT) + { + mImageAssetId = image_asset_id; + mTexturep = texture; + getChildView("preview_outfit")->setVisible(FALSE); + mDefaultImage = false; + mImageUpdatePending = (texture->getDiscardLevel() == -1); + return true; + } + return false; } LLUUID LLOutfitGalleryItem::getImageAssetId() @@ -728,6 +809,7 @@ void LLOutfitGalleryItem::setDefaultImage() mImageAssetId.setNull(); getChildView("preview_outfit")->setVisible(TRUE); mDefaultImage = true; + mImageUpdatePending = false; } LLContextMenu* LLOutfitGalleryContextMenu::createMenu() @@ -930,8 +1012,8 @@ void LLOutfitGallery::onTextureSelectionChanged(LLInventoryItem* itemp) void LLOutfitGallery::loadPhotos() { //Iterate over inventory - LLUUID textures = gInventory.findCategoryUUIDForType(LLFolderType::FT_TEXTURE); - LLViewerInventoryCategory* textures_category = gInventory.getCategory(textures); + mSnapshotFolderID = gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_TEXTURE); + LLViewerInventoryCategory* textures_category = gInventory.getCategory(mSnapshotFolderID); if (!textures_category) return; if (mTexturesObserver == NULL) @@ -941,12 +1023,26 @@ void LLOutfitGallery::loadPhotos() } // Start observing changes in "Textures" category. - mTexturesObserver->addCategory(textures, - boost::bind(&LLOutfitGallery::refreshTextures, this, textures)); - + mTexturesObserver->addCategory(mSnapshotFolderID, + boost::bind(&LLOutfitGallery::refreshTextures, this, mSnapshotFolderID)); + textures_category->fetch(); } +void LLOutfitGallery::updateSnapshotFolderObserver() +{ + if(mSnapshotFolderID != gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_TEXTURE)) + { + if (gInventory.containsObserver(mTexturesObserver)) + { + gInventory.removeObserver(mTexturesObserver); + } + delete mTexturesObserver; + mTexturesObserver = NULL; + loadPhotos(); + } +} + void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) { LLViewerInventoryCategory* category = gInventory.getCategory(category_id); @@ -963,13 +1059,28 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array) { LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); - if (linked_item != NULL && linked_item->getActualType() == LLAssetType::AT_TEXTURE) + LLUUID asset_id, inv_id; + std::string item_name; + if (linked_item != NULL) { - LLUUID asset_id = linked_item->getAssetUUID(); - mOutfitMap[category_id]->setImageAssetId(asset_id); - photo_loaded = true; - std::string linked_item_name = linked_item->getName(); - if (!mOutfitRenamePending.isNull() && mOutfitRenamePending.asString() == linked_item_name) + if (linked_item->getActualType() == LLAssetType::AT_TEXTURE) + { + asset_id = linked_item->getAssetUUID(); + inv_id = linked_item->getUUID(); + item_name = linked_item->getName(); + } + } + else if (outfit_item->getActualType() == LLAssetType::AT_TEXTURE) + { + asset_id = outfit_item->getAssetUUID(); + inv_id = outfit_item->getUUID(); + item_name = outfit_item->getName(); + } + if (asset_id.notNull()) + { + photo_loaded |= mOutfitMap[category_id]->setImageAssetId(asset_id); + // Rename links + if (!mOutfitRenamePending.isNull() && mOutfitRenamePending.asString() == item_name) { LLViewerInventoryCategory *outfit_cat = gInventory.getCategory(mOutfitRenamePending); LLStringUtil::format_map_t photo_string_args; @@ -977,7 +1088,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) std::string new_name = getString("outfit_photo_string", photo_string_args); LLSD updates; updates["name"] = new_name; - update_inventory_item(linked_item->getUUID(), updates, NULL); + update_inventory_item(inv_id, updates, NULL); mOutfitRenamePending.setNull(); LLFloater* inv_floater = LLFloaterReg::getInstance("inventory"); if (inv_floater) @@ -990,7 +1101,11 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) appearance_floater->setFocus(TRUE); } } - break; + if (item_name == LLAppearanceMgr::sExpectedTextureName) + { + // Images with "appropriate" name take priority + break; + } } if (!photo_loaded) { @@ -1005,6 +1120,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } } +// Refresh linked textures from "textures" uploads folder void LLOutfitGallery::refreshTextures(const LLUUID& category_id) { LLInventoryModel::cat_array_t cat_array; @@ -1093,13 +1209,13 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) return; } - S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass). + S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass). void *nruserdata = NULL; nruserdata = (void *)&outfit_id; LLViewerInventoryCategory *outfit_cat = gInventory.getCategory(outfit_id); if (!outfit_cat) return; - + updateSnapshotFolderObserver(); checkRemovePhoto(outfit_id); std::string upload_pending_name = outfit_id.asString(); std::string upload_pending_desc = ""; @@ -1114,6 +1230,7 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id) upload_pending_name, callback, expected_upload_cost, nruserdata); mOutfitLinkPending = outfit_id; } + delete unit; } } @@ -1161,7 +1278,7 @@ void LLOutfitGallery::onTexturePickerCommit(LLTextureCtrl::ETexturePickOp op, LL } else { - image_item_id = floaterp->findItemID(floaterp->getAssetID(), FALSE); + image_item_id = floaterp->findItemID(floaterp->getAssetID(), FALSE, TRUE); if (image_item_id.isNull()) { LL_WARNS() << "id or image_item_id is NULL!" << LL_ENDL; @@ -1270,6 +1387,7 @@ void LLOutfitGallery::onBeforeOutfitSnapshotSave() if (!selected_outfit_id.isNull()) { checkRemovePhoto(selected_outfit_id); + updateSnapshotFolderObserver(); } } |