diff options
Diffstat (limited to 'indra/newview/llnearbychathandler.cpp')
-rw-r--r-- | indra/newview/llnearbychathandler.cpp | 119 |
1 files changed, 74 insertions, 45 deletions
diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index c80583cd0e..47d32e57fb 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -31,7 +31,9 @@ #include "llbottomtray.h" #include "llchatitemscontainerctrl.h" +#include "llfirstuse.h" #include "llfloaterscriptdebug.h" +#include "llhints.h" #include "llnearbychat.h" #include "llrecentpeople.h" @@ -56,7 +58,13 @@ class LLNearbyChatScreenChannel: public LLScreenChannelBase { LOG_CLASS(LLNearbyChatScreenChannel); public: - LLNearbyChatScreenChannel(const LLUUID& id):LLScreenChannelBase(id) { mStopProcessing = false;}; + typedef std::vector<LLHandle<LLToast> > toast_vec_t; + typedef std::list<LLHandle<LLToast> > toast_list_t; + + LLNearbyChatScreenChannel(const LLUUID& id):LLScreenChannelBase(id) + { + mStopProcessing = false; + } void addNotification (LLSD& notification); void arrangeToasts (); @@ -76,15 +84,12 @@ public: } // hide all toasts from screen, but not remove them from a channel - virtual void hideToastsFromScreen() - { - }; // removes all toasts from a channel virtual void removeToastsFromChannel() { - for(std::vector<LLToast*>::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) + for(toast_vec_t::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) { - addToToastPool((*it)); + addToToastPool(it->get()); } m_active_toasts.clear(); }; @@ -101,11 +106,12 @@ protected: void deactivateToast(LLToast* toast); void addToToastPool(LLToast* toast) { + if (!toast) return; LL_DEBUGS("NearbyChat") << "Pooling toast" << llendl; toast->setVisible(FALSE); toast->stopTimer(); toast->setIsHidden(true); - m_toast_pool.push_back(toast); + m_toast_pool.push_back(toast->getHandle()); } void createOverflowToast(S32 bottom, F32 timer); @@ -114,8 +120,8 @@ protected: bool createPoolToast(); - std::vector<LLToast*> m_active_toasts; - std::list<LLToast*> m_toast_pool; + toast_vec_t m_active_toasts; + toast_list_t m_toast_pool; bool mStopProcessing; }; @@ -148,7 +154,7 @@ private: void LLNearbyChatScreenChannel::deactivateToast(LLToast* toast) { - std::vector<LLToast*>::iterator pos = std::find(m_active_toasts.begin(), m_active_toasts.end(), toast); + toast_vec_t::iterator pos = std::find(m_active_toasts.begin(), m_active_toasts.end(), toast->getHandle()); if (pos == m_active_toasts.end()) { @@ -173,8 +179,8 @@ void LLNearbyChatScreenChannel::onToastDestroyed(LLToast* toast, bool app_quitti { // Viewer is quitting. // Immediately stop processing chat messages (EXT-1419). - mStopProcessing = true; - } + mStopProcessing = true; +} else { // The toast is being closed by user (STORM-192). @@ -185,7 +191,7 @@ void LLNearbyChatScreenChannel::onToastDestroyed(LLToast* toast, bool app_quitti } void LLNearbyChatScreenChannel::onToastFade(LLToast* toast) -{ +{ LL_DEBUGS("NearbyChat") << "Toast fading" << llendl; //fade mean we put toast to toast pool @@ -215,9 +221,9 @@ bool LLNearbyChatScreenChannel::createPoolToast() toast->setOnFadeCallback(boost::bind(&LLNearbyChatScreenChannel::onToastFade, this, _1)); - - LL_DEBUGS("NearbyChat") << "Creating and pooling toast" << llendl; - m_toast_pool.push_back(toast); + + LL_DEBUGS("NearbyChat") << "Creating and pooling toast" << llendl; + m_toast_pool.push_back(toast->getHandle()); return true; } @@ -235,17 +241,20 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) { LLUUID fromID = notification["from_id"].asUUID(); // agent id or object id std::string from = notification["from"].asString(); - LLToast* toast = m_active_toasts[0]; - LLNearbyChatToastPanel* panel = dynamic_cast<LLNearbyChatToastPanel*>(toast->getPanel()); - - if(panel && panel->messageID() == fromID && panel->getFromName() == from && panel->canAddText()) + LLToast* toast = m_active_toasts[0].get(); + if (toast) { - panel->addMessage(notification); - toast->reshapeToPanel(); - toast->resetTimer(); - - arrangeToasts(); - return; + LLNearbyChatToastPanel* panel = dynamic_cast<LLNearbyChatToastPanel*>(toast->getPanel()); + + if(panel && panel->messageID() == fromID && panel->getFromName() == from && panel->canAddText()) + { + panel->addMessage(notification); + toast->reshapeToPanel(); + toast->resetTimer(); + + arrangeToasts(); + return; + } } } @@ -275,7 +284,7 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) //take 1st element from pool, (re)initialize it, put it in active toasts LL_DEBUGS("NearbyChat") << "Getting toast from pool" << llendl; - LLToast* toast = m_toast_pool.back(); + LLToast* toast = m_toast_pool.back().get(); m_toast_pool.pop_back(); @@ -288,25 +297,36 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) toast->reshapeToPanel(); toast->resetTimer(); - m_active_toasts.push_back(toast); + m_active_toasts.push_back(toast->getHandle()); arrangeToasts(); } void LLNearbyChatScreenChannel::arrangeToasts() { - if(m_active_toasts.size() == 0 || isHovering()) - return; - - hideToastsFromScreen(); + if(!isHovering()) + { + showToastsBottom(); + } - showToastsBottom(); + if (m_active_toasts.empty()) + { + LLHints::registerHintTarget("incoming_chat", LLHandle<LLView>()); + } + else + { + LLToast* toast = m_active_toasts.front().get(); + if (toast) + { + LLHints::registerHintTarget("incoming_chat", m_active_toasts.front().get()->LLView::getHandle()); + } + } } -int sort_toasts_predicate(LLToast* first,LLToast* second) +int sort_toasts_predicate(LLHandle<LLToast> first, LLHandle<LLToast> second) { - F32 v1 = first->getTimer()->getEventTimer().getElapsedTimeF32(); - F32 v2 = second->getTimer()->getEventTimer().getElapsedTimeF32(); + F32 v1 = first.get()->getTimer()->getEventTimer().getElapsedTimeF32(); + F32 v2 = second.get()->getTimer()->getEventTimer().getElapsedTimeF32(); return v1 < v2; } @@ -324,20 +344,22 @@ void LLNearbyChatScreenChannel::showToastsBottom() //calc max visible item and hide other toasts. - for(std::vector<LLToast*>::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) + for(toast_vec_t::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) { - S32 toast_top = bottom + (*it)->getRect().getHeight() + margin; + LLToast* toast = it->get(); + if (!toast) continue; + + S32 toast_top = bottom + toast->getRect().getHeight() + margin; if(toast_top > gFloaterView->getRect().getHeight()) { while(it!=m_active_toasts.end()) { - addToToastPool((*it)); + addToToastPool(it->get()); it=m_active_toasts.erase(it); } break; } - LLToast* toast = (*it); toast_rect = toast->getRect(); toast_rect.setLeftTopAndSize(getRect().mLeft , bottom + toast_rect.getHeight(), toast_rect.getWidth() ,toast_rect.getHeight()); @@ -348,14 +370,17 @@ void LLNearbyChatScreenChannel::showToastsBottom() // use reverse order to provide correct z-order and avoid toast blinking - for(std::vector<LLToast*>::reverse_iterator it = m_active_toasts.rbegin(); it != m_active_toasts.rend(); ++it) + for(toast_vec_t::reverse_iterator it = m_active_toasts.rbegin(); it != m_active_toasts.rend(); ++it) + { + LLToast* toast = it->get(); + if (toast) { - LLToast* toast = (*it); toast->setIsHidden(false); toast->setVisible(TRUE); + } + } } -} void LLNearbyChatScreenChannel::reshape (S32 width, S32 height, BOOL called_from_parent) { @@ -400,8 +425,6 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args) { if(chat_msg.mMuted == TRUE) return; - if(chat_msg.mSourceType == CHAT_SOURCE_AGENT && chat_msg.mFromID.notNull()) - LLRecentPeople::instance().add(chat_msg.mFromID); if(chat_msg.mText.empty()) return;//don't process empty messages @@ -505,6 +528,12 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args) channel->addNotification(notification); } + if(chat_msg.mSourceType == CHAT_SOURCE_AGENT + && chat_msg.mFromID.notNull() + && chat_msg.mFromID != gAgentID) + { + LLFirstUse::otherAvatarChatFirst(); + } } void LLNearbyChatHandler::onDeleteToast(LLToast* toast) |