feat(chat): retail text style — two-plane glyph outlines, authored SpewBox/chat styles
Campaign CH round 4, user-gate items 1+2. Root cause: retail ships a second (background) glyph atlas per font, dilated 2px on every side, plus two border-pixel scalars (Font.NumHorizontalBorderPixels/ NumVerticalBorderPixels) that acdream's font reader never read — so even the pre-existing outline parameter drew almost nothing once enabled. Landed together (either half alone is a no-op or a regression): - UiDatFont carries BorderX/BorderY from the DAT font resource. - UiRenderContext.DrawStringDat inflates the background blit's source and destination rect by that margin and restructures into retail's exact two-pass whole-string outline-then-fill model (UIElement_Text::DrawSelf), plus the 8-neighbour +-1px fallback for fonts with no background atlas. Corrects the stale "property 0xd" comment to the real ids, 0x21 (Outline) / 0x22 (OutlineColor). - LayoutDesc property 0x21/0x22 import (ElementInfo.Outline/ OutlineColor, LayoutImporter.ReadState, ElementReader.Merge/ ApplyCanonicalLegacyProjection, DatWidgetFactory.BuildText) so every authored-outline element across the DAT set is correct at once. - SpewBox: RetailFontId corrected from a round-3 heuristic (0x40000025) to the actually-authored 0x40000001 (18px bold serif), Outline=true set on the controller's UiText. Fill colour stays the user-gate-round-1-pinned yellow — font atlases are alpha-only (PFID_A8), so there is no baked shading that could explain the screenshot's gold as anything other than the outline itself. - Chat transcript: default fill now seeds from its authored ARGB(255,204,204,204) instead of an unrelated color-table slot (ChatTranscriptRenderer.BuildLines takes the transcript's own DefaultColor as a parameter); the 34-entry LogTextType table is untouched, and every existing CH1 conformance test stays green unmodified. Regenerated the committed chat_2100006f.json fixture from the real installed DAT, confirming end to end (not by missing-field default) that the transcript carries no outline. Tests: font-reader border fields + inflation math pinned against the real DAT font, two-pass draw ordering/tint/inflation via a new TextRenderer.DebugSpriteSegmentVerts test seam, property 0x21/0x22 import at both the ElementReader.Merge and StateDesc-property layers, SpewBox font/outline, and the chat default-shade seed with the color table proven untouched. Full Release suite: 12,610 passed / 4 skipped / 0 failed (AcDream.slnx, complete solution). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
5b54387b8e
commit
bcc34ee301
22 changed files with 1995 additions and 105 deletions
|
|
@ -90,6 +90,27 @@ public sealed class UiText : UiElement, IUiDatStateful
|
|||
/// the controller (e.g. <c>ChatWindowController</c>).</summary>
|
||||
public Vector4 BackgroundColor { get; set; } = new(0f, 0f, 0f, 0f);
|
||||
|
||||
/// <summary>
|
||||
/// Retail LayoutDesc property <c>0x21</c> (<c>UIElement_Text::SetOutline
|
||||
/// @0x0046a81c</c>, <c>m_bitField & 0x10</c>). When true, every dat-font draw
|
||||
/// on this element runs retail's two-pass outline+fill model
|
||||
/// (<see cref="UiRenderContext.DrawStringDat"/>). Default false, matching the
|
||||
/// ctor bitfield (<c>0x300</c>) which clears the outline bit — outlining is
|
||||
/// opt-in per element. Set by <see cref="AcDream.App.UI.Layout.DatWidgetFactory"/>
|
||||
/// from <see cref="AcDream.App.UI.Layout.ElementInfo.Outline"/> for DAT-imported
|
||||
/// text, or directly by a synthesized controller (e.g. the SpewBox).
|
||||
/// </summary>
|
||||
public bool Outline { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Retail LayoutDesc property <c>0x22</c> (<c>m_curOutlineColor</c>). Only
|
||||
/// meaningful when <see cref="Outline"/> is true. Default black, matching the
|
||||
/// ctor default (<c>RGBAColor_Black</c>,
|
||||
/// <c>UIElement_Text::UIElement_Text @0x004686cb</c>) — only 9 elements in the
|
||||
/// whole DAT set author a non-black outline color.
|
||||
/// </summary>
|
||||
public Vector4 OutlineColor { get; set; } = UiRenderContext.DefaultOutlineColor;
|
||||
|
||||
/// <summary>Optional dat state-sprite background (the element's own media), drawn
|
||||
/// UNDER the text. Set by DatWidgetFactory.BuildText from the ElementInfo. 0 = none.</summary>
|
||||
public uint BackgroundSprite { get; set; }
|
||||
|
|
@ -425,7 +446,7 @@ public sealed class UiText : UiElement, IUiDatStateful
|
|||
{
|
||||
float cx = (Width - cdf.MeasureWidth(line0.Text)) * 0.5f;
|
||||
float cy = VOffset(Height, cdf.LineHeight, Padding, VerticalJustify);
|
||||
ctx.DrawStringDat(cdf, line0.Text, cx, cy, line0.Color);
|
||||
ctx.DrawStringDat(cdf, line0.Text, cx, cy, line0.Color, Outline, OutlineColor);
|
||||
}
|
||||
else if ((Font ?? ctx.DefaultFont) is { } cbf)
|
||||
{
|
||||
|
|
@ -447,7 +468,7 @@ public sealed class UiText : UiElement, IUiDatStateful
|
|||
{
|
||||
float rx = Width - rdf.MeasureWidth(line0.Text) - Padding;
|
||||
float ry = VOffset(Height, rdf.LineHeight, Padding, VerticalJustify);
|
||||
ctx.DrawStringDat(rdf, line0.Text, rx, ry, line0.Color);
|
||||
ctx.DrawStringDat(rdf, line0.Text, rx, ry, line0.Color, Outline, OutlineColor);
|
||||
}
|
||||
else if ((Font ?? ctx.DefaultFont) is { } rbf)
|
||||
{
|
||||
|
|
@ -468,7 +489,7 @@ public sealed class UiText : UiElement, IUiDatStateful
|
|||
if (DatFont is { } datSingle)
|
||||
{
|
||||
float y = VOffset(Height, datSingle.LineHeight, Padding, VerticalJustify);
|
||||
ctx.DrawStringDat(datSingle, line0.Text, Padding, y, line0.Color);
|
||||
ctx.DrawStringDat(datSingle, line0.Text, Padding, y, line0.Color, Outline, OutlineColor);
|
||||
}
|
||||
else if ((Font ?? ctx.DefaultFont) is { } bitmapSingle)
|
||||
{
|
||||
|
|
@ -559,7 +580,7 @@ public sealed class UiText : UiElement, IUiDatStateful
|
|||
}
|
||||
|
||||
if (datFont is not null)
|
||||
ctx.DrawStringDat(datFont, text, lineX, y, lines[i].Color);
|
||||
ctx.DrawStringDat(datFont, text, lineX, y, lines[i].Color, Outline, OutlineColor);
|
||||
else
|
||||
ctx.DrawString(text, lineX, y, lines[i].Color, bitmapFont);
|
||||
}
|
||||
|
|
@ -602,7 +623,7 @@ public sealed class UiText : UiElement, IUiDatStateful
|
|||
if (run.Text.Length == 0) continue;
|
||||
if (datFont is not null)
|
||||
{
|
||||
ctx.DrawStringDat(datFont, run.Text, x, y, run.Color);
|
||||
ctx.DrawStringDat(datFont, run.Text, x, y, run.Color, Outline, OutlineColor);
|
||||
x += datFont.MeasureWidth(run.Text);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue