aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llnamelistctrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llnamelistctrl.cpp')
-rw-r--r--linden/indra/newview/llnamelistctrl.cpp46
1 files changed, 40 insertions, 6 deletions
diff --git a/linden/indra/newview/llnamelistctrl.cpp b/linden/indra/newview/llnamelistctrl.cpp
index e445df5..e30c129 100644
--- a/linden/indra/newview/llnamelistctrl.cpp
+++ b/linden/indra/newview/llnamelistctrl.cpp
@@ -39,6 +39,7 @@
39#include "llcachename.h" 39#include "llcachename.h"
40#include "llagent.h" 40#include "llagent.h"
41#include "llinventory.h" 41#include "llinventory.h"
42#include "llviewercontrol.h"
42 43
43static LLRegisterWidget<LLNameListCtrl> r("name_list"); 44static LLRegisterWidget<LLNameListCtrl> r("name_list");
44 45
@@ -56,7 +57,8 @@ LLNameListCtrl::LLNameListCtrl(const std::string& name,
56: LLScrollListCtrl(name, rect, cb, userdata, allow_multiple_selection, 57: LLScrollListCtrl(name, rect, cb, userdata, allow_multiple_selection,
57 draw_border), 58 draw_border),
58 mNameColumnIndex(name_column_index), 59 mNameColumnIndex(name_column_index),
59 mAllowCallingCardDrop(FALSE) 60 mAllowCallingCardDrop(FALSE),
61 mUseDisplayNames(FALSE)
60{ 62{
61 setToolTip(tooltip); 63 setToolTip(tooltip);
62 LLNameListCtrl::sInstances.insert(this); 64 LLNameListCtrl::sInstances.insert(this);
@@ -77,7 +79,7 @@ BOOL LLNameListCtrl::addNameItem(const LLUUID& agent_id, EAddPosition pos,
77 //llinfos << "LLNameListCtrl::addNameItem " << agent_id << llendl; 79 //llinfos << "LLNameListCtrl::addNameItem " << agent_id << llendl;
78 80
79 std::string fullname; 81 std::string fullname;
80 BOOL result = gCacheName->getFullName(agent_id, fullname); 82 BOOL result = getResidentName(agent_id, fullname);
81 83
82 fullname.append(suffix); 84 fullname.append(suffix);
83 85
@@ -164,7 +166,7 @@ BOOL LLNameListCtrl::addNameItem(LLScrollListItem* item, EAddPosition pos)
164 //llinfos << "LLNameListCtrl::addNameItem " << item->getUUID() << llendl; 166 //llinfos << "LLNameListCtrl::addNameItem " << item->getUUID() << llendl;
165 167
166 std::string fullname; 168 std::string fullname;
167 BOOL result = gCacheName->getFullName(item->getUUID(), fullname); 169 BOOL result = getResidentName(item->getUUID(), fullname);
168 170
169 LLScrollListCell* cell = (LLScrollListCell*)item->getColumn(mNameColumnIndex); 171 LLScrollListCell* cell = (LLScrollListCell*)item->getColumn(mNameColumnIndex);
170 ((LLScrollListText*)cell)->setText( fullname ); 172 ((LLScrollListText*)cell)->setText( fullname );
@@ -199,7 +201,7 @@ LLScrollListItem* LLNameListCtrl::addElement(const LLSD& value, EAddPosition pos
199 else // normal resident 201 else // normal resident
200 { 202 {
201 std::string name; 203 std::string name;
202 if (gCacheName->getFullName(item->getUUID(), name)) 204 if (getResidentName(item->getUUID(), name))
203 { 205 {
204 fullname = name; 206 fullname = name;
205 } 207 }
@@ -346,6 +348,12 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto
346 name_list->setAllowCallingCardDrop(allow_calling_card_drop); 348 name_list->setAllowCallingCardDrop(allow_calling_card_drop);
347 } 349 }
348 350
351 BOOL use_display_names;
352 if (node->getAttributeBOOL("use_display_names", use_display_names))
353 {
354 name_list->setUseDisplayNames(use_display_names);
355 }
356
349 name_list->setScrollListParameters(node); 357 name_list->setScrollListParameters(node);
350 358
351 name_list->initFromXML(node, parent); 359 name_list->initFromXML(node, parent);
@@ -456,5 +464,31 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto
456 return name_list; 464 return name_list;
457} 465}
458 466
459 467bool LLNameListCtrl::getResidentName(const LLUUID& agent_id, std::string& fullname)
460 468{
469 std::string name;
470 if (gCacheName->getFullName(agent_id, name))
471 {
472 fullname = name;
473 if (mUseDisplayNames && LLAvatarNameCache::useDisplayNames() && !gSavedSettings.getBOOL("LegacyNamesForFriends"))
474 {
475 LLAvatarName avatar_name;
476 if (LLAvatarNameCache::get(agent_id, &avatar_name))
477 {
478 if (LLAvatarNameCache::useDisplayNames() == 1)
479 {
480 fullname = avatar_name.mDisplayName;
481 }
482 else
483 {
484 fullname = avatar_name.getNames();
485 }
486 }
487 }
488 return true;
489 }
490 else
491 {
492 return false;
493 }
494}