summaryrefslogtreecommitdiff
path: root/indra/newview/llchathistory.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2010-10-22 17:39:03 -0700
committerMerov Linden <merov@lindenlab.com>2010-10-22 17:39:03 -0700
commita0714f01804a2a2220bd72c3adf06f097ad21b73 (patch)
treedb304a8eca349020b48ae927fd8a534264a6ed83 /indra/newview/llchathistory.cpp
parente3ecffc180ae50a0e8b726a061ec39cbe591326e (diff)
parentde6f7e19c44d267d3224c56941c2ab27677c406f (diff)
Merge with viewer-development
Diffstat (limited to 'indra/newview/llchathistory.cpp')
-rw-r--r--indra/newview/llchathistory.cpp92
1 files changed, 76 insertions, 16 deletions
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index eb10add254..378c4358b3 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -26,10 +26,12 @@
#include "llviewerprecompiledheaders.h"
+#include "llchathistory.h"
+
+#include "llavatarnamecache.h"
#include "llinstantmessage.h"
#include "llimview.h"
-#include "llchathistory.h"
#include "llcommandhandler.h"
#include "llpanel.h"
#include "lluictrlfactory.h"
@@ -53,6 +55,7 @@
#include "llworld.h"
#include "lluiconstants.h"
+#include "llviewercontrol.h"
#include "llsidetray.h"//for blocked objects panel
@@ -98,6 +101,18 @@ LLObjectIMHandler gObjectIMHandler;
class LLChatHistoryHeader: public LLPanel
{
public:
+ LLChatHistoryHeader()
+ : LLPanel(),
+ mPopupMenuHandleAvatar(),
+ mPopupMenuHandleObject(),
+ mAvatarID(),
+ mSourceType(CHAT_SOURCE_UNKNOWN),
+ mFrom(),
+ mSessionID(),
+ mMinUserNameWidth(0),
+ mUserNameFont(NULL)
+ {}
+
static LLChatHistoryHeader* createInstance(const std::string& file_name)
{
LLChatHistoryHeader* pInstance = new LLChatHistoryHeader;
@@ -240,7 +255,6 @@ public:
mAvatarID = chat.mFromID;
mSessionID = chat.mSessionID;
mSourceType = chat.mSourceType;
- gCacheName->get(mAvatarID, FALSE, boost::bind(&LLChatHistoryHeader::nameUpdatedCallback, this, _1, _2, _3, _4));
//*TODO overly defensive thing, source type should be maintained out there
if((chat.mFromID.isNull() && chat.mFromName.empty()) || chat.mFromName == SYSTEM_FROM && chat.mFromID.isNull())
@@ -248,22 +262,40 @@ public:
mSourceType = CHAT_SOURCE_SYSTEM;
}
- LLTextBox* userName = getChild<LLTextBox>("user_name");
+ mUserNameFont = style_params.font();
+ LLTextBox* user_name = getChild<LLTextBox>("user_name");
+ user_name->setReadOnlyColor(style_params.readonly_color());
+ user_name->setColor(style_params.color());
- userName->setReadOnlyColor(style_params.readonly_color());
- userName->setColor(style_params.color());
-
- userName->setValue(chat.mFromName);
- mFrom = chat.mFromName;
- if (chat.mFromName.empty() || CHAT_SOURCE_SYSTEM == mSourceType)
+ if (chat.mFromName.empty()
+ || mSourceType == CHAT_SOURCE_SYSTEM
+ || mAvatarID.isNull())
{
mFrom = LLTrans::getString("SECOND_LIFE");
- userName->setValue(mFrom);
+ user_name->setValue(mFrom);
+ updateMinUserNameWidth();
+ }
+ else if (mSourceType == CHAT_SOURCE_AGENT
+ && chat.mChatStyle != CHAT_STYLE_HISTORY)
+ {
+ // ...from a normal user, lookup the name and fill in later.
+ // *NOTE: Do not do this for chat history logs, otherwise the viewer
+ // will flood the People API with lookup requests on startup
+
+ // Start with blank so sample data from XUI XML doesn't
+ // flash on the screen
+ user_name->setValue( LLSD() );
+ LLAvatarNameCache::get(mAvatarID,
+ boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2));
+ }
+ else {
+ // ...from an object, just use name as given
+ mFrom = chat.mFromName;
+ user_name->setValue(mFrom);
+ updateMinUserNameWidth();
}
- mMinUserNameWidth = style_params.font()->getWidth(userName->getWText().c_str()) + PADDING;
-
setTimeField(chat);
LLAvatarIconCtrl* icon = getChild<LLAvatarIconCtrl>("avatar_icon");
@@ -317,12 +349,39 @@ public:
LLPanel::draw();
}
- void nameUpdatedCallback(const LLUUID& id,const std::string& first,const std::string& last,BOOL is_group)
+ void updateMinUserNameWidth()
{
- if (id != mAvatarID)
- return;
- mFrom = first + " " + last;
+ if (mUserNameFont)
+ {
+ LLTextBox* user_name = getChild<LLTextBox>("user_name");
+ const LLWString& text = user_name->getWText();
+ mMinUserNameWidth = mUserNameFont->getWidth(text.c_str()) + PADDING;
+ }
}
+
+ void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name)
+ {
+ mFrom = av_name.mDisplayName;
+
+ LLTextBox* user_name = getChild<LLTextBox>("user_name");
+ user_name->setValue( LLSD(av_name.mDisplayName ) );
+ user_name->setToolTip( av_name.mUsername );
+
+ if (gSavedSettings.getBOOL("NameTagShowUsernames") && LLAvatarNameCache::useDisplayNames())
+ {
+ 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(" - " + av_name.mUsername, FALSE, style_params_name);
+ }
+ setToolTip( av_name.mUsername );
+ // name might have changed, update width
+ updateMinUserNameWidth();
+ }
+
protected:
static const S32 PADDING = 20;
@@ -449,6 +508,7 @@ protected:
LLUUID mSessionID;
S32 mMinUserNameWidth;
+ const LLFontGL* mUserNameFont;
};
LLUICtrl* LLChatHistoryHeader::sInfoCtrl = NULL;