feat(chat): Campaign CH slice CH1 — retail LogTextType color table

Retail colors chat lines by the 34-value wire LogTextType (ACE's
ChatMessageType), NOT by acdream's synthetic 9-value ChatKind. The old
ChatWindowController.RetailChatColor(ChatKind) collapsed distinct retail
colors onto one bucket per ChatKind — e.g. every Channel line rendered
colorLightBlue (Magic's slot) when retail's actual palette spans five
different colors across the Turbine rooms and legacy allegiance family.

Ports ChatInterface::BuildChatColorLookupTable @0x004F31C0 verbatim
(RetailChatColorTable, all 34 RGBA floats read from the PDB-paired
binary's .data section) and threads a new ChatEntry.LogTextType field
through every ingestion site to the correct retail wire value:
HearSpeech/Tell pass the wire chatType through verbatim; Emote/SoulEmote
hard-code 0x0C; the Tell self-echo hard-codes 0x04; legacy ChatChannel
broadcasts derive their type from the channel bit via the new
LegacyChannelChatType helper (ported from the decompiled
Handle_Communication__ChannelBroadcast dispatch, hear vs. own-send);
TurbineChat rooms map through TurbineChatDisplayNames.LogTextType;
CombatChatTranslator's hit/miss/evade lines map to ACE's CombatSelf/
CombatEnemy per Player_Combat.cs; kill/death lines use retail's
decompiled 0x00 Default (not a combat color). ChatWindowController's
transcript now folds LogTextType through RetailChatColorTable with
retail's exact "out-of-range keeps the previous line's color" carry
rule; ChatPanel's combat highlighting sources the same table.

Corrects HearSpeech.cs's doc-comment ChatType legend (4 of 6 entries
were wrong). Adds register row AP-175 for the pre-existing (unchanged)
Popup-renders-in-chat divergence and updates AP-39's stale per-ChatKind
description. Narrows ISSUES #139 — its chat-colors half is done.

Retail renders no chat timestamp prefix path exists in acdream today,
so the "timestamp is always colorGrey 0x0C" rule has nothing to attach
to; noted here per the research doc rather than left silent.

Research: docs/research/2026-08-09-chat-retail-color-table.md
Full Release suite: 11,833 passed / 4 skipped / 0 failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-09 15:23:31 +02:00
parent 8df35d1e18
commit 172c6f9aa3
26 changed files with 1360 additions and 85 deletions

View file

@ -153,9 +153,19 @@ public sealed class ChatPanel : IPanel
for (int i = 0; i < lines.Count; i++)
{
var line = lines[i];
if (line.Kind == ChatKind.Combat && line.CombatKind is { } ck)
if (line.Kind == ChatKind.Combat)
{
renderer.TextColored(ColorForCombat(ck), line.Text);
// Campaign CH slice CH1: color combat lines from the
// retail LogTextType table (Combat_Self/Combat_Enemy/
// Default per CombatChatTranslator's ACE-cited
// mapping) instead of the CombatLineKind info/
// warning/error severity bucket. Every LogTextType
// CombatChatTranslator emits is in-range (<0x22), so
// the fallback below is defensive only.
Vector4 color = RetailChatColorTable.TryGetColor(line.LogTextType, out var resolved)
? resolved
: ColorForCombat(line.CombatKind ?? CombatLineKind.Info);
renderer.TextColored(color, line.Text);
}
else
{

View file

@ -112,7 +112,13 @@ public sealed class ChatVM : IDisposable
/// client-handled commands (/help, /clear, future) to surface
/// local feedback without round-tripping the server.
/// </summary>
public void ShowSystemMessage(string text) => _log.OnSystemMessage(text, chatType: 0);
/// <remarks>
/// LogTextType <c>0x1A</c>: this text never reaches the wire — the
/// same "client-local text" category as retail's own command-parser
/// errors and <c>cant_jump_*</c> strings (research doc
/// <c>docs/research/2026-08-09-chat-retail-color-table.md</c> §2.2).
/// </remarks>
public void ShowSystemMessage(string text) => _log.OnSystemMessage(text, chatType: 0x1Au);
/// <summary>
/// Drain the chat log. Used by the /clear client-side command.
@ -256,7 +262,9 @@ public sealed class ChatVM : IDisposable
/// <see cref="ChatPanel"/> can pick the right rendering primitive
/// per entry (plain <c>Text</c> for most kinds; <c>TextColored</c>
/// for combat lines, with the rgba chosen from
/// <see cref="ChatEntry.CombatKind"/>).
/// <see cref="ChatEntry.CombatKind"/>). Campaign CH slice CH1 also
/// carries <see cref="ChatEntry.LogTextType"/> through — the retail
/// color key, keyed independently of <see cref="ChatKind"/>.
/// </summary>
public IReadOnlyList<FormattedLine> RecentLinesDetailed()
{
@ -272,7 +280,8 @@ public sealed class ChatVM : IDisposable
lines[i] = new FormattedLine(
Text: FormatEntry(entry),
Kind: entry.Kind,
CombatKind: entry.CombatKind);
CombatKind: entry.CombatKind,
LogTextType: entry.LogTextType);
}
return lines;
}
@ -284,7 +293,12 @@ public sealed class ChatVM : IDisposable
/// <see cref="CombatKind"/> to pick a rendering primitive
/// (<c>Text</c> vs <c>TextColored(rgba)</c>).
/// </summary>
/// <param name="LogTextType">
/// Campaign CH slice CH1: the retail wire <c>LogTextType</c> that keys
/// <see cref="RetailChatColorTable"/> — see <see cref="ChatEntry.LogTextType"/>.
/// </param>
public readonly record struct FormattedLine(
string Text,
ChatKind Kind,
CombatLineKind? CombatKind);
CombatLineKind? CombatKind,
uint LogTextType);

View file

@ -0,0 +1,109 @@
using System.Numerics;
namespace AcDream.UI.Abstractions.Panels.Chat;
/// <summary>
/// The exact retail chat font-color lookup table, indexed by the wire
/// <c>LogTextType</c> (the same integer ACE calls <c>ChatMessageType</c>).
///
/// <para>
/// Faithful port of <c>ChatInterface::BuildChatColorLookupTable @0x004F31C0</c>
/// (Sept 2013 EoR build; verified against the PDB-paired binary's <c>.data</c>
/// section, image base <c>0x400000</c>, RGBAColor constants at <c>0x0081C4A8</c>+).
/// Retail default-fills all 34 slots (indices <c>0x00</c>-<c>0x21</c>, 34 loop
/// iterations) with <c>colorGreen</c>, then overwrites 27 of them with 13 named
/// colors; the 7 slots retail never overwrites (<c>0x00, 0x01, 0x10, 0x14, 0x17,
/// 0x18, 0x19</c>) stay green. Every color's alpha is 1.0 in the source data.
/// Full derivation: <c>docs/research/2026-08-09-chat-retail-color-table.md</c> §1-2.
/// </para>
///
/// <para>
/// <b>Out-of-range rule.</b> Retail's consumer,
/// <c>UIElement_Text::SetFontColorHelper @0x00466AC0</c>, reads the list's
/// element count and only applies a new color when the index is IN range;
/// an index &gt;= 34 falls through leaving <c>m_curFontColor</c> untouched — the
/// line inherits whatever color the PREVIOUS line resolved to, not a default.
/// <see cref="TryGetColor"/> models this: it returns <see langword="false"/>
/// for an out-of-range index instead of substituting a fallback color, so
/// callers can implement the same "keep the last color" carry-forward.
/// </para>
/// </summary>
public static class RetailChatColorTable
{
// Named RGBAColor constants (retail .data, 0x0081C4A8-0x0081C578).
private static readonly Vector4 ColorWhite = new(1f, 1f, 1f, 1f);
private static readonly Vector4 Yellow = new(1f, 1f, 0.247f, 1f);
private static readonly Vector4 DarkYellow = new(0.824f, 0.824f, 0.392f, 1f);
private static readonly Vector4 ColorBrightPurple = new(1f, 0.498f, 1f, 1f);
private static readonly Vector4 ColorDarkRed = new(1f, 0.247f, 0.247f, 1f);
private static readonly Vector4 ColorLightRed = new(0.96f, 0.459f, 0.447f, 1f);
private static readonly Vector4 ColorLightBlue = new(0.247f, 0.749f, 1f, 1f);
private static readonly Vector4 ColorPink = new(1f, 0.588f, 0.588f, 1f);
private static readonly Vector4 ColorCyan = new(0.247f, 0.863f, 0.863f, 1f);
private static readonly Vector4 ColorBlueGrey = new(0.706f, 0.863f, 0.941f, 1f);
private static readonly Vector4 ColorGrey = new(0.824f, 0.824f, 0.784f, 1f);
private static readonly Vector4 Orange = new(0.933f, 0.573f, 0.118f, 1f);
private static readonly Vector4 ColorGreen = new(0.5f, 1f, 0.498f, 1f);
private static readonly Vector4 ColorBrightRed = new(1f, 0f, 0f, 1f);
/// <summary>
/// The 34-entry table, index == <c>LogTextType</c> (<c>0x00</c>-<c>0x21</c>).
/// Default-fill is <c>colorGreen</c>; explicit overrides match the builder's
/// <c>SetValue</c> calls verbatim.
/// </summary>
public static readonly IReadOnlyList<Vector4> Colors = new[]
{
/* 0x00 Default */ ColorGreen,
/* 0x01 All */ ColorGreen,
/* 0x02 Speech */ ColorWhite,
/* 0x03 Tell */ Yellow,
/* 0x04 Speech_Direct_Send */ DarkYellow,
/* 0x05 System */ ColorBrightPurple,
/* 0x06 Combat */ ColorDarkRed,
/* 0x07 Magic */ ColorLightBlue,
/* 0x08 Channel */ ColorPink,
/* 0x09 Channel_Send */ ColorPink,
/* 0x0A Social */ Yellow,
/* 0x0B Social_Send */ DarkYellow,
/* 0x0C Emote */ ColorGrey,
/* 0x0D Advancement */ ColorCyan,
/* 0x0E Abuse */ ColorBlueGrey,
/* 0x0F Help */ ColorDarkRed,
/* 0x10 Appraisal */ ColorGreen,
/* 0x11 Spellcasting */ ColorLightBlue,
/* 0x12 Allegiance */ Orange,
/* 0x13 Fellowship */ Yellow,
/* 0x14 World_Broadcast */ ColorGreen,
/* 0x15 Combat_Enemy */ ColorDarkRed,
/* 0x16 Combat_Self */ ColorLightRed,
/* 0x17 Recall */ ColorGreen,
/* 0x18 Craft */ ColorGreen,
/* 0x19 Salvaging */ ColorGreen,
/* 0x1A (client-local text) */ ColorBrightRed,
/* 0x1B (Turbine General) */ ColorBlueGrey,
/* 0x1C (Turbine Trade) */ ColorBlueGrey,
/* 0x1D (Turbine LFG) */ ColorBlueGrey,
/* 0x1E (Turbine Roleplay) */ ColorBlueGrey,
/* 0x1F Admin_Tell */ Yellow,
/* 0x20 (Turbine Society) */ ColorBlueGrey,
/* 0x21 (reserved) */ Orange,
};
/// <summary>
/// Resolve <paramref name="logTextType"/> to its retail color.
/// Returns <see langword="false"/> for an out-of-range index (&gt;=
/// <see cref="Colors"/>.Count) — per retail's <c>SetFontColorHelper</c>,
/// the caller should keep whatever color the previous line resolved to
/// rather than substitute a default.
/// </summary>
public static bool TryGetColor(uint logTextType, out Vector4 color)
{
if (logTextType < (uint)Colors.Count)
{
color = Colors[(int)logTextType];
return true;
}
color = default;
return false;
}
}