acdream/src/AcDream.App/UI/Layout/IndicatorDetailText.cs
Erik a96767ba6d feat(ui): share indicator detail panels
Port the authored Link Status, Vitae, and Mini Game detail roots and register every indicator page with retail's one-active gmPanelUI owner. Helpful/Harmful and the new pages now replace Inventory, Character, or Magic at one canonical window position while preserving the DAT restore-previous flag.

Correct the retail ping wire to its payload-free request/response, publish measured RTT, and port Vitae recovery XP from the live modifier and player properties. Keep transport packet-loss averaging and mini-game gameplay explicitly tracked under AP-110.

Release build and all 5,814 tests pass with five intentional skips. Connected visual gate pending.

Co-authored-by: OpenAI Codex <codex@openai.com>
2026-07-17 10:27:41 +02:00

40 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
namespace AcDream.App.UI.Layout;
/// <summary>
/// Shared text shaping for retail indicator detail pages. Retail
/// <c>UIElement_Text::SetText</c> reflows newline-delimited strings into the
/// authored field width; acdream's retained text seam carries already-shaped
/// lines, so controllers perform the equivalent shaping before publication.
/// </summary>
internal static class IndicatorDetailText
{
public static IReadOnlyList<UiText.Line> Shape(UiText target, string text)
{
ArgumentNullException.ThrowIfNull(target);
text ??= string.Empty;
float maxWidth = Math.Max(1f, target.Width - (2f * target.Padding));
float Measure(string value)
=> target.DatFont?.MeasureWidth(value)
?? target.Font?.MeasureWidth(value)
?? value.Length * 8f;
var lines = new List<UiText.Line>();
string normalized = text.Replace("\\n", "\n", StringComparison.Ordinal);
foreach (string paragraph in normalized.Split('\n'))
{
if (paragraph.Length == 0)
{
lines.Add(new UiText.Line(string.Empty, target.DefaultColor));
continue;
}
foreach (string line in ChatWindowController.WrapText(paragraph, maxWidth, Measure))
lines.Add(new UiText.Line(line, target.DefaultColor));
}
return lines;
}
}