From 1baf1d218644ac5dc00d9b41119a1ef168c709a2 Mon Sep 17 00:00:00 2001 From: angela Date: Mon, 16 Nov 2009 20:46:40 +0800 Subject: fix chat format for /me --- indra/newview/llchathistory.cpp | 6 +++-- indra/newview/llchathistory.h | 2 +- indra/newview/llchatitemscontainerctrl.cpp | 24 ++++++++++++++++-- indra/newview/llexpandabletextbox.cpp | 5 ++-- indra/newview/llimfloater.cpp | 28 ++++++++++++++++++++- indra/newview/llnearbychat.cpp | 28 ++++++++++++++++++++- indra/newview/llnearbychathandler.cpp | 1 + indra/newview/lltoastimpanel.cpp | 4 +-- indra/newview/llviewerchat.cpp | 17 +++++++++++++ indra/newview/llviewerchat.h | 3 +-- indra/newview/llviewermessage.cpp | 40 ++++++++++++++++-------------- 11 files changed, 126 insertions(+), 32 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 028bb7a384..bec8eb2666 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -345,7 +345,7 @@ LLView* LLChatHistory::getHeader(const LLChat& chat,const LLStyle::Params& style return header; } -void LLChatHistory::appendWidgetMessage(const LLChat& chat) +void LLChatHistory::appendWidgetMessage(const LLChat& chat, const LLStyle::Params& input_append_params) { LLView* view = NULL; std::string view_text = "\n[" + formatCurrentTime() + "] "; @@ -367,7 +367,9 @@ void LLChatHistory::appendWidgetMessage(const LLChat& chat) style_params.color(txt_color); style_params.readonly_color(txt_color); style_params.font(fontp); - + style_params.italic = input_append_params.italic; + style_params.underline = input_append_params.underline; + style_params.bold = input_append_params.bold; if (mLastFromName == chat.mFromName) { diff --git a/indra/newview/llchathistory.h b/indra/newview/llchathistory.h index f689a225fe..c89d4b4ec6 100644 --- a/indra/newview/llchathistory.h +++ b/indra/newview/llchathistory.h @@ -109,7 +109,7 @@ class LLChatHistory : public LLTextEditor * @param time time of a message. * @param message message itself. */ - void appendWidgetMessage(const LLChat& chat); + void appendWidgetMessage(const LLChat& chat, const LLStyle::Params& input_append_params = LLStyle::Params()); private: std::string mLastFromName; diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index d2e3247250..1cc6b2beef 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -173,10 +173,28 @@ void LLNearbyChatToastPanel::init(LLSD& notification) caption->getChild("msg_time", false)->setText(appendTime() , style_params ); - LLChatMsgBox* msg_text = getChild("msg_text", false); - msg_text->setText(mText, style_params); + + if(notification["chat_style"].asInteger()== CHAT_STYLE_IRC) + { + if (mFromName.size() > 0) + { + style_params.italic= true; + + msg_text->setText(mFromName, style_params); + } + mText = mText.substr(3); + style_params.underline = true; + msg_text->addText(mText,style_params); + } + else + { + msg_text->setText(mText, style_params); + } + + + LLUICtrl* msg_inspector = caption->getChild("msg_inspector"); if(mSourceType != CHAT_SOURCE_AGENT) msg_inspector->setVisible(false); @@ -196,6 +214,8 @@ void LLNearbyChatToastPanel::setMessage (const LLChat& chat_msg) notification["from_id"] = chat_msg.mFromID; notification["time"] = chat_msg.mTime; notification["source"] = (S32)chat_msg.mSourceType; + notification["chat_type"] = (S32)chat_msg.mChatType; + notification["chat_style"] = (S32)chat_msg.mChatStyle; std::string r_color_name="White"; F32 r_color_alpha = 1.0f; diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp index 6d7da107ac..27df6be730 100644 --- a/indra/newview/llexpandabletextbox.cpp +++ b/indra/newview/llexpandabletextbox.cpp @@ -80,7 +80,7 @@ public: draw_rect.mRight, draw_rect.mTop, mStyle->getColor(), LLFontGL::RIGHT, LLFontGL::TOP, - 0, + mStyle->getFontStyle(), mStyle->getShadowType(), end - start, draw_rect.getWidth(), &right_x, @@ -164,8 +164,7 @@ void LLExpandableTextBox::LLTextBoxEx::showExpandText() S32 last_line = visible_lines.second - 1; LLStyle::Params expander_style = getDefaultStyle(); - expander_style.font.name.setIfNotProvided(LLFontGL::nameFromFont(expander_style.font)); - expander_style.font.style = "UNDERLINE"; + expander_style.underline = true; expander_style.color = LLUIColorTable::instance().getColor("HTMLLinkColor"); LLExpanderSegment* expanderp = new LLExpanderSegment(new LLStyle(expander_style), getLineStart(last_line), getLength() + 1, mExpanderLabel, *this); insertSegment(expanderp); diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index e3121fbc7a..dff27ee032 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -477,7 +477,33 @@ void LLIMFloater::updateMessages() chat.mFromName = from; chat.mText = message; - mChatHistory->appendWidgetMessage(chat); + LLStyle::Params append_style_params; + //Handle IRC styled /me messages. + std::string prefix = message.substr(0, 4); + if (prefix == "/me " || prefix == "/me'") + { + if (from.size() > 0) + { + append_style_params.italic= true; + chat.mText = from + " "; + mChatHistory->appendWidgetMessage(chat, append_style_params); + } + message = message.substr(3); + + LLColor4 txt_color = LLUIColorTable::instance().getColor("White"); + LLViewerChat::getChatColor(chat,txt_color); + LLFontGL* fontp = LLViewerChat::getChatFont(); + append_style_params.color(txt_color); + append_style_params.readonly_color(txt_color); + append_style_params.font(fontp); + append_style_params.underline = true; + mChatHistory->appendText(message, FALSE, append_style_params); + } + else + { + chat.mText = message; + mChatHistory->appendWidgetMessage(chat); + } mLastMessageIndex = msg["index"].asInteger(); } diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index 85db69174d..68677decae 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -155,7 +155,33 @@ void LLNearbyChat::addMessage(const LLChat& chat) if (!chat.mMuted) { - mChatHistory->appendWidgetMessage(chat); + std::string message = chat.mText; + std::string prefix = message.substr(0, 4); + if (chat.mChatStyle == CHAT_STYLE_IRC) + { + LLStyle::Params append_style_params; + if (chat.mFromName.size() > 0) + { + append_style_params.italic= true; + LLChat add_chat=chat; + add_chat.mText = chat.mFromName + " "; + mChatHistory->appendWidgetMessage(add_chat, append_style_params); + } + message = message.substr(3); + + LLColor4 txt_color = LLUIColorTable::instance().getColor("White"); + LLViewerChat::getChatColor(chat,txt_color); + LLFontGL* fontp = LLViewerChat::getChatFont(); + append_style_params.color(txt_color); + append_style_params.readonly_color(txt_color); + append_style_params.font(fontp); + append_style_params.underline = true; + mChatHistory->appendText(message, FALSE, append_style_params); + } + else + { + mChatHistory->appendWidgetMessage(chat); + } } } diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index 458845fff3..74a75d0369 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -341,6 +341,7 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg) notification["time"] = chat_msg.mTime; notification["source"] = (S32)chat_msg.mSourceType; notification["chat_type"] = (S32)chat_msg.mChatType; + notification["chat_style"] = (S32)chat_msg.mChatStyle; std::string r_color_name = "White"; F32 r_color_alpha = 1.0f; diff --git a/indra/newview/lltoastimpanel.cpp b/indra/newview/lltoastimpanel.cpp index 1ea5f515b7..3acab85bf7 100644 --- a/indra/newview/lltoastimpanel.cpp +++ b/indra/newview/lltoastimpanel.cpp @@ -56,9 +56,9 @@ LLToastIMPanel::LLToastIMPanel(LLToastIMPanel::Params &p) : LLToastPanel(p.notif if (prefix == "/me " || prefix == "/me'") { mMessage->clear(); - style_params.font.style= "ITALIC"; + style_params.italic = true; mMessage->appendText(p.from + " ", FALSE, style_params); - style_params.font.style= "UNDERLINE"; + style_params.underline = true; mMessage->appendText(p.message.substr(3), FALSE, style_params); } else diff --git a/indra/newview/llviewerchat.cpp b/indra/newview/llviewerchat.cpp index d65a060bbc..ccf9ce9056 100644 --- a/indra/newview/llviewerchat.cpp +++ b/indra/newview/llviewerchat.cpp @@ -201,3 +201,20 @@ S32 LLViewerChat::getChatFontSize() { return gSavedSettings.getS32("ChatFontSize"); } + + +//static +void LLViewerChat::formatChatMsg(const LLChat& chat, std::string& formated_msg) +{ + std::string tmpmsg = chat.mText; + + if(chat.mChatStyle == CHAT_STYLE_IRC) + { + formated_msg = chat.mFromName + tmpmsg.substr(3); + } + else + { + formated_msg = tmpmsg; + } + +} \ No newline at end of file diff --git a/indra/newview/llviewerchat.h b/indra/newview/llviewerchat.h index d8840d5dd2..502d6ea7e5 100644 --- a/indra/newview/llviewerchat.h +++ b/indra/newview/llviewerchat.h @@ -45,8 +45,7 @@ public: static void getChatColor(const LLChat& chat, std::string& r_color_name, F32& r_color_alpha); static LLFontGL* getChatFont(); static S32 getChatFontSize(); - - + static void formatChatMsg(const LLChat& chat, std::string& formated_msg); }; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 0153116887..ef6a621323 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -2343,14 +2343,14 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) std::string prefix = mesg.substr(0, 4); if (prefix == "/me " || prefix == "/me'") { - chat.mText = from_name; - chat.mText += mesg.substr(3); +// chat.mText = from_name; +// chat.mText += mesg.substr(3); ircstyle = TRUE; } - else - { +// else +// { chat.mText = mesg; - } +// } // Look for the start of typing so we can put "..." in the bubbles. if (CHAT_TYPE_START == chat.mChatType) @@ -2376,19 +2376,6 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) return; } - // We have a real utterance now, so can stop showing "..." and proceed. - if (chatter && chatter->isAvatar()) - { - LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, FALSE); - ((LLVOAvatar*)chatter)->stopTyping(); - - if (!is_muted && !is_busy) - { - visible_in_chat_bubble = gSavedSettings.getBOOL("UseChatBubbles"); - ((LLVOAvatar*)chatter)->addChat(chat); - } - } - // Look for IRC-style emotes if (ircstyle) { @@ -2428,6 +2415,23 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) chat.mText += mesg; } + // We have a real utterance now, so can stop showing "..." and proceed. + if (chatter && chatter->isAvatar()) + { + LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, FALSE); + ((LLVOAvatar*)chatter)->stopTyping(); + + if (!is_muted && !is_busy) + { + visible_in_chat_bubble = gSavedSettings.getBOOL("UseChatBubbles"); + std::string formated_msg = ""; + LLViewerChat::formatChatMsg(chat, formated_msg); + LLChat chat_bubble = chat; + chat_bubble.mText = formated_msg; + ((LLVOAvatar*)chatter)->addChat(chat_bubble); + } + } + if (chatter) { chat.mPosAgent = chatter->getPositionAgent(); -- cgit v1.2.3