Refactor display name handling based on display name and username visibility setting

Ansariel 2014-05-16 10:05:54 +02:00
parent f662c413c5
commit 429599f8bc
4 changed files with 32 additions and 48 deletions

View File

@ -350,3 +350,22 @@ LLSD FSCommon::populateGroupCount()
return LLSD(groupcountstring);
}
std::string FSCommon::getAvatarNameByDisplaySettings(const LLAvatarName& av_name)
{
std::string name;
static LLCachedControl<bool> NameTagShowUsernames(gSavedSettings, "NameTagShowUsernames");
static LLCachedControl<bool> UseDisplayNames(gSavedSettings, "UseDisplayNames");
if ((NameTagShowUsernames) && (UseDisplayNames))
{
name = av_name.getCompleteName();
}
else if (UseDisplayNames)
{
name = av_name.getDisplayName();
}
else
{
name = av_name.getUserNameForDisplay();
}
return name;
}

View File

@ -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

View File

@ -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<bool> nameTagShowUsernames(gSavedSettings, "NameTagShowUsernames");
static LLCachedControl<bool> useDisplayNames(gSavedSettings, "UseDisplayNames");
static LLCachedControl<bool> 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<bool> im_coloring(gSavedSettings, "FSColorIMsDistinctly");
LLColor4 textColor = LLUIColorTable::instance().getColor( im_coloring ? "AgentIMColor" : "AgentChatColor" );
// <FS:CR> FIRE-1061 - Color friends, lindens, muted, etc

View File

@ -62,14 +62,14 @@
#include "llvoavatar.h"
#include "llavataractions.h"
#include "lggcontactsets.h"
// <FS:Ansariel> [FS communication UI]
// Firestorm includes
#include "fscommon.h"
#include "fsfloaterim.h"
#include "fsfloaternearbychat.h"
// <FS:Ansariel> [FS communication UI]
#include "fskeywords.h"
#include "lggcontactsets.h"
#include "llfloaterreg.h"
#include "llnotificationmanager.h"
#include "fskeywords.h" // <FS:PP> 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;
// <FS:Ansariel> Make name clickable
// args["NAME"] = av_name.getDisplayName();
std::string used_name;
static LLCachedControl<bool> NameTagShowUsernames(gSavedSettings, "NameTagShowUsernames");
static LLCachedControl<bool> 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;
// </FS:Ansariel>
@ -1092,20 +1078,7 @@ bool LLCollectAllBuddies::operator()(const LLUUID& buddy_id, LLRelationship* bud
LLAvatarNameCache::get(buddy_id, &av_name);
// <FS:Ansariel> FIRE-13756: Friends avatar picker only shows display name
//mFullName = av_name.getDisplayName();
static LLCachedControl<bool> NameTagShowUsernames(gSavedSettings, "NameTagShowUsernames");
static LLCachedControl<bool> 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);
// </FS:Ansariel>
buddy_map_t::value_type value(mFullName, buddy_id);
if(buddy->isOnline())