diff options
Diffstat (limited to 'indra/newview/llavatariconctrl.cpp')
-rw-r--r-- | indra/newview/llavatariconctrl.cpp | 94 |
1 files changed, 61 insertions, 33 deletions
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp index 3cd6126739..f6eb7f6494 100644 --- a/indra/newview/llavatariconctrl.cpp +++ b/indra/newview/llavatariconctrl.cpp @@ -36,17 +36,20 @@ #include "llavatarconstants.h" #include "llavatariconctrl.h" #include "llcallingcard.h" // for LLAvatarTracker -#include "llfriendactions.h" +#include "llavataractions.h" #include "llimview.h" #include "llmenugl.h" #include "lluictrlfactory.h" #include "llcachename.h" +#include "llagentdata.h" #define MENU_ITEM_VIEW_PROFILE 0 #define MENU_ITEM_SEND_IM 1 -static LLDefaultWidgetRegistry::Register<LLAvatarIconCtrl> r("avatar_icon"); +static LLDefaultChildRegistry::Register<LLAvatarIconCtrl> r("avatar_icon"); + +LLAvatarIconCtrl::avatar_image_map_t LLAvatarIconCtrl::sImagesCache; LLAvatarIconCtrl::LLAvatarIconCtrl(const LLAvatarIconCtrl::Params& p) : LLIconCtrl(p), @@ -106,7 +109,7 @@ LLAvatarIconCtrl::LLAvatarIconCtrl(const LLAvatarIconCtrl::Params& p) registrar.add("AvatarIcon.Action", boost::bind(&LLAvatarIconCtrl::onAvatarIconContextMenuItemClicked, this, _2)); - LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_avatar_icon.xml", gMenuHolder); + LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_avatar_icon.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); mPopupMenuHandle = menu->getHandle(); } @@ -137,7 +140,17 @@ void LLAvatarIconCtrl::setValue(const LLSD& value) LLAvatarPropertiesProcessor::getInstance()->addObserver(value.asUUID(), this); LLAvatarPropertiesProcessor::getInstance()->sendDataRequest(value.asUUID(),APT_PROPERTIES); mAvatarId = value.asUUID(); + + // Check if cache already contains image_id for that avatar + avatar_image_map_t::iterator it; + + it = sImagesCache.find(mAvatarId); + if (it != sImagesCache.end()) + { + updateFromCache(it->second); + } } + } else { @@ -147,6 +160,37 @@ void LLAvatarIconCtrl::setValue(const LLSD& value) gCacheName->get(mAvatarId, FALSE, boost::bind(&LLAvatarIconCtrl::nameUpdatedCallback, this, _1, _2, _3, _4)); } +void LLAvatarIconCtrl::updateFromCache(LLAvatarIconCtrl::LLImagesCacheItem data) +{ + // Update the avatar + if (data.image_id.notNull()) + { + LLIconCtrl::setValue(data.image_id); + } + else + { + LLIconCtrl::setValue("default_profile_picture.j2c"); + } + + // Update color of status symbol and tool tip + if (data.flags & AVATAR_ONLINE) + { + mStatusSymbol->setColor(LLColor4::green); + if (mDrawTooltip) + { + setToolTip((LLStringExplicit)"Online"); + } + } + else + { + mStatusSymbol->setColor(LLColor4::grey); + if (mDrawTooltip) + { + setToolTip((LLStringExplicit)"Offline"); + } + } +} + //virtual void LLAvatarIconCtrl::processProperties(void* data, EAvatarProcessorType type) { @@ -160,33 +204,10 @@ void LLAvatarIconCtrl::processProperties(void* data, EAvatarProcessorType type) return; } - // Update the avatar - if (avatar_data->image_id.notNull()) - { - LLIconCtrl::setValue(avatar_data->image_id); - } - else - { - LLIconCtrl::setValue("default_profile_picture.j2c"); - } + LLAvatarIconCtrl::LLImagesCacheItem data(avatar_data->image_id, avatar_data->flags); - // Update color of status symbol and tool tip - if (avatar_data->flags & AVATAR_ONLINE) - { - mStatusSymbol->setColor(LLColor4::green); - if (mDrawTooltip) - { - setToolTip((LLStringExplicit)"Online"); - } - } - else - { - mStatusSymbol->setColor(LLColor4::grey); - if (mDrawTooltip) - { - setToolTip((LLStringExplicit)"Offline"); - } - } + updateFromCache(data); + sImagesCache.insert(std::pair<LLUUID, LLAvatarIconCtrl::LLImagesCacheItem>(mAvatarId, data)); } } } @@ -198,10 +219,17 @@ BOOL LLAvatarIconCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) if(menu) { bool is_friend = LLAvatarTracker::instance().getBuddyInfo(mAvatarId) != NULL; - + menu->setItemEnabled("Add Friend", !is_friend); menu->setItemEnabled("Remove Friend", is_friend); + if(gAgentID == mAvatarId) + { + menu->setItemEnabled("Add Friend", false); + menu->setItemEnabled("Send IM", false); + menu->setItemEnabled("Remove Friend", false); + } + menu->buildDrawLabels(); menu->updateParent(LLMenuGL::sMenuContainer); LLMenuGL::showPopup(this, menu, x, y); @@ -230,7 +258,7 @@ void LLAvatarIconCtrl::onAvatarIconContextMenuItemClicked(const LLSD& userdata) if (level == "profile") { - LLFriendActions::showProfile(id); + LLAvatarActions::showProfile(id); } else if (level == "im") { @@ -248,10 +276,10 @@ void LLAvatarIconCtrl::onAvatarIconContextMenuItemClicked(const LLSD& userdata) name.append(" "); name.append(getLastName()); - LLFriendActions::requestFriendshipDialog(id, name); + LLAvatarActions::requestFriendshipDialog(id, name); } else if (level == "remove") { - LLFriendActions::removeFriendDialog(id); + LLAvatarActions::removeFriendDialog(id); } } |