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.cpp135
1 files changed, 83 insertions, 52 deletions
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp
index 0b127b1b93..22420e8896 100644
--- a/indra/newview/lloutfitgallery.cpp
+++ b/indra/newview/lloutfitgallery.cpp
@@ -105,9 +105,9 @@ const LLOutfitGallery::Params& LLOutfitGallery::getDefaultParams()
return LLUICtrlFactory::getDefaultParams<LLOutfitGallery>();
}
-BOOL LLOutfitGallery::postBuild()
+bool LLOutfitGallery::postBuild()
{
- BOOL rv = LLOutfitListBase::postBuild();
+ bool rv = LLOutfitListBase::postBuild();
mScrollPanel = getChild<LLScrollContainer>("gallery_scroll_panel");
LLPanel::Params params = LLPanel::getDefaultParams(); // Don't parse XML when creating dummy LLPanel
mGalleryPanel = LLUICtrlFactory::create<LLPanel>(params);
@@ -123,12 +123,12 @@ void LLOutfitGallery::onOpen(const LLSD& info)
{
uuid_vec_t cats;
getCurrentCategories(cats);
- int n = cats.size();
+ int n = static_cast<int>(cats.size());
buildGalleryPanel(n);
mScrollPanel->addChild(mGalleryPanel);
for (int i = 0; i < n; i++)
{
- addToGallery(mOutfitMap[cats[i]]);
+ addToGallery(getItem(cats[i]));
}
reArrangeRows();
mGalleryCreated = true;
@@ -144,9 +144,9 @@ void LLOutfitGallery::draw()
}
}
-BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask)
+bool LLOutfitGallery::handleKeyHere(KEY key, MASK mask)
{
- BOOL handled = FALSE;
+ bool handled = false;
switch (key)
{
case KEY_RETURN:
@@ -156,7 +156,7 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask)
// Or should it wearSelectedOutfit?
getSelectedItem()->openOutfitsContent();
}
- handled = TRUE;
+ handled = true;
break;
case KEY_DELETE:
#if LL_DARWIN
@@ -168,12 +168,12 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask)
{
onRemoveOutfit(mSelectedOutfitUUID);
}
- handled = TRUE;
+ handled = true;
break;
case KEY_F2:
LLAppearanceMgr::instance().renameOutfit(mSelectedOutfitUUID);
- handled = TRUE;
+ handled = true;
break;
case KEY_PAGE_UP:
@@ -181,7 +181,7 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask)
{
mScrollPanel->pageUp(30);
}
- handled = TRUE;
+ handled = true;
break;
case KEY_PAGE_DOWN:
@@ -189,7 +189,7 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask)
{
mScrollPanel->pageDown(30);
}
- handled = TRUE;
+ handled = true;
break;
case KEY_HOME:
@@ -197,7 +197,7 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask)
{
mScrollPanel->goToTop();
}
- handled = TRUE;
+ handled = true;
break;
case KEY_END:
@@ -205,27 +205,27 @@ BOOL LLOutfitGallery::handleKeyHere(KEY key, MASK mask)
{
mScrollPanel->goToBottom();
}
- handled = TRUE;
+ handled = true;
break;
case KEY_LEFT:
moveLeft();
- handled = TRUE;
+ handled = true;
break;
case KEY_RIGHT:
moveRight();
- handled = TRUE;
+ handled = true;
break;
case KEY_UP:
moveUp();
- handled = TRUE;
+ handled = true;
break;
case KEY_DOWN:
moveDown();
- handled = TRUE;
+ handled = true;
break;
default:
@@ -254,7 +254,7 @@ void LLOutfitGallery::moveUp()
item = mIndexToItemMap[n];
LLUUID item_id = item->getUUID();
ChangeOutfitSelection(nullptr, item_id);
- item->setFocus(TRUE);
+ item->setFocus(true);
scrollToShowItem(mSelectedOutfitUUID);
}
@@ -276,7 +276,7 @@ void LLOutfitGallery::moveDown()
item = mIndexToItemMap[n];
LLUUID item_id = item->getUUID();
ChangeOutfitSelection(nullptr, item_id);
- item->setFocus(TRUE);
+ item->setFocus(true);
scrollToShowItem(mSelectedOutfitUUID);
}
@@ -301,7 +301,7 @@ void LLOutfitGallery::moveLeft()
item = mIndexToItemMap[n];
LLUUID item_id = item->getUUID();
ChangeOutfitSelection(nullptr, item_id);
- item->setFocus(TRUE);
+ item->setFocus(true);
scrollToShowItem(mSelectedOutfitUUID);
}
@@ -324,7 +324,7 @@ void LLOutfitGallery::moveRight()
item = mIndexToItemMap[n];
LLUUID item_id = item->getUUID();
ChangeOutfitSelection(nullptr, item_id);
- item->setFocus(TRUE);
+ item->setFocus(true);
scrollToShowItem(mSelectedOutfitUUID);
}
@@ -377,7 +377,7 @@ void LLOutfitGallery::onOutfitsRemovalConfirmation(const LLSD& notification, con
void LLOutfitGallery::scrollToShowItem(const LLUUID& item_id)
{
- LLOutfitGalleryItem* item = mOutfitMap[item_id];
+ LLOutfitGalleryItem* item = getItem(item_id);
if (item)
{
const LLRect visible_content_rect = mScrollPanel->getVisibleContentRect();
@@ -524,6 +524,10 @@ LLPanel* LLOutfitGallery::addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item
void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item)
{
+ if (!item)
+ {
+ return;
+ }
if(item->isHidden())
{
mHiddenItems.push_back(item);
@@ -601,8 +605,8 @@ void LLOutfitGallery::removeFromGalleryMiddle(LLOutfitGalleryItem* item)
removeFromGalleryLast(mItems[i]);
}
removeFromGalleryLast(mItems[n]);
- int saved_count = saved.size();
- for (int i = 0; i < saved_count; i++)
+ auto saved_count = saved.size();
+ for (size_t i = 0; i < saved_count; i++)
{
addToGallery(saved.back());
saved.pop_back();
@@ -631,9 +635,19 @@ LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name, LLUUID
return gitem;
}
-LLOutfitGalleryItem* LLOutfitGallery::getSelectedItem()
+LLOutfitGalleryItem* LLOutfitGallery::getSelectedItem() const
{
- return mOutfitMap[mSelectedOutfitUUID];
+ return getItem(mSelectedOutfitUUID);
+}
+
+LLOutfitGalleryItem* LLOutfitGallery::getItem(const LLUUID& id) const
+{
+ auto it = mOutfitMap.find(id);
+ if (it != mOutfitMap.end())
+ {
+ return it->second;
+ }
+ return nullptr;
}
void LLOutfitGallery::buildGalleryPanel(int row_count)
@@ -860,11 +874,11 @@ void LLOutfitGallery::onChangeOutfitSelection(LLWearableItemsList* list, const L
return;
if (mOutfitMap[mSelectedOutfitUUID])
{
- mOutfitMap[mSelectedOutfitUUID]->setSelected(FALSE);
+ mOutfitMap[mSelectedOutfitUUID]->setSelected(false);
}
if (mOutfitMap[category_id])
{
- mOutfitMap[category_id]->setSelected(TRUE);
+ mOutfitMap[category_id]->setSelected(true);
}
// mSelectedOutfitUUID will be set in LLOutfitListBase::ChangeOutfitSelection
}
@@ -897,15 +911,15 @@ void LLOutfitGallery::updateMessageVisibility()
{
if (mItems.empty())
{
- mMessageTextBox->setVisible(TRUE);
- mScrollPanel->setVisible(FALSE);
+ mMessageTextBox->setVisible(true);
+ mScrollPanel->setVisible(false);
std::string message = getString(getFilterSubString().empty() ? "no_outfits_msg" : "no_matched_outfits_msg");
mMessageTextBox->setValue(message);
}
else
{
- mScrollPanel->setVisible(TRUE);
- mMessageTextBox->setVisible(FALSE);
+ mScrollPanel->setVisible(true);
+ mMessageTextBox->setVisible(false);
}
}
@@ -934,7 +948,7 @@ LLOutfitGalleryItem::~LLOutfitGalleryItem()
}
-BOOL LLOutfitGalleryItem::postBuild()
+bool LLOutfitGalleryItem::postBuild()
{
setDefaultImage();
@@ -943,7 +957,7 @@ BOOL LLOutfitGalleryItem::postBuild()
mTextBgPanel = getChild<LLPanel>("text_bg_panel");
setOutfitWorn(false);
mHidden = false;
- return TRUE;
+ return true;
}
void LLOutfitGalleryItem::draw()
@@ -954,7 +968,7 @@ void LLOutfitGalleryItem::draw()
LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "OutfitGalleryItemSelected" : "OutfitGalleryItemUnselected", LLColor4::white);
LLRect border = getChildView("preview_outfit")->getRect();
border.mRight = border.mRight + 1;
- gl_rect_2d(border, border_color.get(), FALSE);
+ gl_rect_2d(border, border_color.get(), false);
// If the floater is focused, don't apply its alpha to the texture (STORM-677).
const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
@@ -1010,31 +1024,31 @@ void LLOutfitGalleryItem::setSelected(bool value)
setOutfitWorn(mWorn);
}
-BOOL LLOutfitGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask)
+bool LLOutfitGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask)
{
- setFocus(TRUE);
+ setFocus(true);
return LLUICtrl::handleMouseDown(x, y, mask);
}
-BOOL LLOutfitGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask)
+bool LLOutfitGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
- setFocus(TRUE);
+ setFocus(true);
return LLUICtrl::handleRightMouseDown(x, y, mask);
}
-BOOL LLOutfitGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask)
+bool LLOutfitGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask)
{
return openOutfitsContent() || LLPanel::handleDoubleClick(x, y, mask);
}
-BOOL LLOutfitGalleryItem::handleKeyHere(KEY key, MASK mask)
+bool LLOutfitGalleryItem::handleKeyHere(KEY key, MASK mask)
{
if (!mGallery)
{
- return FALSE;
+ return false;
}
- BOOL handled = FALSE;
+ bool handled = false;
switch (key)
{
case KEY_LEFT:
@@ -1110,7 +1124,7 @@ bool LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id)
{
mImageAssetId = image_asset_id;
mTexturep = texture;
- getChildView("preview_outfit")->setVisible(FALSE);
+ getChildView("preview_outfit")->setVisible(false);
mDefaultImage = false;
mImageUpdatePending = (texture->getDiscardLevel() == -1);
return true;
@@ -1127,7 +1141,7 @@ void LLOutfitGalleryItem::setDefaultImage()
{
mTexturep = NULL;
mImageAssetId.setNull();
- getChildView("preview_outfit")->setVisible(TRUE);
+ getChildView("preview_outfit")->setVisible(true);
mDefaultImage = true;
mImageUpdatePending = false;
}
@@ -1187,10 +1201,11 @@ void LLOutfitGalleryGearMenu::onUpdateItemsVisibility()
{
if (!mMenu) return;
bool have_selection = getSelectedOutfitID().notNull();
- mMenu->setItemVisible("expand", FALSE);
- mMenu->setItemVisible("collapse", FALSE);
+ mMenu->setItemVisible("expand", false);
+ mMenu->setItemVisible("collapse", false);
mMenu->setItemVisible("thumbnail", have_selection);
- mMenu->setItemVisible("sort_folders_by_name", TRUE);
+ mMenu->setItemVisible("sepatator3", true);
+ mMenu->setItemVisible("sort_folders_by_name", true);
LLOutfitListGearMenuBase::onUpdateItemsVisibility();
}
@@ -1263,7 +1278,15 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id)
}
if (asset_id.notNull())
{
- photo_loaded |= mOutfitMap[category_id]->setImageAssetId(asset_id);
+ LLOutfitGalleryItem* item = getItem(category_id);
+ if (item)
+ {
+ photo_loaded |= item->setImageAssetId(asset_id);
+ }
+ else
+ {
+ photo_loaded = true;
+ }
// Rename links
if (!mOutfitRenamePending.isNull() && mOutfitRenamePending.asString() == item_name)
{
@@ -1278,7 +1301,7 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id)
LLFloater* appearance_floater = LLFloaterReg::getInstance("appearance");
if (appearance_floater)
{
- appearance_floater->setFocus(TRUE);
+ appearance_floater->setFocus(true);
}
}
if (item_name == LLAppearanceMgr::sExpectedTextureName)
@@ -1289,13 +1312,21 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id)
}
if (!photo_loaded)
{
- mOutfitMap[category_id]->setDefaultImage();
+ LLOutfitGalleryItem* item = getItem(category_id);
+ if (item)
+ {
+ item->setDefaultImage();
+ }
}
}
}
else
{
- mOutfitMap[category_id]->setImageAssetId(asset_id);
+ LLOutfitGalleryItem* item = getItem(category_id);
+ if (item)
+ {
+ item->setImageAssetId(asset_id);
+ }
}
}