fix(ui): chat window retail parity — focus rails, authored captions, menu flick, drag-stable text

Four of the five owner-reported chat deltas (2026-08-24), each traced to
its retail mechanism:

1. Missing gold separator left of the input: the chat input authors two
   1px Type-3 rail CHILDREN (0x10000017 at X=0, 0x10000018
   right-anchored) whose only media is Normal_focussed (0x06004D67,
   live-DAT probed). UiField consumes its DAT children, so the rails
   were swallowed and never drawn. The factory now folds them into the
   field, which draws both while focused.

2. Button says "General", retail says "Gen": the talk button's short
   caption comes from per-target ID_Chat_ChatTargetMenu* strings
   (HandleSelection @0x004cd540, StringTable 0x23000001 via
   compute_str_hash — recovered from the raw binary after BN elided the
   ids into name-hash globals). Authored set: Chat/Tell/Fell/Pat/Mon/
   Vas/Alg/Gen/Trade/LFG/RP/Soc/Olt. Menu rows + squelch/tell specials
   resolve from the same table (ID_Chat_TellTo*); production resolves
   through DatStringResolver, fallbacks ARE the authored EoR English.
   ChatStringsLiveDatTests pins the whole set against the installed DAT.

3. Channel button stayed green while the popup was open: retail's
   pressed face is the momentary physical press ("flicks"); the OPEN
   state drives only the arrow-cap child's StateDesc swap
   (UIElement_Menu::UpdateState @0x0046cad0 writes attribute 0xe).
   UiMenu now keys the face on the press, not on IsOpen.

4. Window-title/button text "vibrates" while dragging windows:
   DrawStringDatPass snapped glyphs with MathF.Round — banker's
   rounding. A centered label with a constant .5 fraction alternates
   round-up/round-down across successive integers, double-stepping then
   sticking while the background glides. Half-up Floor(v+0.5) snaps
   every tie one way: uniform 1px steps in lock-step with sprites.

The fifth report (input row sticking out on window resize) did not
reproduce: a controller-bound fixture resize at 220/300/600px keeps the
whole input row inside the window (test added) — awaiting the owner's
exact gesture.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-24 20:27:04 +02:00
parent 2d6333f84c
commit c12a95b6e8
11 changed files with 401 additions and 46 deletions

View file

@ -338,7 +338,16 @@ public sealed class UiRenderContext
// digits never showed it because their bar baseline lands on an integer; chat text
// does. Snapping the baseline once, then adding the integer offset, keeps the whole
// line on one row and pixel-aligned.
float baseY = System.MathF.Round(originY);
//
// HALF-UP, not MathF.Round (2026-08-24 owner report: window-title and
// button labels "vibrate" while dragging a window): MathF.Round is
// banker's rounding — a centered label whose origin carries a constant
// .5 fraction (odd text width over /2) alternates round-up/round-down
// as the dragged window crosses successive integers, so the text
// double-steps then sticks while the background glides 1px per frame.
// Floor(v + 0.5) snaps every tie the same direction: constant fraction
// → uniform 1px steps in lock-step with the sprites.
float baseY = System.MathF.Floor(originY + 0.5f);
float pen = originX;
for (int i = 0; i < text.Length; i++)
@ -349,7 +358,8 @@ public sealed class UiRenderContext
// Horizontal: snap each glyph's dest X to a whole pixel (the pen keeps its
// true fractional advance). Vertical: integer baseline + integer per-glyph
// offset — never an independent per-glyph round (see baseY's note above).
float gx = System.MathF.Round(pen + g.HorizontalOffsetBefore);
// Half-up for the same anti-vibration reason as baseY.
float gx = System.MathF.Floor(pen + g.HorizontalOffsetBefore + 0.5f);
float gy = baseY + g.VerticalOffsetBefore;
float gw = g.Width;
float gh = g.Height;