From 1ca2a567cd92d756b01abb53728aa21c1c5b0d6c Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Sat, 18 May 2013 19:24:42 -0400 Subject: [PATCH] Improve upon the nametag system Use the user-desired name with Resident stripped out, when on SecondLife grid. When using legacy names without group titles, don't show the last name on a new line. When using chat bubbles or typing bubbles, use the desired tag color. --- indra/newview/llvoavatar.cpp | 46 ++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 843c9ad81..e35c88e0b 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -126,6 +126,7 @@ #pragma warning (disable:4702) #endif +#include #include using namespace LLAvatarAppearanceDefines; @@ -3142,6 +3143,23 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) // LLFontGL::getFontSansSerifSmall()); } + // On SecondLife we can take a shortcut through getPNSName, which will strip out Resident + if (gHippoGridManager->getConnectedGrid()->isSecondLife()) + { + if (!LLAvatarNameCache::getPNSName(getID(), firstnameText)) + { + // ...call this function back when the name arrives and force a rebuild + LLAvatarNameCache::get(getID(), boost::bind(&LLVOAvatar::clearNameTag, this)); + } +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + else if (fRlvShowNames && !isSelf()) + { + firstnameText = RlvStrings::getAnonym(firstnameText); + } +// [/RLVa:KB] + } + else + { // static LLUICachedControl show_display_names("NameTagShowDisplayNames"); // static LLUICachedControl show_usernames("NameTagShowUsernames"); @@ -3214,6 +3232,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) // [/RLVa:KB] } + } static const LLCachedControl allow_nameplate_override ("CCSAllowNameplateOverride", true); std::string client_name = SHClientTagMgr::instance().getClientName(this, is_friend); @@ -3228,7 +3247,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) else if(allow_nameplate_override && !mCCSAttachmentText.empty()) tag_format=mCCSAttachmentText; else - tag_format=sRenderGroupTitles ? "%g\n%f %l %t" : "%f\n%l %t"; + tag_format=sRenderGroupTitles ? "%g\n%f %l %t" : "%f %l %t"; // replace first name, last name and title typedef boost::tokenizer > tokenizer; @@ -3246,21 +3265,18 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) addNameTagLine(client_name, name_tag_color, LLFontGL::NORMAL, LLFontGL::getFontSansSerifSmall()); else { - std::string::size_type index; - while ((index = line.find("%f")) != std::string::npos) - line.replace(index, 2, firstnameText); - while ((index = line.find("%l")) != std::string::npos) + boost::algorithm::replace_all(line, "%f", firstnameText); + if (lastnameText.empty()) //Entire displayname string crammed into firstname so eat the extra space. { - //llinfos << "'" << line.substr(index) << "'" << llendl; - if(lastnameText.empty() && line[index+2] == ' ') //Entire displayname string crammed into firstname - line.replace(index, 3, ""); //so eat the extra space. - else - line.replace(index, 2, lastnameText); + boost::algorithm::replace_all(line, " %l", ""); + boost::algorithm::replace_all(line, "%l", ""); } - while ((index = line.find("%g")) != std::string::npos) - line.replace(index, 2, groupText); - while ((index = line.find("%t")) != std::string::npos) - line.replace(index, 2, client_name); + else + { + boost::algorithm::replace_all(line, "%l", lastnameText); + } + boost::algorithm::replace_all(line, "%g", groupText); + boost::algorithm::replace_all(line, "%t", client_name); LLStringUtil::trim(line); if(!line.empty()) addNameTagLine(line, name_tag_color, LLFontGL::NORMAL, LLFontGL::getFontSansSerif()); @@ -3288,7 +3304,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) std::deque::iterator chat_iter = mChats.begin(); mNameText->clearString(); - LLColor4 new_chat = gColors.getColor( "AvatarNameColor" ); + LLColor4 new_chat = getNameTagColor(is_friend); if (mVisibleChat) { LLColor4 normal_chat = lerp(new_chat, LLColor4(0.8f, 0.8f, 0.8f, 1.f), 0.7f);