Skip to content

Suggestion: IPC for styling individual messages (background color, fade, hide) #186

Description

@Shuro

Hey there,

I'm working on a plugin aimed at roleplayers that highlights chats from certain Characters (think colored backgrounds per friend group) and fades out messages from people standing far away. The text formating part is easy, I can just rewrite the SeStrings before Chat 2 ingests them. But backgrounds and per-message opacity can't be expressed in a SeString at all, only Chat 2's renderer is in a position to draw those.

I'd rather not maintain a fork for this, since everyone and their mother uses Chat2 (me too). Also per-sender highlighting might be something that other plugins could use it too.

So: would you take a PR adding a small styling IPC? Rough shape, following the same conventions as the typing IPC.

Proposed IPC

  • ChatTwo.StyleVersion -> int (currently 1)
  • ChatTwo.SetMessageStyleProvider(string gateName) -> registers a provider gate owned by the calling plugin; empty string unregisters; single provider, last writer wins.

Chat 2 calls the provider once per incoming message, on the message processing thread (throws fall back to unstyled):

(string senderName, string senderWorld, ulong contentId, ushort chatType, string senderRaw, string contentText)
    -> (uint BackgroundRgba, float Alpha)

BackgroundRgba = 0 means no background;
Alpha is 1 = normal, 0 < a < 1 = faded, <= 0 = hidden.
Hiding is visual only (still in DB, exports, web ui). The style applies only at ingestion.

Works both in Pretty Modern style and classic.

Optional follow-up: tab awareness

A second, smaller PR would let users scope styling per tab:

  • Persist Tab.Identifier (currently [NonSerialized], regenerated each load) so tabs have a stable identity across restarts -> old configs migrate automatically on next save.
  • ChatTwo.GetTabs -> Dictionary<Guid, string> and a ChatTwo.TabsChanged event (pushed from SaveConfig).
  • ChatTwo.SetTabStylePolicies(Dictionary<Guid, int>) -> suppress-flags per tab (1 = no backgrounds, 2 = no fading, 4 = no hiding); unlisted tabs have everything enabled.

Implementation

I have both parts working locally in a test setup on top of current Chat2 main and would split them into two PRs (plus a third unrelated one, thought it might be a nice feature).
Happy to change gate names, payload shapes or the registration model entirely if you'd prefer something else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions