From 429599f8bc366fa32a65dc11907476b79e4f4c3e Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 16 May 2014 10:05:54 +0200 Subject: [PATCH] Refactor display name handling based on display name and username visibility setting --- indra/newview/fscommon.cpp | 19 ++++++++++++++++ indra/newview/fscommon.h | 4 ++++ indra/newview/fsconsoleutils.cpp | 18 +++------------ indra/newview/llcallingcard.cpp | 39 +++++--------------------------- 4 files changed, 32 insertions(+), 48 deletions(-) diff --git a/indra/newview/fscommon.cpp b/indra/newview/fscommon.cpp index 7f8e18bce7..6e003ced24 100644 --- a/indra/newview/fscommon.cpp +++ b/indra/newview/fscommon.cpp @@ -350,3 +350,22 @@ LLSD FSCommon::populateGroupCount() return LLSD(groupcountstring); } +std::string FSCommon::getAvatarNameByDisplaySettings(const LLAvatarName& av_name) +{ + std::string name; + static LLCachedControl NameTagShowUsernames(gSavedSettings, "NameTagShowUsernames"); + static LLCachedControl UseDisplayNames(gSavedSettings, "UseDisplayNames"); + if ((NameTagShowUsernames) && (UseDisplayNames)) + { + name = av_name.getCompleteName(); + } + else if (UseDisplayNames) + { + name = av_name.getDisplayName(); + } + else + { + name = av_name.getUserNameForDisplay(); + } + return name; +} diff --git a/indra/newview/fscommon.h b/indra/newview/fscommon.h index 403fd4c440..29e8037fac 100644 --- a/indra/newview/fscommon.h +++ b/indra/newview/fscommon.h @@ -33,6 +33,8 @@ #include "llpanelpeople.h" #include "llviewerobject.h" +class LLAvatarName; + const F32 AVATAR_UNKNOWN_Z_OFFSET = -1.f; // Const value for avatars at unknown height const F32 AVATAR_UNKNOWN_RANGE = -1.f; @@ -77,6 +79,8 @@ namespace FSCommon bool checkIsActionEnabled(const LLUUID& av_id, EFSRegistrarFunctionActionType); LLSD populateGroupCount(); + + std::string getAvatarNameByDisplaySettings(const LLAvatarName& av_name); }; #endif // FS_COMMON_H diff --git a/indra/newview/fsconsoleutils.cpp b/indra/newview/fsconsoleutils.cpp index 5d7d0dfd8b..e1d34b9c53 100644 --- a/indra/newview/fsconsoleutils.cpp +++ b/indra/newview/fsconsoleutils.cpp @@ -29,6 +29,7 @@ #include "fsconsoleutils.h" +#include "fscommon.h" #include "fsfloaternearbychat.h" #include "lggcontactsets.h" #include "llagent.h" @@ -245,21 +246,7 @@ void FSConsoleUtils::onProccessInstantMessageNameLookup(const LLUUID& agent_id, message = message.substr(3); } - static LLCachedControl nameTagShowUsernames(gSavedSettings, "NameTagShowUsernames"); - static LLCachedControl useDisplayNames(gSavedSettings, "UseDisplayNames"); - static LLCachedControl im_coloring(gSavedSettings, "FSColorIMsDistinctly"); - if (nameTagShowUsernames && useDisplayNames) - { - senderName = av_name.getCompleteName(); - } - else if (useDisplayNames) - { - senderName = av_name.getDisplayName(); - } - else - { - senderName = av_name.getUserNameForDisplay(); - } + senderName = FSCommon::getAvatarNameByDisplaySettings(av_name); // Replacing the "IM" in front of group chat messages with the actual group name if (!group.empty()) @@ -267,6 +254,7 @@ void FSConsoleUtils::onProccessInstantMessageNameLookup(const LLUUID& agent_id, senderName = "[" + group + "] " + senderName; } + static LLCachedControl im_coloring(gSavedSettings, "FSColorIMsDistinctly"); LLColor4 textColor = LLUIColorTable::instance().getColor( im_coloring ? "AgentIMColor" : "AgentChatColor" ); // FIRE-1061 - Color friends, lindens, muted, etc diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 69f071476e..4efaecb7fb 100755 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -62,14 +62,14 @@ #include "llvoavatar.h" #include "llavataractions.h" -#include "lggcontactsets.h" -// [FS communication UI] +// Firestorm includes +#include "fscommon.h" #include "fsfloaterim.h" #include "fsfloaternearbychat.h" -// [FS communication UI] +#include "fskeywords.h" +#include "lggcontactsets.h" #include "llfloaterreg.h" #include "llnotificationmanager.h" -#include "fskeywords.h" // FIRE-10178: Keyword Alerts in group IM do not work unless the group is in the foreground ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs @@ -817,21 +817,7 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id, LLSD args; // Make name clickable // args["NAME"] = av_name.getDisplayName(); - std::string used_name; - static LLCachedControl NameTagShowUsernames(gSavedSettings, "NameTagShowUsernames"); - static LLCachedControl UseDisplayNames(gSavedSettings, "UseDisplayNames"); - if ((NameTagShowUsernames) && (UseDisplayNames)) - { - used_name = av_name.getCompleteName(); - } - else if (UseDisplayNames) - { - used_name = av_name.getDisplayName(); - } - else - { - used_name = av_name.getUserNameForDisplay(); - } + std::string used_name = FSCommon::getAvatarNameByDisplaySettings(av_name); args["NAME"] = used_name; // @@ -1092,20 +1078,7 @@ bool LLCollectAllBuddies::operator()(const LLUUID& buddy_id, LLRelationship* bud LLAvatarNameCache::get(buddy_id, &av_name); // FIRE-13756: Friends avatar picker only shows display name //mFullName = av_name.getDisplayName(); - static LLCachedControl NameTagShowUsernames(gSavedSettings, "NameTagShowUsernames"); - static LLCachedControl UseDisplayNames(gSavedSettings, "UseDisplayNames"); - if ((NameTagShowUsernames) && (UseDisplayNames)) - { - mFullName = av_name.getCompleteName(); - } - else if (UseDisplayNames) - { - mFullName = av_name.getDisplayName(); - } - else - { - mFullName = av_name.getUserNameForDisplay(); - } + mFullName = FSCommon::getAvatarNameByDisplaySettings(av_name); // buddy_map_t::value_type value(mFullName, buddy_id); if(buddy->isOnline())