summaryrefslogtreecommitdiff
path: root/indra/newview/lloutfitgallery.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lloutfitgallery.cpp')
-rw-r--r--indra/newview/lloutfitgallery.cpp101
1 files changed, 70 insertions, 31 deletions
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp
index 31e89c0ed0..cca65f2ce1 100644
--- a/indra/newview/lloutfitgallery.cpp
+++ b/indra/newview/lloutfitgallery.cpp
@@ -344,7 +344,7 @@ void LLOutfitGallery::removeFromLastRow(LLOutfitGalleryItem* item)
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);
@@ -353,6 +353,7 @@ LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name)
gitem->setFollowsLeft();
gitem->setFollowsTop();
gitem->setOutfitName(name);
+ gitem->setUUID(outfit_id);
return gitem;
}
@@ -511,7 +512,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));
@@ -661,7 +662,8 @@ LLOutfitGalleryItem::LLOutfitGalleryItem(const Params& p)
mSelected(false),
mWorn(false),
mDefaultImage(true),
- mOutfitName("")
+ mOutfitName(""),
+ mUUID(LLUUID())
{
buildFromFile("panel_outfit_gallery_item.xml");
}
@@ -697,13 +699,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()));
+ }
}
}
@@ -745,23 +758,20 @@ BOOL LLOutfitGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask)
return LLUICtrl::handleRightMouseDown(x, y, mask);
}
-BOOL LLOutfitGallery::handleDoubleClick(S32 x, S32 y, MASK mask)
+BOOL LLOutfitGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask)
{
LLTabContainer* appearence_tabs = LLPanelOutfitsInventory::findInstance()->getChild<LLTabContainer>("appearance_tabs");
- LLPanel* panel = NULL;
- LLAccordionCtrl* accordion = NULL;
- if (appearence_tabs != NULL)
+ if (appearence_tabs && (mUUID != LLUUID()))
{
appearence_tabs->selectTabByName("outfitslist_tab");
- panel = appearence_tabs->getCurrentPanel();
- if (panel != NULL)
+ LLPanel* panel = appearence_tabs->getCurrentPanel();
+ if (panel)
{
- accordion = panel->getChild<LLAccordionCtrl>("outfits_accordion");
+ LLAccordionCtrl* accordion = panel->getChild<LLAccordionCtrl>("outfits_accordion");
LLOutfitsList* outfit_list = dynamic_cast<LLOutfitsList*>(panel);
if (accordion != NULL && outfit_list != NULL)
{
- LLUUID item_id = getSelectedOutfitUUID();
- outfit_list->setSelectedOutfitByUUID(item_id);
+ outfit_list->setSelectedOutfitByUUID(mUUID);
LLAccordionCtrlTab* tab = accordion->getSelectedTab();
tab->showAndFocusHeader();
return TRUE;
@@ -769,15 +779,22 @@ BOOL LLOutfitGallery::handleDoubleClick(S32 x, S32 y, MASK mask)
}
}
- return LLUICtrl::handleDoubleClick(x, y, mask);
+ return LLPanel::handleDoubleClick(x, y, mask);
}
-void LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id)
+bool LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id)
{
- 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;
+ 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()
@@ -791,6 +808,7 @@ void LLOutfitGalleryItem::setDefaultImage()
mImageAssetId.setNull();
getChildView("preview_outfit")->setVisible(TRUE);
mDefaultImage = true;
+ mImageUpdatePending = false;
}
LLContextMenu* LLOutfitGalleryContextMenu::createMenu()
@@ -1026,13 +1044,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;
@@ -1040,7 +1073,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)
@@ -1053,7 +1086,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)
{
@@ -1068,6 +1105,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;
@@ -1177,6 +1215,7 @@ void LLOutfitGallery::uploadPhoto(LLUUID outfit_id)
upload_pending_name, callback, expected_upload_cost, nruserdata);
mOutfitLinkPending = outfit_id;
}
+ delete unit;
}
}