From 6048c2405bfe4bbbc56f1ddcea7f87920967fd8c Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Mon, 20 May 2013 08:39:51 -0400 Subject: [PATCH] Correct the (hopefully) last chat color issues~ --- indra/newview/llfloaterchat.cpp | 72 +++++---------------------------- indra/newview/llimview.cpp | 53 ++++++++++++++---------- 2 files changed, 42 insertions(+), 83 deletions(-) diff --git a/indra/newview/llfloaterchat.cpp b/indra/newview/llfloaterchat.cpp index a96dfdffa..bf92422a1 100644 --- a/indra/newview/llfloaterchat.cpp +++ b/indra/newview/llfloaterchat.cpp @@ -72,7 +72,8 @@ // // Global statics // -LLColor4 get_text_color(const LLChat& chat); +LLColor4 agent_chat_color(const LLUUID& id, const std::string&, bool local_chat = true); +LLColor4 get_text_color(const LLChat& chat, bool from_im = false); // // Member Functions @@ -165,13 +166,12 @@ void LLFloaterChat::handleVisibilityChange(BOOL new_visibility) // virtual void LLFloaterChat::onFocusReceived() { - LLView* chat_editor = getChildView("Chat Editor"); - if (getVisible() && childIsVisible("Chat Editor")) + LLUICtrl* chat_editor = getChild("Chat Editor"); + if (getVisible() && chat_editor->getVisible()) { gFocusMgr.setKeyboardFocus(chat_editor); - LLUICtrl * ctrl = static_cast(chat_editor); - ctrl->setFocus(TRUE); + chat_editor->setFocus(TRUE); } LLFloater::onFocusReceived(); @@ -424,7 +424,7 @@ void LLFloaterChat::addChat(const LLChat& chat, BOOL from_instant_message, BOOL local_agent) { - LLColor4 text_color = get_text_color(chat); + LLColor4 text_color = get_text_color(chat, from_instant_message); BOOL invisible_script_debug_chat = chat.mChatType == CHAT_TYPE_DEBUG_MSG @@ -459,14 +459,6 @@ void LLFloaterChat::addChat(const LLChat& chat, && gConsole && !local_agent) { - if (chat.mSourceType == CHAT_SOURCE_SYSTEM) - { - text_color = gSavedSettings.getColor("SystemChatColor"); - } - else if(from_instant_message) - { - text_color = gSavedSettings.getColor("IMChatColor"); - } // We display anything if it's not an IM. If it's an IM, check pref... if ( !from_instant_message || gSavedSettings.getBOOL("IMInChatConsole") ) { @@ -532,7 +524,7 @@ void LLFloaterChat::triggerAlerts(const std::string& text) } } -LLColor4 get_text_color(const LLChat& chat) +LLColor4 get_text_color(const LLChat& chat, bool from_im) { LLColor4 text_color; @@ -552,48 +544,7 @@ LLColor4 get_text_color(const LLChat& chat) text_color = gSavedSettings.getColor4("SystemChatColor"); break; case CHAT_SOURCE_AGENT: - if (chat.mFromID.isNull()) - { - text_color = gSavedSettings.getColor4("SystemChatColor"); - } - else - { - if(gAgent.getID() == chat.mFromID) - { - text_color = gSavedSettings.getColor4("UserChatColor"); - } - else - { - static LLCachedControl color_linden_chat("ColorLindenChat"); - if (color_linden_chat && LLMuteList::getInstance()->isLinden(chat.mFromName)) - { - text_color = gSavedSettings.getColor4("AscentLindenColor"); - } - else if (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) - { - static LLCachedControl color_friend_chat("ColorFriendChat"); - static LLCachedControl color_eo_chat("ColorEstateOwnerChat"); - if (color_friend_chat && LLAvatarTracker::instance().isBuddy(chat.mFromID)) - { - text_color = gSavedSettings.getColor4("AscentFriendColor"); - } - else if (color_eo_chat) - { - LLViewerRegion* parent_estate = gAgent.getRegion(); - if (parent_estate && parent_estate->isAlive() && chat.mFromID == parent_estate->getOwner()) - text_color = gSavedSettings.getColor4("AscentEstateOwnerColor"); - else - text_color = gSavedSettings.getColor4("AgentChatColor"); - } - else - text_color = gSavedSettings.getColor4("AgentChatColor"); - } - else - { - text_color = gSavedSettings.getColor4("AgentChatColor"); - } - } - } + text_color = agent_chat_color(chat.mFromID, chat.mFromName, !from_im); break; case CHAT_SOURCE_OBJECT: if (chat.mChatType == CHAT_TYPE_DEBUG_MSG) @@ -736,13 +687,12 @@ void LLFloaterChat::hide(LLFloater* instance, const LLSD& key) BOOL LLFloaterChat::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash ) { - LLView* chat_editor = getChildView("Chat Editor"); - if (getVisible() && childIsVisible("Chat Editor")) + LLUICtrl* chat_editor = getChild("Chat Editor"); + if (getVisible() && chat_editor->getVisible()) { gFocusMgr.setKeyboardFocus(chat_editor); - LLUICtrl * ctrl = static_cast(chat_editor); - ctrl->setFocus(TRUE); + chat_editor->setFocus(TRUE); return TRUE; } diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 45362705d..f87b29525 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -88,6 +88,36 @@ LLIMMgr* gIMMgr = NULL; // // Helper Functions // +LLColor4 agent_chat_color(const LLUUID& id, const std::string& name, bool local_chat) +{ + if (id.isNull() || (name == SYSTEM_FROM)) + return gSavedSettings.getColor4("SystemChatColor"); + + if (id == gAgentID) + return gSavedSettings.getColor4("UserChatColor"); + + static const LLCachedControl color_linden_chat("ColorLindenChat"); + if (color_linden_chat && LLMuteList::getInstance()->isLinden(name)) + return gSavedSettings.getColor4("AscentLindenColor"); + + // [RLVa:LF] Chat colors would identify names, don't use them in local chat if restricted + if (local_chat && rlv_handler_t::isEnabled() && gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + return gSavedSettings.getColor4("AgentChatColor"); + + static const LLCachedControl color_friend_chat("ColorFriendChat"); + if (color_friend_chat && LLAvatarTracker::instance().isBuddy(id)) + return gSavedSettings.getColor4("AscentFriendColor"); + + static const LLCachedControl color_eo_chat("ColorEstateOwnerChat"); + if (color_eo_chat) + { + const LLViewerRegion* parent_estate = gAgent.getRegion(); + if (parent_estate && id == parent_estate->getOwner()) + return gSavedSettings.getColor4("AscentEstateOwnerColor"); + } + + return local_chat ? gSavedSettings.getColor4("AgentChatColor") : gSavedSettings.getColor("IMChatColor"); +} // returns true if a should appear before b //static BOOL group_dictionary_sort( LLGroupData* a, LLGroupData* b ) @@ -565,34 +595,13 @@ void LLIMMgr::addMessage( } // now add message to floater - bool is_from_system = target_id.isNull() || (from == SYSTEM_FROM); - - static LLCachedControl color_linden_chat("ColorLindenChat"); - bool linden = color_linden_chat && LLMuteList::getInstance()->isLinden(from); - - static LLCachedControl color_friend_chat("ColorFriendChat"); - bool contact = color_friend_chat && LLAvatarTracker::instance().isBuddy(other_participant_id); - - static LLCachedControl color_eo_chat("ColorEstateOwnerChat"); - bool estate_owner = false; - if (color_eo_chat) - { - LLViewerRegion* parent_estate = gAgent.getRegion(); - estate_owner = (parent_estate && parent_estate->isAlive() && other_participant_id == parent_estate->getOwner()); - } - - const LLColor4& color = ( is_from_system ? gSavedSettings.getColor4("SystemChatColor") - : linden ? gSavedSettings.getColor4("AscentLindenColor") - : contact ? gSavedSettings.getColor4("AscentFriendColor") - : estate_owner ? gSavedSettings.getColor4("AscentEstateOwnerColor") - : gSavedSettings.getColor("IMChatColor")); + const LLColor4& color = agent_chat_color(other_participant_id, from, false); if ( !link_name ) { floater->addHistoryLine(msg,color); // No name to prepend, so just add the message normally } else { - if( other_participant_id == session_id ) { // The name can be bogus on InWorldz