Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions indra/newview/alavatargroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// lib includes
#include "llavatarname.h"
#include "llavatarnamecache.h"
#include "llchat.h"
#include "lluicolor.h"
#include "lluicolortable.h"
#include "lluuid.h"
Expand All @@ -34,6 +35,7 @@
// viewer includes
#include "llagent.h"
#include "llcallingcard.h"
#include "llinstantmessage.h" // SYSTEM_FROM
#include "llmutelist.h"
#include "llviewercontrol.h"
#include "rlvactions.h"
Expand Down Expand Up @@ -294,3 +296,99 @@ std::string ALAvatarGroups::getAvatarColorName(const LLUUID& id, std::string_vie

return out_color_name;
}

bool ALAvatarGroups::getIRCChatColor(const LLChat& chat, LLUIColor& color)
{
static LLCachedControl<bool> enabled(gSavedSettings, "AlchemyChatIRCColorsEnabled", false);
if (!enabled)
{
return false;
}

// Only override "other" speakers; self, system, objects and owner-say keep
// their user-configured chat colors from the existing switch.
if (chat.mSourceType == CHAT_SOURCE_AGENT
&& chat.mFromID.notNull()
&& chat.mFromID != gAgentID
&& SYSTEM_FROM != chat.mFromName
// A stable per-avatar color would defeat @shownames, so skip it while
// restricted from seeing this speaker's name.
&& RlvActions::canShowName(RlvActions::SNC_DEFAULT, chat.mFromID))
{
color = deterministicAgentColor(chat.mFromID);
return true;
}

return false;
}

bool ALAvatarGroups::getIRCNameColor(const LLChat& chat, LLUIColor& color)
{
static LLCachedControl<bool> enabled(gSavedSettings, "AlchemyChatIRCColorsEnabled", false);
if (!enabled)
{
return false;
}

// Keep the default name styling while restricted from seeing this speaker's
// name, matching getIRCChatColor.
if (!RlvActions::canShowName(RlvActions::SNC_DEFAULT, chat.mFromID))
{
return false;
}

color = nameColor(chat.mFromID);
return true;
}

bool ALAvatarGroups::getIRCNameTagColor(const LLUUID& id, LLColor4& color)
{
static LLCachedControl<bool> enabled(gSavedSettings, "AlchemyChatIRCColorsEnabled", false);
static LLCachedControl<bool> name_tags(gSavedSettings, "AlchemyChatIRCColorNameTags", false);
if (!enabled || !name_tags)
{
return false;
}

// Mirror the chat-color override: only other agents get a per-avatar color,
// self keeps the user-configured name tag colors. Skip while restricted from
// seeing this avatar's name so the color can't defeat @shownames. The name
// lightness applied to chat names is applied here too so tags match.
if (id.notNull() && id != gAgentID
&& RlvActions::canShowName(RlvActions::SNC_DEFAULT, id))
{
color = nameColor(id);
return true;
}

return false;
}

LLColor4 ALAvatarGroups::deterministicAgentColor(const LLUUID& id)
{
static LLCachedControl<F32> saturation(gSavedSettings, "AlchemyChatIRCAgentSaturation", 0.7f);
static LLCachedControl<F32> lightness(gSavedSettings, "AlchemyChatIRCAgentLightness", 0.9f);

LLColor4 color;
color.setHSL(static_cast<F32>(id.getCRC32() % 360) / 360.f, saturation(), lightness());
color.mV[VALPHA] = 1.f;

return color;
}

LLColor4 ALAvatarGroups::nameColor(const LLUUID& id)
{
static LLCachedControl<F32> saturation(gSavedSettings, "AlchemyChatIRCAgentSaturation", 0.7f);
static LLCachedControl<F32> name_lightness(gSavedSettings, "AlchemyChatIRCNameLightness", 0.7f);

// Same hue and saturation as the per-agent chat color, but with the name's
// own independent lightness. Built from the same inputs as the chat color
// rather than derived from it, so the chat Lightness slider doesn't bleed
// into the name (a very light/dark chat color loses saturation, and hue at
// the extremes, when round-tripped through RGB).
LLColor4 result;
result.setHSL(static_cast<F32>(id.getCRC32() % 360) / 360.f, saturation(), name_lightness());
result.mV[VALPHA] = 1.f;

return result;
}
14 changes: 14 additions & 0 deletions indra/newview/alavatargroups.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>

class LLChat;
class LLColor4;
class LLUIColor;
class LLUUID;

class ALAvatarGroups final : public LLSingleton < ALAvatarGroups >
Expand Down Expand Up @@ -54,4 +56,16 @@ class ALAvatarGroups final : public LLSingleton < ALAvatarGroups >

LLColor4 getAvatarColor(const LLUUID& id, LLColor4 default_color, EColorType color_type);
std::string getAvatarColorName(const LLUUID& id, std::string_view color_name, EColorType color_type);

// IRC-style chat coloring: when enabled, gives every other speaker a stable
// deterministic color and dims the displayed name relative to its text color.
// Other message categories (self, system, objects, owner-say) keep their
// user-configured chat colors.
bool getIRCChatColor(const LLChat& chat, LLUIColor& color);
bool getIRCNameColor(const LLChat& chat, LLUIColor& color);
bool getIRCNameTagColor(const LLUUID& id, LLColor4& color);

private:
LLColor4 deterministicAgentColor(const LLUUID& id);
LLColor4 nameColor(const LLUUID& id);
};
55 changes: 55 additions & 0 deletions indra/newview/app_settings/settings_alchemy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,61 @@
<key>Value</key>
<string>/tp2cam</string>
</map>
<key>AlchemyChatIRCColorsEnabled</key>
<map>
<key>Comment</key>
<string>Use IRC-style deterministic colors for local chat names and text.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>AlchemyChatIRCColorNameTags</key>
<map>
<key>Comment</key>
<string>Overwrite each other agent's name tag with their IRC-style per-agent chat color.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>AlchemyChatIRCAgentSaturation</key>
<map>
<key>Comment</key>
<string>Saturation of the per-agent IRC-style chat colors (0-1).</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.7</real>
</map>
<key>AlchemyChatIRCAgentLightness</key>
<map>
<key>Comment</key>
<string>Lightness of the per-agent IRC-style chat colors (0-1).</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.9</real>
</map>
<key>AlchemyChatIRCNameLightness</key>
<map>
<key>Comment</key>
<string>Lightness of the displayed name in IRC-style chat colors; shares the chat color's hue and saturation (0-1).</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.7</real>
</map>
<key>AlchemyChatMarkUnnamedObjects</key>
<map>
<key>Comment</key>
Expand Down
15 changes: 15 additions & 0 deletions indra/newview/llchathistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include "llviewercontrol.h"
#include "llviewermenu.h"
#include "llviewerobjectlist.h"
#include "alavatargroups.h"
// [SL:KB] - Patch: Chat-Alerts | Checked: 2012-07-10 (Catznip-3.3)
#include "llaudioengine.h"
#include "lltextparser.h"
Expand Down Expand Up @@ -1338,6 +1339,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
LLUIColor txt_color = LLUIColorTable::instance().getColor("White");
LLUIColor name_color = LLUIColorTable::instance().getColor("ChatHeaderDisplayNameColor"); // <alchemy/>
LLViewerChat::getChatColor(chat, txt_color, alpha);
const bool irc_name_color = ALAvatarGroups::instance().getIRCNameColor(chat, name_color);

LLFontGL* fontp = LLViewerChat::getChatFont();
std::string font_name = LLFontGL::nameFromFont(fontp);
Expand Down Expand Up @@ -1463,6 +1465,11 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
static LLUIColor link_color = LLUIColorTable::instance().getColor("HTMLLinkColor");
link_params.color = link_color;
link_params.readonly_color = link_color;
if (irc_name_color)
{
link_params.color = name_color;
link_params.readonly_color = name_color;
}
link_params.is_link = true;
link_params.link_href = url;

Expand Down Expand Up @@ -1500,6 +1507,14 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
{
LLStyle::Params link_params(body_message_params);
link_params.overwriteFrom(LLStyleMap::instance().lookupAgent(chat.mFromID));
if (irc_name_color)
{
// Keep our dimmed name color instead of letting the agent
// SLURL re-parse to the default HTMLLinkColor link style.
link_params.use_default_link_style = false;
link_params.color = name_color;
link_params.readonly_color = name_color;
}

if (use_irssi_text_chat_history)
{
Expand Down
Loading