From ae79bc0da2e01eb07f5adbb6ecfd4e9a66cd8501 Mon Sep 17 00:00:00 2001 From: Tozh Date: Sun, 20 Mar 2011 23:54:05 -0400 Subject: [PATCH] added wait for the display name update in nearby chat v1 compatibility mode --- indra/newview/llchathistory.cpp | 43 +++++++++++++++++++++++++++------ indra/newview/llchathistory.h | 5 +++- indra/newview/llnearbychat.cpp | 2 +- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 9f3be05d99..40088c63de 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -695,6 +695,19 @@ void LLChatHistory::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName mDisplayName_Username = mDisplayName + " ("+av_name.mUsername+")"; } +//-TT Display names timing in chat +void LLChatHistory::lookupDisplayNames(const LLChat& chat) +{ + // resolve display names if necessary + if (gSavedSettings.getBOOL("UseDisplayNames")) + { + mDisplayName=chat.mFromName; + mDisplayName_Username=chat.mFromName; + LLAvatarNameCache::get(chat.mFromID,boost::bind(&LLChatHistory::onAvatarNameCache, this, _1, _2)); + } +} +//-TT + void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LLStyle::Params& input_append_params) { @@ -703,13 +716,15 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL //time to get an answer back before it's needed. if (use_plain_text_chat_history) { - // resolve display names if necessary - if (gSavedSettings.getBOOL("UseDisplayNames")) - { - mDisplayName=chat.mFromName; - mDisplayName_Username=chat.mFromName; - LLAvatarNameCache::get(chat.mFromID,boost::bind(&LLChatHistory::onAvatarNameCache, this, _1, _2)); - } + lookupDisplayNames(chat); + //ms_sleep(250); + //// resolve display names if necessary + //if (gSavedSettings.getBOOL("UseDisplayNames")) + //{ + // mDisplayName=chat.mFromName; + // mDisplayName_Username=chat.mFromName; + // LLAvatarNameCache::get(chat.mFromID,boost::bind(&LLChatHistory::onAvatarNameCache, this, _1, _2)); + //} } llassert(mEditor); @@ -863,10 +878,12 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL link_params.readonly_color(header_name_color); if ((gSavedSettings.getBOOL("NameTagShowUsernames")) && (gSavedSettings.getBOOL("UseDisplayNames"))) { + checkDisplayName(); mEditor->appendText(mDisplayName_Username, false, link_params); } else if (gSavedSettings.getBOOL("UseDisplayNames")) { + checkDisplayName(); mEditor->appendText(mDisplayName, false, link_params); } else @@ -1044,6 +1061,18 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL } } +bool LLChatHistory::checkDisplayName() +{ + for (int i = 0; i <=20; i++) + { + if (mDisplayName.empty()) + ms_sleep(50); + else + return true; + } + return false; +} + void LLChatHistory::draw() { if (mEditor->scrolledToEnd()) diff --git a/indra/newview/llchathistory.h b/indra/newview/llchathistory.h index efacf285ae..fd4836a05d 100644 --- a/indra/newview/llchathistory.h +++ b/indra/newview/llchathistory.h @@ -118,7 +118,10 @@ class LLChatHistory : public LLUICtrl */ void appendMessage(const LLChat& chat, const LLSD &args = LLSD(), const LLStyle::Params& input_append_params = LLStyle::Params()); /*virtual*/ void clear(); - +//-TT Display names timing in chat + void lookupDisplayNames(const LLChat& chat); + bool checkDisplayName(); +//-TT private: std::string mLastFromName; LLUUID mLastFromID; diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index bd18905a9c..dd499f4339 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -235,11 +235,11 @@ std::string appendTime() void LLNearbyChat::addMessage(const LLChat& chat,bool archive,const LLSD &args) { LLChat& tmp_chat = const_cast(chat); + bool use_plain_text_chat_history = gSavedSettings.getBOOL("PlainTextChatHistory"); if(tmp_chat.mTimeStr.empty()) tmp_chat.mTimeStr = appendTime(); - bool use_plain_text_chat_history = gSavedSettings.getBOOL("PlainTextChatHistory"); if (!chat.mMuted) {