c4c85cf4b8
- Translated project documentation (LEARNING-JOURNEY, CONTRIBUTORS, AI_DISCLOSURE) to English for better accessibility. - Standardized internal code documentation by converting XML-doc blocks to standard comment format. - Cleaned up inline comments and removed redundant versioning metadata across the codebase. - Refactored non-functional text elements to improve readability and maintain a consistent style.
71 lines
2.6 KiB
C#
71 lines
2.6 KiB
C#
namespace HellionChat.Ui;
|
|
|
|
// Deterministic hash-based color and icon tinting for Auto-Tell sidebar tabs.
|
|
// Same tell partner (name+world) always produces the same color and icon across
|
|
// sessions. Pure string logic, no Dalamud dependency — testable without game refs.
|
|
internal static class AutoTellTabTint
|
|
{
|
|
// Fallback for invalid input (empty name or world=0). White matches
|
|
// TextPrimary default so the sidebar stays visually consistent.
|
|
public const uint Fallback = 0xFFFFFFFFu;
|
|
|
|
// 12 saturated mid-bright colors from the built-in theme pool, readable
|
|
// on dark backgrounds. Collision risk is low at realistic 1-5 active tells.
|
|
// RGBA format, matching ColourUtil.RgbaToAbgr convention.
|
|
public static readonly IReadOnlyList<uint> Palette = new uint[]
|
|
{
|
|
0x00BED2FFu, // Arctic Cyan
|
|
0xF97316FFu, // Ember Orange
|
|
0xB585FFFFu, // Light Cosmic Purple
|
|
0xE374E8FFu, // Bloom Magenta
|
|
0x5DD39EFFu, // Mint Green
|
|
0xF0AD4EFFu, // Warning Yellow
|
|
0xE85C6AFFu, // Coral
|
|
0x5CB85CFFu, // Status Green
|
|
0x6278FFFFu, // Bloom Blue
|
|
0xC9982EFFu, // Warm Gold
|
|
0x9CCB7CFFu, // Soft Sage
|
|
0xE85D04FFu, // Deep Ember
|
|
};
|
|
|
|
public static uint For(string name, uint world)
|
|
{
|
|
if (string.IsNullOrEmpty(name) || world == 0)
|
|
return Fallback;
|
|
|
|
// Mask to positive range so modulo always yields a valid index.
|
|
var key = $"{name}@{world}";
|
|
var hash = (uint)(key.GetHashCode() & 0x7FFFFFFF);
|
|
return Palette[(int)(hash % Palette.Count)];
|
|
}
|
|
|
|
// 7 visually distinct FA glyphs that make sense in a tell context.
|
|
// Excludes cog/comment/users — those read as system or group tabs.
|
|
public static readonly IReadOnlyList<string> IconPool = new[]
|
|
{
|
|
"envelope",
|
|
"star",
|
|
"heart",
|
|
"bell",
|
|
"bookmark",
|
|
"flag",
|
|
"fire",
|
|
};
|
|
|
|
// "envelope" matches the tell context better than the old hardcoded "clock".
|
|
public const string IconFallback = "envelope";
|
|
|
|
public static string IconFor(string name, uint world)
|
|
{
|
|
if (string.IsNullOrEmpty(name) || world == 0)
|
|
return IconFallback;
|
|
|
|
// Reversed key ("world@name") gives icon and color independent variation
|
|
// so the same tell partner doesn't always get the same color+icon pair.
|
|
// 7 icons x 12 colors = 84 distinct combinations.
|
|
var key = $"{world}@{name}";
|
|
var hash = (uint)(key.GetHashCode() & 0x7FFFFFFF);
|
|
return IconPool[(int)(hash % IconPool.Count)];
|
|
}
|
|
}
|