feat(ui): add sender name display options

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-22 17:12:50 +02:00
parent ba4cd918da
commit c652b102fc
6 changed files with 243 additions and 0 deletions
@@ -0,0 +1,53 @@
using System;
namespace HellionChat._Helpers;
// UI-7 pure decision helper: builds the display string for a sender's name +
// world per the user's NameFormMode / WorldSuffixMode. Dalamud-free so the
// Build Suite can cover every combination; SenderNameDisplay feeds it the name
// and world it pulled from the PlayerPayload.
// TEST-MIRROR: ../../../Hellion Build test/Ui/SenderNameFormatterTests.cs
public static class SenderNameFormatter
{
public static string Format(
string fullName,
string worldName,
bool isHomeWorld,
NameFormMode formMode,
WorldSuffixMode suffixMode)
{
var name = FormatName(fullName, formMode);
var showWorld = suffixMode switch
{
WorldSuffixMode.Never => false,
WorldSuffixMode.Always => true,
WorldSuffixMode.OtherWorldOnly => !isHomeWorld,
_ => !isHomeWorld,
};
return showWorld && !string.IsNullOrEmpty(worldName)
? $"{name}@{worldName}"
: name;
}
private static string FormatName(string fullName, NameFormMode mode)
{
if (mode == NameFormMode.Full)
return fullName;
// FFXIV character names are two words. Anything else (one word, odd
// spacing) falls back to the full name rather than risking an empty or
// misleading render.
var parts = fullName.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (parts.Length < 2)
return fullName;
return mode switch
{
NameFormMode.FirstNameOnly => parts[0],
NameFormMode.Initials => $"{parts[0][0]}. {parts[^1][0]}.",
_ => fullName,
};
}
}