diff options
Diffstat (limited to 'indra/newview/llnearbychathandler.cpp')
-rw-r--r-- | indra/newview/llnearbychathandler.cpp | 91 |
1 files changed, 68 insertions, 23 deletions
diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index e199f9f180..1fadb126e4 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -32,10 +32,12 @@ #include "llviewerprecompiledheaders.h" +#include "llagentdata.h" // for gAgentID #include "llnearbychathandler.h" #include "llbottomtray.h" #include "llchatitemscontainerctrl.h" +#include "llfloaterscriptdebug.h" #include "llnearbychat.h" #include "llrecentpeople.h" @@ -56,7 +58,6 @@ LLToastPanelBase* createToastPanel() return item; } - class LLNearbyChatScreenChannel: public LLScreenChannelBase { public: @@ -88,11 +89,7 @@ public: { for(std::vector<LLToast*>::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) { - LLToast* toast = (*it); - toast->setVisible(FALSE); - toast->stopTimer(); - m_toast_pool.push_back(toast); - + addToToastPool((*it)); } m_active_toasts.clear(); }; @@ -105,6 +102,14 @@ public: } protected: + void addToToastPool(LLToast* toast) + { + toast->setVisible(FALSE); + toast->stopTimer(); + toast->setIsHidden(true); + m_toast_pool.push_back(toast); + } + void createOverflowToast(S32 bottom, F32 timer); create_toast_panel_callback_t m_create_toast_panel_callback_t; @@ -132,11 +137,12 @@ void LLNearbyChatScreenChannel::onToastFade(LLToast* toast) //fade mean we put toast to toast pool if(!toast) return; - m_toast_pool.push_back(toast); std::vector<LLToast*>::iterator pos = std::find(m_active_toasts.begin(),m_active_toasts.end(),toast); if(pos!=m_active_toasts.end()) m_active_toasts.erase(pos); + + addToToastPool(toast); arrangeToasts(); } @@ -228,7 +234,7 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) toast->reshapeToPanel(); toast->resetTimer(); - m_active_toasts.insert(m_active_toasts.begin(),toast); + m_active_toasts.push_back(toast); arrangeToasts(); } @@ -240,7 +246,14 @@ void LLNearbyChatScreenChannel::arrangeToasts() hideToastsFromScreen(); - showToastsBottom(); + showToastsBottom(); +} + +int sort_toasts_predicate(LLToast* first,LLToast* second) +{ + F32 v1 = first->getTimer()->getEventTimer().getElapsedTimeF32(); + F32 v2 = second->getTimer()->getEventTimer().getElapsedTimeF32(); + return v1 < v2; } void LLNearbyChatScreenChannel::showToastsBottom() @@ -252,39 +265,41 @@ void LLNearbyChatScreenChannel::showToastsBottom() S32 bottom = getRect().mBottom; S32 margin = gSavedSettings.getS32("ToastGap"); + //sort active toasts + std::sort(m_active_toasts.begin(),m_active_toasts.end(),sort_toasts_predicate); + + //calc max visible item and hide other toasts. + for(std::vector<LLToast*>::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it) { - LLToast* toast = (*it); - S32 toast_top = bottom + toast->getRect().getHeight() + margin; + S32 toast_top = bottom + (*it)->getRect().getHeight() + margin; if(toast_top > gFloaterView->getRect().getHeight()) { while(it!=m_active_toasts.end()) { - toast->setVisible(FALSE); - toast->stopTimer(); - m_toast_pool.push_back(toast); + addToToastPool((*it)); it=m_active_toasts.erase(it); } break; } - bottom = toast_top - toast->getTopPad(); - } - - // 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) - { LLToast* toast = (*it); - S32 toast_top = bottom + toast->getTopPad(); toast_rect = toast->getRect(); - toast_rect.setLeftTopAndSize(getRect().mLeft , toast_top, toast_rect.getWidth() ,toast_rect.getHeight()); + toast_rect.setLeftTopAndSize(getRect().mLeft , bottom + toast_rect.getHeight(), toast_rect.getWidth() ,toast_rect.getHeight()); toast->setRect(toast_rect); + bottom += toast_rect.getHeight() - toast->getTopPad() + margin; + } + + // 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) + { + LLToast* toast = (*it); toast->setIsHidden(false); toast->setVisible(TRUE); - bottom = toast->getRect().mBottom - margin; } } @@ -345,6 +360,36 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args) //if(tmp_chat.mFromName.empty() && tmp_chat.mFromID!= LLUUID::null) // tmp_chat.mFromName = tmp_chat.mFromID.asString(); } + + // don't show toast and add message to chat history on receive debug message + // with disabled setting showing script errors or enabled setting to show script + // errors in separate window. + if (chat_msg.mChatType == CHAT_TYPE_DEBUG_MSG) + { + if(gSavedSettings.getBOOL("ShowScriptErrors") == FALSE) + return; + + // don't process debug messages from not owned objects, see EXT-7762 + if (gAgentID != chat_msg.mOwnerID) + { + return; + } + + if (gSavedSettings.getS32("ShowScriptErrorsLocation")== 1)// show error in window //("ScriptErrorsAsChat")) + { + + LLColor4 txt_color; + + LLViewerChat::getChatColor(chat_msg,txt_color); + + LLFloaterScriptDebug::addScriptLine(chat_msg.mText, + chat_msg.mFromName, + txt_color, + chat_msg.mFromID); + return; + } + } + nearby_chat->addMessage(chat_msg, true, args); if( nearby_chat->getVisible() || ( chat_msg.mSourceType == CHAT_SOURCE_AGENT |