Skip to content
Snippets Groups Projects
Commit b7894fce authored by andreykproductengine's avatar andreykproductengine
Browse files

MAINT-7665 Outfit folders should be capable of accepting images for preview

parent cdf65484
No related branches found
No related tags found
No related merge requests found
...@@ -1321,6 +1321,8 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items) ...@@ -1321,6 +1321,8 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items)
//========================================================================= //=========================================================================
const std::string LLAppearanceMgr::sExpectedTextureName = "OutfitPreview";
const LLUUID LLAppearanceMgr::getCOF() const const LLUUID LLAppearanceMgr::getCOF() const
{ {
return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT);
...@@ -1570,6 +1572,7 @@ void LLAppearanceMgr::removeOutfitPhoto(const LLUUID& outfit_id) ...@@ -1570,6 +1572,7 @@ void LLAppearanceMgr::removeOutfitPhoto(const LLUUID& outfit_id)
LLInventoryModel::EXCLUDE_TRASH); LLInventoryModel::EXCLUDE_TRASH);
BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array) BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array)
{ {
// Note: removing only links
LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem();
if (linked_item != NULL && linked_item->getActualType() == LLAssetType::AT_TEXTURE) if (linked_item != NULL && linked_item->getActualType() == LLAssetType::AT_TEXTURE)
{ {
...@@ -3218,9 +3221,26 @@ void update_base_outfit_after_ordering() ...@@ -3218,9 +3221,26 @@ void update_base_outfit_after_ordering()
BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array) BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array)
{ {
LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem();
if (linked_item != NULL && linked_item->getActualType() == LLAssetType::AT_TEXTURE) if (linked_item != NULL)
{
if (linked_item->getActualType() == LLAssetType::AT_TEXTURE)
{
app_mgr.setOutfitImage(linked_item->getLinkedUUID());
if (linked_item->getName() == LLAppearanceMgr::sExpectedTextureName)
{
// Images with "appropriate" name take priority
break;
}
}
}
else if (outfit_item->getActualType() == LLAssetType::AT_TEXTURE)
{ {
app_mgr.setOutfitImage(linked_item->getLinkedUUID()); app_mgr.setOutfitImage(outfit_item->getUUID());
if (outfit_item->getName() == LLAppearanceMgr::sExpectedTextureName)
{
// Images with "appropriate" name take priority
break;
}
} }
} }
......
...@@ -291,6 +291,9 @@ class LLAppearanceMgr: public LLSingleton<LLAppearanceMgr> ...@@ -291,6 +291,9 @@ class LLAppearanceMgr: public LLSingleton<LLAppearanceMgr>
BOOL getIsInCOF(const LLUUID& obj_id) const; BOOL getIsInCOF(const LLUUID& obj_id) const;
// Is this in the COF and can the user delete it from the COF? // Is this in the COF and can the user delete it from the COF?
BOOL getIsProtectedCOFItem(const LLUUID& obj_id) const; BOOL getIsProtectedCOFItem(const LLUUID& obj_id) const;
// Outfits will prioritize textures with such name to use for preview in gallery
static const std::string sExpectedTextureName;
}; };
class LLUpdateAppearanceOnDestroy: public LLInventoryCallback class LLUpdateAppearanceOnDestroy: public LLInventoryCallback
......
...@@ -699,13 +699,24 @@ void LLOutfitGalleryItem::draw() ...@@ -699,13 +699,24 @@ void LLOutfitGalleryItem::draw()
const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
if (mTexturep) if (mTexturep)
{ {
LLRect interior = border; if (mImageUpdatePending && mTexturep->getDiscardLevel() >= 0)
interior.stretch(-1); {
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 // Pump the priority
mTexturep->addTextureStats((F32)(interior.getWidth() * interior.getHeight())); mTexturep->addTextureStats((F32)(interior.getWidth() * interior.getHeight()));
}
} }
} }
...@@ -771,12 +782,19 @@ BOOL LLOutfitGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask) ...@@ -771,12 +782,19 @@ BOOL LLOutfitGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask)
return LLPanel::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; LLPointer<LLViewerFetchedTexture> texture = LLViewerTextureManager::getFetchedTexture(image_asset_id, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
mTexturep = 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)
getChildView("preview_outfit")->setVisible(FALSE); {
mDefaultImage = false; mImageAssetId = image_asset_id;
mTexturep = texture;
getChildView("preview_outfit")->setVisible(FALSE);
mDefaultImage = false;
mImageUpdatePending = (texture->getDiscardLevel() == -1);
return true;
}
return false;
} }
LLUUID LLOutfitGalleryItem::getImageAssetId() LLUUID LLOutfitGalleryItem::getImageAssetId()
...@@ -790,6 +808,7 @@ void LLOutfitGalleryItem::setDefaultImage() ...@@ -790,6 +808,7 @@ void LLOutfitGalleryItem::setDefaultImage()
mImageAssetId.setNull(); mImageAssetId.setNull();
getChildView("preview_outfit")->setVisible(TRUE); getChildView("preview_outfit")->setVisible(TRUE);
mDefaultImage = true; mDefaultImage = true;
mImageUpdatePending = false;
} }
LLContextMenu* LLOutfitGalleryContextMenu::createMenu() LLContextMenu* LLOutfitGalleryContextMenu::createMenu()
...@@ -1025,13 +1044,28 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) ...@@ -1025,13 +1044,28 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id)
BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array) BOOST_FOREACH(LLViewerInventoryItem* outfit_item, outfit_item_array)
{ {
LLViewerInventoryItem* linked_item = outfit_item->getLinkedItem(); 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(); if (linked_item->getActualType() == LLAssetType::AT_TEXTURE)
mOutfitMap[category_id]->setImageAssetId(asset_id); {
photo_loaded = true; asset_id = linked_item->getAssetUUID();
std::string linked_item_name = linked_item->getName(); inv_id = linked_item->getUUID();
if (!mOutfitRenamePending.isNull() && mOutfitRenamePending.asString() == linked_item_name) 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); LLViewerInventoryCategory *outfit_cat = gInventory.getCategory(mOutfitRenamePending);
LLStringUtil::format_map_t photo_string_args; LLStringUtil::format_map_t photo_string_args;
...@@ -1039,7 +1073,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) ...@@ -1039,7 +1073,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id)
std::string new_name = getString("outfit_photo_string", photo_string_args); std::string new_name = getString("outfit_photo_string", photo_string_args);
LLSD updates; LLSD updates;
updates["name"] = new_name; updates["name"] = new_name;
update_inventory_item(linked_item->getUUID(), updates, NULL); update_inventory_item(inv_id, updates, NULL);
mOutfitRenamePending.setNull(); mOutfitRenamePending.setNull();
LLFloater* inv_floater = LLFloaterReg::getInstance("inventory"); LLFloater* inv_floater = LLFloaterReg::getInstance("inventory");
if (inv_floater) if (inv_floater)
...@@ -1052,7 +1086,11 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) ...@@ -1052,7 +1086,11 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id)
appearance_floater->setFocus(TRUE); appearance_floater->setFocus(TRUE);
} }
} }
break; if (item_name == LLAppearanceMgr::sExpectedTextureName)
{
// Images with "appropriate" name take priority
break;
}
} }
if (!photo_loaded) if (!photo_loaded)
{ {
...@@ -1067,6 +1105,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) ...@@ -1067,6 +1105,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id)
} }
} }
// Refresh linked textures from "textures" uploads folder
void LLOutfitGallery::refreshTextures(const LLUUID& category_id) void LLOutfitGallery::refreshTextures(const LLUUID& category_id)
{ {
LLInventoryModel::cat_array_t cat_array; LLInventoryModel::cat_array_t cat_array;
......
...@@ -259,7 +259,7 @@ class LLOutfitGalleryItem : public LLPanel ...@@ -259,7 +259,7 @@ class LLOutfitGalleryItem : public LLPanel
/*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
void setDefaultImage(); void setDefaultImage();
void setImageAssetId(LLUUID asset_id); bool setImageAssetId(LLUUID asset_id);
LLUUID getImageAssetId(); LLUUID getImageAssetId();
void setOutfitName(std::string name); void setOutfitName(std::string name);
void setOutfitWorn(bool value); void setOutfitWorn(bool value);
...@@ -282,6 +282,7 @@ class LLOutfitGalleryItem : public LLPanel ...@@ -282,6 +282,7 @@ class LLOutfitGalleryItem : public LLPanel
bool mSelected; bool mSelected;
bool mWorn; bool mWorn;
bool mDefaultImage; bool mDefaultImage;
bool mImageUpdatePending;
bool mHidden; bool mHidden;
std::string mOutfitName; std::string mOutfitName;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment