Replaces NullCommandBus.Instance in PanelContext with a real LiveCommandBus when a live session is active. Panels publish SendChatCmd; the host routes it to the right wire opcode + emits a ChatLog.OnSelfSent local echo (optimistic; retail-equivalent for Talk). Pieces: - ChatChannelKind enum (UI.Abstractions) - mirrors holtburger's ChatChannelKind (references/holtburger/.../client/types.rs:35-49). - SendChatCmd record (UI.Abstractions) - (Channel, TargetName?, Text). - LiveCommandBus (UI.Abstractions) - single-handler-per-type; Register<T> throws on double-register; Publish<T> logs missing handler but does not throw. - ChannelResolver (UI.Abstractions) - port of holtburger's resolve_legacy_channel (client/commands.rs:50-62) mapping ChatChannelKind to legacy ChatChannel ids verbatim from holtburger-protocol/.../chat/types.rs:8-24 (Fellow=0x0800, AllegianceBroadcast=0x02000000, Vassals=0x1000, Patron=0x2000, Monarch=0x4000, CoVassals=0x01000000). - WorldSession.SendTalk / SendTell / SendChannel - 3-line wrappers around existing ChatRequests.Build* + SendGameAction. Internal GameActionCapture seam + InternalsVisibleTo for tests. - GameWindow registers SendChatCmd handler: Say -> SendTalk + ChatLog echo, Tell -> SendTell + echo, channel kinds -> ChannelResolver.Resolve -> SendChannel + echo. 12 new tests across SendChatCmd + LiveCommandBus + ChannelResolver + WorldSessionChat. NullCommandBus.Instance retained for back-compat when no live session. Solution total: 893 green (51 + 229 + 613). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
47 lines
2.2 KiB
C#
47 lines
2.2 KiB
C#
namespace AcDream.UI.Abstractions;
|
|
|
|
/// <summary>
|
|
/// Maps a <see cref="ChatChannelKind"/> to the legacy <c>ChatChannel</c>
|
|
/// bitflag id used by the 0x0147 ChatChannel GameAction. Ported from
|
|
/// holtburger's <c>resolve_legacy_channel</c>
|
|
/// (<c>references/holtburger/crates/holtburger-core/src/client/commands.rs</c>
|
|
/// lines 50-62) cross-referenced against the <c>ChatChannel</c> enum
|
|
/// (<c>references/holtburger/crates/holtburger-protocol/src/messages/chat/types.rs</c>
|
|
/// lines 8-24) for the actual numeric ids.
|
|
///
|
|
/// <para>
|
|
/// Returns <c>null</c> for non-legacy kinds (Say, Tell, Unknown, and the
|
|
/// Turbine-routed General/Trade/etc.) — those callers handle dispatch
|
|
/// themselves. <see cref="ChatChannelKind.Say"/> rides Talk (0x0015) and
|
|
/// <see cref="ChatChannelKind.Tell"/> rides Tell (0x005D); the Turbine
|
|
/// channels need TurbineChat wiring not yet in place (Phase I.6).
|
|
/// </para>
|
|
/// </summary>
|
|
public static class ChannelResolver
|
|
{
|
|
/// <summary>Result of a successful legacy-channel resolution.</summary>
|
|
public readonly record struct Resolved(uint ChannelId, string DisplayName);
|
|
|
|
/// <summary>
|
|
/// Resolve <paramref name="kind"/> to a legacy ChatChannel id + a
|
|
/// human-readable display name for chat-log echo. Returns <c>null</c>
|
|
/// for non-legacy kinds; the caller routes those separately.
|
|
/// </summary>
|
|
public static Resolved? Resolve(ChatChannelKind kind) => kind switch
|
|
{
|
|
// ChatChannel values from holtburger-protocol/src/messages/chat/types.rs:
|
|
// Fellow = 0x00000800
|
|
// Vassals = 0x00001000
|
|
// Patron = 0x00002000
|
|
// Monarch = 0x00004000
|
|
// CoVassals = 0x01000000
|
|
// AllegianceBroadcast = 0x02000000
|
|
ChatChannelKind.Fellowship => new Resolved(0x00000800u, "Fellowship"),
|
|
ChatChannelKind.Allegiance => new Resolved(0x02000000u, "Allegiance"),
|
|
ChatChannelKind.Vassals => new Resolved(0x00001000u, "Vassals"),
|
|
ChatChannelKind.Patron => new Resolved(0x00002000u, "Patron"),
|
|
ChatChannelKind.Monarch => new Resolved(0x00004000u, "Monarch"),
|
|
ChatChannelKind.CoVassals => new Resolved(0x01000000u, "CoVassals"),
|
|
_ => null,
|
|
};
|
|
}
|