diff options
author | Kyle Ambroff <ambroff@lindenlab.com> | 2010-10-29 19:52:01 -0700 |
---|---|---|
committer | Kyle Ambroff <ambroff@lindenlab.com> | 2010-10-29 19:52:01 -0700 |
commit | fa17864382a64c90e9106a54368386f6e4115d67 (patch) | |
tree | 7883e97e7bd4d3b0a7d9ac7a0096424e71e0c1ad /indra/newview/llchathistory.cpp | |
parent | 4b49b0eff79c41060ba53d0d33ff83b4c18e277b (diff) | |
parent | 42b49397d2347b6a97394ce0b35efe5cc2ab44a2 (diff) |
Merge with lindenlab/viewer-development
Diffstat (limited to 'indra/newview/llchathistory.cpp')
-rw-r--r-- | indra/newview/llchathistory.cpp | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 378c4358b3..3dc6e786d3 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -54,6 +54,7 @@ #include "llviewertexteditor.h" #include "llworld.h" #include "lluiconstants.h" +#include "llstring.h" #include "llviewercontrol.h" @@ -260,7 +261,7 @@ public: if((chat.mFromID.isNull() && chat.mFromName.empty()) || chat.mFromName == SYSTEM_FROM && chat.mFromID.isNull()) { mSourceType = CHAT_SOURCE_SYSTEM; - } + } mUserNameFont = style_params.font(); LLTextBox* user_name = getChild<LLTextBox>("user_name"); @@ -268,14 +269,14 @@ public: user_name->setColor(style_params.color()); if (chat.mFromName.empty() - || mSourceType == CHAT_SOURCE_SYSTEM - || mAvatarID.isNull()) + || mSourceType == CHAT_SOURCE_SYSTEM) { mFrom = LLTrans::getString("SECOND_LIFE"); user_name->setValue(mFrom); updateMinUserNameWidth(); } else if (mSourceType == CHAT_SOURCE_AGENT + && !mAvatarID.isNull() && chat.mChatStyle != CHAT_STYLE_HISTORY) { // ...from a normal user, lookup the name and fill in later. @@ -288,7 +289,41 @@ public: LLAvatarNameCache::get(mAvatarID, boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2)); } - else { + else if (chat.mChatStyle == CHAT_STYLE_HISTORY || + mSourceType == CHAT_SOURCE_AGENT) + { + //if it's an avatar name with a username add formatting + S32 username_start = chat.mFromName.rfind(" ("); + S32 username_end = chat.mFromName.rfind(')'); + + if (username_start != std::string::npos && + username_end == (chat.mFromName.length() - 1)) + { + mFrom = chat.mFromName.substr(0, username_start); + user_name->setValue(mFrom); + + if (gSavedSettings.getBOOL("NameTagShowUsernames")) + { + std::string username = chat.mFromName.substr(username_start + 2); + username = username.substr(0, username.length() - 1); + LLStyle::Params style_params_name; + LLColor4 userNameColor = LLUIColorTable::instance().getColor("EmphasisColor"); + style_params_name.color(userNameColor); + style_params_name.font.name("SansSerifSmall"); + style_params_name.font.style("NORMAL"); + style_params_name.readonly_color(userNameColor); + user_name->appendText(" - " + username, FALSE, style_params_name); + } + } + else + { + mFrom = chat.mFromName; + user_name->setValue(mFrom); + updateMinUserNameWidth(); + } + } + else + { // ...from an object, just use name as given mFrom = chat.mFromName; user_name->setValue(mFrom); @@ -367,7 +402,9 @@ public: user_name->setValue( LLSD(av_name.mDisplayName ) ); user_name->setToolTip( av_name.mUsername ); - if (gSavedSettings.getBOOL("NameTagShowUsernames") && LLAvatarNameCache::useDisplayNames()) + if (gSavedSettings.getBOOL("NameTagShowUsernames") && + LLAvatarNameCache::useDisplayNames() && + !av_name.mIsDisplayNameDefault) { LLStyle::Params style_params_name; LLColor4 userNameColor = LLUIColorTable::instance().getColor("EmphasisColor"); @@ -753,8 +790,9 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL // (don't let object names with hyperlinks override our objectim Url) LLStyle::Params link_params(style_params); link_params.color.control = "HTMLLinkColor"; + link_params.is_link = true; link_params.link_href = url; - mEditor->appendText("<nolink>" + chat.mFromName + "</nolink>" + delimiter, + mEditor->appendText(chat.mFromName + delimiter, false, link_params); } else if ( chat.mFromName != SYSTEM_FROM && chat.mFromID.notNull() && !message_from_log) @@ -767,7 +805,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL } else { - mEditor->appendText(chat.mFromName + delimiter, false, style_params); + mEditor->appendText("<nolink>" + chat.mFromName + "</nolink>" + delimiter, false, style_params); } } } |