|
26 | 26 | // lib includes |
27 | 27 | #include "llavatarname.h" |
28 | 28 | #include "llavatarnamecache.h" |
| 29 | +#include "llchat.h" |
29 | 30 | #include "lluicolor.h" |
30 | 31 | #include "lluicolortable.h" |
31 | 32 | #include "lluuid.h" |
|
34 | 35 | // viewer includes |
35 | 36 | #include "llagent.h" |
36 | 37 | #include "llcallingcard.h" |
| 38 | +#include "llinstantmessage.h" // SYSTEM_FROM |
37 | 39 | #include "llmutelist.h" |
38 | 40 | #include "llviewercontrol.h" |
39 | 41 | #include "rlvactions.h" |
@@ -294,3 +296,98 @@ std::string ALAvatarGroups::getAvatarColorName(const LLUUID& id, std::string_vie |
294 | 296 |
|
295 | 297 | return out_color_name; |
296 | 298 | } |
| 299 | + |
| 300 | +bool ALAvatarGroups::getIRCChatColor(const LLChat& chat, LLUIColor& color) |
| 301 | +{ |
| 302 | + static LLCachedControl<bool> enabled(gSavedSettings, "AlchemyChatIRCColorsEnabled", false); |
| 303 | + if (!enabled) |
| 304 | + { |
| 305 | + return false; |
| 306 | + } |
| 307 | + |
| 308 | + // Only override "other" speakers; self, system, objects and owner-say keep |
| 309 | + // their user-configured chat colors from the existing switch. |
| 310 | + if (chat.mSourceType == CHAT_SOURCE_AGENT |
| 311 | + && chat.mFromID.notNull() |
| 312 | + && chat.mFromID != gAgentID |
| 313 | + && SYSTEM_FROM != chat.mFromName |
| 314 | + // A stable per-avatar color would defeat @shownames, so skip it while |
| 315 | + // restricted from seeing this speaker's name. |
| 316 | + && RlvActions::canShowName(RlvActions::SNC_DEFAULT, chat.mFromID)) |
| 317 | + { |
| 318 | + color = deterministicAgentColor(chat.mFromID); |
| 319 | + return true; |
| 320 | + } |
| 321 | + |
| 322 | + return false; |
| 323 | +} |
| 324 | + |
| 325 | +bool ALAvatarGroups::getIRCNameColor(const LLChat& chat, const LLUIColor& chat_color, LLUIColor& color) |
| 326 | +{ |
| 327 | + static LLCachedControl<bool> enabled(gSavedSettings, "AlchemyChatIRCColorsEnabled", false); |
| 328 | + if (!enabled) |
| 329 | + { |
| 330 | + return false; |
| 331 | + } |
| 332 | + |
| 333 | + // Keep the default name styling while restricted from seeing this speaker's |
| 334 | + // name, matching getIRCChatColor. |
| 335 | + if (!RlvActions::canShowName(RlvActions::SNC_DEFAULT, chat.mFromID)) |
| 336 | + { |
| 337 | + return false; |
| 338 | + } |
| 339 | + |
| 340 | + color = dimNameColor(chat_color.get()); |
| 341 | + return true; |
| 342 | +} |
| 343 | + |
| 344 | +bool ALAvatarGroups::getIRCNameTagColor(const LLUUID& id, LLColor4& color) |
| 345 | +{ |
| 346 | + static LLCachedControl<bool> enabled(gSavedSettings, "AlchemyChatIRCColorsEnabled", false); |
| 347 | + static LLCachedControl<bool> name_tags(gSavedSettings, "AlchemyChatIRCColorNameTags", false); |
| 348 | + if (!enabled || !name_tags) |
| 349 | + { |
| 350 | + return false; |
| 351 | + } |
| 352 | + |
| 353 | + // Mirror the chat-color override: only other agents get a per-avatar color, |
| 354 | + // self keeps the user-configured name tag colors. Skip while restricted from |
| 355 | + // seeing this avatar's name so the color can't defeat @shownames. The name |
| 356 | + // dimming applied to chat names is applied here too so tags match. |
| 357 | + if (id.notNull() && id != gAgentID |
| 358 | + && RlvActions::canShowName(RlvActions::SNC_DEFAULT, id)) |
| 359 | + { |
| 360 | + color = dimNameColor(deterministicAgentColor(id)); |
| 361 | + return true; |
| 362 | + } |
| 363 | + |
| 364 | + return false; |
| 365 | +} |
| 366 | + |
| 367 | +LLColor4 ALAvatarGroups::deterministicAgentColor(const LLUUID& id) |
| 368 | +{ |
| 369 | + static LLCachedControl<F32> saturation(gSavedSettings, "AlchemyChatIRCAgentSaturation", 0.7f); |
| 370 | + static LLCachedControl<F32> lightness(gSavedSettings, "AlchemyChatIRCAgentLightness", 0.9f); |
| 371 | + |
| 372 | + LLColor4 color; |
| 373 | + color.setHSL(static_cast<F32>(id.getCRC32() % 360) / 360.f, saturation(), lightness()); |
| 374 | + color.mV[VALPHA] = 1.f; |
| 375 | + |
| 376 | + return color; |
| 377 | +} |
| 378 | + |
| 379 | +LLColor4 ALAvatarGroups::dimNameColor(const LLColor4& color) |
| 380 | +{ |
| 381 | + static LLCachedControl<F32> scale(gSavedSettings, "AlchemyChatIRCNameLightnessScale", 0.8f); |
| 382 | + |
| 383 | + F32 hue = 0.f; |
| 384 | + F32 saturation = 0.f; |
| 385 | + F32 lightness = 0.f; |
| 386 | + color.calcHSL(&hue, &saturation, &lightness); |
| 387 | + |
| 388 | + LLColor4 result; |
| 389 | + result.setHSL(hue, saturation, lightness * scale()); |
| 390 | + result.mV[VALPHA] = 1.f; |
| 391 | + |
| 392 | + return result; |
| 393 | +} |
0 commit comments