feat(ui): Chat tab — channel filters + display prefs + font slider

Phase L.0 (cont.) — fourth tab on the Settings shell. Mixes retail's
CharacterOptions2 chat-channel filter bits (Hear*Chat / TimeStamp /
FilterLanguage / AppearOffline) with a font-size slider that has no
retail bitfield equivalent.

ChatSettings record (9 fields):
 · 5 channel filters: HearGeneralChat, HearTradeChat, HearLFGChat,
   HearRoleplayChat, HearSocietyChat
 · 3 display flags: ShowTimestamps, FilterProfanity, AppearOffline
 · 1 visual: FontSize (10..20 pt)

Local-only this phase per the brainstorm — Hear*Chat flags affect
client-side display filtering only; the server still streams every
channel. Server-sync arrives later when the protocol round-trip is
in place.

SettingsStore grows LoadChat / SaveChat using the existing generic
SaveSection helper. All four non-keybind sections (display, audio,
gameplay, chat) now coexist non-destructively in settings.json.

SettingsVM grows the parallel chat state machine. HasUnsavedChanges,
Save, Cancel, ResetAllToDefaults all cover chat. Constructor signature
adds two more params; existing call sites updated.

SettingsPanel.RenderChatTab replaces the L.0-shell placeholder —
8 Checkbox calls grouped under "Channel filters" + "Display"
headers, plus a font-size SliderFloat. The "Coming soon" placeholder
test was retargeted from "Chat" to "Character" since Chat is no
longer a placeholder.

GameWindow wires SettingsStore.LoadChat / SaveChat + a TODO comment
for the future ChatPanel filter integration (read SettingsVM.ChatDraft
when filtering inbound chat lines).

13 new tests:
 · ChatSettings record (3) — defaults pinned, value equality, with-
   expressions
 · SettingsStore chat (3) — missing-file → defaults, round-trip, all
   four sections coexist
 · SettingsVM chat (5) — initial draft, SetChat marks dirty, Save
   invokes callback, Cancel reverts, ResetAllToDefaults covers
 · SettingsPanel chat tab (2) — checkboxes + slider render only when
   active

dotnet build green (0 warnings); dotnet test 1,289 / 1,289 green
(243 Core.Net + 373 UI.Abstractions + 673 Core).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-26 18:21:14 +02:00
parent b7165e5b17
commit 356b5f219e
9 changed files with 440 additions and 42 deletions

View file

@ -46,6 +46,11 @@ public sealed class SettingsVM
private GameplaySettings _gameplayDraft;
private readonly Action<GameplaySettings> _onSaveGameplay;
// L.0 — Chat tab (CharacterOptions2 channel filters + visual prefs).
private ChatSettings _chatPersisted;
private ChatSettings _chatDraft;
private readonly Action<ChatSettings> _onSaveChat;
/// <summary>The action currently being rebound, or null when idle.</summary>
public InputAction? RebindInProgress { get; private set; }
@ -70,7 +75,8 @@ public sealed class SettingsVM
=> !KeyBindingsEqual(_persisted, _draft)
|| _displayPersisted != _displayDraft
|| _audioPersisted != _audioDraft
|| _gameplayPersisted != _gameplayDraft;
|| _gameplayPersisted != _gameplayDraft
|| _chatPersisted != _chatDraft;
/// <summary>The current Display draft. Panel reads from here;
/// mutation goes through <see cref="SetDisplay"/>.</summary>
@ -84,6 +90,10 @@ public sealed class SettingsVM
/// mutation goes through <see cref="SetGameplay"/>.</summary>
public GameplaySettings GameplayDraft => _gameplayDraft;
/// <summary>The current Chat draft. Panel reads from here;
/// mutation goes through <see cref="SetChat"/>.</summary>
public ChatSettings ChatDraft => _chatDraft;
public SettingsVM(
KeyBindings persisted,
InputDispatcher dispatcher,
@ -93,7 +103,9 @@ public sealed class SettingsVM
AudioSettings persistedAudio,
Action<AudioSettings> onSaveAudio,
GameplaySettings persistedGameplay,
Action<GameplaySettings> onSaveGameplay)
Action<GameplaySettings> onSaveGameplay,
ChatSettings persistedChat,
Action<ChatSettings> onSaveChat)
{
_persisted = persisted ?? throw new ArgumentNullException(nameof(persisted));
_dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
@ -104,10 +116,13 @@ public sealed class SettingsVM
_onSaveAudio = onSaveAudio ?? throw new ArgumentNullException(nameof(onSaveAudio));
_gameplayPersisted = persistedGameplay ?? throw new ArgumentNullException(nameof(persistedGameplay));
_onSaveGameplay = onSaveGameplay ?? throw new ArgumentNullException(nameof(onSaveGameplay));
_chatPersisted = persistedChat ?? throw new ArgumentNullException(nameof(persistedChat));
_onSaveChat = onSaveChat ?? throw new ArgumentNullException(nameof(onSaveChat));
_draft = CloneBindings(persisted);
_displayDraft = persistedDisplay;
_audioDraft = persistedAudio;
_gameplayDraft = persistedGameplay;
_chatDraft = persistedChat;
}
/// <summary>
@ -144,6 +159,17 @@ public sealed class SettingsVM
_gameplayDraft = value ?? throw new ArgumentNullException(nameof(value));
}
/// <summary>
/// Replace the entire Chat draft with <paramref name="value"/>.
/// Local-only this phase — values persist on Save but the Hear*Chat
/// flags affect client-side display filtering, not server-side
/// channel subscriptions.
/// </summary>
public void SetChat(ChatSettings value)
{
_chatDraft = value ?? throw new ArgumentNullException(nameof(value));
}
/// <summary>
/// Begin rebinding <paramref name="action"/>. The supplied
/// <paramref name="original"/> binding will be removed when the new
@ -255,6 +281,7 @@ public sealed class SettingsVM
_displayDraft = DisplaySettings.Default;
_audioDraft = AudioSettings.Default;
_gameplayDraft = GameplaySettings.Default;
_chatDraft = ChatSettings.Default;
}
/// <summary>
@ -271,10 +298,12 @@ public sealed class SettingsVM
_onSaveDisplay(_displayDraft);
_onSaveAudio(_audioDraft);
_onSaveGameplay(_gameplayDraft);
_onSaveChat(_chatDraft);
_persisted = CloneBindings(_draft);
_displayPersisted = _displayDraft;
_audioPersisted = _audioDraft;
_gameplayPersisted = _gameplayDraft;
_chatPersisted = _chatDraft;
}
/// <summary>
@ -288,6 +317,7 @@ public sealed class SettingsVM
_displayDraft = _displayPersisted;
_audioDraft = _audioPersisted;
_gameplayDraft = _gameplayPersisted;
_chatDraft = _chatPersisted;
CancelRebind();
}