From 9e403da7b0fd013371e73820b8aa70820f4f620b Mon Sep 17 00:00:00 2001 From: Sergey Borushevsky Date: Mon, 23 Nov 2009 20:34:06 +0200 Subject: Implemented major sub-task EXT-2517 (Add support for the viewer 1.23 chat history style (widget-less)) --HG-- branch : product-engine --- indra/newview/llchathistory.cpp | 94 ++++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 38 deletions(-) (limited to 'indra/newview/llchathistory.cpp') diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 4ce3b50ed5..422aae3c25 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -334,20 +334,14 @@ LLView* LLChatHistory::getHeader(const LLChat& chat,const LLStyle::Params& style return header; } -void LLChatHistory::appendWidgetMessage(const LLChat& chat, const LLStyle::Params& input_append_params) +void LLChatHistory::clear() { - LLView* view = NULL; - std::string view_text = "\n[" + chat.mTimeStr + "] "; - if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM) - view_text += chat.mFromName + ": "; - - - LLInlineViewSegment::Params p; - p.force_newline = true; - p.left_pad = mLeftWidgetPad; - p.right_pad = mRightWidgetPad; + mLastFromName.clear(); + LLTextEditor::clear(); +} - +void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_chat_history, const LLStyle::Params& input_append_params) +{ LLColor4 txt_color = LLUIColorTable::instance().getColor("White"); LLViewerChat::getChatColor(chat,txt_color); LLFontGL* fontp = LLViewerChat::getChatFont(); @@ -360,39 +354,63 @@ void LLChatHistory::appendWidgetMessage(const LLChat& chat, const LLStyle::Param style_params.font.size(font_size); style_params.font.style(input_append_params.font.style); - + std::string header_text = "[" + chat.mTimeStr + "] "; + if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM) + header_text += chat.mFromName + ": "; - if (mLastFromName == chat.mFromName) + if (use_plain_text_chat_history) { - view = getSeparator(); - p.top_pad = mTopSeparatorPad; - p.bottom_pad = mBottomSeparatorPad; + appendText(header_text, getText().size() != 0, style_params); } else { - view = getHeader(chat,style_params); - if (getText().size() == 0) - p.top_pad = 0; + LLView* view = NULL; + LLInlineViewSegment::Params p; + p.force_newline = true; + p.left_pad = mLeftWidgetPad; + p.right_pad = mRightWidgetPad; + + if (mLastFromName == chat.mFromName) + { + view = getSeparator(); + p.top_pad = mTopSeparatorPad; + p.bottom_pad = mBottomSeparatorPad; + } else - p.top_pad = mTopHeaderPad; - p.bottom_pad = mBottomHeaderPad; - + { + view = getHeader(chat, style_params); + if (getText().size() == 0) + p.top_pad = 0; + else + p.top_pad = mTopHeaderPad; + p.bottom_pad = mBottomHeaderPad; + + } + p.view = view; + + //Prepare the rect for the view + LLRect target_rect = getDocumentView()->getRect(); + // squeeze down the widget by subtracting padding off left and right + target_rect.mLeft += mLeftWidgetPad + mHPad; + target_rect.mRight -= mRightWidgetPad; + view->reshape(target_rect.getWidth(), view->getRect().getHeight()); + view->setOrigin(target_rect.mLeft, view->getRect().mBottom); + + appendWidget(p, header_text, false); + mLastFromName = chat.mFromName; } - p.view = view; - - //Prepare the rect for the view - LLRect target_rect = getDocumentView()->getRect(); - // squeeze down the widget by subtracting padding off left and right - target_rect.mLeft += mLeftWidgetPad + mHPad; - target_rect.mRight -= mRightWidgetPad; - view->reshape(target_rect.getWidth(), view->getRect().getHeight()); - view->setOrigin(target_rect.mLeft, view->getRect().mBottom); - - appendWidget(p, view_text, false); - - //Append the text message - appendText(chat.mText, FALSE, style_params); + //Handle IRC styled /me messages. + std::string prefix = chat.mText.substr(0, 4); + if (prefix == "/me " || prefix == "/me'") + { + style_params.font.style = "ITALIC"; - mLastFromName = chat.mFromName; + if (chat.mFromName.size() > 0) + appendText(chat.mFromName + " ", TRUE, style_params); + appendText(chat.mText.substr(4), FALSE, style_params); + } + else + appendText(chat.mText, FALSE, style_params); blockUndo(); } + -- cgit v1.2.3